tye

tye

Joined
Sep 19, 2003
Location
Canada
Website
Interests
Web Development

Activity Stream

tye commented on a Page, List Files  -  Apr 29, 2009

You can use substr to get the portion of the text before the last .

$basefile = substr($file,0,strrpos($file,'.'));

If you add that to the while loop in the above function you can use $basefile to refer to the filename without the extension.

 Respond  
tye   -  Sep 22, 2007

I don\'t use IRC anymore.

 Respond  
tye commented on a Page, Redirection  -  Feb 26, 2007

What\'s the purpose of the $uri variable?

 Respond  
tye commented on a Page, time by nick. V2  -  Feb 24, 2007

I believe /echo -t will only timestamp if you have timestamping enabled in your option.s

 Respond  
tye commented on a Page, Bad word warning and kick  -  Feb 08, 2007

It will work on any network.

In addition to changing the variables specified in the description you must also be opped for it to work.

 Respond  
tye created a Page  -  Feb 07, 2007

Modify the %swears variable to the words you want to warn/kick on. Change the %warnings to the number of warnings you want to give out.

tye commented on a Page, Google Search  -  Jan 05, 2007

You can\'t show more than one result without rewriting the snippet. The snippet uses the \"I\'m Feeling Lucky\" feature which returns only one result.

 Respond  
tye commented on a Page, xml parsing  -  Jan 01, 2007

SPL contains a class for parsing XML, http://www.php.net/~helly/php/ext/spl/classSimpleXMLIterator.html
Although poorly documented so far it looks promising.

 Respond  
tye commented on a Page, Upload File  -  Dec 31, 2006

There\'s also an error in your if statement that checks the type/size, it will accept a gif image of any size. It should be:

