Exemple #1
0
 /**
  *  读模板页进行替换后写入到cache页里
  *
  * @param string $tplfile :模板源文件地址
  * @param string $objfile :模板cache文件地址
  * @return string
  */
 function complie($tplfile, $objfile)
 {
     $template = file_get_contents($tplfile);
     $template = $this->parse($template);
     MooMakeDir(dirname($objfile));
     MooWriteFile($objfile, $template, $mod = 'w', TRUE);
 }
Exemple #2
0
/** 
 * 创建数组缓存
 * int setArrayCache( string $name, array $arr )
 * @param	string $name 缓存名称,尽量长点避免重名,用于读取缓存
 * @param	array  $arr 要缓存的数组
 * @return	integer 0不成功,非0成功
 * @author 	xiaowu
 * */
function setArrayCache($name, $arr)
{
    $cache_dir = getCacheFile();
    $cache_file = getCacheFile($name);
    MooMakeDir($cache_dir);
    $str = "<?php\n//Array Cache File, Do Not Modify Me!\n//Created: " . gmdate("Y-m-d H:i:s") . "\n\n\t\tif(!defined('IN_MOOPHP')) exit('Access Denied');\n\$data=" . var_export($arr, true) . ";\n?>";
    return file_put_contents($cache_file, $str);
}
Exemple #3
0
function music_add()
{
    //note 指定会员POST
    $post_old_uid = !empty($_POST['old_uid']) ? $_POST['old_uid'] : '';
    $post_uid = !empty($_POST['uid']) ? $_POST['uid'] : '';
    $old_uid = $post_old_uid ? MooGetGPC('old_uid', 'integer', 'P') : MooGetGPC('uid', 'integer', 'G');
    $uid = $post_uid ? MooGetGPC('uid', 'integer', 'P') : $old_uid;
    if (isset($_POST['ispost']) && !empty($uid)) {
        $ps = '信息不全';
        //是否MP3
        if (preg_match('/\\.mp3$/i', $_FILES['mp3']['name'])) {
            //限制大小6兆
            if ($_FILES['mp3']['size'] < 6 * 1024 * 1024) {
                MooMakeDir(MP3_DIR . '/' . substr($uid, -2));
                $file = str_replace('\\\\', '\\', $_FILES['mp3']['tmp_name']);
                $path = substr($uid, -2) . '/' . $uid . '_' . time() . '.mp3';
                if (move_uploaded_file($file, MP3_DIR . $path)) {
                    $title = MooGetGPC('title', 'string', 'P');
                    $path = $path;
                    $note = MooGetGPC('note', 'string', 'P');
                    $dateline = time();
                    $sql = "INSERT INTO {$GLOBALS['dbTablePre']}art_music (uid,path,title,note,dateline) VALUES ('{$uid}','{$path}','{$title}','{$note}','{$dateline}')";
                    $insert = $GLOBALS['_MooClass']['MooMySQL']->query($sql);
                    $ps = '添加音频成功...';
                } else {
                    $ps = '文件保存失败...';
                }
            } else {
                $ps = 'MP3大小不能超过6KB...';
            }
        } else {
            $ps = '请上传MP3格式...';
        }
        salert($ps, 'index.php?action=diamond_music&h=list');
        //echo "<script>window.history.go(-1);</script>";
    }
    require adminTemplate('diamond_music_add');
}
Exemple #4
0
 function writeCache($cacheFile, $cacheContent)
 {
     $cacheContent = "<?php\n//MooPHP Cache File, Do Not Modify Me!" . "\n//Created: " . date("Y-m-d H:i:s") . "\n{$cacheContent}?>";
     $cacheDir = MOOPHP_DATA_DIR . '/cache/';
     $cacheFile = MOOPHP_DATA_DIR . '/cache/cache_' . $cacheFile . '.php';
     MooMakeDir($cacheDir);
     MooWriteFile($cacheFile, $cacheContent);
 }
Exemple #5
0
/**
* PHP下递归创建目录的函数,使用示例MooMakeDir('D:\web\web/a/b/c/d/f');
* @param string $dir - 需要创建的目录路径,可以是绝对路径或者相对路径
* @return boolean 返回是否写入成功
*/
function MooMakeDir($dir)
{
    return is_dir($dir) or MooMakeDir(dirname($dir)) and mkdir($dir, 0777);
}