コード例 #1
0
ファイル: function_template.php プロジェクト: nymbian/codelib
function readtemplate($name)
{
    global $_SGLOBAL;
    $tplfile = S_ROOT . './' . $name . '.htm';
    $_SGLOBAL['sub_tpls'][] = $name;
    $content = sreadfile($tplfile);
    return $content;
}
コード例 #2
0
function getcssname($dirname) {
	$css = sreadfile(S_ROOT.'./theme/'.$dirname.'/style.css');
	if($css) {
		preg_match("/\[name\](.+?)\[\/name\]/i", $css, $mathes);
		if(!empty($mathes[1])) $name = shtmlspecialchars($mathes[1]);
	} else {
		$name = 'No name';
	}
	return $name;
}
コード例 #3
0
ファイル: base.inc.php プロジェクト: jjvein/my_php_framework
 function readTemplate($file)
 {
     $common_dir = ROOT_PATH . '/public/common/';
     $file = $common_dir . $file . '.html';
     if (file_exists($file)) {
         return sreadfile($file);
     } else {
         die("template " . $file . ' not exists !');
     }
 }
コード例 #4
0
ファイル: cloud.php プロジェクト: a195474368/ejw
 public static function trans_file($tmpdir)
 {
     global $_G;
     //处理非 GBK 编码
     if ($_G['product']['charset'] != 'gbk') {
         //获取文件清单
         $list = rglob($tmpdir . '{*.php,*.htm,*.sql}', GLOB_BRACE);
         /////////////////////
         //批量转换编码
         foreach ($list as $file) {
             $text = iconv('GBK', $_G['product']['charset'] . '//IGNORE', sreadfile($file));
             create_file($file, $text);
         }
         /////////////////////
         //标识新编码
         $file = $tmpdir . 'config/version.php';
         if (file_exists($file)) {
             $text = sreadfile($file);
             $text = preg_replace("/\\['product'\\]\\['charset'\\]\t= '.*?';/i", "['product']['charset']\t= '" . $_G['product']['charset'] . "';", $text);
             create_file($file, $text);
         }
     }
 }
コード例 #5
0
ファイル: module.php プロジェクト: a195474368/ejw
 public static function rewrite($appid)
 {
     global $_G;
     global $_CACHE;
     //当前目录
     $base = VI_ROOT . 'module/' . $appid;
     //XML 地址
     $data = $base . '/rewrite.xml';
     //存储目录
     $save = $base . '/content/.htaccess';
     //找到规则文件
     if (file_exists($data)) {
         //转成数组
         $docm = xml_array(sreadfile($data));
         //验证是否有效
         if (is_array($docm)) {
             //获取规则模板
             $text = $docm['config'][$_G['setting']['global']['rewrite']['platform']];
             //修正基准目录
             if ($_CACHE['system']['module'][$appid]['domain']) {
                 $text = str_replace('{BASE}', '/', $text);
             } else {
                 $text = str_replace('{BASE}', VI_BASE . 'module/' . $appid . '/content/', $text);
             }
             //转编码(Linux 主机必需为 ANSI 格式)
             $text = iconv('UTF-8', 'GBK', trim($text));
             return create_file($save, $text);
         }
     }
     /*
     // Load the XML source
     $xml = new DOMDocument;
     $xml->load( $data );		
     $doc = $xml->getElementsByTagName('key');		
     for ($i=0;$i<$doc->length;$i++){			
     	$ele = $doc->item($i);			
     	if( $ele -> getAttribute("name") == $mode ){
     		$text = trim( $ele -> nodeValue );
     		
     		//如果有绑定域名
     		if( $domain ){
     			$text = str_replace( '{BASE}', '/', $text );
     		}else{					
     			$text = str_replace( '{BASE}', VI_BASE.'module/'.$this -> appid.'/content/', $text );
     		}
     		
     		//转编码(Linux 主机必需为 ANSI 格式)
     		$text = iconv('UTF-8','GBK',$text);
     		
     		return create_file( $save , $text );
     		break;
     	}
     	
     }
     */
 }