if ( (($_FILES[\"file\"][\"type\"] == \"image/gif\") || ($_FILES[\"file\"][\"type\"] == \"image/jpeg\")) && ($_FILES[\"file\"][\"size\"] < 20000))

 Respond  
tye commented on a Page, Upload File  -  Dec 31, 2006

It\'s not always a good idea to rely on $_FILES[][\'type\'] because this is simply the MIME type the client browser has given. This can potentially be faked by a client and browsers can also report the incorrect MIME type or give a generic MIME type.

You can use the getimagesize() function to get the MIME type of an image:

list($x,$x,$mime_type) = getimagesize($_FILES[\'files\'][\'tmp_name\']);

if ($mime_type == \'image/jpeg\' || $mime_type == \'image/gif\' || $mime_type == \'image/png\') {
....

 Respond  
tye created a Page  -  Dec 31, 2006
11,334 

Shows differences in two strings of text.

  2 Threads   PHP  
tye commented on a Page, Recursive Directory Browser  -  Aug 20, 2006

Adding an extra slash should not break paths
Example: /home/tye//file is the same as /home/tye/file

 Respond  
tye commented on a Page, Image Thumbnails  -  Jun 06, 2006

Thanks for posting that bug. The scale_dimensions function wasn\'t working for some combinations of numbers. I\'ve rewritten the function and tested it with every combination of numbers I could think of and it seems to work. If it doesn\'t please let me know.

 Respond  
tye commented on a Page, Infect Game[UPDATED](Again)  -  May 30, 2006

Why is this even being discussed here?

Raichu, if you have a complaint about a ripped script send a message to Hawkee.

 Respond  
tye commented on a Page, Image Thumbnails  -  May 27, 2006

Thanks for the changes.

I put them in the snippet and extended them to work on transparent PNG images.

 Respond  
tye commented on a Page, List Files  -  Feb 22, 2006

If you need more than just a list of files, the SPL has a DirectoryIterator object: http://www.php.net/manual/en/function.directoryiterator-construct.php

With it you can do more than just list files, you can also get information about their properties, ownership, permissions, whether or not php can write or read from the file etc.

 Respond  
tye commented on a Page, Session Handling  -  Oct 04, 2005

It mostly has to do with the fact that the sessions are stored in the database. You can use them in queries etc.

 Respond  
tye commented on a Page, displays real ip address  -  Oct 04, 2005

Use this with caution since the X-Forwarded-For header can be sent by a client even if they\'re not being a proxy.

 Respond  
tye created a Page  -  Sep 26, 2005

This snippet is for PHP 5+.

  3 Threads   PHP  
tye commented on a Page, Recursive Directory Browser  -  Sep 08, 2005

Forgot something in my comment:

function directoryToArray($directory, $extension = false, $full_path = true) {
if ($extension !== false && strlen($extension)) { $extension = \"\.$extension\"; }
elseif ($extension !== false && !strlen($extension)) { $extension = \"^[^.]*$\"; }

 Respond  
tye commented on a Page, Recursive Directory Browser  -  Sep 08, 2005

This is a nice snippet but a a minor change that could improve it a bit. The extension could be treated differently so you can specify no extension and only grab files with no extensions. Would be easy to do like this:

function directoryToArray($directory, $extension = false, $full_path = true) {
if ($extension !== false && strlen($extension)) { $extension = \"\.$extension\"; }

And the if statement that checks for a condition:

if($extension !== false || (ereg(\"$extension\$\", $file)))

Then leaving an empty string would return all files with no extensions, or specifying false (or leaving it empty) will return all files.

 Respond  
tye commented on a Page, Random Text  -  Aug 29, 2005

Using srand() before rand() isn\'t necessary for PHP 4.2.0+. rand() also takes two parameters like this:

rand(min,max)

This code could be simplified to:
print($random_text[rand(0,count($random_text) - 1)]);

 Respond  
tye created a Page  -  Aug 29, 2005
350 

This function will brand an image with some text. You can give it a filename or an image resource. You can use built-in gd fonts or, with some modification, TrueType fonts if GD on the server supports it. Usage when giving the function a filename: brand_image('/path/to/file','text',font); The font is the built-in GDfont number. This number can be from 1 to 4. See also the PHP function imageloadfont()..

  2 Threads   PHP  
tye commented on a Page, Image Thumbnails  -  Apr 21, 2005

I updated the snippet to support GIFs and fix a few bugs. The new code has more error checking and more comments.

 Respond  
tye commented on a Page, Image Thumbnails  -  Apr 21, 2005

I\'ve written a better version of this snippet since I uploaded it. I\'ll post that soon. This one seems to have a few problems.

 Respond  
tye commented on a Page, A little custom timestamp NICK!  -  Mar 13, 2005

you should add some switches to the /echo such as: /echo -ti2mbfl. The -t will add a timestamp if timestamping is on, i2 will cause wrapped text to be indented, m will cause the window to be highlighted with the \'message\' colour instead of the event colour and bfl will apply beep, flashing and highlighting options as configured in the mIRC options.

 Respond  
tye commented on a Page, $vie - IP, Email Validator  -  Mar 13, 2005

This doesn\'t work very well. I use $vie(999.999.999.999) and it said it was valid.

 Respond  
tye commented on a Page, Binary to text  -  Mar 13, 2005

You can use $base to convert from binary to decimal. Example: $base(101,2,10) = 5 (the 101 is the binary number, 2 is the in \'base\', 10 is the out \'base\'. 2 = binary, 10 = decimal, 16 = hexidecimal)

 Respond  
tye commented on a Page, Wget FTP CSV Datafeed Import Script  -  Mar 11, 2005

wget is almost universally installed on Linux and BSD servers. It won\'t work on Windows, however.

 Respond  
tye created a Page  -  Mar 10, 2005

This uses the GD library to create a thumbnail out of an image. $infile = path to source image $outfile = file and path to write the thumbnail to $maxw = Maximum width of the thumbnail $maxh = Maximum height of the thumbnail $stretch = Stretch image if it is smaller than the maxw and maxh The function will preserve the aspect ratio of the image. If you specify 0 for either $maxw or $maxh then the function..

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.