Page 1 of 1

Script don't work..

Posted: Sat Mar 27, 2004 2:55 am
by seeker2921
Okay so in the borads there was a link to this max guys site and he made a script that I want to use.. I have edited the code in getcam.php and I got errors most of them were just simple chmod on my mail files.. now it just show this..

0 files were added to make a total of 0 files. Thankyou.

Please click here to return to the phonecam.

exactly what it is supposed to.. no errors no nothing now I have a email in my inbox and the script doesn't pull it out or do anything with it.. no files are being written and I'm woundering why.. can someone please help me out on this one??

Code: Select all

<? 
//Function for finding strings 
function strpos2($haystack, $needle, $match) { 
    $offset = 0; 
    $needlelen = strlen($needle); 
    for($i=0; $i<$match; ++$i) { 
        $thispos = strpos($haystack, $needle, $offset); 
        if(!$thispos) return false; 
        $offset = $thispos + $needlelen; 
    } 
    return $thispos; 
} 
// Open the mailbox 
system('rm /home/stephen/public_html/site/moblog/*'); //full path to scratch directory 
$inbox = '/home/stephen/mail/cam/'; //full path to inbox 
$open = fopen($inbox, "r"); 
$input = fread($open, filesize($inbox)); 
fclose($open); 

function Remove($string, $sep1, $sep2, $count) 
{ 
  $check = strpos2($string, $sep2, $count);  //starts cropping inbox files 
  $string = strrev(substr($string, 0,  strpos2($string, $sep2, $count))); 
  $string = strrev(substr($string,0,strpos($string, strrev($sep1)))); 
  if ($check == 'FALSE') $string = "ended"; 
  return $string; 
} 

$maxcount = 2 * substr_count($input, 'From stephengunn@charter.net'); //in all cases, replace xxxxxxxxx with phone number 
for ($count=2;$count<=$maxcount;$count=$count+2){ 
    $predecode = remove($input, 'filename=picture.jpg', '--Boundary_', $count); 
    $text = remove($input, 'From stephengunn@charter.net', 'Return-path: <stephengunn@charter.net>', $count/2); 
    $date = strtotime($text); 
    $dateout = date ('D d/m/Y g:ia', mktime (date("H", $date)+8 , date("i", $date), date("s", $date), date("m", $date), date("d", $date), date("y", $date))); 
    $output = base64_decode($predecode); 
    $textname = "$count"; 
    $fptext = fopen("/home/stephen/public_html/site/moblog/$textname", "a"); 
    $write = fputs($fptext, $dateout); 
    fclose ($fptext); 
    $filename = "$count.jpg"; 
    $fp = fopen("/home/stephen/public_html/site/moblog/$filename", "a"); 
    $write = fputs($fp, $output); 
    fclose($fp); 
} 

//counts number of existing files 
function countFiles($dir) 
  { 
    $count  = 0; 
    if (file_exists($dir)) 
    { 
      $handle = opendir($dir); 
      while (false !== ($file = readdir($handle))) 
      { 
        if ($file != "." && $file != "..") 
        { 
          $count++; 
        } 
      } 
      closedir($handle); 
    } 
    return $count; 
  } 
//finishes counting, and writes files and dates 
$count = 1 + (countfiles('/site/moblog/images/camera'))/2; 
$newfiles = countfiles('/site/moblog/images'); 
if ($newfiles != 0){ 
for ($repeat = 2;$repeat<=$newfiles;$repeat = $repeat+2) { 
copy ("/site/moblog/images/$repeat.jpg","/site/moblog/images/camera/$count.jpg"); 
copy ("/site/moblog/images/$repeat","/site/moblog/images/camera/$count"); 
$count++; 
}} 
$count--; 
system('rm /home/stephen/mail/cam/inbox'); 
//copy ("/home/stephen/mail/cam/empty", "/home/stephen/mail/stephen/inbox"); 
$donefiles = $newfiles/2; 
print(''.$donefiles.' files were added to make a total of '.$count.' files. Thankyou.'); 
print('<br><br>Please click <a href="phonecam.php">here</a> to return to the phonecam.'); 
?>

Posted: Sat Mar 27, 2004 8:42 am
by Illusionist
seeker2921 wrote:

Code: Select all

$inbox = '/home/stephen/mail/cam/'; //full path to inbox
$open = fopen($inbox, "r");
$input = fread($open, filesize($inbox));
fclose($open);
are you trying to open a directory and read it as a file??
if your trying to open a directory and read the files inside, try the [php_man]opendir[/php_man] and [php_man]readdir[/php_man] functions.

Posted: Sat Mar 27, 2004 8:15 pm
by seeker2921
nope.. theres a file in the cam dir that is called inbox it doesn't have an extention or anything so just inbox and not like inbox.php

Posted: Sat Mar 27, 2004 8:25 pm
by Illusionist
uhh... where are you opening this inbox file??

Code: Select all

$inbox = '/home/stephen/mail/cam/'; //full path to inbox
$open = fopen($inbox, "r");
doesn't open any file named inbox, you know that, right??

Posted: Sat Mar 27, 2004 8:34 pm
by seeker2921
nope.. didn't know that.. the script just says fullpath to inbox so I put the path to it.. I have no clue about the script..

Posted: Sat Mar 27, 2004 8:52 pm
by Illusionist
ya... full path to inbox including the file is waht it should be...

Posted: Sat Mar 27, 2004 8:54 pm
by seeker2921
Okay, I added inbox to the path and now it puts two files in my /site/moblog directory one called 2 and the other 2.jpg contained in 2 is the date of the file and 2.jpg is 0 bytes in size so it doesn't show the image that is in my inbox, also isn't the script supposed to delete the email out of the inbox.. if so it doesn;t do that either.. I also get zero errors

Posted: Sat Mar 27, 2004 9:03 pm
by Illusionist
have you trie dit? and why dont you add any kind of extension to the file??

Posted: Sat Mar 27, 2004 9:05 pm
by seeker2921
I edited my post above explaining what happens when I tried it.. also I didn't know what exteention to add becuase its all my web hosts stuff I didn't wanna mess anythin up..

Posted: Sat Mar 27, 2004 9:09 pm
by Illusionist
whta exactly is the 'inbox' ?? Is it an actuall folder with email files in it?? Or is it one big file that stores all emails??

Posted: Sat Mar 27, 2004 9:12 pm
by seeker2921
one big file that stores all e-mails inside of it..

Posted: Sun Mar 28, 2004 10:29 pm
by seeker2921
still having issues.. any ideas?