[PHP] Re: Which CAPTCHA is the besta?

2007-08-16 Thread Hamza Saglam
Not a script you can install/hack but why don't you have a look at: 
http://recaptcha.net/ ?


Regards,
Hamza.


""Tony Di Croce"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I need a CAPTCHA script Which one is the best? (I dont mind if its
> somewhat difficult).
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Render fonts

2007-08-19 Thread Hamza Saglam
Hi Emil,

Just an alternative solution you may want to consider..

Rather than converting your captions/headings to images, you can also use 
the sIFR Image replacement technique.

Quote from the the author's description:

"sIFR is meant to replace short passages of plain browser text with text 
rendered in your typeface of  choice, regardless of whether or not your 
users have that font installed on their systems. It accomplishes this by 
using a combination of javascript, CSS, and Flash."



You can find more details on: http://www.mikeindustries.com/sifr/ and a demo 
page is located at http://www.mikeindustries.com/blog/files/sifr/2.0/ .


Regards,
Hamza


"Emil Edeholt" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi
>
> I would like to render some fonts into images, for captions on a site. 
> What tools should I use to get the best looking render? Do you guys use 
> the built-in tools PHP has, or are there third party libraries that does a 
> better job?
>
> Thanks!
>
> Kind regards Emil 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: SQL Distinct-like behaviour

2007-08-23 Thread Hamza Saglam

$files = glob("directory/*.jpg");
will give you a list of all the jpg files in the directory,

$files_unique = array_unique($files);
will get rid of the duplicates and create a shiny new array.


Regards,
Hamza.


PS: glob is case-sensitive so the above will only match *.jpg, and not *.JPG


""Marcelo de Moraes Serpa"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> How could I iterate over the files in a directory and build a list of 
> unique
> filenames? Take the following filelist:
>
> file1_01.jpg
> file2_01.jpg
> file2_02.jpg
> file2_03.jpg
> file3_01.jpg
> file3_02.jpg
> file3_03.jpg
> file4_01.jpg
> file4_02.jpg
> file4_03.jpg
>
> I would like to build an array like this: $names =
> ("file1","file2","file3","file4")
>
> How could I do that ?
>
> Thanks in advance.
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SQL Distinct-like behaviour

2007-08-24 Thread Hamza Saglam
I don't know what I was thinking when I wrote that actually, that is so 
blatantly obvious :)


Thanks Brian.

Hamza.


"brian" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Marcelo de Moraes Serpa wrote:
>> How could I iterate over the files in a directory and build a list of 
>> unique
>> filenames? Take the following filelist:
>>
>> file1_01.jpg
>> file2_01.jpg
>> file2_02.jpg
>> file2_03.jpg
>> file3_01.jpg
>> file3_02.jpg
>> file3_03.jpg
>> file4_01.jpg
>> file4_02.jpg
>> file4_03.jpg
>>
>> I would like to build an array like this: $names =
>> ("file1","file2","file3","file4")
>>
>
> As mentioned, use array_unique(). But that'll only help once you've built 
> up an array of filenames (after trimming off the last bit). I think Jay & 
> Hamza missed the fact that the files are *already unique*. One would be 
> hard-pressed to store multiple files with the same name in a directory.
>
> So, i'm assuming your filenames wil be more like:
>
> foo_01.jpg
> foo_02.jpg
> bar_01.jpg
>
> etc. IOW, you want to perform a regexp such that you isolate the last part 
> to remove it before shuffling out the dupes. So:
>
> $filenames = Array('foo_01.jpg', 'foo_02.jpg', 'bar_01.jpg', 'baz_01.jpg', 
> 'bar_02.jpg');
>
> $out = array_unique(preg_replace('/^([a-z]+)_[0-9]+\.jpg$/', '$1', 
> $filenames));
>
> var_dump($out);
>
> --snip--
> array(3) {
>   [0]=>  string(3) "foo"
>   [2]=>  string(3) "bar"
>   [3]=>  string(3) "baz"
> }
> --snip--
>
> Note that if you might have uppercase letters, dashes, underscores, etc. 
> in the filename you'll need to modify that a bit. Something like:
>
> '/^([a-zA-Z-_]+)_[0-9]+\.jpg$/'
>
> If you'll have more than one file extension, replace 'jpg' with '[a-z]+'
>
> However, the array_unique call will cause, eg. both 'bar_01.jpg' and 
> 'bar_01.png' to output 'bar' only once, which may not be what you want.
>
> HTH,
> brian 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to implement a plugin system?

2007-08-06 Thread Hamza Saglam
Hello all,

I am working on a project which needs to have some sort of plugins
architecture and I am kinda stuck. Basically I want to give a list of
items to the user, and according to his/her selection, I want to load
relevant functionality into my application.


