Esempio n. 1
0
function htmlcac_dir($mode = 'arc', $spath = '', $wri = 0)
{
    //结尾没有斜线
    $cacdir = M_ROOT . "dynamic/htmlcac/{$mode}/";
    if ($spath) {
        $cacdir .= $spath . '/';
    }
    $wri && mmkdir($cacdir);
    return $cacdir;
}
Esempio n. 2
0
function marc_static($maid = 0, $matid = 0)
{
    //只是将公示页生成静态,受限页不生成静态
    global $db, $tblprefix, $arc, $cms_abs, $marchtmldir, $timestamp, $templatedir, $G, $_no_dbhalt, $btags, $mconfigs, $_mp, $_actid, $_midarr, $_a_vars, $_a_var, $mpnav, $mptitle, $mpstart, $mpend, $mppre, $mpnext, $mppage, $mpcount, $mpacount;
    @extract($mconfigs, EXTR_SKIP);
    @extract($btags);
    if ($maid) {
        $arc->init();
        $arc->arcid($maid, $matid);
    }
    if (empty($arc->maid)) {
        return false;
    }
    if (!$arc->archive['checked']) {
        marc_un_static(0);
        return false;
    }
    if (!($tplname = $arc->matype['arctpl'])) {
        return false;
    }
    $subpath = $arc->archive['matid'] . '/' . date('Ym', $arc->archive['createdate']) . '/';
    mmkdir(M_ROOT . $marchtmldir . '/' . $subpath);
    $namepre = $subpath . $arc->maid . '_';
    $arc->archive['arcurl'] = $cms_abs . $marchtmldir . '/' . $namepre . '1.html';
    $_da =& $arc->archive;
    marc_parse($_da);
    $_o_content = ob_get_contents();
    ob_clean();
    $_no_dbhalt = true;
    $pcount = 1;
    for ($_pp = 1; $_pp <= $pcount; $_pp++) {
        $_mp = $G = array();
        $_mp['surlpre'] = $cms_abs . $marchtmldir . '/' . $namepre . '{$page}.html';
        $_mp['static'] = 1;
        $_mp['nowpage'] = $_pp;
        _aenter($_da, 1);
        extract($_da, EXTR_OVERWRITE);
        tpl_refresh($tplname);
        @(include M_ROOT . "template/{$templatedir}/pcache/{$tplname}.php");
        $_content = ob_get_contents();
        ob_clean();
        str2file($_content, M_ROOT . $marchtmldir . '/' . $namepre . "{$_pp}.html");
        unset($_content);
        $pcount = @$_mp['pcount'];
    }
    echo $_o_content;
    unset($_o_content);
    $_no_dbhalt = false;
    $db->query("UPDATE {$tblprefix}marchives_{$matid} SET arcurl='" . $namepre . "1.html' WHERE maid='" . $arc->maid . "'");
    return true;
}
Esempio n. 3
0
function dir_writeable($dir)
{
    mmkdir($dir, $dir == '.' ? 0 : 1);
    if (is_dir($dir)) {
        if ($fp = @fopen("{$dir}/test.txt", 'w')) {
            @fclose($fp);
            @unlink("{$dir}/test.txt");
            $writeable = 1;
        } else {
            $writeable = 0;
        }
    }
    return $writeable;
}
Esempio n. 4
0
 function thumb($url = '', $source = '', $name = '', $type = -1, $width = 0, $height = 0)
 {
     //如何生成不成功,则返回原url
     global $cms_abs, $cmsurl, $ftp_url, $atm_smallsite;
     if (!$url || !$source || !$name || !$width || !$height) {
         return $url;
     }
     include_once M_ROOT . "./include/upload.cls.php";
     if ($ftp_url && preg_match(u_regcode($ftp_url), $url)) {
         //ftp上的文件
         include_once M_ROOT . "./include/http.cls.php";
         include_once M_ROOT . "./include/ftp.fun.php";
         //下载原图
         $tempfile = M_ROOT . './dynamic/imcache/' . basename($url);
         mmkdir($tempfile, 0, 1);
         $m_http = new http();
         $m_http->savetofile($url, $tempfile);
         unset($m_http);
         //生成缩略图
         $m_upload = new cls_upload();
         $m_upload->image_resize($tempfile, $width, $height, $tempfile . '.s.jpg');
         @unlink($tempfile);
         unset($m_upload);
         //上传缩略图
         $ftpfile = preg_replace(u_regcode($ftp_url), '', $url) . 's/' . $width . '_' . $height . '.jpg';
         //根据url得到缩略上传到的位置
         $tempfile .= '.s.jpg';
         if (ftp_upload($tempfile, $ftpfile)) {
             $this->refresh_record($source, $name, $type, $width, $height);
             //将缩略图规格写入数据库
             return $url . 's/' . $width . '_' . $height . '.jpg';
         } else {
             return $url;
         }
         @unlink($tempfile);
     } else {
         //本地服务器上的文件
         $m_upload = new cls_upload();
         $localfile = local_atm($url);
         $m_upload->image_resize($localfile, $width, $height, $localfile . 's/' . $width . '_' . $height . '.jpg');
         unset($m_upload);
         return $url . 's/' . $width . '_' . $height . '.jpg';
     }
 }
Esempio n. 5
0
function tpl_refresh($tplname)
{
    global $templatedir, $debugtag;
    $tpl_dir = M_ROOT . "template/{$templatedir}/";
    if (file_exists($utags = $tpl_dir . "function/utags.fun.php")) {
        include_once $utags;
    }
    mmkdir($tpl_dir . 'pcache/');
    if ($debugtag || !file_exists($tpl_dir . 'pcache/' . $tplname . '.php')) {
        $str = load_tpl($tplname);
        $str = preg_replace("/<\\?(?!php\\s|=|\\s)/i", '<?=\'<?\'?>', $str);
        $str = preg_replace("/\\<\\!\\-\\-\\{(.+?)\\}\\-\\-\\>/s", "{\\1}", $str);
        breplace($str, '');
        mp_pre($str);
        nreplace($str, 'p');
        nreplace($str, 'c');
        nreplace($str, 'u');
        quit_avar();
        $str = tpl_basecode($str);
        str2file($str, $tpl_dir . 'pcache/' . $tplname . '.php');
    }
}
Esempio n. 6
0
function str2file($result, $filename)
{
    mmkdir($filename, 0, 1);
    if (!@($fp = fopen($filename, 'w'))) {
        return false;
    }
    flock($fp, 2);
    fwrite($fp, $result);
    fclose($fp);
    return true;
}
Esempio n. 7
0
     $submitstr .= makesubmitstr('subsitenew[sitename]', 1, 0, 0, 80);
     $submitstr .= makesubmitstr('subsitenew[dirname]', 1, 'tagtype', 0, 15);
     tabfooter('btosubsite');
     check_submit_func($submitstr);
     a_guide('tosubsite');
 } else {
     $subsitenew['sitename'] = trim(strip_tags($subsitenew['sitename']));
     $subsitenew['dirname'] = trim(strip_tags($subsitenew['dirname']));
     if (!$subsitenew['sitename'] || !$subsitenew['dirname']) {
         amessage('subdatamiss', M_REFERER);
     }
     if (preg_match("/[^a-zA-Z_0-9]+/", $subsitenew['dirname'])) {
         amessage('substadirill', M_REFERER);
     }
     $subsitenew['dirname'] = strtolower($subsitenew['dirname']);
     if (!mmkdir(M_ROOT . $subsitenew['dirname'], 0)) {
         anmessage('nowcresubstadir', M_REFERER);
     }
     $db->query("INSERT INTO {$tblprefix}subsites SET \n\t\t\t\t\tsitename='{$subsitenew['sitename']}',\n\t\t\t\t\tdirname='{$subsitenew['dirname']}',\n\t\t\t\t\ttemplatedir='{$templatedir}',\n\t\t\t\t\tineedstatic='{$timestamp}'\n\t\t\t\t\t");
     if ($nsid = $db->insert_id()) {
         updatecache('subsites');
         //需要先将模板目录放入子站内存之中,才能进行模板的转换
         $subsites = reload_cache('subsites');
         include_once M_ROOT . "./include/cparse.fun.php";
         cn_blank('', $nsid, 0);
         foreach (array('catalogs', 'cnconfigs', 'cnodes', 'archives', 'freeinfos', 'gmissions', 'gmodels', 'gurls') as $dbtable) {
             $db->query("UPDATE {$tblprefix}{$dbtable} SET sid='{$nsid}' WHERE sid='0'");
         }
         //将在子站记录中要保留的记录存下来
         $s_config = array();
         load_cache('channels');
Esempio n. 8
0
function cnode_dir($cnstr, $sid, $wri = 0)
{
    $cacdir = M_ROOT . './dynamic/cache' . ($sid ? "/{$sid}" : '') . '/cnodes';
    $wri && mmkdir($cacdir);
    return $cacdir;
}
Esempio n. 9
0
<?php

(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
include_once M_ROOT . "./include/database.fun.php";
aheader();
backallow('database') || amessage('no_apermission');
$tabletype = $db->version() > '4.1' ? 'Engine' : 'Type';
if (!($backupdir = $db->result_one("SELECT value FROM {$tblprefix}mconfigs WHERE varname='backupdir'"))) {
    $backupdir = random(6);
    $db->query("REPLACE INTO {$tblprefix}mconfigs (varname, value) values ('backupdir','{$backupdir}')");
}
$backupdir = 'backup_' . $backupdir;
mmkdir(M_ROOT . './dynamic/' . $backupdir);
$url_type = 'data';
include 'urlsarr.inc.php';
if ($action == 'dbexport') {
    if (!submitcheck('bdbexport')) {
        url_nav(lang('dboperate'), $urlsarr, 'dbbackup');
        $dbtables = array();
        $query = $db->query("SHOW TABLES FROM `{$dbname}`");
        while ($dbtable = $db->fetch_row($query)) {
            //如果有外来表,会出现什么情况?
            $dbtable[0] = preg_replace("/^" . $tblprefix . "(.*?)/s", "\\1", $dbtable[0]);
            $dbtables[] = $dbtable[0];
        }
        $num = 3;
        tabheader(lang('choose_table') . '<input class="checkbox" type="checkbox" name="chkall" onclick="checkall(this.form)">' . lang('selectall'), 'dbexport', '?entry=database&action=dbexport', 2 * $num);
        $i = 0;
        foreach ($dbtables as $dbtable) {
            if (!($i % $num)) {
                echo "<tr class=\"txt\">";
Esempio n. 10
0
<?php

(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
aheader();
backallow('tpl') || amessage('no_apermission');
load_cache('cotypes,bnames');
load_cache('mtpls', $sid);
include_once M_ROOT . "./include/template.fun.php";
$tpclasses = array('index' => lang('index'), 'cindex' => lang('catasindex'), 'archive' => lang('archivecontent'), 'freeinfo' => lang('freeinfocontent'), 'commu' => lang('archivecommu'), 'mcommu' => lang('membercommu'), 'search' => lang('searchpage0'), 'wap' => lang('waptpl'), 'other' => lang('isolutepage'), 'js' => lang('jstemplate'));
if (!$sid) {
    $tpclasses['marchive'] = lang('membertpl');
    $tpclasses['space'] = lang('spacepage');
}
$true_tpldir = M_ROOT . "./template/{$templatedir}";
mmkdir($true_tpldir);
$url_type = 'tpl';
include 'urlsarr.inc.php';
if ($action == 'mtpladd') {
    url_nav(lang('tplallconfig'), $urlsarr, 'retpl', 12);
    if (!submitcheck('bmtpladd') && !submitcheck('bmtplsave')) {
        if (submitcheck('bmtplsearch')) {
            $mtplstmp = findfiles($true_tpldir);
            $enamearr = array_keys($mtpls);
            foreach ($mtplstmp as $k => $tplname) {
                if (in_array($tplname, $enamearr)) {
                    unset($mtplstmp[$k]);
                }
            }
            empty($mtplstmp) && amessage('mtplsearchnone', "?entry=mtpls&action=mtpladd{$param_suffix}");
            $in_search = 1;
        }
Esempio n. 11
0
function dircopy($source, $destination, $child = 1)
{
    if (!is_dir($source)) {
        return false;
    }
    mmkdir($destination);
    $handle = dir($source);
    while ($entry = $handle->read()) {
        if ($entry != "." && $entry != "..") {
            if (is_dir($source . "/" . $entry)) {
                dircopy($source . "/" . $entry, $destination . "/" . $entry, $child);
            } else {
                copy($source . "/" . $entry, $destination . "/" . $entry);
            }
        }
    }
    return true;
}
Esempio n. 12
0
 function image_resize($target = '', $to_w = 0, $to_h = 0, $tofile = '')
 {
     $tofile = !$tofile ? $target . 's/' . $to_w . '_' . $to_h . '.jpg' : $tofile;
     mmkdir($tofile, 0, 1);
     $info = @getimagesize($target);
     $thumbed = false;
     if (in_array($info['mime'], array('image/jpeg', 'image/gif', 'image/png'))) {
         $from_w = $info[0];
         $from_h = $info[1];
         $isanimated = 0;
         if ($info['mime'] == 'image/gif') {
             $fp = fopen($target, 'rb');
             $im = fread($fp, filesize($target));
             fclose($fp);
             $isanimated = strpos($im, 'NETSCAPE2.0') === FALSE ? 0 : 1;
         }
         if (!$isanimated && ($from_w > $to_w || $from_h > $to_h)) {
             switch ($info['mime']) {
                 case 'image/jpeg':
                     $im = imagecreatefromjpeg($target);
                     break;
                 case 'image/gif':
                     $im = imagecreatefromgif($target);
                     break;
                 case 'image/png':
                     $im = imagecreatefrompng($target);
                     break;
             }
             $to_scale = $to_w / $to_h;
             $from_scale = $from_w / $from_h;
             if ($to_scale <= $from_scale) {
                 $cut_x = round(($from_w - $from_h / $to_h * $to_w) / 2);
                 $cut_y = 0;
                 $cut_w = round($from_h / $to_h * $to_w);
                 $cut_h = $from_h;
             } else {
                 $cut_x = 0;
                 $cut_y = round(($from_h - $from_w / $to_w * $to_h) / 2);
                 $cut_w = $from_w;
                 $cut_h = round($from_w / $to_w * $to_h);
             }
             $fto_x = $fto_y = 0;
             $fto_w = $cut_w > $to_w ? $to_w : $cut_w;
             $fto_h = $cut_w > $to_w ? $to_h : $cut_h;
             if (function_exists("imagecreatetruecolor")) {
                 if ($im_n = imagecreatetruecolor($fto_w, $fto_h)) {
                     imagecopyresampled($im_n, $im, $fto_x, $fto_y, $cut_x, $cut_y, $fto_w, $fto_h, $cut_w, $cut_h);
                 } elseif ($im_n = imagecreate($fto_w, $fto_h)) {
                     imagecopyresized($im_n, $im, $fto_x, $fto_y, $cut_x, $cut_y, $fto_w, $fto_h, $cut_w, $cut_h);
                 }
             } else {
                 $im_n = imagecreate($fto_w, $fto_h);
                 imagecopyresized($im_n, $im, $fto_x, $fto_y, $cut_x, $cut_y, $fto_w, $fto_h, $cut_w, $cut_h);
             }
             imagejpeg($im_n, $tofile);
             imagedestroy($im);
             imagedestroy($im_n);
             $thumbed = true;
         }
     }
     if (!$thumbed) {
         @copy($target, $tofile);
     }
     return;
 }
Esempio n. 13
0
                amessage('tpldirillegal', M_REFERER);
            }
            mmkdir(M_ROOT . 'template/' . $mconfigsnew['templatedir']);
            $mconfigsnew['css_dir'] = trim(strip_tags($mconfigsnew['css_dir']));
            $mconfigsnew['js_dir'] = trim(strip_tags($mconfigsnew['js_dir']));
            $mconfigsnew['jsrefsource'] = trim(preg_replace("/(\\s*(\r\n|\n\r|\n|\r)\\s*)/", "\r\n", $mconfigsnew['jsrefsource']));
            saveconfig('tpl');
        } else {
            $subsitenew['hometpl'] = empty($subsitenew['hometpl']) ? '' : trim($subsitenew['hometpl']);
            $subsitenew['w_index_tpl'] = empty($subsitenew['w_index_tpl']) ? '' : trim($subsitenew['w_index_tpl']);
            $subsitenew['templatedir'] = trim(strip_tags($subsitenew['templatedir']));
            //指定新的模板文件夹,所以可以有不同的模板样式
            if (empty($subsitenew['templatedir']) || preg_match("/[^a-zA-Z_0-9]+/", $subsitenew['templatedir'])) {
                amessage('tpldirillegal', M_REFERER);
            }
            mmkdir(M_ROOT . 'template/' . $subsitenew['templatedir'], 0);
            $subsitenew['css_dir'] = trim(strip_tags($subsitenew['css_dir']));
            $subsitenew['js_dir'] = trim(strip_tags($subsitenew['js_dir']));
            $db->query("UPDATE {$tblprefix}subsites SET \n\t\t\thometpl='{$subsitenew['hometpl']}',\n\t\t\tw_index_tpl='{$subsitenew['w_index_tpl']}',\n\t\t\ttemplatedir='{$subsitenew['templatedir']}',\n\t\t\tcss_dir='{$subsitenew['css_dir']}',\n\t\t\tjs_dir='{$subsitenew['js_dir']}'\n\t\t\tWHERE sid='{$sid}'");
            updatecache('subsites');
        }
        adminlog(lang('websiteset'), lang('pagandtemset'));
        amessage('websitesetfinish', M_REFERER);
    }
} elseif ($action == 'tplchannel') {
    url_nav(lang('tplallconfig'), $urlsarr, 'channel', 12);
    load_cache('channels');
    if (!($chids = array_keys($channels))) {
        amessage('defineachannel');
    }
    $chid = empty($chid) ? $chids[0] : $chid;
Esempio n. 14
0
<?php

(!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission');
aheader();
if (!empty($mnid)) {
    $forward = empty($forward) ? M_REFERER : $forward;
    if (!submitcheck('bmguide')) {
        load_cache('mmnlangs');
        $content = '';
        if (@(include M_ROOT . "./dynamic/mguides/mguide_{$mnid}.php")) {
            $content = $mguide;
        }
        tabheader(lang('memcenpaggui'), 'mguide', "?entry=mguides&mnid={$mnid}&forward=" . rawurlencode($forward), 2, 0, 1);
        trbasic(lang('memcenpacna'), '', $mmnlangs["mmenuitem_{$mnid}"], '');
        trbasic(lang('guidecontent'), 'contentnew', $content, 'btextarea');
        tabfooter('bmguide');
        $submitstr = '';
        $submitstr .= makesubmitstr('contentnew', 0, 0, 0, 500);
        check_submit_func($submitstr);
        a_guide('mguides');
    } else {
        $contentnew = stripslashes(strip_tags(trim($contentnew)));
        mmkdir(M_ROOT . './dynamic/mguides/');
        if (@($fp = fopen(M_ROOT . "./dynamic/mguides/mguide_{$mnid}.php", 'wb'))) {
            fwrite($fp, "<?php\n\$mguide = '" . addcslashes($contentnew, '\'\\') . "';\n?>");
            fclose($fp);
        }
        amessage('mecenpagusetfin', $forward);
    }
}
Esempio n. 15
0
 if (!$sid) {
     foreach (array('cnhtmldir', 'infohtmldir', 'marchtmldir') as $var) {
         $mconfigsnew[$var] = strtolower($mconfigsnew[$var]);
         if ($mconfigsnew[$var] == $mconfigs[$var]) {
             continue;
         }
         if (!$mconfigsnew[$var] || preg_match("/[^a-zA-Z_0-9]+/", $mconfigsnew[$var])) {
             $mconfigsnew[$var] = $mconfigs[$var];
             continue;
         }
         if ($mconfigs[$var] && is_dir(M_ROOT . $mconfigs[$var])) {
             if (!rename(M_ROOT . $mconfigs[$var], M_ROOT . $mconfigsnew[$var])) {
                 $mconfigsnew[$var] = $mconfigs[$var];
             }
         } else {
             mmkdir(M_ROOT . $mconfigsnew[$var]);
         }
     }
     $mconfigsnew['homedefault'] = trim(strip_tags($mconfigsnew['homedefault']));
     $mconfigsnew['arccustomurl'] = preg_replace("/^\\/+/", '', trim($mconfigsnew['arccustomurl']));
     $mconfigsnew['cn_max_addno'] = min(empty($_sys_cnaddmax) ? 2 : $_sys_cnaddmax, max(0, intval($mconfigsnew['cn_max_addno'])));
     if ($mconfigsnew['cn_max_addno'] < $cn_max_addno) {
         $db->query("UPDATE {$tblprefix}cnodes SET addnum=LEAST({$mconfigsnew['cn_max_addno']},addnum)");
         foreach ($subsites as $k => $v) {
             updatecache('cnodes', '', $k);
         }
     }
     $mconfigsnew['mcn_max_addno'] = min(empty($_sys_mcnaddmax) ? 0 : $_sys_mcnaddmax, max(0, intval($mconfigsnew['mcn_max_addno'])));
     if ($mconfigsnew['mcn_max_addno'] < $mcn_max_addno) {
         $db->query("UPDATE {$tblprefix}mcnodes SET addnum=LEAST({$mconfigsnew['mcn_max_addno']},addnum)");
         updatecache('mcnodes');
Esempio n. 16
0
function dir_copy($source, $destination, $f = 0, $d = 0)
{
    //$f-是否复制文件夹下文件,$d是否复制搜索下级文件夹
    if (!is_dir($source)) {
        return false;
    }
    mmkdir($destination, 0);
    if ($f || $d) {
        $handle = dir($source);
        while ($entry = $handle->read()) {
            if ($entry != "." && $entry != "..") {
                if (is_dir($source . "/" . $entry)) {
                    $d && dir_copy($source . "/" . $entry, $destination . "/" . $entry, $f, $d);
                } else {
                    $f && copy($source . "/" . $entry, $destination . "/" . $entry);
                }
            }
        }
    }
    return true;
}
Esempio n. 17
0
function ocache_save($carr, $cname, $dir)
{
    if (!is_array($carr) || empty($cname)) {
        return;
    }
    $cacstr = var_export($carr, TRUE);
    mmkdir($dir);
    if (@($fp = fopen($dir . $cname . '.cac.php', 'wb'))) {
        $cname .= '_0';
        fwrite($fp, "<?php\n\${$cname} = {$cacstr} ;\n?>");
        fclose($fp);
    }
}