Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Cron script

  1. #1
    Regular Coder
    Join Date
    Dec 2008
    Posts
    116
    Thanks
    11
    Thanked 4 Times in 4 Posts

    Cron script

    1) Project Details: Cron script to check database

    2) Payment Amount: $10

    3) Payment method: Paypal

    ok updated the script a bit now the problem is if you loop the aim parts it stops working I also concluded a working script at the bottom if you can help me pm.

    PHP Code:
    <?php
    ob_implicit_flush
    (true); 
    include(
    "aimclassw.php"); //Toc

    //Database connect

    $query3 "SELECT COUNT(*) as num FROM jobs WHERE status = '0'";
    $total_jobs mysql_fetch_array(mysql_query($query3));
    $total_jobs $total_jobs[num];

    if (
    $total_jobs 0) {

    $b = new Aim("screenname","password",4); 
    $b->registerHandler("Config","onConfig"); 
    $b->registerHandler("Nick","onNick"); 
    $b->signon(); 
    sleep(3); // delay after sign in 

    while(!defined("CAN_SEND")){ 
    $b->receive(); 
    }

    //check if their are jobs
    $query "SELECT * FROM jobs WHERE status = '0'";
    $result mysql_query($query) or die(mysql_error());

    while(
    $row mysql_fetch_array($result)) {

    $message $row['message'];
    $hostid $row['hostid'];

    //select all the aims with the host id given
    $q "SELECT aim FROM friends WHERE hostid = '$hostid'";
    $re mysql_query($q) or die(mysql_error());

    while(
    $r mysql_fetch_array($re)){

    $aim $r['aim'];

    $b->sendIM("$aim","$message"); 
    sleep(3); 

    }
    //End while loop

    $query2 "DELETE FROM `jobs` WHERE `message` = '$message' AND `hostid` = '$hostid'";
    $result2 mysql_query($query2); 

    //end loop 

    function onConfig() 

    define("CAN_SEND",1); 
    return; 


    }
    // end if
    ?>
    heres an example of a working version tho it can not grab the host id or the message so I have to manually put it in

    PHP Code:
    <?php
    ob_implicit_flush
    (true); 
    include(
    "aimclassw.php"); //Toc

    //Database connect

    $hostid "c9723097991b56826b1b854f61c177f3";
    $message "This is a test notification";
     
    //Grab them screen names 
    $query "SELECT aim FROM friends WHERE hostid = '$hostid'";
         
    $result mysql_query($query) or die(mysql_error());

    $b = new Aim("screenanme","password",4); 
    $b->registerHandler("Config","onConfig"); 
    $b->registerHandler("Nick","onNick"); 
    $b->signon(); 
    sleep(3); // delay after sign in 


    while(!defined("CAN_SEND")){ 
    $b->receive(); 


    while(
    $row mysql_fetch_array($result)){

    $b->sendIM($row['aim'],"$message"); 
    sleep(3); 

      }
    //End while loop
      
    function onConfig() 

    define("CAN_SEND",1); 
    return; 


    ?>
    Last edited by The_Return; 08-24-2009 at 09:29 PM.

  • #2
    Banned
    Join Date
    Jun 2007
    Location
    Web Designer
    Posts
    321
    Thanks
    0
    Thanked 6 Times in 6 Posts
    What is the work ? - just adding this php file in your cron job list ?

  • #3
    Regular Coder
    Join Date
    Dec 2008
    Posts
    116
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Just to fix my script so it does this

    First checks for jobs in the database if so continue

    Next it grabs the row with message and hostid

    Then gets all the screen names with host and sends out message (That part is working fine)

    Deletes the job because it is finished

    Goes to next job if their is any


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •