[Phpwm] Basic PHP Query (Very basic!)

Phil Beynon phil at infolinkelectronics.co.uk
Thu Apr 27 12:34:22 BST 2006


> Thanks for input Jon - I know there was / is a CRON job running due to
> previously having access to the mailbox that received the job. This
> windows account has now been closed so it is no longer possible to get
> them. Code for the cron.php file used on the site is below:
>
>
> <?
>
> $mysql_link = mysql_connect("217.8.240.11", "birthday", "card");
> $sdp=mysql_select_db("emp_data");
> $adminemail = "happybirthday at coopbirthday.co.uk ";
> $dt = date("Y/m/d");
>
>         $str = "Select empid,firstname,lastname,email from
> employeemaster where dayofmonth(dateofbirth)='" .date("d") . "' and
> month(dateofbirth)='" . date("m") . "'" ;
>         //echo $str;
>         $rs = mysql_query($str) or die(mysql_error());
>         $num_rows = mysql_num_rows($rs);
>
>         if ($num_rows > 0)
>         {
>                 $strf = "select cardurl from birthdaycardmaster";
>                 $resultf = mysql_query($strf) or die(mysql_error());
>                 if (mysql_num_rows($resultf) > 0)
>                 list($cardfile) = mysql_fetch_array($resultf);
>                 if (isset($cardfile) && $cardfile <> "" &&
> file_exists($cardfile))
>                 {
>                         $msgsubj = "";
>                         $sql="Select msgid,msgsubj from messagemaster
> order by msgid desc limit 1";
>                         $result=mysql_query($sql);
>                         if(mysql_num_rows($result)>0)
>
> list($msgid,$msgsubj)=mysql_fetch_array($result);
>                         //echo $msgid . " " . $msgsubj . "dd";
>                         if (isset($msgsubj) && $msgsubj <> "")
>                         {
>
>
> while(list($empid,$firstname,$lastname,$email) = mysql_fetch_array($rs))
>                                         {
>                                                 //echo $cardfile .
> $email . "<br>";
>                                                 /*$m= new Mail; //
> create the mail
>                                                 $m->From($adminemail);
>                                                 $m->To($email);
>                                                 $m->Subject($msgsubj);
>                                                 //$m->Attach($cardfile,
> "application/x-zip-compressed" ,"attachment") ;        // attach a file
> of type image/gif
>                                                 $msg =  "<font
> face='Arial, Helvetica, sans-serif' size='2'><b>Dear " .
> ucfirst($firstname) . "</b>,<br>Many happy returns of the day<br><br>To
> view your card, click on the following link. <br><br> <a
> href=\"http://www.coopbirthday.co.uk/cardview.php?id=$empid\">http://www
> .coopbirthday.co.uk/cardview.php?id=$empid</a><br><br>Best
> Wishes<br><br>The Management Team.<br></font>";
>                                                         //
>                                                 $m->Body( $msg);
> // set the body
>                                                 $m->Priority(2) ;
> // set the priority to Low
>                                                 $m->Send();        //
> send the mail
>                                                 */
>                                                 $subject = $msgsubj;
>                                                 $emal = $adminemail ; //
> from
>                                                 $eml = $email;  //to
>                                                 $headers = "From:" .
> $emal ."\nReply-To: " .$emal. "\nContent-Type: text/html;
> charset=iso-8859-1;";
>                                                 $msg =
> "<html><body><p><font face='Arial, Helvetica, sans-serif'
> size='2'><b>Dear " . ucfirst($firstname) . "</b>,<br>Many happy returns
> of the day<br><br>To view your card, click on the following link.
> <br><br> <a
> href=\"http://www.coopbirthday.co.uk/cardview.php?id=$empid\">http://www
> .coopbirthday.co.uk/cardview.php?id=$empid</a><br><br>Best
> Wishes<br><br>The Management Team.<br></font></p></body></html>" ;
>
>                                                 //echo $eml . " " .
> $subject . " " . $msg . " " . $headers;
>                                                 if
> (!mail("$eml","$subject","$msg","$headers"))
>                                                 $mailmsg=1;
>                                                 else
>                                                 $mailmsg=2;
>
>                                                 $strEmp = "Update
> employeemaster set msgid = $msgid,msgdate = '" . $dt . "' where empid =
> " . $empid;
>                                                 mysql_query($strEmp);
>                                         }
>                         }
>                 }
>         }
> //echo $str;
> ?>
>
> Thanks
>
> Justin

Hi Justin,
Do you have access via the ISP to the line of code in the CRON job that runs
the program perhaps?
I would think, based upon the way I normally do it, that you would have
something like;

33 22 1 * * cd /usr/bin; ./lynx --dump http://www.mydomain.com/monthly.php
>/dev/null

If you are trying to get an server admin type error warning only upon
execution failure, OR

03 0,12 * * * cd /usr/local/sbin; ./chkrootkit -v 2>&1 | mail -s username

If you want it to be sent to a specific usernames email account. If you
wanted this then to be sent to multiple recipients you can put a .forward
file in that users /mail directory.

Putting your MySQL username and password into an email isn't terribly good
practice by the way! :-)


Regards,

Phil Beynon
Sales director

** http://www.diygear.com THE Online DIY Toolstore For DIY & Business
** Infolink Electronic Systems Ltd. http://www.infolinkelectronics.co.uk
** Professional Web Design & Cobalt Hosting Solutions
** Contact: Sales at infolinkelectronics.co.uk
** Tel / Fax 0121 458 4894 (office) 0121 441 3558 (home) 07801 548464
(mobile)




More information about the Phpwm mailing list