Go Back   CodingForums.com > Web Projects and Services Marketplace > Web Projects > Small projects (quick fixes and changes)

Notices

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-24-2009, 07:03 AM   PM User | #1
The_Return
Regular Coder

 
Join Date: Dec 2008
Posts: 116
Thanks: 11
Thanked 4 Times in 4 Posts
The_Return has a little shameless behaviour in the past
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 08:29 PM..
The_Return is offline   Reply With Quote
Old 08-24-2009, 09:16 AM   PM User | #2
it career
Banned

 
Join Date: Jun 2007
Location: Web Designer
Posts: 321
Thanks: 0
Thanked 6 Times in 6 Posts
it career can only hope to improve
What is the work ? - just adding this php file in your cron job list ?
it career is offline   Reply With Quote
Old 08-24-2009, 04:04 PM   PM User | #3
The_Return
Regular Coder

 
Join Date: Dec 2008
Posts: 116
Thanks: 11
Thanked 4 Times in 4 Posts
The_Return has a little shameless behaviour in the past
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
The_Return is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:07 PM.


Advertisement
Log in to turn off these ads.