I was thinking of having an abstract plugin class, and have the
plugins implement that but then how would I actually load the plugins?
Say for instance I want to load plugins X,Y,Z (and lets say i
implemented them as [X|Y|Z].class.php) , should I just 'include' (or
require) them? Or should I initialize all possible plugins and just
pick the ones user has chosen (which sounds a bit pointless as it
would load unnecessary stuff)?


How would you go about doing something like this?


Thanks.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to implement a plugin system?

2007-08-06 Thread Hamza Saglam
Hello Boro,

Thanks for your response. However I am looking for something a bit more 
comprehensive :)

I could do it as you suggested if I had only a few plugins. As I am going to 
add loads of plugins over the time, rather than adding all the plugins one 
by one, could something like a 'loader' class be implemented? What I mean by 
that is, it will take the requested plugin names (with their own parameters 
necessary) and load/initialise them.

In semi-psuedo-code, it would be something like:

 foreach plugin suplied as the argument
   include the plugin
   initialise it
 end

Perhaps I should change the question to: "Do you think something like this 
would be efficient and useable? If not what sort of pattern would you 
follow?"


Warm regards,
Hamza.


"Borokov Smith" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hey Hamza,
>
> require_once($chosenPlugin . '.class.php');
>
> $obj = new $chosenPlugin();
> return $obj;
>
> And you can start from there.
>
> hth,
>
> boro
>
>
>
> Hamza Saglam schreef:
>> Hello all,
>>
>> I am working on a project which needs to have some sort of plugins
>> architecture and I am kinda stuck. Basically I want to give a list of
>> items to the user, and according to his/her selection, I want to load
>> relevant functionality into my application.
>>
>>
>> I was thinking of having an abstract plugin class, and have the
>> plugins implement that but then how would I actually load the plugins?
>> Say for instance I want to load plugins X,Y,Z (and lets say i
>> implemented them as [X|Y|Z].class.php) , should I just 'include' (or
>> require) them? Or should I initialize all possible plugins and just
>> pick the ones user has chosen (which sounds a bit pointless as it
>> would load unnecessary stuff)?
>>
>>
>> How would you go about doing something like this?
>>
>>
>> Thanks.
>>
>> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: How to implement a plugin system?

2007-08-06 Thread Hamza Saglam
I think I have a rough understanding of the whole process so I should start 
coding :)

Many thanks to everyone for your suggestions.


Regards,
Hamza.


""Hamza Saglam"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hello all,
>
> I am working on a project which needs to have some sort of plugins
> architecture and I am kinda stuck. Basically I want to give a list of
> items to the user, and according to his/her selection, I want to load
> relevant functionality into my application.
>
>
> I was thinking of having an abstract plugin class, and have the
> plugins implement that but then how would I actually load the plugins?
> Say for instance I want to load plugins X,Y,Z (and lets say i
> implemented them as [X|Y|Z].class.php) , should I just 'include' (or
> require) them? Or should I initialize all possible plugins and just
> pick the ones user has chosen (which sounds a bit pointless as it
> would load unnecessary stuff)?
>
>
> How would you go about doing something like this?
>
>
> Thanks. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Object reference into variable?

2007-08-07 Thread Hamza Saglam
You may find the following article interesting. It talks about object 
cloning, which I think what you are after...

http://www.phpfreaks.com/phpmanual/page/language.oop5.cloning.html


Regards,
Hamza.


""Sándor Tamás (GMail)"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hello,
>
> I have a question (what a surprise :-) )
>
> I browsed the archives, but didn't find what I'm looking for.
> I have an object instance stored in some variable (like $myobject). I want 
> to save this instance into another variable (like $tempobject). I thought, 
> this will be the way:
>  $myobject = new MyObject();
>  $tempobject = $myobject;
> (or I tried this too:
>  $tempobject = &$myobject)
>
> None of them worked, like I cannot access methods in the object:
>  $tempobject->Foo()
> gives me an error: calling to method on a non-object variable.
>
> How can I tell PHP that $tempobject is a class instance of MyObject, and 
> that I can use it's methods?
>
> Thanks,
> SanTa 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to implement a plugin system?

2007-08-07 Thread Hamza Saglam
""Nathan Nobbe"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 8/6/07, Stut <[EMAIL PROTECTED]> wrote:
>>
>> Hamza Saglam wrote:
>> > Thanks for your response. However I am looking for something a bit more
>> > comprehensive :)
>> >
>> > I could do it as you suggested if I had only a few plugins. As I am
>> going to
>> > add loads of plugins over the time, rather than adding all the plugins
>> one
>> > by one, could something like a 'loader' class be implemented? What I
>> mean by
>> > that is, it will take the requested plugin names (with their own
>> parameters
>> > necessary) and load/initialise them.
>> >
>> > In semi-psuedo-code, it would be something like:
>> >
>> >  foreach plugin suplied as the argument
>> >include the plugin
>> >initialise it
>> >  end
>> >
>> > Perhaps I should change the question to: "Do you think something like
>> this
>> > would be efficient and useable? If not what sort of pattern would you
>> > follow?"
>>
>> What you're describing is the Factory pattern, and yes that's the most
>> efficient way to implement plugins. You should never load classes unless
>> you need them - it's a complete waste of time, and definitely not
>> recommended if you're going to have a lot of plugins.
>>
>> I would suggest you name your plugins X_plugin, Y_plugin and Z_plugin
>> (where plugin could be anything) because that adds a level of security.
>> Otherwise you could open yourself up to security issues because the user
>> could instantiate any class in your system.
>>
>> -Stut
>>
>> --
>> http://stut.net/
>>
>> > "Borokov Smith" <[EMAIL PROTECTED]> wrote in message
>> > news:[EMAIL PROTECTED]
>> >> Hey Hamza,
>> >>
>> >> require_once($chosenPlugin . '.class.php');
>> >>
>> >> $obj = new $chosenPlugin();
>> >> return $obj;
>> >>
>> >> And you can start from there.
>> >>
>> >> hth,
>> >>
>> >> boro
>> >>
>> >>
>> >>
>> >> Hamza Saglam schreef:
>> >>> Hello all,
>> >>>
>> >>> I am working on a project which needs to have some sort of plugins
>> >>> architecture and I am kinda stuck. Basically I want to give a list of
>> >>> items to the user, and according to his/her selection, I want to load
>> >>> relevant functionality into my application.
>> >>>
>> >>>
>> >>> I was thinking of having an abstract plugin class, and have the
>> >>> plugins implement that but then how would I actually load the 
>> >>> plugins?
>> >>> Say for instance I want to load plugins X,Y,Z (and lets say i
>> >>> implemented them as [X|Y|Z].class.php) , should I just 'include' (or
>> >>> require) them? Or should I initialize all possible plugins and just
>> >>> pick the ones user has chosen (which sounds a bit pointless as it
>> >>> would load unnecessary stuff)?
>> >>>
>> >>>
>> >>> How would you go about doing something like this?
>> >>>
>> >>>
>> >>> Thanks.
>> >>>
>> >>>
>> >
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> allow me to elaborate.  you want to aim for composition as a flexible
> alternative to sub-classing to extend behavior.
> Namely what you want is the Strategy pattern.  Strategy allows you to
> compose objects at run time dynamically, thereby changing
> behavior in your system on-the-fly.  The components are made similar by a
> common interface, which can be either the PHP
> *interface* or the PHP *abstract class*.
>
> these components each encapsulate a different algorithm or module as you
> would call it.  and the interface makes the system simple
> to extend.  to create a new module you simply implement the interface and 
> it
> is interchangeable with the other modules in the system.
> the factory method pattern is sort of complex.  it is used to encapsulate
> object creation.  it is typically used to instantiate objects in a 
> *family*
> *of products* which is defined by a common interface, ie the strategy
> pattern. 

[PHP] Re: Object reference into variable?

2007-08-07 Thread Hamza Saglam
I strongly suggest you put some pressure on you web provider to at least 
upgrade it to the 4.4.7, as 4.2 is way too old to be secure :)

Unfortunately I don't know how this could be accomplished in PHP4, but a 
quick google query returned these:

http://www.hat.net/geeky/php_tricks_-_php_5_clone_in_php4
http://www.dgx.cz/trine/item/how-to-emulate-php5-object-model-in-php4

Someone with more experience might shed some light into this..


Regards,
Hamza.


""Sándor Tamás (GMail)"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
I forgot to tell you that I have to use PHP4.2 because of my web provider.
Anything besides of _clone?

SanTa

  - Original Message - 
  From: Hamza Saglam
  To: "Sándor Tamás (GMail)"
  Sent: Tuesday, August 07, 2007 10:49 AM
  Subject: Re: Object reference into variable?


  You may find the following article interesting. It talks about object
  cloning, which I think what you are after...

  http://www.phpfreaks.com/phpmanual/page/language.oop5.cloning.html


  Regards,
  Hamza.


  ""Sándor Tamás (GMail)"" <[EMAIL PROTECTED]> wrote in message
  news:[EMAIL PROTECTED]
  > Hello,
  >
  > I have a question (what a surprise :-) )
  >
  > I browsed the archives, but didn't find what I'm looking for.
  > I have an object instance stored in some variable (like $myobject). I 
want
  > to save this instance into another variable (like $tempobject). I 
thought,
  > this will be the way:
  >  $myobject = new MyObject();
  >  $tempobject = $myobject;
  > (or I tried this too:
  >  $tempobject = &$myobject)
  >
  > None of them worked, like I cannot access methods in the object:
  >  $tempobject->Foo()
  > gives me an error: calling to method on a non-object variable.
  >
  > How can I tell PHP that $tempobject is a class instance of MyObject, and
  > that I can use it's methods?
  >
  > Thanks,
  > SanTa

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php