Exemplo n.º 1
0
function wpr_run_cron($camp_id="",$mincamp="",$maxcamp="",$minpost="",$maxpost="",$randtime=10,$chance=100) {
	global $wpdb, $wpr_table_campaigns;

	if(empty($chance) || $chance == "" || $chance == " ") {$chance = 100;}
	if($chance >= rand(1,100)) {
	
		$rtime = rand(0,$randtime);
		$comment_date = time() - $rtime * 60;
		$_POST['postdate']=date("Y-m-d H:i:s", $comment_date);		
		$csql = "";
		
		if(isset($camp_id)) {	
			if(empty($minpost) || empty($maxpost)) {$randpost = 1;} else {$randpost = rand($minpost,$maxpost);}
			for ($i = 1; $i <= $randpost; $i++) {
				wpr_poster($camp_id, "", 1);
			}
		} else {
			if(!empty($mincamp) && !empty($maxcamp)) {$campnumber = rand($mincamp,$maxcamp);$csql = " ORDER BY RAND() LIMIT $campnumber";}
			
			$results = $wpdb->get_results("SELECT id FROM " . $wpr_table_campaigns . "$csql"); 
			foreach($results as $result) {
				if(empty($minpost) || empty($maxpost)) {$minpost = 1;$randpost = 1;} else {$randpost = rand($minpost,$maxpost);}
				for ($i = $minpost; $i <= $randpost; $i++) {
					$rtime = rand(0,$randtime);
					$comment_date = time() - $rtime * 60;
					$_POST['postdate']=date("Y-m-d H:i:s", $comment_date);					
					wpr_poster($result->id, "", 1);
				}			
			}
		}
	}
}
Exemplo n.º 2
0
function wpr_run_cron($camp_id = "")
{
    global $wpdb, $wpr_table_campaigns;
    if (isset($camp_id)) {
        wpr_poster($camp_id);
    } else {
        $results = $wpdb->get_results("SELECT id FROM " . $wpr_table_campaigns . "");
        foreach ($results as $result) {
            wpr_poster($result->id);
        }
    }
}