function item_adManage_cron() { $conn = getConnection(); $allItems = $conn->osc_dbFetchResults("SELECT * FROM %st_item", DB_TABLE_PREFIX); foreach ($allItems as $itemA) { $pCats = $conn->osc_dbFetchResult("SELECT * FROM %st_plugin_category WHERE s_plugin_name = '%s' AND fk_i_category_id = '%d'", DB_TABLE_PREFIX, 'adManage', $itemA['fk_i_category_id']); $pCatCount = count($pCats); $repub = $conn->osc_dbFetchResult("SELECT * FROM %st_item_adManage_limit WHERE fk_i_item_id = %d", DB_TABLE_PREFIX, $itemA['pk_i_id']); if (osc_expire_date($itemA['pk_i_id']) == TRUE && $pCatCount != 0) { item_expire_email($itemA['pk_i_id'], $repub['r_secret'], osc_adManage_expire()); $conn->osc_dbExec("INSERT %st_item_adManage_log (fk_i_item_id, log_date, error_action) VALUES ('%d', '%s', '%s')", DB_TABLE_PREFIX, $itemA['pk_i_id'], date('Y-m-d H:i:s'), 'Ad about to expire email sent. Successful'); } if (osc_item_adManage_adEmailEx() == 1) { if (item_is_expired($itemA)) { $exEmailed = $conn->osc_dbFetchResult("SELECT * FROM %st_item_adManage_limit WHERE fk_i_item_id= '%d'", DB_TABLE_PREFIX, $itemA['pk_i_id']); if ($exEmailed['ex_email'] != 1) { item_expired_email($itemA['pk_i_id'], $repub['r_secret'], osc_item_adManage_deleteDays()); $conn->osc_dbExec("UPDATE %st_item_adManage_limit SET ex_email = '%d' WHERE fk_i_item_id = '%d'", DB_TABLE_PREFIX, 1, $itemA['pk_i_id']); $conn->osc_dbExec("INSERT %st_item_adManage_log (fk_i_item_id, log_date, error_action) VALUES ('%d', '%s', '%s')", DB_TABLE_PREFIX, $itemA['pk_i_id'], date('Y-m-d H:i:s'), 'Expired email sent. Successful'); } // end check of expired email has been sent. } // end of is item expired check. } // end of if expired email enabled if (osc_item_adManage_deleteDays() != 0) { if ($pCatCount != 0) { if (item_is_expired($itemA, osc_item_adManage_deleteDays())) { $item = Item::newInstance()->listWhere("i.pk_i_id = '%s' AND ((i.s_secret = '%s') OR (i.fk_i_user_id = '%d'))", $itemA['pk_i_id'], $itemA['s_secret'], $itemA['fk_i_user_id']); if (count($item) == 1) { $mItems = new ItemActions(false); $success = $mItems->delete($item[0]['s_secret'], $item[0]['pk_i_id']); if ($success) { $conn->osc_dbExec("INSERT %st_item_adManage_log (fk_i_item_id, log_date, error_action) VALUES ('%d', '%s', '%s')", DB_TABLE_PREFIX, $itemA['pk_i_id'], date('Y-m-d H:i:s'), 'Cron item deleted. Successful.'); } else { $conn->osc_dbExec("INSERT %st_item_adManage_log (fk_i_item_id, log_date, error_action) VALUES ('%d', '%s', '%s')", DB_TABLE_PREFIX, $itemA['pk_i_id'], date('Y-m-d H:i:s'), 'Cron item could not be deleted.'); } // end success } // end count of items that need to be deleted. $conn->osc_dbExec("INSERT %st_item_adManage_log (fk_i_item_id, log_date, error_action) VALUES ('%d', '%s', '%s')", DB_TABLE_PREFIX, $itemA['pk_i_id'], date('Y-m-d H:i:s'), 'Cron item could not be deleted item not found.'); } // end of if item is expired past set expired date } // end check if item is in pCatCount } // end check if deleteDays is not equal to zero. } //end of foreach }
} else { $rTimes = osc_adManage_repubTimes() != '' ? osc_adManage_repubTimes() : ''; } $freeTimes = ''; $dao_preference = new Preference(); if (Params::getParam('freeTimes') != '') { $freeTimes = Params::getParam('freeTimes'); } else { $freeTimes = osc_item_adManage_freeRepubs() != '' ? osc_item_adManage_freeRepubs() : ''; } $adEmailEx = ''; $dao_preference = new Preference(); if (Params::getParam('adEmailEx') != '') { $adEmailEx = Params::getParam('adEmailEx'); } else { $adEmailEx = osc_item_adManage_adEmailEx() != '' ? osc_item_adManage_adEmailEx() : ''; } $deleteDays = ''; $dao_preference = new Preference(); if (Params::getParam('deleteDays') != '') { $deleteDays = Params::getParam('deleteDays'); } else { $deleteDays = osc_item_adManage_deleteDays() != '' ? osc_item_adManage_deleteDays() : ''; } if (Params::getParam('option') == 'stepone') { $dao_preference->update(array("s_value" => $expire_days), array("s_section" => "plugin-item_adManage", "s_name" => "adManageed_expire")); $dao_preference->update(array("s_value" => $payPost), array("s_section" => "plugin-item_adManage", "s_name" => "adManageed_payperpost")); $dao_preference->update(array("s_value" => $rTimes), array("s_section" => "plugin-item_adManage", "s_name" => "adManageed_repubTimes")); $dao_preference->update(array("s_value" => $freeTimes), array("s_section" => "plugin-item_adManage", "s_name" => "adManageed_freeRepubs")); $dao_preference->update(array("s_value" => $adEmailEx), array("s_section" => "plugin-item_adManage", "s_name" => "adManageed_expireEmail")); $dao_preference->update(array("s_value" => $deleteDays), array("s_section" => "plugin-item_adManage", "s_name" => "adManageed_deleteDays"));