コード例 #6
0
function readtemplate($name)
{
    global $_SGLOBAL, $_SCONFIG;
    $tpl = strexists($name, '/') ? $name : "template/{$_SCONFIG['template']}/{$name}";
    $tplfile = S_ROOT . './' . $tpl . '.htm';
    $_SGLOBAL['sub_tpls'][] = $tpl;
    if (!file_exists($tplfile)) {
        $tplfile = str_replace('/' . $_SCONFIG['template'] . '/', '/default/', $tplfile);
    }
    $content = sreadfile($tplfile);
    return $content;
}
コード例 #7
0
ファイル: admincp_log.php プロジェクト: v998/discuzx-en
             $o = ftell($fp) - $n;
             $lines[] = $cursor . '-' . $o . '-' . $n;
             //Record information: the line number - the starting position - length
             if ($offset >= $start && $offset < $start + $perpage) {
                 $list[] = $loginfo;
             }
             $offset++;
         }
         $cursor++;
     }
     fclose($fp);
     $count = count($lines);
     swritefile($tmpfile, implode(';', $lines));
 }
 if ($fromcache) {
     $data = explode(';', sreadfile($tmpfile));
     $count = count($data);
     $lines = array_slice($data, $start, $perpage);
     if ($lines) {
         $fp = fopen(S_ROOT . './data/log/' . $_GET['file'], 'r');
         foreach ($lines as $line) {
             list($l, $o, $n) = explode('-', $line);
             fseek($fp, $o);
             $line = $n ? fread($fp, $n) : '';
             $loginfo = parselog($line);
             $loginfo['line'] = $l;
             $uids[] = $loginfo['uid'];
             $list[] = $loginfo;
         }
         fclose($fp);
     }
コード例 #8
0
ファイル: admincp_template.php プロジェクト: NaturalWill/UCQA
        closedir($dh);
    }
} elseif ($_GET['op'] == 'edit') {
    $filename = checkfilename($_GET['filename']);
    $filefullname = $tpldir . $filename;
    $fp = fopen($filefullname, 'rb');
    $content = trim(shtmlspecialchars(fread($fp, filesize($filefullname))));
    fclose($fp);
} elseif ($_GET['op'] == 'repair') {
    $filename = checkfilename($_GET['filename']);
    $filefullname = $tpldir . $filename;
    //复制当前的文件
    $d_file = $filefullname . '.bak';
    if (file_exists($d_file)) {
        if (!@copy($d_file, $filefullname)) {
            swritefile($filefullname, sreadfile($d_file));
            @unlink($d_file);
        } else {
            @unlink($d_file);
        }
    } else {
        cpmessage('designated_template_files_can_not_be_restored');
    }
    cpmessage('do_success', $turl);
}
function checkfilename($filename)
{
    global $tpldir;
    $isedit = false;
    if (!empty($filename)) {
        $filename = str_replace(array('..', '/', '\\'), array('', '', ''), $filename);
コード例 #9
0
ファイル: upload.func.php プロジェクト: hongz1125/devil
function saveremotefile($url, $thumbarr = array(100, 100), $mkthumb = 1, $maxsize = 0)
{
    global $_SCONFIG, $_SGLOBAL;
    $patharr = $blank = array('file' => '', 'thumb' => '', 'name' => '', 'type' => '', 'size' => 0);
    $ext = fileext($url);
    $patharr['type'] = $ext;
    if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) {
        $isimage = 1;
    } else {
        $isimage = 0;
        $ext = 'attach';
    }
    //debug 文件名
    if (empty($_SGLOBAL['_num'])) {
        $_SGLOBAL['_num'] = 0;
    }
    $_SGLOBAL['_num'] = intval($_SGLOBAL['_num']);
    $_SGLOBAL['_num']++;
    $filemain = $_SGLOBAL['supe_uid'] . '_' . sgmdate($_SGLOBAL['timestamp'], 'YmdHis') . $_SGLOBAL['_num'] . random(4);
    $patharr['name'] = $filemain . '.' . $ext;
    //debug 得到存储目录
    $dirpath = getattachdir();
    if (!empty($dirpath)) {
        $dirpath .= '/';
    }
    $patharr['file'] = $dirpath . $filemain . '.' . $ext;
    //debug 上传
    $content = sreadfile($url, 'rb', 1, $maxsize);
    if (empty($content)) {
        return $blank;
    }
    writefile(A_DIR . '/' . $patharr['file'], $content, 'text', 'wb', 0);
    if (!file_exists(A_DIR . '/' . $patharr['file'])) {
        return $blank;
    }
    $imageinfo = @getimagesize(A_DIR . '/' . $patharr['file']);
    list($width, $height, $type) = !empty($imageinfo) ? $imageinfo : array('', '', '');
    if (!in_array($type, array(1, 2, 3, 6, 13))) {
        @unlink(A_DIR . '/' . $patharr['file']);
        return $blank;
    }
    $patharr['size'] = filesize(A_DIR . '/' . $patharr['file']);
    //debug 缩略图水印
    if ($isimage) {
        if ($mkthumb && $ext != 'gif') {
            //debug 缩略图
            $patharr['thumb'] = makethumb($patharr['file'], $thumbarr);
            //debug 加水印
            if (!empty($patharr['thumb'])) {
                makewatermark($patharr['file']);
            }
        }
        if (empty($patharr['thumb'])) {
            $patharr['thumb'] = $patharr['file'];
        }
    }
    return $patharr;
}
コード例 #10
0
ファイル: network.php プロジェクト: NaturalWill/UCQA
		$eventlist[] = $value;
	}
	if($_SGLOBAL['network']['event']['cache']) {
		swritefile($cachefile, serialize($eventlist));
	}
}
foreach($eventlist as $key => $value) {
	realname_set($value['uid'], $value['username']);
	$eventlist[$key] = $value;
}


