Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by section31

  1. I have some issues with modrewrite and the ampersand.


    I encoded the ampersand to %26, but it doesn't seem to work. View the following php scripts to replicate the issue.


    Using Simple Get Request


    >prints Array ( [foo] => a&b )


    Using Mod Rewrite (RewriteRule ^foo/(.*) get.php?foo=$1)


    >prints Array ( [foo] => a [b] => )


    Anyone have any experience using an ampersand with mod rewrite.

  2. Ok, I was trying to break the habit of using the mail() function and instead start using pear's mail library so I can authenticate myself and I won't have to send as "nobody".


    Well, I wrote a sample script and had it send 3 emails, one for each of the largest free email providers. One to gmail, yahoo, and hotmail. All of them go through fine except hotmail. It doesn't throw it in the junk mail, it just doesn't get delivered. I've tried this on 2 servers, one on tch and also on another host. Same results...Any Ideas? If someone wants to try it out, that would be great.


    Here is the snippet of code to get you going.



    $headers['From'] = 'name <user@yourdomain.tld>';  // put your name and email here
    $headers['Subject'] = 'Testing SMTP Mail';
    $body = 'This is a plain text body message.';
    $params['auth'] = true;
    $params['host'] = 'localhost';
    $params['username'] = 'user@yourdomain.tld';  // put your username here which is your email address
    $params['password'] = 'pass'; // pur your pass here
    $params["persist"] = true;
    $mail_object =& Mail::factory('smtp', $params);
    foreach (array('user@hotmail.com', 'user@yahoo.com', 'user@gmail.com') as $to) {  // put your emails here
    $headers['To'] = $to;
    $mail_object->send($to, $headers, $body);
    echo "Email sent to $to!<br />";

  3. When I send out an email with php's mail() function and I add the 5th parameter to specify the return path to on my valid email address ex. admin@****, is the email suppose to bounce back to that address if it fails to send it. I just tried doing that, and I can't get it to bounce back.

  4. Hi guys, does anyone happen to know a script that can do the exact same thing cpanel does when you go into subdomain stats and click on latest visitors. It gives you like some type of path analysis to show you how the client navigated your site.


    Here is a screenshot from cpanel. Even the exact same script in perl or php would be great.


  5. I would have thought adding the '-z' to your tar command would have more effect on your problem than the '2>&1'.  All the '2>&1' does is redirect any error messages (STDERR) to where your PHP script can capture them in the $output variable (STDOUT).


    I guess you have file names with spaces in them, huh?  :(


    Glad to hear you finally got it working!  :thumbup1:


    Yeah, i don't really understand why the '2>&1' made the difference and not the z flag.


    My files did have spaces in them, but that -print0 and xargs -0 fixed that problem.

  6. Hey david, It appears the 2>&1 fixed the problem, but now I figured out a way without it. So, here is the final solution to my goal for the record.


    ># Works with spaces in filenames/directorys too
    find './foobarDir/' -iregex '.*\.\(jpg\|jpeg\)' -maxdepth 1 -print0 | xargs -0 tar -cvzf backup.tar.gz


    Thanks you two for being so patient with me.

  7. I took off the trailing slash and no change.


    This is whats returned, so there isn't much to work with. Is there a way I can force out more error codes or something. I'm going to start weeping if we don't figure this out. cry.gif

    >exec($cmd, $output, $returnCode);
    echo '<pre>' , print_r($output, true) , "\nReturn Code - " , $returnCode , '</pre>';


    The above returns this






    Return Code - 2


    NOTE: in case you need a link to exec() http://us3.php.net/function.exec

  8. Sorry I took so long for the reply.


    Yeah, I tried using the find first and I get the identical results as the other method. It works when I use find . but doesn't work when I use find ./someDir/.


    You mean something like this right?

    >find . -iregex '.*\.\(jpg\|jpeg\)' -maxdepth 1 | xargs tar -cvf backup.tar.gz

  9. Tried that bruce, and I got the same results an empty archive.


    I double checked what find returns and the results were correct either way, you're way or my way.


    This is odd behavior isn't it?

  10. i've been trying to troubleshoot this for a long time now and I can't figure it out :cry: I was hoping to see if anyone had problems like this?


    Purpose: To make a gzipped tarball of a subdirectory. Please look at the 2nd bit of code, thats where the problem is. Whenever I change the path of the find directory, it doesn't work properly even after I checked the find's results and they are correct. The problem happens when making the tar.gz, like stated below it creates an empty archive instead.

    /* This Works Fine */
    /* finds any jpg or jpegs in the current working directory and makes a gzip tarball of it. */
    $cmd = "tar -cvf backup.tar.gz `find . -iregex '.*\.\(jpg\|jpeg\)' -maxdepth 1`";
    exec($cmd, $output, $returnCodes);
    /* This Does Not Work, it puts an emtpy gzip tarball thats app. 10k in the directory */
    /* The only thing thats diff here is i change the find to look in a subdirectory */
    $cmd = "tar -cvf backup.tar.gz `find './foobarDir/' -iregex '.*\.\(jpg\|jpeg\)' -maxdepth 1`";
    exec($cmd, $output, $returnCodes);

  11. Does anyone happen to have a function using GD to create thumbnails while maintaining their proportions and padded to a fixed resolution?  Any of the above opensource scripts happen to do that?


    Ok, I figured it out. In case anybody wants to use it someday.

    //  Makes thumbnails to a fixed size and uses padding to keep aspect ratio.
    //  email section31 at gmail to report bugs or improvements.  :)
    function makeThumb($file)
    $dstWidth = 80;
    $dstHeight = 120;
    list(, , $type, ) = getimagesize($file);
    //1 = GIF, 2 = JPG, 3 = PNG   
    if ($type == 2)
     $handle = @imagecreatefromjpeg($file);
    elseif ($type == 3)
     $handle = @imagecreatefrompng($file);
    elseif ($type == 1)
     $handle = @imagecreatefromgif($file);
    elseif (!$handle)
     return false;
     return false;
    $srcWidth  = @imagesx($handle);
    $srcHeight = @imagesy($handle);
    if ($srcWidth >= $dstWidth && $srcHeight >= $dstHeight) {
     $newHandle = @imagecreatetruecolor($dstWidth, $dstHeight);
     if ($srcWidth/$srcHeight > $dstWidth / $dstHeight) {
    	 $thumbwidth = $dstWidth;
    	 $thumbheight = round( ($thumbwidth / $srcWidth) * $srcHeight );
    	 $xOffset = 0;
    	 $yOffset = round(($dstHeight - $thumbheight) / 2);
     else {
    	 $thumbheight = $dstHeight;
    	 $thumbwidth = round( ($thumbheight / $srcHeight) * $srcWidth );
    	 $xOffset = round(($dstWidth - $thumbwidth) / 2);
    	 $yOffset = 0;
     // Fill background with RGB Color ex. 255, 0, 0 equales RED
     $background = imageColorAllocate($newHandle, 0, 0, 0);
     imagefilledrectangle($newHandle, 0, 0, $dstWidth, $dstHeight, $background);
     if (!@imagecopyresampled($newHandle, $handle, $xOffset, $yOffset, 0, 0, $thumbwidth, $thumbheight, $srcWidth, $srcHeight))
    	 return false;
     if ($type == 3)
    	 @imagepng($newHandle, $file);
     elseif ($type == 2)
    	 @imagejpeg($newHandle, $file, 90);
     elseif ($type == 1)
    	 @imagegif($newHandle, $file);
    	 return false;
     return true;
     return false;

  12. Does anyone happen to have a function using GD to create thumbnails while maintaining their proportions and padded to a fixed resolution? Any of the above opensource scripts happen to do that?

  13. thanks for the reply david. Yeah, I don't think i'll ever be using ob_start again for storing stuff to a variable for later use. Its just I've come across all these contradicting sites doing things different ways that claim to be more efficient and I have this urge to find the most appropriate way of doing something. I don't really like just taking their word for it, so I benchmark it myself.

  14. In case anyone is actually interested in this stuff, I'm going to continue my own debate on this issue.l


    I think i might have made a mistake on my previous code. Granted that article explicitely states that using obstart is faster than concatenating multiple small strings but now my benchmarks contradict that.





    For some reason on the code I used before, the string i used wasn't the same length....lol


    I've tested both of these using ab and have confirmed the results. Now i'm really confused, just when I thought it was all becoming clear to me.

  • Create New...