コード例 #1
0
ファイル: index.php プロジェクト: oanav/closetshare
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
}
コード例 #2
0
ファイル: admin.php プロジェクト: oanav/closetshare
    if ($days > 999) {
        $days = 999;
    }
    // Set maximum days as per the sql structure of the field: i_expiration_days = int(3)
    $conn = getConnection();
    $conn->osc_dbExec("UPDATE %st_category SET i_expiration_days = '%s'", DB_TABLE_PREFIX, $days);
    osc_add_flash_ok_message(__('Ad expiration successfully set for all categories'), 'admin');
    echo '<script>location.href="' . osc_admin_render_plugin_url('advanced_ad_management/admin.php?mUpdated=1') . '"</script>';
}
//end Ad Expiration section
$expire_days = '';
$dao_preference = new Preference();
if (Params::getParam('expire') != '') {
    $expire_days = Params::getParam('expire');
} else {
    $expire_days = osc_adManage_expire() != '' ? osc_adManage_expire() : '';
}
$payPost = '';
$dao_preference = new Preference();
if (Params::getParam('payPost') != '') {
    $payPost = Params::getParam('payPost');
} else {
    $payPost = osc_adManage_payperpost() != '' ? osc_adManage_payperpost() : '';
}
$rTimes = '';
$dao_preference = new Preference();
if (Params::getParam('rTimes') != '') {
    $rTimes = Params::getParam('rTimes');
} else {
    $rTimes = osc_adManage_repubTimes() != '' ? osc_adManage_repubTimes() : '';
}