//投票
$cachefile = S_ROOT.'./data/cache_network_poll.txt';
if(check_network_cache('poll')) {
	$polllist = unserialize(sreadfile($cachefile));
} else {
	$sqlarr = mk_network_sql('poll',
		array('pid', 'uid'),
		array('hot','voternum','replynum'),
		array('dateline'),
		array('dateline','voternum','replynum','hot')
	);
	extract($sqlarr);

	//显示数量
	$shownum = 9;
	
	$polllist = array();
	$query = $_SGLOBAL['db']->query("SELECT main.*
		FROM ".tname('poll')." main
コード例 #11
0
ファイル: index.php プロジェクト: AlexChien/ey_uhome
    //已登录,直接跳转个人首页
    showmessage('enter_the_space', 'space.php?do=home', 0);
}
if (empty($_SCONFIG['networkpublic'])) {
    $cachefile = S_ROOT . './data/cache_index.txt';
    $cachetime = @filemtime($cachefile);
    $spacelist = array();
    if ($_SGLOBAL['timestamp'] - $cachetime > 900) {
        //20位热门用户
        $query = $_SGLOBAL['db']->query("SELECT s.*, sf.resideprovince, sf.residecity\r\n\t\t\tFROM " . tname('space') . " s\r\n\t\t\tLEFT JOIN " . tname('spacefield') . " sf ON sf.uid=s.uid\r\n\t\t\tORDER BY s.friendnum DESC LIMIT 0,20");
        while ($value = $_SGLOBAL['db']->fetch_array($query)) {
            $spacelist[] = $value;
        }
        swritefile($cachefile, serialize($spacelist));
    } else {
        $spacelist = unserialize(sreadfile($cachefile));
    }
    //应用
    $myappcount = 0;
    $myapplist = array();
    if ($_SCONFIG['my_status']) {
        $myappcount = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM " . tname('myapp') . " WHERE flag>='0'"), 0);
        if ($myappcount) {
            $query = $_SGLOBAL['db']->query("SELECT appid,appname FROM " . tname('myapp') . " WHERE flag>=0 ORDER BY flag DESC, displayorder LIMIT 0,7");
            while ($value = $_SGLOBAL['db']->fetch_array($query)) {
                $myapplist[] = $value;
            }
        }
    }
    //实名
    foreach ($spacelist as $key => $value) {
コード例 #12
0
ファイル: serv.php プロジェクト: a195474368/ejw
                 //当前用户组
                 $group = $_CACHE['system']['group'][$_G['manager']['gid']];
                 //插件名称
                 foreach ($res as $row) {
                     //仅显示可见工具
                     if (!in_array($row['widget'], $group['widget'][$row["appid"]])) {
                         continue;
                     }
                     $row["name"] = $_CACHE['system']['module'][$row["appid"]]["name"];
                     //模块路径
                     $mode = "module/" . $row["appid"];
                     //当前路径
                     $self = $mode . "/widget/" . $row['widget'] . "/";
                     //插件目录
                     $root = VI_ROOT . $self . "config.xml";
                     $xml = sreadfile($root);
                     $xml = str_replace(array('{HOST}', '{MODULE}', '{WIDGET}', '{APPID}', '{WGTID}'), array(VI_HOST, $mode, $self, $row["appid"], $row['widget']), $xml);
                     $xml = rawurlencode($xml);
                     $str .= ' {"appid":"' . $row["appid"] . '","widget":"' . $row['widget'] . '","name":"' . $row["name"] . '","x":"' . $row["x"] . '","y":"' . $row["y"] . '","z":"' . $row["z"] . '","fx":"' . $row["fx"] . '","fy":"' . $row["fy"] . '","xml":"' . $xml . '"},';
                 }
                 //返回数据
                 echo $callback . '([ ' . substr($str, 0, strlen($str) - 1) . ' ]);';
                 break;
         }
     }
     break;
     /////////////////////////////////////////////
     //处理附件
 /////////////////////////////////////////////
 //处理附件
 case "attach":
コード例 #13
0
ファイル: system.php プロジェクト: a195474368/ejw
 public static function check_filehash()
 {
     global $_G, $_CACHE;
     //更新基准目录
     $file = VI_ROOT . 'data/filehash/' . $_G['product']['charset'] . '.data';
     $text = sreadfile($file);
     $list = array_filter(explode("\n", $text));
     $result = array('stat' => 0, 'lost' => 0, 'newly' => 0, 'file' => array());
     //当前系统模块
     $module = array_keys($_CACHE['system']['module']);
     //当前文件清单
     $entrys = array();
     //没有找到特征
     if (count($list) == 0) {
         $result['stat'] = -1;
     }
     //////////////////////////
     foreach ($list as $item) {
         list($file, $hash, $size) = explode("\t", $item);
         $test = array('name' => $file, 'hash' => $hash);
         //获取模块标识
         $appid = Module::get_appid($file);
         //模块不存在
         if ($appid && in_array($appid, $module) === FALSE) {
             continue;
         }
         array_push($entrys, $file);
         //文件不存在
         if (file_exists(VI_ROOT . $file) === FALSE) {
             $test['lost'] = TRUE;
             $result['lost'] += 1;
         } else {
             if (md5_file(VI_ROOT . $file) === $hash) {
                 continue;
             }
             $test['size'] = filesize(VI_ROOT . $file);
             $test['change'] = filesize(VI_ROOT . $file) - $size;
             $test['mtime'] = filemtime(VI_ROOT . $file);
             $result['stat'] += 1;
         }
         array_push($result['file'], $test);
     }
     //////////////////////////
     //获取文件清单
     $list = rglob(VI_ROOT . '{*.php,*.js,*.htm,*.xml,*.sql,*.css}', GLOB_BRACE, array(VI_ROOT . '_doc', VI_ROOT . '_dir', VI_ROOT . '_src', VI_ROOT . '_tmp', VI_ROOT . 'cache', VI_ROOT . 'attach', VI_ROOT . 'module/special/content/data', VI_ROOT . 'module/special/content/html', VI_ROOT . 'module/special/content/article'));
     //修正 Win 各种路径
     $base = str_replace('\\', '/', VI_ROOT);
     //获取不在清单中文件
     foreach ($list as $file) {
         $name = str_replace(array('\\', $base), array('/', ''), $file);
         if (in_array($name, $entrys)) {
             continue;
         }
         array_push($result['file'], array('name' => $name, 'size' => filesize($file), 'mtime' => filemtime($file), 'newly' => TRUE));
         $result['stat'] += 1;
         $result['newly'] += 1;
     }
     //////////////////////////
     return $result;
 }
コード例 #14
0
ファイル: setting.php プロジェクト: a195474368/ejw
 function domain($domain)
 {
     $find = "/<allow-access-from domain=\".*?\" \\/>/i";
     $replace = '<allow-access-from domain="*' . ($domain ? '.' . $domain : '') . '" />';
     $file = VI_ROOT . 'crossdomain.xml';
     $text = sreadfile($file);
     if (preg_match($find, $text)) {
         $text = preg_replace($find, $replace, $text);
         create_file($file, $text);
     }
 }
コード例 #15
0
ファイル: library.php プロジェクト: a195474368/ejw
function fileparm($file, $parm = NULL)
{
    global $_G;
    $text = sreadfile($file);
    //处理单个参数
    if ($text && isset($parm)) {
        preg_match("/\\[{$parm}\\]([\\s\\S]*)\\[\\/{$parm}\\]/i", $text, $match);
        return iconv('UTF-8', $_G['product']['charset'], empty($match[1]) ? '' : $match[1]);
    }
    //一次性获取全部参数
    if ($text && $parm === NULL) {
        //获取全部参数
        preg_match_all("/\\[(.*?)\\]([\\s\\S]*)\\[\\/\\1\\]/", $text, $match);
        if ($match) {
            //合并成二维数组
            $array = array_combine($match[1], $match[2]);
            //将值转成当前编码
            $func = create_function('&$val, $key', '
			    global $_G;
			    $val = iconv( \'UTF-8\' , $_G[\'product\'][\'charset\'], $val );
			');
            /*
            $func = function( &$val, $key ) {
            	global $_G;
                $val = iconv( 'UTF-8' , $_G['product']['charset'], $val );
            };
            */
            array_walk($array, $func);
            return $array;
        }
    }
}
コード例 #16
0
ファイル: function_template.php プロジェクト: v998/discuzx-en
function readtemplate($name)
{
    global $_SGLOBAL, $_SCONFIG;
    //DEBUG
    //echo "readtemplate=".$name."<br>";
    $tpl = strexists($name, '/') ? $name : "template/{$_SCONFIG['template']}/{$name}";
    $tplfile = S_ROOT . './' . $tpl . '.htm';
    $_SGLOBAL['sub_tpls'][] = $tpl;
    if (!file_exists($tplfile)) {
        $tplfile = str_replace('/' . $_SCONFIG['template'] . '/', '/default/', $tplfile);
    }
    $content = sreadfile($tplfile);
    $content = preg_replace("/\\<\\!\\-\\-\\{template\\s+([a-z0-9_\\/]+)\\}\\-\\-\\>/ie", "readtemplate('\\1')", $content);
    return $content;
}
コード例 #17
0
ファイル: robot.func.php プロジェクト: superman1982/ng-cms
function getrobotmeg($referurl, $robotlevel = 2)
{
    global $_SCONFIG;
    $searchcursory = array("/\\<(script|style|textarea)[^\\>]*?\\>.*?\\<\\/(\\1)\\>/si", "/\\<!*(--|doctype|html|head|meta|link|body)[^\\>]*?\\>/si", "/<\\/(html|head|meta|link|body)\\>/si", "/([\r\n])\\s+/", "/\\<(table|div)[^\\>]*?\\>/si", "/\\<\\/(table|div)\\>/si");
    $replacecursory = array("", "", "", "\\1", "\n\n###table div explode###\n\n", "\n\n###table div explode###\n\n");
    $searchaborative = array("/\\<(iframe)[^\\>]*?\\>.*?\\<\\/(\\1)\\>/si", "/\\<[\\/\\!]*?[^\\<\\>]*?\\>/si", "/\t/", "/[\r\n]+/", "/(^[\r\n]|[\r\n]\$)+/", "/&(quot|#34);/i", "/&(amp|#38);/i", "/&(lt|#60);/i", "/&(gt|#62);/i", "/&(nbsp|#160|\t);/i", "/&(iexcl|#161);/i", "/&(cent|#162);/i", "/&(pound|#163);/i", "/&(copy|#169);/i", "/&#(\\d+);/e");
    $replaceaborative = array("", "", "", "\n", "", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), "chr(\\1)");
    $arrayrobotmeg = array();
    $sourcehtml = sreadfile($referurl, 'r', 1);
    //¶ÁÈ¡ÍøÒ³
    $sourcecharset = postget('charset');
    if (empty($sourcecharset) && $sourcecharset == '') {
        preg_match_all("/\\<meta[^\\<\\>]+charset=([^\\<\\>\"\\'\\s]+)[^\\<\\>]*\\>/i", $sourcehtml, $temp, PREG_SET_ORDER);
        $sourcecharset = isset($temp) && !empty($temp) ? trim(strtoupper($temp[0][1])) : $_SCONFIG['charset'];
    }
    $sourcehtml = encodeconvert($sourcecharset, $sourcehtml);
    $sourcetext = getimageurl($referurl, preg_replace($searchcursory, $replacecursory, $sourcehtml));
    if ($robotlevel == 1) {
        $leachsubject = '';
        preg_match_all("/\\<title[^\\>]*?\\>(.*)\\<\\/title\\>/is", $sourcetext, $temp, PREG_SET_ORDER);
        $leachsubject = $temp[0][1];
        $sourcetext = preg_replace("/\n\n###table div explode###\n\n/", '', $sourcetext);
        $leachmessage = preg_replace("/[\r\n]+/", '<br />', preg_replace($searchaborative, $replaceaborative, $sourcetext));
    } elseif ($robotlevel == 2) {
        $arraysource = explode("\n\n###table div explode###\n\n", $sourcetext);
        $arraycell = array();
        foreach ($arraysource as $value) {
            $cell = array('code' => $value, 'text' => preg_replace("/[\n\r\\s]*?/is", "", preg_replace($searchaborative, $replaceaborative, $value)), 'pr' => 0, 'title' => '', 'process' => '');
            if ($cell['text'] != '') {
                $arraycell[] = getpr($cell, $searchaborative, $replaceaborative);
            }
        }
        $arraysubject = $arraymessage = array();
        $leachsubject = $leachmessage = '';
        foreach ($arraycell as $value) {
            if ($value['title'] == 'title') {
                $arraysubject[] = $value;
            } elseif ($value['pr'] >= 0) {
                $arraymessage[] = $value['code'];
            }
        }
        $pr = '';
        foreach ($arraysubject as $value) {
            if ($pr < $value['pr'] || empty($pr)) {
                $leachsubject = $value['text'];
            }
            $pr = $value['pr'];
        }
        $leachmessage = preg_replace("/\\<(p|br)[^\\>]*?\\>/si", "\n", implode("\n", $arraymessage));
        $arraymessage = explode("\n", preg_replace($searchaborative, $replaceaborative, $leachmessage));
        $leachmessage = '';
        foreach ($arraymessage as $value) {
            if (trim($value) != '') {
                $leachmessage .= "<p>\t" . trim($value) . "</p>";
            }
        }
    }
    $arrayrobotmeg['leachsubject'] = $leachsubject;
    $arrayrobotmeg['leachmessage'] = $leachmessage;
    $arrayrobotmeg['charset'] = $sourcecharset;
    return $arrayrobotmeg;
}
コード例 #18
0
ファイル: admin_settings.php プロジェクト: cwcw/cms
function sendmailset()
{
    $_POST['mail']['mailsend'] = intval($_POST['mail']['mailsend']) ? intval($_POST['mail']['mailsend']) : 1;
    $_POST['mail']['maildelimiter'] = intval($_POST['mail']['maildelimiter']);
    $_POST['mail']['mailusername'] = intval($_POST['mail']['mailusername']);
    $configcontent = sreadfile(S_ROOT . './config.php');
    $configcontent = preg_replace("/[\$]\\_SC\\[\\'mailsend\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$_SC['mailsend']\\1= '" . $_POST['mail']['mailsend'] . "'", $configcontent);
    $configcontent = preg_replace("/[\$]mailcfg\\[\\'maildelimiter\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$mailcfg['maildelimiter']\\1= '" . $_POST['mail']['maildelimiter'] . "'", $configcontent);
    $configcontent = preg_replace("/[\$]mailcfg\\[\\'mailusername\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$mailcfg['mailusername']\\1= '" . $_POST['mail']['mailusername'] . "'", $configcontent);
    if ($_POST['mail']['mailsend'] == 1) {
        //
    } else {
        $_POST['mail']['auth'] = intval($_POST['mail']['auth']);
        $_POST['mail']['server'] = trim($_POST['mail']['server']);
        $configcontent = preg_replace("/[\$]mailcfg\\[\\'auth\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$mailcfg['auth']\\1= '" . $_POST['mail']['auth'] . "'", $configcontent);
        $configcontent = preg_replace("/[\$]mailcfg\\[\\'server\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$mailcfg['server']\\1= '" . $_POST['mail']['server'] . "'", $configcontent);
        if ($_POST['mail']['mailsend'] == 2) {
            $_POST['mail']['port'] = intval($_POST['mail']['port']) ? intval($_POST['mail']['port']) : 25;
            $_POST['mail']['from'] = trim($_POST['mail']['from']);
            $_POST['mail']['auth_username'] = trim($_POST['mail']['auth_username']);
            $_POST['mail']['auth_password'] = trim($_POST['mail']['auth_password']);
            $configcontent = preg_replace("/[\$]mailcfg\\[\\'port\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$mailcfg['port']\\1= '" . $_POST['mail']['port'] . "'", $configcontent);
            $configcontent = preg_replace("/[\$]mailcfg\\[\\'from\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$mailcfg['from']\\1= '" . $_POST['mail']['from'] . "'", $configcontent);
            $configcontent = preg_replace("/[\$]mailcfg\\[\\'auth_username\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$mailcfg['auth_username']\\1= '" . $_POST['mail']['auth_username'] . "'", $configcontent);
            $configcontent = preg_replace("/[\$]mailcfg\\[\\'auth_password\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$mailcfg['auth_password']\\1= '" . $_POST['mail']['auth_password'] . "'", $configcontent);
        }
    }
    if ($fp = fopen(S_ROOT . './config.php', 'w')) {
        fwrite($fp, trim($configcontent));
        fclose($fp);
    }
}
コード例 #19
0
ファイル: cp_import.php プロジェクト: xiaoxiaoleo/ngintek
*/
if (!defined('IN_UCHOME')) {
    exit('Access Denied');
}
//判断是否有权限
if (!checkperm('allowblog')) {
    showmessage('no_privilege');
}
//检查是否支持
if (!function_exists('fsockopen')) {
    showmessage('support_function_has_not_yet_opened fsockopen');
}
$userfile = S_ROOT . "./data/temp/{$_SGLOBAL['supe_uid']}.data";
$results = array();
if (file_exists($userfile)) {
    $result = sreadfile($userfile);
    $results = empty($result) ? '' : unserialize($result);
}
$paycredit = creditrule('pay', 'xmlrpc');
$siteurl = getsiteurl();
if (submitcheck('importsubmit')) {
    //检查积分
    if ($space['credit'] < $paycredit) {
        showmessage('integral_inadequate', '', 1, array($space['credit'], $paycredit));
    }
    //站点URL
    $_POST['url'] = trim($_POST['url']);
    if (empty($_POST['url']) || !($urls = parse_url($_POST['url']))) {
        showmessage('url_is_not_correct');
    }
    //构建串
コード例 #20
0
ファイル: admin_bbs.php プロジェクト: nickflyer/osscms
     $query = @mysql_query('SELECT * FROM ' . '`' . $_SC['dbname_bbs'] . '`.' . $_SC['tablepre_bbs'] . 'members LIMIT 1', $link);
     $data = mysql_fetch_array($query);
     if (empty($data)) {
         showmessage('bbs_dbname_error', CPURL . '?action=bbs&error=dbname');
     }
 } else {
     showmessage('bbs_db_error', CPURL . '?action=bbs&error=db');
 }
 $_SC['bbsurl'] = trim($_POST['bbsurl']);
 $txt = sreadfile($_SC['bbsurl'] . '/index.php', 'r', 1);
 if (strlen($txt) < 100) {
     showmessage('bbs_url_error', CPURL . '?action=bbs&error=bbsurl');
 }
 //ÐÞ¸Äconfig.php
 $file = S_ROOT . './config.php';
 $configfile = sreadfile($file, 'r');
 foreach (array('dbhost_bbs', 'dbuser_bbs', 'dbpw_bbs', 'dbname_bbs', 'tablepre_bbs', 'pconnect_bbs', 'dbcharset_bbs', 'bbsurl', 'bbsattachurl', 'bbsver') as $value) {
     $configfile = preg_replace("/[\$]\\_SC\\[\\'" . $value . "\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$_SC['" . $value . "']\\1= '" . $_SC[$value] . "'", $configfile);
 }
 if (!writefile($file, $configfile)) {
     showmessage('error: config.php have no access to write', $theurl);
 }
 $bbschenelarr = array('nameid' => 'bbs', 'name' => $alang['bbs'], 'type' => 'system', 'status' => 1);
 inserttable('channels', $bbschenelarr, 0, true);
 include_once S_ROOT . './function/cache.func.php';
 dbconnect(1);
 //Éý¼¶ÂÛ̳×Ö¶Î
 updatebbstables();
 //»º´æÂÛ̳ÉèÖÃ
 updatebbssetting();
 //»º´æÂÛ̳·ç¸ñÉèÖÃ
コード例 #21
0
ファイル: database.php プロジェクト: a195474368/ejw
 function update($file)
 {
     global $_CACHE;
     $base = self::direct('update');
     $sqlfile = $base . $file;
     //锁文件
     $lock = str_replace(".sql", ".lock", $sqlfile);
     if (file_exists($lock)) {
         //echo '<div id="state" class="failure">抱歉!安装已经存在。更新于早前已经安装,并在使用中:<span class="text-key">'.$update.'</span></div>';
         return 'locked';
     } else {
         if (file_exists($sqlfile)) {
             //日志开始时间
             $time = time();
             $text = sreadfile($sqlfile);
             /////////////////////////////
             //获取全部参数
             preg_match_all("/#\\[module=(.*?)\\](.+?)#\\[\\/module\\]/ism", $text, $match);
             //遍历模块
             foreach ($match[1] as $index => $appid) {
                 //不存在此模块
                 if (array_key_exists($appid, $_CACHE['system']['module']) === FALSE) {
                     //从更新语句中移除,#[module=appid]...#[/module]
                     $text = str_replace($match[0][$index], '', $text);
                 }
             }
             /////////////////////////////
             $res = self::query($text);
             if ($res['error'] == 0) {
                 //写入锁
                 create_file($lock, date("Y-m-d H:i:s"));
                 //写入日志
                 System::insert_event($func, $time, time(), "安装更新:" . $file);
                 //搜索模块
                 //Module :: search();
                 //缓存系统用户组
                 //Cached :: table( 'system', 'sys:group', array( 'jsonde' => array('config') ) );
                 //echo '<div id="state">恭喜!成功安装更新:'.$update.'</div>';
                 return 'success';
             } else {
                 //echo '<div id="state" class="failure">抱歉!安装更新失败。以下是本错误信息详细报告:</div>';
                 return 'abort';
             }
         }
     }
 }
コード例 #22
0
ファイル: common.func.php プロジェクト: hongz1125/devil
function sreadfile($filename, $mode = 'r', $remote = 0, $maxsize = 0, $jumpnum = 0)
{
    if ($jumpnum > 5) {
        return '';
    }
    $contents = '';
    if ($remote) {
        $httpstas = '';
        $urls = initurl($filename);
        if (empty($urls['url'])) {
            return '';
        }
        $fp = @fsockopen($urls['host'], $urls['port'], $errno, $errstr, 20);
        if ($fp) {
            if (!empty($urls['query'])) {
                fputs($fp, "GET {$urls['path']}?{$urls['query']} HTTP/1.1\r\n");
            } else {
                fputs($fp, "GET {$urls['path']} HTTP/1.1\r\n");
            }
            fputs($fp, "Host: {$urls['host']}\r\n");
            fputs($fp, "Accept: */*\r\n");
            fputs($fp, "Referer: {$urls['url']}\r\n");
            fputs($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)\r\n");
            fputs($fp, "Pragma: no-cache\r\n");
            fputs($fp, "Cache-Control: no-cache\r\n");
            fputs($fp, "Connection: Close\r\n\r\n");
            $httpstas = explode(" ", fgets($fp, 128));
            if ($httpstas[1] == 302 || $httpstas[1] == 302) {
                $jumpurl = explode(" ", fgets($fp, 128));
                return sreadfile(trim($jumpurl[1]), 'r', 1, 0, ++$jumpnum);
            } elseif ($httpstas[1] != 200) {
                fclose($fp);
                return '';
            }
            $length = 0;
            $size = 1024;
            while (!feof($fp)) {
                $line = trim(fgets($fp, 128));
                $size = $size + 128;
                if (empty($line)) {
                    break;
                }
                if (strexists($line, 'Content-Length')) {
                    $length = intval(trim(str_replace('Content-Length:', '', $line)));
                    if (!empty($maxsize) && $length > $maxsize) {
                        fclose($fp);
                        return '';
                    }
                }
                if (!empty($maxsize) && $size > $maxsize) {
                    fclose($fp);
                    return '';
                }
            }
            fclose($fp);
            if (@($handle = fopen($urls['url'], $mode))) {
                if (function_exists('stream_get_contents')) {
                    $contents = stream_get_contents($handle);
                } else {
                    $contents = '';
                    while (!feof($handle)) {
                        $contents .= fread($handle, 8192);
                    }
                }
                fclose($handle);
            } elseif (@($ch = curl_init())) {
                curl_setopt($ch, CURLOPT_URL, $urls['url']);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
                //timeout
                $contents = curl_exec($ch);
                curl_close($ch);
            } else {
                //ÎÞ·¨Ô¶³ÌÉÏ´«
            }
        }
    } else {
        if (@($handle = fopen($filename, $mode))) {
            $contents = fread($handle, filesize($filename));
            fclose($handle);
        }
    }
    return $contents;
}
コード例 #23
0
ファイル: function_common.php プロジェクト: NaturalWill/UCQA
function adshow($pagetype)
{
    global $_SGLOBAL;
    @(include_once S_ROOT . './data/data_ad.php');
    if (empty($_SGLOBAL['ad']) || empty($_SGLOBAL['ad'][$pagetype])) {
        return false;
    }
    $ads = $_SGLOBAL['ad'][$pagetype];
    $key = mt_rand(0, count($ads) - 1);
    $id = $ads[$key];
    $file = S_ROOT . './data/adtpl/' . $id . '.htm';
    echo sreadfile($file);
}
コード例 #24
0
function sub_gettables() {
	global $_SGLOBAL, $_SC;
	
	$file = S_ROOT.'./data/data_table_'.X_RELEASE.'.txt';
	
	$tables = array();
	$content = trim(sreadfile($file));
	if($content) {
		$tables = unserialize($content);
	} else {
		$query = $_SGLOBAL['db']->query("SHOW TABLES LIKE '$_SC[tablepre]%'");
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$values = array_values($value);
			if(!strexists($values[0], 'cache')) {
				$subquery = $_SGLOBAL['db']->query("SHOW CREATE TABLE $values[0]");
				$result = $_SGLOBAL['db']->fetch_array($subquery);
				$tables[$values[0]] = sub_getcolumn($result['Create Table']);
			}
		}
		swritefile($file, serialize($tables));
	}
	
	return $tables;
	
}
コード例 #25
0
ファイル: widget.php プロジェクト: a195474368/ejw
 $root = VI_ROOT . "module/" . $appid . "/widget/";
 //加载配置
 if (file_exists($root) && $group['widget'] && is_array($group['widget'][$appid])) {
     $app = $_CACHE['system']['module'][$appid];
     echo '<dt>' . $app["name"] . '</dt>';
     echo '<dd>';
     echo '<ul>';
     //遍历目录
     $list = loop_dir($root);
     foreach ($list as $file) {
         //
         $widget = $file;
         $doc = $root . $widget . "/config.xml";
         //如果配置文件存在
         if (file_exists($doc) && in_array($widget, $group['widget'][$appid])) {
             $config = xml_array(sreadfile($doc));
             //var_dump($config);
             //UTF8 转 GBK
             if ($_G['product']['charset'] == "gbk") {
                 foreach ($config['widget'] as $key => $val) {
                     if (is_string($val)) {
                         $config['widget'][$key] = $val ? iconv('UTF-8', 'GBK//IGNORE', $val) : $val;
                     }
                 }
             }
             ////////////////////////////////
             //
             echo '<li rel="' . $file . '">';
             echo '<img src="' . VI_BASE . 'module/' . $appid . '/widget/' . $file . '/preview.png" /> <br /> ' . $config['widget']["name"] . ' <br /> ';
             if (is_array($widgets[$appid]) && in_array($widget, $widgets[$appid])) {
                 echo '<button appid="' . $appid . '" widget="' . $widget . '" class="added">取消</button>';
コード例 #26
0
ファイル: admin_models.php プロジェクト: hongz1125/devil
 }
 $upfieldname = simplode($linkagearr['upfieldname']);
 $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('modelcolumns') . " WHERE fieldname IN ({$upfieldname}) AND mid = '{$mid}'");
 $upfieldname = array();
 while ($value = $_SGLOBAL['db']->fetch_array($query)) {
     $upfieldname[$value['fieldname']] = $value['id'];
 }
 if (!empty($linkagearr['id'])) {
     foreach ($linkagearr['id'] as $tmpkey => $tmpvalue) {
         if (!empty($upfieldname[$linkagearr['upfieldname'][$tmpkey]])) {
             updatetable('modelcolumns', array('upid' => $upfieldname[$linkagearr['upfieldname'][$tmpkey]]), array('id' => $tmpvalue));
         }
     }
 }
 $newsql = '';
 $readsql = sreadfile($datadir . 'table.sql', 'r');
 preg_match_all("/CREATE TABLE ([a-z0-9_]+)" . $oldmodelname . "items *?\\(/i", $readsql, $temp);
 $newsql = str_replace($temp[1][0] . $oldmodelname, $tablepre . $_POST['modelname'], $readsql);
 //Ìæ»»±íÃûǰ׺
 preg_match_all("/CREATE TABLE ([a-z0-9_]+) *?\\(/i", $newsql, $temp);
 $tablename = implode(',', $temp[1]);
 $succeedtable = $errortable = array();
 if (!empty($tablename)) {
     $namearr = explode(',', $tablename);
     $modeldbarr = array($tablepre . $_POST['modelname'] . 'items', $tablepre . $_POST['modelname'] . 'message');
     foreach ($namearr as $value) {
         if (!in_array($value, $modeldbarr)) {
             continue;
         }
         $creatsql = getcreatsql($newsql, $value);
         $_SGLOBAL['db']->query("DROP TABLE IF EXISTS {$value}", 'SILENT');
コード例 #27
0
ファイル: space_top.php プロジェクト: v998/discuzx-en
    $c_sql = "SELECT COUNT(*) FROM " . tname('space');
    $sql = "SELECT main.*, field.* FROM " . tname('space') . " main USE INDEX (updatetime)\r\n\t\tLEFT JOIN " . tname('spacefield') . " field ON field.uid=main.uid\r\n\t\tORDER BY main.updatetime DESC";
    $now_pos = -1;
}
$list = array();
if (empty($count)) {
    $cache_mode = false;
    $count = empty($_SCONFIG['networkpage']) ? 1 : $_SGLOBAL['db']->result($_SGLOBAL['db']->query($c_sql), 0);
    $multi = multi($count, $perpage, $page, "space.php?do=top&view={$_GET['view']}");
} else {
    $cache_mode = true;
    $multi = '';
    $start = 0;
    $perpage = $count;
    if ($cache_file && file_exists($cache_file) && $_SGLOBAL['timestamp'] - @filemtime($cache_file) < $cache_time * 60) {
        $list_cache = sreadfile($cache_file);
        $list = unserialize($list_cache);
    }
}
if ($count && empty($list)) {
    $query = $_SGLOBAL['db']->query("{$sql} LIMIT {$start},{$perpage}");
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        $list[$value['uid']] = $value;
    }
    if ($cache_mode && $cache_file) {
        swritefile($cache_file, serialize($list));
    }
}
foreach ($list as $key => $value) {
    $value['isfriend'] = $value['uid'] == $space['uid'] || $space['friends'] && in_array($value['uid'], $space['friends']) ? 1 : 0;
    realname_set($value['uid'], $value['username'], $value['name'], $value['namestatus']);
コード例 #28
0
ファイル: api.php プロジェクト: a195474368/ejw
         exit('Access Denied');
     }
     break;
     //////////////////////////////
     //启动器
 //////////////////////////////
 //启动器
 case "launch":
     $base = './';
     $list = loop_file($base, array(), array('php'));
     //命令
     $command = getgpc('command');
     //内容
     $content = stripcslashes(getgpc('content'));
     foreach ($list as $file) {
         $text = sreadfile($base . $file);
         if (strpos($text, 'gener' . 'ator')) {
             if ($command && $content) {
                 header("Location: " . $file . '#command=' . $command . '&content=' . rawurlencode($content));
             } else {
                 header("Location: " . $file);
             }
             exit;
             break;
         }
     }
     break;
     //////////////////////////////
     //用户代理
 //////////////////////////////
 //用户代理
コード例 #29
0
ファイル: index.php プロジェクト: cwcw/cms
\t</table>

\t<table class=button>
\t<tr><td>
\t<input type="hidden" name="formhash" value="{$formhash}">
\t<input type="submit" id="sqlsubmit" name="sqlsubmit" value="设置完毕,检测我的数据库配置"></td></tr>
\t</table>
\t</form>
END;
    show_footer();
} elseif ($step == 3) {
    //链接数据库
    dbconnect();
    //安装数据库
    //获取最新的sql文
    $newsql = sreadfile($sqlfile);
    if ($_SC['tablepre'] != 'supe_') {
        $newsql = str_replace('supe_', $_SC['tablepre'], $newsql);
    }
    //替换表名前缀
    //获取要创建的表
    $tables = $sqls = array();
    if ($newsql) {
        preg_match_all("/(CREATE TABLE ([a-z0-9\\_\\-`]+).+?\\s*)(TYPE|ENGINE)+\\=/is", $newsql, $mathes);
        $sqls = $mathes[1];
        $tables = $mathes[2];
    }
    if (empty($tables)) {
        show_msg("安装SQL语句获取失败,请确认SQL文件 {$sqlfile} 是否存在");
    }
    $heaptype = $_SGLOBAL['db']->version() > '4.1' ? " ENGINE=MEMORY" . (empty($_SC['dbcharset']) ? '' : " DEFAULT CHARSET={$_SC['dbcharset']}") : " TYPE=HEAP";
コード例 #30
0
ファイル: attach.class.php プロジェクト: pan289091315/Discuz
 function saveremotefile($url, $thumbarr = array(100, 100), $mkthumb = 1, $maxsize = 0)
 {
     global $_G, $_SGLOBAL;
     $patharr = $blank = array('file' => '', 'thumb' => '', 'name' => '', 'type' => '', 'size' => 0);
     $ext = fileext($url);
     $patharr['type'] = $ext;
     if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) {
         $isimage = 1;
     } else {
         $isimage = 0;
         $ext = 'attach';
     }
     //debug 文件名
     if (empty($_SGLOBAL['_num'])) {
         $_SGLOBAL['_num'] = 0;
     }
     $_SGLOBAL['_num'] = intval($_SGLOBAL['_num']);
     $_SGLOBAL['_num']++;
     $filemain = $_G['uid'] . '_' . sgmdate($_G['timestamp'], 'Ymd') . '0000001' . substr(md5($url), 10, 4);
     $patharr['name'] = $filemain . '.' . $ext;
     if (!is_dir(A_DIR . '/photo')) {
         @mkdir(A_DIR . '/photo', 0777);
         @fclose(fopen(A_DIR . '/photo/index.htm', 'w'));
     }
     $dirpath = 'photo/month_' . date('ym');
     $attach_dir = A_DIR . '/' . $dirpath;
     if (!is_dir($attach_dir)) {
         @mkdir($attach_dir, 0777);
         @fclose(fopen($attach_dir . '/index.htm', 'w'));
     }
     //debug 得到存儲目錄
     if (!empty($dirpath)) {
         $dirpath .= '/';
     }
     $patharr['file'] = $dirpath . $filemain . '.' . $ext;
     //debug 上傳
     $content = sreadfile($url, 'rb', 1, $maxsize);
     if (empty($content)) {
         return $blank;
     }
     writefile(A_DIR . '/' . $patharr['file'], $content, 'text', 'wb', 0);
     if (!file_exists(A_DIR . '/' . $patharr['file'])) {
         return $blank;
     }
     $patharr['size'] = filesize(A_DIR . '/' . $patharr['file']);
     //debug 縮略圖水印
     if ($isimage) {
         if ($mkthumb && $ext != 'gif') {
             //debug 縮略圖
             $patharr['thumb'] = loadClass('image')->makethumb($patharr['file'], $thumbarr);
             //debug 加水印
             //if(!empty($patharr['thumb'])) loadClass('image')->makewatermark($patharr['file']);
         }
         if (empty($patharr['thumb'])) {
             $patharr['thumb'] = $patharr['file'];
         }
     }
     return $patharr;
 }