Example #1
0
 /**
  * header_footer数据
  * @param array $tag 标签属性
  * @param array $content 标签内容
  * @return string
  */
 public function _commonstf($tag, $content)
 {
     $common = D('setting')->where('id=1')->find();
     $con = D('contact')->find();
     $common['tel'] = $con['tel'];
     $frdoption = F('frdoption');
     $common['frdlink'] = $frdoption;
     $common['copyright'] = "@2015 " . $common['site_name'];
     $name = $tag['name'];
     $parseStr = '<?php $' . $name . '=' . varToStr($common) . '; ?>';
     return $parseStr;
 }
Example #2
0
function varToStr($vari, $t = null)
{
    switch (gettype($vari)) {
        case 'string':
            return "'" . str_replace(array("\\", "'"), array("\\\\", "\\'"), $vari) . "'";
        case 'array':
            $output = "array(\r\n";
            foreach ($vari as $key => $value) {
                $output .= $t . "\t" . varToStr($key, $t . "\t") . ' => ' . varToStr($value, $t . "\t");
                $output .= ",\r\n";
            }
            $output .= $t . ')';
            return $output;
        case 'boolean':
            return $vari ? 'true' : 'false';
        case 'NULL':
            return 'NULL';
        case 'integer':
        case 'double':
        case 'float':
            return "'" . (string) $vari . "'";
    }
    return 'NULL';
}
Example #3
0
function writeFoldersCache()
{
    global $db;
    $rows = $db->row_select("folders", "", 0, "*", "id");
    $folders = array();
    $folders_option = "";
    foreach ($rows as $row) {
        $folders[$row['id']] = $row;
        $folders_option .= "<option value=\"{$row['id']}\">{$row['title']}</option>";
    }
    $str = "<?php \r\n \$cache_folders = " . varToStr($folders) . "; \r\n";
    $str .= "\$cache_foldersoption = " . varToStr($folders_option) . "; \r\n";
    $str .= "?>";
    writeFile(getCacheFilePath("folders.php"), $str);
}