コード例 #1
0
 private function removeCronJob($startDate)
 {
     $cronDate = $this->cronDateTime($startDate);
     $needle = $cronDate['minute'] . " " . $cronDate['hour'] . " " . $cronDate['day'] . " " . $cronDate['month'] . " " . '*';
     $cron = new Crontab('nymedia_crontab');
     $cronJobs = $cron->getJobs();
     for ($i = 0; $i < count($cronJobs); $i++) {
         if ($cronJobs[$i]->getMinute() == $cronDate['minute'] && $cronJobs[$i]->getHour() == $cronDate['hour'] && $cronJobs[$i]->getDay() == $cronDate['day'] && $cronJobs[$i]->getMonth() == $cronDate['month']) {
             $cron->removeJob($i);
         }
     }
     $cron->saveCronFile();
     // save to my_crontab cronfile
     $cron->saveToCrontab();
     // adds all my_crontab jobs to system (replacing previous my_crontab jobs)
 }
コード例 #2
0
ファイル: lethe.php プロジェクト: BersnardC/DROPINN
/* Submission Account Limit Resetter */
$opSubAcc = $myconn->query("SELECT * FROM " . db_table_pref . "submission_accounts WHERE isActive=1 AND daily_reset<'" . date("Y-m-d H:i:s") . "'") or die(mysqli_error($myconn));
while ($opSubAccRs = $opSubAcc->fetch_assoc()) {
    $newReset = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s") . "+" . $opSubAccRs['limit_range'] . " minutes"));
    $myconn->query("UPDATE " . db_table_pref . "submission_accounts SET daily_sent=0, daily_reset='" . $newReset . "' WHERE ID=" . $opSubAccRs['ID'] . "") or die(mysqli_error($myconn));
}
$opSubAcc->free();
$debugs[] = '* Submission Account Limits Controlled';
/* Organization Daily Limit Resetter */
$newReset = date("Y-m-d H:i:s", strtotime(date("Y-m-d H:i:s") . "+1 day"));
if ($myconn->query("UPDATE " . db_table_pref . "organizations SET daily_sent=0, daily_reset='" . $newReset . "' WHERE isActive=1 AND daily_reset<'" . date("Y-m-d H:i:s") . "'")) {
    $debugs[] = '* Organization Daily Limit Reset';
}
/* Task List Modifier */
$letChr = new Crontab();
$currJobs = $letChr->getJobs();
$remJobs = array();
$addJobs = array();
$opTasks = $myconn->query("SELECT * FROM " . db_table_pref . "chronos ORDER BY pos DESC") or die(mysqli_error($myconn));
while ($opTasksRs = $opTasks->fetch_assoc()) {
    /* Remove Crons */
    if ($opTasksRs['pos'] == 1) {
        if ($letChr->doesJobExist($opTasksRs['cron_command'])) {
            $remJobs[] = $opTasksRs['cron_command'];
            $myconn->query("DELETE FROM " . db_table_pref . "chronos WHERE ID=" . $opTasksRs['ID'] . "");
            $debugs[] = '* Removed Cron: ' . $opTasksRs['cron_command'];
        } else {
            $debugs[] = '* There No Expired Cron Command Found';
        }
    } else {
        if ($opTasksRs['launch_date'] <= date('Y-m-d H:i:s')) {
コード例 #3
0
	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($id)
	{
		$model=$this->loadModel($id);

		// comment the following line if AJAX validation is not needed
		 $this->performAjaxValidation($model);

		if(isset($_POST['ScheduleTiming']))
		{
			$model->attributes=$_POST['ScheduleTiming'];
			if($model->schedule_timing_minute==60)
			{
			  $minute="*";
			}
			else
			{
			  $minute=$model->schedule_timing_minute;
			}
			if($model->schedule_timing_hour==24)
			{
			  $hour="*";
			}
			else
			{
		          $hour=$model->schedule_timing_hour;
			}
			if($model->schedule_timing_date==32)
			{
				$date="*";
			}
			else
			{
				$date=$model->schedule_timing_date;
			}
			$days=array("Sunday"=>7,"Monday"=>1,"Tuesday"=>2,"Wednesday"=>3,"Thursday"=>4,"Friday"=>5,"Saturday"=>6,"*"=>"*");
			$day=$days[$model->schedule_timing_day];
			$months=array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12,'*'=>'*');
			$month=$months[$model->schedule_timing_month];
		
			$model->schedule_timing_name=$minute."-".$hour."-".$date."-".$model->schedule_timing_month."-".$model->schedule_timing_day;
			if($model->save())
			{
			$crons=StudentSmsEmailDetails::model()->findAll(array('condition'=>'student_sms_email_details_schedule_time_id='.$model->schedule_timing_id));
			$j = count($crons);
			$i = 0;

			foreach($crons as $cron)
			{
			    if($cron->student_sms_email_details_purpose=="fees")
			    {
				$period=$cron->academic_period_id;
				$sem=$cron->academic_name_id;
				$branch=$cron->branch_id;
				$div=$cron->division_id;
				$purpose=$cron->student_sms_email_details_purpose;
				$message=$cron->message_email_text;
				$user=$cron->created_by;
				$to=$cron->student_sms_email_details_fees_msg_type;
				$mobile=$cron->student_sms_email_details_to_mobile;
				$cronid=$cron->student_sms_email_details_cron_no-$i;
				$mycron = new Crontab('my_crontab'); 
				$jobs_obj = $mycron->getJobs();	
				$mycron->removeJob($cronid); 	
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
				StudentSmsEmailDetails::model()->updateCounters(array('student_sms_email_details_cron_no'=>-1),'student_sms_email_details_cron_no>'.$cronid);
				$mycron = new Crontab('my_crontab'); 
				$cron->student_sms_email_details_cron_no=((count($mycron->getJobs())));
				$cron->save();
				$mycron->addJob(Yii::getPathOfAlias('webroot').'/protected/yiic feesschedulesms '.$period." ".$sem." ".$branch." ".$div." ".$purpose." \"$message\" ".$user." ".$to." ".$mobile , $minute, $hour,$date,$month,$day);
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
			     }
			     else
			     {
				$period=$cron->academic_period_id;
				$sem=$cron->academic_name_id;
				$branch=$cron->branch_id;
				$div=$cron->division_id;
				$purpose=$cron->student_sms_email_details_purpose;
				$user=$cron->created_by;
				$mobile=$cron->student_sms_email_details_to_mobile;
				$cronid=$cron->student_sms_email_details_cron_no-$i;
				$mycron = new Crontab('my_crontab'); 
				$jobs_obj = $mycron->getJobs();	
				$mycron->removeJob($cronid); 	
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
				StudentSmsEmailDetails::model()->updateCounters(array('student_sms_email_details_cron_no'=>-1),'student_sms_email_details_cron_no>'.$cronid);
				$mycron = new Crontab('my_crontab'); 
				$cron->student_sms_email_details_cron_no=(count($mycron->getJobs()));
				$cron->save();
				$mycron->addJob(Yii::getPathOfAlias('webroot').'/protected/yiic attendance '.$period." ".$sem." ".$branch." ".$div." ".$purpose." ".$user." ".$mobile,$minute,$hour,$date,$month,$day);
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
			      }
			$i++;	
			}
			$backup_crons=DatabaseBackupCron::model()->findAll(array('condition'=>'database_backup_cron_schedule_time_id='.$model->schedule_timing_id));
			$j = count($backup_crons);
			$i = 0;

			foreach($backup_crons as $cron)
			{
				$cronid=$cron->database_backup_cron_no-$i;
				$mycron = new Crontab('backup_crontab'); 
				$jobs_obj = $mycron->getJobs();	
				$mycron->removeJob($cronid); 	
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
				DatabaseBackupCron::model()->updateCounters(array('database_backup_cron_no'=>-1),'database_backup_cron_no>'.$cronid);
				$mycron = new Crontab('backup_crontab'); 
				$cron->database_backup_cron_no=((count($mycron->getJobs())));
				$cron->save();
				$mycron->addJob(Yii::getPathOfAlias('webroot').'/protected/yiic backup' , $minute, $hour,$date,$month,$day);	
				$mycron->saveCronFile(); 	
				$mycron->saveToCrontab();
				$i++;	
			}
			
				$this->redirect(array('view','id'=>$model->schedule_timing_id));
			}
		}
		$this->render('update',array(
			'model'=>$model,
		));
	}
コード例 #4
0
	/**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
	public function actionDelete($id)
	{
		$model=$this->loadModel($id);
		$cron = new Crontab('backup_crontab'); 
		$jobs_obj = $cron->getJobs();	
		$cron->removeJob($model->database_backup_cron_no); 			
		$cron->saveCronFile(); 	
		$cron->saveToCrontab();	
		$cronid=$model->database_backup_cron_no;
		DatabaseBackupCron::model()->updateCounters(array('database_backup_cron_no'=>-1),'database_backup_cron_no>'.$cronid);

		// we only allow deletion via POST request
		$this->loadModel($id)->delete();

		// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
		if(!isset($_GET['ajax']))
	 	  $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
	}
コード例 #5
0
	/**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
	public function actionDelete($id)
	{
		$model=$this->loadModel($id);
		$cron = new Crontab('my_crontab'); 
		$jobs_obj = $cron->getJobs();	
		$cron->removeJob($model->student_sms_email_details_cron_no); 			
		$cron->saveCronFile(); 	
		$cron->saveToCrontab();	
		$cronid=$model->student_sms_email_details_cron_no;
		StudentSmsEmailDetails::model()->updateCounters(array('student_sms_email_details_cron_no'=>-1),'student_sms_email_details_cron_no>'.$cronid);
		$this->loadModel($id)->delete();
		// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
		if(!isset($_GET['ajax']))
			$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('scheduleMessages'));
	}
コード例 #6
0
	/**
	 * Deletes a particular model.
	 * If deletion is successful, the browser will be redirected to the 'admin' page.
	 * @param integer $id the ID of the model to be deleted
	 */
	public function actionDelete($id)
	{
		if(Yii::app()->request->isPostRequest)
		{
			// we only allow deletion via POST request
			// we only allow deletion via POST request
			$model=$this->loadModel($id);
			$cron = new Crontab('mail_crontab'); 
			$jobs_obj = $cron->getJobs();	
			$cron->removeJob($model->student_attendence_email_cron_no); 				$cron->saveCronFile(); 	
			$cron->saveToCrontab();	
			$cronid=$model->student_attendence_email_cron_no;
			StudentAttendenceEmail::model()->updateCounters(array('student_attendence_email_cron_no'=>-1),'student_attendence_email_cron_no>'.$cronid);
			$this->loadModel($id)->delete();

			// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
			if(!isset($_GET['ajax']))
				$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
		}
		else
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
	}