コード例 #1
0
/**
 * nv_set_status_module()
 *
 * @return
 */
function nv_set_status_module()
{
    global $db, $module_name, $module_data, $global_config;
    $check_run_cronjobs = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/data_logs/cronjobs_' . md5($module_data . 'nv_set_status_module' . $global_config['sitekey']) . '.txt';
    $p = NV_CURRENTTIME - 300;
    if (file_exists($check_run_cronjobs) and @filemtime($check_run_cronjobs) > $p) {
        return;
    }
    file_put_contents($check_run_cronjobs, '');
    //status_0 = "Cho duyet";
    //status_1 = "Xuat ban";
    //status_2 = "Hen gio dang";
    //status_3= "Het han";
    // Dang cai bai cho kich hoat theo thoi gian
    $query = $db->query('SELECT id, listcatid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=2 AND publtime < ' . NV_CURRENTTIME . ' ORDER BY publtime ASC');
    while (list($id, $listcatid) = $query->fetch(3)) {
        $array_catid = explode(',', $listcatid);
        foreach ($array_catid as $catid_i) {
            $catid_i = intval($catid_i);
            if ($catid_i > 0) {
                $db->query('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_' . $catid_i . ' SET status=1 WHERE id=' . $id);
            }
        }
        $db->query('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_rows SET status=1 WHERE id=' . $id);
    }
    // Ngung hieu luc cac bai da het han
    $query = $db->query('SELECT id, listcatid, archive FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=1 AND exptime > 0 AND exptime <= ' . NV_CURRENTTIME . ' ORDER BY exptime ASC');
    while (list($id, $listcatid, $archive) = $query->fetch(3)) {
        if (intval($archive) == 0) {
            nv_del_content_module($id);
        } else {
            nv_archive_content_module($id, $listcatid);
        }
    }
    // Tim kiem thoi gian chay lan ke tiep
    $time_publtime = $db->query('SELECT min(publtime) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=2 AND publtime > ' . NV_CURRENTTIME)->fetchColumn();
    $time_exptime = $db->query('SELECT min(exptime) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=1 AND exptime > ' . NV_CURRENTTIME)->fetchColumn();
    $timecheckstatus = min($time_publtime, $time_exptime);
    if (!$timecheckstatus) {
        $timecheckstatus = max($time_publtime, $time_exptime);
    }
    $sth = $db->prepare("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = :config_value WHERE lang = '" . NV_LANG_DATA . "' AND module = :module_name AND config_name = 'timecheckstatus'");
    $sth->bindValue(':module_name', $module_name, PDO::PARAM_STR);
    $sth->bindValue(':config_value', intval($timecheckstatus), PDO::PARAM_STR);
    $sth->execute();
    nv_del_moduleCache('settings');
    nv_del_moduleCache($module_name);
    unlink($check_run_cronjobs);
    clearstatcache();
}
コード例 #2
0
/**
 * nv_set_status_module()
 * 
 * @return
 */
