示例#1
0
function sxd_php2json($obj)
{
    if (count($obj) == 0) {
        return '[]';
    }
    $is_obj = isset($obj[count($obj) - 1]) ? false : true;
    $str = $is_obj ? '{' : '[';
    foreach ($obj as $key => $value) {
        $str .= $is_obj ? "'" . addcslashes($key, "\n\r\t'\\/") . "'" . ':' : '';
        if (is_array($value)) {
            $str .= sxd_php2json($value);
        } elseif (is_null($value)) {
            $str .= 'null';
        } elseif (is_bool($value)) {
            $str .= $value ? 'true' : 'false';
        } elseif (is_numeric($value)) {
            $str .= $value;
        } else {
            $str .= "'" . addcslashes($value, "\n\r\t'\\/") . "'";
        }
        $str .= ',';
    }
    return substr_replace($str, $is_obj ? '}' : ']', -1);
}
示例#2
0
文件: index.php 项目: rigidus/izverg
 function getFileListExtended()
 {
     $files = array();
     if (is_dir($this->CFG['backup_path']) && false !== ($handle = opendir($this->CFG['backup_path']))) {
         while (false !== ($file = readdir($handle))) {
             if (preg_match("/^.+?\\.sql(\\.(gz|bz2))?\$/", $file, $m)) {
                 $fp = $this->openFile($this->CFG['backup_path'] . $file, 'r');
                 $ext = !empty($m[2]) ? $m[2] : 'sql';
                 $temp = fgets($fp);
                 if (preg_match('/^(#SXD20\\|.+?)\\n/s', $temp, $m)) {
                     $h = explode('|', $m[1]);
                     $files[] = array($h[5], substr($h[4], 0, -3), $ext, $h[7], number_format($h[8], 0, '', ' '), filesize($this->CFG['backup_path'] . $file), $h[9], $file);
                 }
             }
         }
         closedir($handle);
     }
     function s($a, $b)
     {
         return strcmp($b[1], $a[1]);
     }
     usort($files, 's');
     return 'sxd.files.clear();sxd.files.add(' . sxd_php2json($files) . ');';
 }
示例#3
0
文件: index.php 项目: omodev/hooks
 function getFileListExtended()
 {
     $files = array();
     if (is_dir($this->CFG["backup_path"]) && false !== ($handle = opendir($this->CFG["backup_path"]))) {
         while (false !== ($file = readdir($handle))) {
             if (preg_match("/^.+?\\.sql(\\.(gz|bz2))?\$/", $file, $m)) {
                 $fp = $this->openFile($this->CFG["backup_path"] . $file, "r");
                 $ext = !empty($m[2]) ? $m[2] : "sql";
                 $temp = fgets($fp);
                 if (preg_match("/^(#SXD20\\|.+?)\\n/s", $temp, $m)) {
                     $h = explode("|", $m[1]);
                     $files[] = array($h[5], substr($h[4], 0, -3), $ext, $h[7], number_format($h[8], 0, "", " "), filesize($this->CFG["backup_path"] . $file), $h[9], $file);
                 } elseif (preg_match("/^(#SKD101\\|.+?)\\n/s", $temp, $m)) {
                     $h = explode("|", $m[1]);
                     $files[] = array($h[1], substr($h[3], 0, -3), $ext, $h[2], number_format($h[4], 0, "", " "), filesize($this->CFG["backup_path"] . $file), "SXD 1.0.x", $file);
                 } else {
                     $files[] = array($file, "-", $ext, "-", "-", filesize($this->CFG["backup_path"] . $file), "", $file);
                 }
             }
         }
         closedir($handle);
     }
     function s($a, $b)
     {
         return strcmp($b[1], $a[1]);
     }
     usort($files, "s");
     return "sxd.files.clear();sxd.files.add(" . sxd_php2json($files) . ");";
 }