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.');
?>