Example #1
0
 public static function write($type, $filename, $content)
 {
     if (!static::exists(app()->cachePath() . $type)) {
         static::makeDir($type);
     }
     $path = app()->cachePath() . $type . DIRECTORY_SEPARATOR . join(explode(DIRECTORY_SEPARATOR, $filename), '.');
     return parent::writeFile($path, $content);
 }
Example #2
0
 /**
  * 设置缓存
  *
  * @access public
  *
  * @param string $key 缓存数据key
  * @param mixed $value 缓存数据值
  * @param string $expire 缓存生存周期
  *
  * @return boolean
  */
 public function set($key, $value, $expire = null)
 {
     //参数分析
     if (!$key) {
         return false;
     }
     $expire = is_null($expire) ? $this->_defaultOptions['expire'] : $expire;
     $expire = time() + $expire;
     //分析缓存文件
     $filePath = $this->_parseCacheFile($key);
     //分析缓存内容
     $content = '<?php if(!defined(\'IN_DOIT\'))exit(); return array(' . $expire . ', ' . var_export($value, true) . ');';
     return File::writeFile($filePath, $content);
 }
 /**
  * 设置缓存
  *
  * @access public
  *
  * @param string $key 缓存数据key
  * @param mixed $value 缓存数据值
  * @param string $expire 缓存生存周期
  *
  * @return boolean
  */
 public function set($key, $value, $expire = null)
 {
     //参数分析
     if (!$key) {
         return false;
     }
     if (is_null($expire)) {
         $expire = $_SERVER['REQUEST_TIME'] + $this->_defaultOptions['expire'];
     } else {
         if ($expire === 0) {
             $expire = 0;
         } else {
             $expire += $_SERVER['REQUEST_TIME'];
         }
     }
     //分析缓存文件
     $filePath = $this->_parseCacheFile($key);
     //分析缓存内容
     $content = '<?php if(!defined(\'IN_DOIT\'))exit(); return array(' . $expire . ', ' . var_export($value, true) . ');';
     return File::writeFile($filePath, $content);
 }
<?php

/**
 * easy4php
 *
 * check the database 
 *
 * @copyright	Copyright (c) 2013 - 2018
 * @link		http://www.easy4php.com
 * @author		kuishui
 * @version		1.0
 */
require_once 'init.php';
importClass('DB_Factory');
$dbFac = new DB_Factory($_POST);
list($result, $msg) = $dbFac->dbCheck();
if ($result === true) {
    importClass('File');
    $file = md5(implode(',', $_POST));
    File::writeFile(TMP . 'config_' . $file . '.php', serialize($msg), 'w');
    $return = 'succ|' . $file;
} else {
    $return = 'fail|' . $msg;
}
header('Content-Type: text/html; charset=gbk');
exit($return);
?>

Example #5
0
            if ($debug) {
                print "Error missing parameter timeallowed\n";
            }
            $err = Errors::getInstance();
            $err->errorEvent(ERROR_PARAMETER, "Missing parameter timeallowed");
        }
        // set rule to time using mysql
        $rule->setValiduntil(gmdate("Y-m-d H:i:s", $valid_until));
    }
    // We don't add a priority - let it default to the standard in the Rule constructor
    // in future may want to check rule against existing rules - perhaps only if valid_until is unlimited as unlikely to be adding a rule with exact timestamp for temp rules
    // add the rule into the database
    $kdb->insertRule($rule);
    //-regenerate the kidsafe.rules file....
    $rules_file = new File($rulesfilename);
    $rules_file->writeFile($kdb->getRulesFile());
    if ($debug) {
        print "Rule added\n\n";
    }
    $url = $parms->getParm('url');
    // setup and load headers
    $title = "kidsafe Rule added";
    include "inc/headers.php";
    print <<<EOT
{$header}
{$start}
<h1>New rule added</h1>
<p>Click below to continue to the website.</p>
<p><a href="{$url}">{$url}</a></p>.
{$footer}
EOT;
Example #6
0
 /**
  * 将url页面内容写入html文件
  *
  * @access public
  *
  * @param string $fileName 所要生成的HTML文件名(注:不带.html后缀)
  * @param string $url 所要生成HTML的页面的URL
  *
  * @return boolean
  */
 public function createHtml($fileName, $url)
 {
     //parse params
     if (!$fileName || !$url) {
         return false;
     }
     $fileName = $this->_htmlPath . $fileName . '.html';
     ob_start();
     //获取并显示url的页面内容
     echo file_get_contents($url);
     return File::writeFile($fileName, ob_get_clean());
 }
 public function writeTmpContent($content)
 {
     File::writeFile($this->getTmpContenFile(), $content, 'w');
 }
Example #8
0
 public static function generateStaticXMLConfigFile($return, $pGlobalVarName)
 {
     $content = "<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n<?xml-stylesheet type=\"text/xsl\" href=\"../scripts/catalog_list.xsl\"?>\r\n<{$pGlobalVarName}s>";
     for ($i = 0; $i < count($return); $i++) {
         $content .= "<{$pGlobalVarName}>\r\n";
         $key = "";
         foreach ($return[$i] as $option_name => $option_value) {
             $content .= "<{$option_name}>";
             $content .= "{$option_value}";
             $content .= "</{$option_name}>";
         }
         $content .= "</{$pGlobalVarName}>\r\n";
     }
     $content .= "</{$pGlobalVarName}s>\r\n";
     $sql = "update static_file set modify_time = " . time() . " where static_file_name = 'static.{$pGlobalVarName}.xml'";
     MySQL::noneResultQuery($sql);
     return File::writeFile(ROOT_PATH . "static/static.{$pGlobalVarName}.xml", $content);
 }
 * @version		1.0
 */
require_once 'init.php';
$ope = $_GET['ope'];
$dbUnique = $_GET['u'];
ob_start();
importClass('File');
$dbConfig = getConfigByUnique($dbUnique);
$tmpDict = TMP . 'dict_' . $dbUnique . '.php';
if (!file_exists($tmpDict) || $ope == 'refresh' || $ope == 'init') {
    importClass('DB_Factory');
    $dbFac = new DB_Factory($dbConfig);
    $dict = $dbFac->getDict();
    $serialized_object = serialize($dict);
    $safe_object = str_replace("", "~~NULL_BYTE~~", $serialized_object);
    File::writeFile($tmpDict, $safe_object, 'w');
} else {
    $dict = getDictByConfig($dbUnique);
}
$msg = ob_get_contents();
ob_end_clean();
//V($msg);
if ($ope == 'init') {
    if ($msg) {
        exit('fail');
    }
    exit('succ');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">