Exemple #1
0
function ArrayToString2($obj, $withKey = true)
{
    if (empty($obj)) {
        return "array()";
    }
    $objType = gettype($obj);
    if ($objType == 'array') {
        $objstring = "array(";
        foreach ($obj as $objkey => $objv) {
            if ($withKey) {
                $objstring .= "\"{$objkey}\"=>";
            }
            $vtype = gettype($objv);
            if ($vtype == 'integer') {
                $objstring .= "{$objv},";
            } else {
                if ($vtype == 'double') {
                    $objstring .= "{$objv},";
                } else {
                    if ($vtype == 'string') {
                        $objv = str_replace('"', "\\\"", $objv);
                        $objstring .= "\"" . $objv . "\",";
                    } else {
                        if ($vtype == 'array') {
                            $objstring .= "" . ArrayToString2($objv, $withKey) . ",";
                        } else {
                            if ($vtype == 'object') {
                                $objstring .= "" . ArrayToString2($objv, $withKey) . ",";
                            } else {
                                $objstring .= "\"" . $objv . "\",";
                            }
                        }
                    }
                }
            }
        }
        $objstring = substr($objstring, 0, -1) . "";
        return $objstring . ")\n";
    }
}
Exemple #2
0
 function mk_archive($pagesize)
 {
     if ($_POST['value'] == 0) {
         $where = "1";
         if ($_POST['group'] > 0) {
             $where .= " and `nid`='" . $_POST['group'] . "'";
         }
         if ($_POST['startid'] > 0) {
             $where .= " and `id`>='" . $_POST['startid'] . "'";
         }
         if ($_POST['endid'] > 0) {
             $where .= " and `id`<='" . $_POST['endid'] . "'";
         }
         $rows = $this->obj->DB_select_all("news_base", $where, "`id`,`datetime`");
         $allnum = count($rows);
         $allpage = ceil($allnum / $pagesize);
         $i = 1;
         foreach ($rows as $v) {
             if (count($val[$i]) <= $pagesize) {
                 $val[$i][$v['id']] = $v['datetime'];
             } else {
                 $i++;
                 $val[$i][$v['id']] = $v['datetime'];
             }
         }
         include_once LIB_PATH . "public.function.php";
         $this->obj->made_web("../plus/news.cache.php", ArrayToString2($val), "newscache");
         $page = 1;
     } else {
         $page = $_POST['value'];
         include_once PLUS_PATH . "news.cache.php";
         if (is_array($newscache)) {
             foreach ($newscache as $k => $va) {
                 if ($k == $page) {
                     foreach ($va as $key => $value) {
                         $this->makearchive($key, $value);
                     }
                 } elseif ($k > $page) {
                     $val[$k] = $va;
                 }
             }
         }
         $page = $page + 1;
         if (!is_array($val)) {
             $page = 0;
             unlink("../plus/news.cache.php");
         }
     }
     return $page;
 }
Exemple #3
0
 public function cache($filename, $data)
 {
     $data_new['data'] = ArrayToString2($data, true);
     $this->obj->DB_update_all("outside", "`lasttime`='" . mktime() . "'", "id='" . $filename . "'");
     return $this->obj->made_web_array($this->cachedir . $filename . ".php", $data_new);
 }
Exemple #4
0
 function cron($id = '')
 {
     @(include PLUS_PATH . 'cron.cache.php');
     if (is_array($cron) && !empty($cron)) {
         foreach ($cron as $key => $value) {
             if ($id) {
                 if ($value['id'] == $id) {
                     $timestamp[$value['nexttime']] = $value;
                     $timestamp[$value['nexttime']]['cronkey'] = $key;
                 }
             } else {
                 if ($value['nexttime'] <= time()) {
                     $timestamp[$value['nexttime']] = $value;
                     $timestamp[$value['nexttime']]['cronkey'] = $key;
                 }
             }
         }
         if ($timestamp) {
             krsort($timestamp);
             $croncache = current($timestamp);
             ignore_user_abort();
             set_time_limit(600);
             if (file_exists(LIB_PATH . 'cron/' . $croncache['dir'])) {
                 include LIB_PATH . 'cron/' . $croncache['dir'];
                 if ($croncache['dir'] == "notice.php") {
                     $notice = new notice($this->obj);
                     $notice->index();
                 }
             }
             $nexttime = $this->nextexe($croncache);
             $this->obj->DB_update_all("cron", "`nowtime`='" . time() . "',`nexttime`='" . strtotime($nexttime) . "'", "`id`='" . $value['id'] . "'");
             include_once LIB_PATH . "public.function.php";
             $cron[$croncache['cronkey']]['nexttime'] = strtotime($nexttime);
             $data['cron'] = ArrayToString2($cron);
             $this->obj->made_web_array(PLUS_PATH . 'cron.cache.php', $data);
         }
     }
 }
Exemple #5
0
 public function link_cache($dir)
 {
     $rows = $this->obj->DB_select_all("admin_link", "`link_state`='1' ORDER BY `link_sorting` DESC");
     if (is_array($rows)) {
         foreach ($rows as $key => $value) {
             $row[$key]['id'] = $value["id"];
             $row[$key]['link_name'] = $value["link_name"];
             $row[$key]['link_url'] = $value["link_url"];
             $row[$key]['img_type'] = $value["img_type"];
             $row[$key]['pic'] = $value["pic"];
             $row[$key]['link_type'] = $value["link_type"];
             $row[$key]['domain'] = $value["domain"];
             $row[$key]['tem_type'] = $value["tem_type"];
         }
     }
     $data['link'] = ArrayToString2($row);
     return $this->obj->made_web_array($this->cachedir . $dir, $data);
 }