function nv_set_status_module()
{
    global $db, $module_name, $module_data, $global_config;
    $check_run_cronjobs = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/data_logs/cronjobs_' . md5($module_data . 'nv_set_status_module' . $global_config['sitekey']) . '.txt';
    $p = NV_CURRENTTIME - 300;
    if (file_exists($check_run_cronjobs) and @filemtime($check_run_cronjobs) > $p) {
        return;
    }
    file_put_contents($check_run_cronjobs, '');
    //status_0 = "Cho duyet";
    //status_1 = "Xuat ban";
    //status_2 = "Hen gio dang";
    //status_3= "Het han";
    // Dang cai bai cho kich hoat theo thoi gian
    $query = $db->sql_query("SELECT `id`, `listcatid` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`=2 AND `publtime` < " . NV_CURRENTTIME . " ORDER BY `publtime` ASC");
    while (list($id, $listcatid) = $db->sql_fetchrow($query)) {
        $array_catid = explode(",", $listcatid);
        foreach ($array_catid as $catid_i) {
            $catid_i = intval($catid_i);
            if ($catid_i > 0) {
                $db->sql_query("UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_" . $catid_i . "` SET `status`='1' WHERE `id`=" . $id . "");
            }
        }
        $db->sql_query("UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_rows` SET `status`='1' WHERE `id`=" . $id . "");
    }
    // Ngung hieu luc cac bai da het han
    $query = $db->sql_query("SELECT `id`, `listcatid`, `archive` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`=1 AND `exptime` > 0 AND `exptime` <= " . NV_CURRENTTIME . " ORDER BY `exptime` ASC");
    while (list($id, $listcatid, $archive) = $db->sql_fetchrow($query)) {
        if (intval($archive) == 0) {
            nv_del_content_module($id);
        } else {
            nv_archive_content_module($id, $listcatid);
        }
    }
    // Tim kiem thoi gian chay lan ke tiep
    list($time_publtime) = $db->sql_fetchrow($db->sql_query("SELECT min(publtime) FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`=2 AND `publtime` > " . NV_CURRENTTIME));
    list($time_exptime) = $db->sql_fetchrow($db->sql_query("SELECT min(exptime) FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`=1 AND `exptime` > " . NV_CURRENTTIME));
    $timecheckstatus = min($time_publtime, $time_exptime);
    if (!$timecheckstatus) {
        $timecheckstatus = max($time_publtime, $time_exptime);
    }
    $db->sql_query("REPLACE INTO `" . NV_CONFIG_GLOBALTABLE . "` (`lang`, `module`, `config_name`, `config_value`) VALUES('" . NV_LANG_DATA . "', " . $db->dbescape($module_name) . ", 'timecheckstatus', '" . intval($timecheckstatus) . "')");
    nv_del_moduleCache('settings');
    nv_del_moduleCache($module_name);
    unlink($check_run_cronjobs);
    clearstatcache();
}
コード例 #3
0
$result = $db->sql_query($sql);
while (list($catid_i, $parentid_i, $title_i, $alias_i, $is_top_menu_i, $is_leaf_i, $viewcat_i, $subcatid_i, $numlinks_i, $del_cache_time_i, $description_i, $inhome_i, $keywords_i, $who_view_i, $groups_view_i) = $db->sql_fetchrow($result)) {
    $link_i = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=" . $alias_i;
    $global_array_cat[$catid_i] = array("catid" => $catid_i, "parentid" => $parentid_i, "title" => $title_i, "alias" => $alias_i, "is_top_menu" => $is_top_menu_i, "is_leaf" => $is_leaf_i, "link" => $link_i, "viewcat" => $viewcat_i, "subcatid" => $subcatid_i, "numlinks" => $numlinks_i, "description" => $description_i, "inhome" => $inhome_i, "keywords" => $keywords_i, "who_view" => $who_view_i, "groups_view" => $groups_view_i);
    if ($alias_cat_url == $alias_i) {
        $catid = $catid_i;
        $parentid = $parentid_i;
    }
    if (NV_CURRENTTIME > $del_cache_time_i) {
        $sql = "SELECT `id`, `listcatid`, `exptime`, `archive` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_" . $catid_i . "` WHERE `exptime` > 0 AND `exptime` <= UNIX_TIMESTAMP() AND `archive`!='2' ORDER BY `exptime` ASC LIMIT 0 , 1";
        list($id, $listcatid, $minexptime, $archive) = $db->sql_fetchrow($db->sql_query($sql));
        if (intval($id) > 0) {
            if (intval($archive) == 0) {
                nv_del_content_module($id);
            } else {
                nv_archive_content_module($id, $listcatid);
            }
            nv_del_moduleCache($module_name);
        }
        list($minpubltime) = $db->sql_fetchrow($db->sql_query("SELECT min(publtime) FROM `" . NV_PREFIXLANG . "_" . $module_data . "_" . $catid_i . "` WHERE `publtime` > UNIX_TIMESTAMP()"));
        $minpubltime = empty($minpubltime) ? NV_CURRENTTIME + 26000000 : intval($minpubltime);
        list($id, $listcatid, $minexptime, $archive) = $db->sql_fetchrow($db->sql_query($sql));
        $minexptime = empty($minexptime) ? NV_CURRENTTIME + 26000000 : intval($minexptime);
        $del_cache_time = min($minpubltime, $minexptime);
        $db->sql_query("UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_cat` SET `del_cache_time`=" . $db->dbescape($del_cache_time) . " WHERE `catid`=" . $catid_i . "");
    }
}
foreach ($global_array_cat as $catid_i => $array_cat_i) {
    if ($catid_i > 0 and $array_cat_i['parentid'] == 0) {
        $act = 0;
        $submenu = array();
コード例 #4
0
ファイル: global.functions.php プロジェクト: nukeplus/shops
/**
 * nv_set_status_module()
 *
 * @return
 */
function nv_set_status_module()
{
    global $db, $module_name, $module_data, $global_config, $db_config;
    $check_run_cronjobs = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/data_logs/cronjobs_' . md5($module_data . 'nv_set_status_module' . $global_config['sitekey']) . '.txt';
    $p = NV_CURRENTTIME - 300;
    if (file_exists($check_run_cronjobs) and @filemtime($check_run_cronjobs) > $p) {
        return;
    }
    file_put_contents($check_run_cronjobs, '');
    // status_0 = "Cho duyet";
    // status_1 = "Xuat ban";
    // status_2 = "Hen gio dang";
    // status_3= "Het han";
    // Dang cac san pham cho kich hoat theo thoi gian
    $result = $db->query('SELECT id FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE status =2 AND publtime < ' . NV_CURRENTTIME . ' ORDER BY publtime ASC');
    while (list($id) = $result->fetch(3)) {
        $db->query('UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_rows SET status =1 WHERE id=' . $id);
    }
    // Ngung hieu luc cac san pham da het han
    $result = $db->query('SELECT id, archive FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE status =1 AND exptime > 0 AND exptime <= ' . NV_CURRENTTIME . ' ORDER BY exptime ASC');
    while (list($id, $archive) = $result->fetch(3)) {
        if (intval($archive) == 0) {
            nv_del_content_module($id);
        } else {
            nv_archive_content_module($id);
        }
    }
    // Tim kiem thoi gian chay lan ke tiep
    $time_publtime = $db->query('SELECT MIN(publtime) FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE status =2 AND publtime > ' . NV_CURRENTTIME)->fetchColumn();
    $time_exptime = $db->query('SELECT MIN(exptime) FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE status =1 AND exptime > ' . NV_CURRENTTIME)->fetchColumn();
    $timecheckstatus = min($time_publtime, $time_exptime);
    if (!$timecheckstatus) {
        $timecheckstatus = max($time_publtime, $time_exptime);
    }
    $db->query("REPLACE INTO " . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES('" . NV_LANG_DATA . "', " . $db->quote($module_name) . ", 'timecheckstatus', '" . intval($timecheckstatus) . "')");
    $nv_Cache->delMod('settings');
    $nv_Cache->delMod($module_name);
    unlink($check_run_cronjobs);
    clearstatcache();
}