本文整理汇总了PHP中file::forcemkdir方法的典型用法代码示例。如果您正苦于以下问题:PHP file::forcemkdir方法的具体用法?PHP file::forcemkdir怎么用?PHP file::forcemkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::forcemkdir方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_file_list
function get_file_list($dir, $attimg)
{
$imgname['size'] = 0;
foreach ($dir as $filedirs) {
$filedir = HDWIKI_ROOT . '/' . $filedirs;
file::forcemkdir($filedir);
$handle = opendir($filedir);
$i = 0;
while ($filename = readdir($handle)) {
if (!is_dir($filedir . '/' . $filename) && '.' != $filename && '..' != $filename && '.svn' != $filename && 'index.htm' != $filename) {
$fstr = explode(".", $filename);
$flast = substr(strrchr($fstr[0], '_'), 1);
if (!in_array($filedirs . '/' . $filename, $attimg)) {
//if !in_array($filedirs.'/'.$filename,$attimg) && $flast!='140' && $flast!="s"
$i++;
$imgname[] = $filedirs . '/' . $filename;
$imgname['size'] += filesize($filedir . '/' . $filename);
}
}
}
$imgname['num'] = $i;
closedir($handle);
}
return $imgname;
}
示例2: extract_zip
function extract_zip()
{
$zip_file = UPGRADE_PATH . $this->package['release_code'] . '.zip';
require HDWIKI_ROOT . '/lib/zip.class.php';
$zip = new zip();
$swap_dir = UPGRADE_PATH . $this->package['release_code'];
if (!is_dir($swap_dir)) {
file::forcemkdir($swap_dir);
}
if (file::iswriteable($swap_dir)) {
$zip->extract($zip_file, $swap_dir);
}
unset($zip);
return count(@scandir($swap_dir)) > 0;
}
示例3: editionconvert
function editionconvert($type, $number)
{
if ($type == 'txt') {
$changenum = 100;
$maxeid = $this->db->result_first("SELECT MAX(eid) FROM " . DB_TABLEPRE . "edition WHERE 1");
if ($maxeid < $number - $changenum) {
return true;
}
$query = $this->db->query("SELECT eid,content FROM " . DB_TABLEPRE . "edition WHERE eid >({$number}-{$changenum}) AND eid <= {$number}");
while ($edition = $this->db->fetch_array($query)) {
if ($edition['content']) {
$path = 'data/edition/' . ceil($edition['eid'] / $changenum) * $changenum;
file::forcemkdir($path);
file::writetofile($path . "/" . $edition['eid'] . ".txt", $edition['content']);
}
}
$this->db->query("UPDATE " . DB_TABLEPRE . "edition SET content='' WHERE eid >({$number}-{$changenum}) AND eid <= {$number}");
} else {
$dirlist = array();
if ($handle = opendir('data/edition')) {
while (false !== ($dir = readdir($handle))) {
$dirlist[] = $dir;
}
closedir($handle);
}
$maxeid = @max($dirlist);
if ($number > $maxeid) {
return true;
}
$path = "data/edition/{$number}";
$files = file::get_file_by_ext($path, array('txt'));
foreach ((array) $files as $file) {
$eid = substr($file, 0, -4);
$filename = $path . "/" . $file;
$content = string::haddslashes(file::readfromfile($filename), 1);
if ($content) {
$this->db->query("UPDATE " . DB_TABLEPRE . "edition SET content='{$content}' WHERE eid={$eid}");
@unlink($filename);
}
}
}
return false;
}
示例4: dobackup
function dobackup()
{
set_time_limit(0);
$filedir = HDWIKI_ROOT . "/data/db_backup/";
file::createaccessfile($filedir);
if (!isset($this->post['backupsubmit']) && !isset($this->get[9])) {
$sqlfilename = date("Ymd", $this->time) . "_" . util::random(8);
$tables = $_ENV['db']->showtables();
file::forcemkdir($filedir);
$filename = $_ENV['db']->get_sqlfile_list($filedir);
$this->view->assign('filename', $filename);
$this->view->assign('filedir', $filedir);
$this->view->assign('tables', $tables);
$this->view->assign('sqlfilename', $sqlfilename);
$this->view->display("admin_dbbackup");
} else {
$sqldump = '';
$type = isset($this->post['type']) ? $this->post['type'] : $this->get[2];
$sqlfilename = isset($this->post['sqlfilename']) ? $this->post['sqlfilename'] : rawurldecode($this->get[3]);
$sizelimit = isset($this->post['sizelimit']) ? $this->post['sizelimit'] : intval($this->get[4]);
$tableid = intval($this->get[5]);
$startfrom = intval($this->get[6]);
$volume = intval($this->get[7]) + 1;
$compression = isset($this->post['compression']) ? $this->post['compression'] : intval($this->get[8]);
$backupfilename = $filedir . $sqlfilename;
$backupsubmit = 1;
$tables = array();
if (substr(trim(ini_get('memory_limit')), 0, -1) < 32 && substr(trim(ini_get('memory_limit')), 0, -1) > 0) {
@ini_set('memory_limit', '32M');
}
if (!util::is_mem_available($sizelimit * 1024 * 3)) {
$this->message($sizelimit . "KB" . $this->view->lang['dblimitsizeBig'], 'index.php?admin_db-backup');
}
switch ($type) {
case "full":
$tables = $_ENV['db']->showtables();
break;
case "stand":
$tables = array(DB_TABLEPRE . "category", DB_TABLEPRE . "doc", DB_TABLEPRE . "edition", DB_TABLEPRE . "user");
break;
case "min":
$tables = array(DB_TABLEPRE . "doc", DB_TABLEPRE . "user");
break;
case "custom":
if (!(bool) $this->post['tables']) {
$tables = $this->cache->getcache('backup_tables', '0');
} else {
$tables = $this->post['tables'];
$this->cache->writecache('backup_tables', $tables);
}
break;
}
if ($sizelimit < 512) {
$this->message($this->view->lang['dblimitsizeSmall'], 'BACK');
}
if (count($tables) == 0) {
$this->message($this->view->lang['dbChooseOne'], 'BACK');
}
if (!file_exists($filedir)) {
file::forcemkdir($filedir);
}
if (!file::iswriteable($filedir)) {
$this->message($this->view->lang['dbFileNotWrite'], 'index.php?admin_db-backup');
}
if (in_array(DB_TABLEPRE . "usergroup", $tables)) {
$num = array_search(DB_TABLEPRE . "usergroup", $tables);
$tables[$num] = $tables[0];
$tables[0] = DB_TABLEPRE . "usergroup";
}
if (in_array(DB_TABLEPRE . "user", $tables)) {
$num = array_search(DB_TABLEPRE . "user", $tables);
if ($tables[0] == DB_TABLEPRE . "usergroup") {
$tables[$num] = $tables[1];
$tables[1] = DB_TABLEPRE . "user";
} else {
$tables[$num] = $tables[0];
$tables[0] = DB_TABLEPRE . "user";
}
}
$complete = TRUE;
for (; $complete && $tableid < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $tableid++) {
$result = $_ENV['db']->sqldumptable($tables[$tableid], $complete, $sizelimit, $startfrom, strlen($sqldump));
$sqldump .= $result['tabledump'];
$complete = $result['complete'];
if ($complete) {
$startfrom = 0;
} else {
$startfrom = $result['startfrom'];
}
}
$dumpfile = $backupfilename . "_%s" . '.sql';
!$complete && $tableid--;
if (trim($sqldump)) {
$result = $_ENV['db']->write_to_sql($sqldump, $dumpfile, $volume);
if (!$result) {
$this->message($this->view->lang['dbBackupWriteSqlFiled'], 'BACK');
} else {
$url = "index.php?admin_db-backup-{$type}-" . rawurlencode($sqlfilename) . "-{$sizelimit}-{$tableid}-{$startfrom}-{$volume}-{$compression}-{$backupsubmit}";
$this->message("<image src='style/default/loading.gif'><br />" . $this->view->lang['dbBackupNext1'] . $volume . $this->view->lang['dbBackupNext2'] . "<script type=\"text/JavaScript\">setTimeout(\"window.location.replace('{$url}');\", 2000);</script>", '');
}
//.........这里部分代码省略.........
示例5: get
function get($name, $expires = 0)
{
$file = $this->dir . $name . '.php';
if (!file_exists($file)) {
$data = util::hfopen($this->url_cache . rawurlencode($name) . '.php');
if ($data) {
file::forcemkdir($this->dir);
$flag = file::writetofile($this->dir . $name . '.php', $data);
} else {
return '';
}
}
if (file_exists($file)) {
$data = file::readfromfile($file);
$data = str_replace($this->phpexit, '', $data);
return unserialize(base64_decode($data));
} else {
return '';
}
}
示例6: uploadfile
function uploadfile($attachment, $target, $maxsize = 1024, $is_image = 1)
{
$result = array('result' => false, 'msg' => 'upload mistake');
if ($is_image) {
$attach = $attachment;
$filesize = $attach['size'] / 1024;
if (0 == $filesize) {
$result['msg'] = '上传错误';
return $result;
}
if (substr($attach['type'], 0, 6) != 'image/' || !in_array(file::extname($attach['name']), array('jpg', 'jpeg', 'bmp', 'gif', 'png'))) {
$result['msg'] = '格式错误';
return $result;
}
if ($filesize > $maxsize) {
$result['msg'] = '文件过大';
return $result;
}
} else {
$attach['tmp_name'] = $attachment;
}
$filedir = dirname($target);
file::forcemkdir($filedir);
if (@copy($attach['tmp_name'], $target) || @move_uploaded_file($attach['tmp_name'], $target)) {
$result['result'] = true;
$result['msg'] = '上传成功';
}
if (!$result['result'] && @is_readable($attach['tmp_name'])) {
@($fp = fopen($attach['tmp_name'], 'rb'));
@flock($fp, 2);
@($attachedfile = fread($fp, $attach['size']));
@fclose($fp);
@($fp = fopen($target, 'wb'));
@flock($fp, 2);
if (@fwrite($fp, $attachedfile)) {
@unlink($attach['tmp_name']);
$result['result'] = true;
$result['msg'] = '上传失败';
}
@fclose($fp);
}
return $result;
}
示例7: writelog
function writelog($regular, $pluginid)
{
if ('admin' == substr($this->base->get[0], 0, 5)) {
if ('' == $pluginid) {
$menu = $this->db->fetch_first("select name from " . DB_TABLEPRE . "regular where regular like'%" . $regular . "%'");
} else {
if (is_numeric($pluginid)) {
$menu = $this->db->fetch_first("select name from " . DB_TABLEPRE . "plugin where pluginid='" . $pluginid . "'");
}
}
$str = "<?php exit;?>" . "\t" . $this->base->user['username'] . "\t" . $this->base->user['grouptitle'] . "\t" . $this->base->ip . "\t" . $this->base->date($this->base->time) . "\t" . $menu['name'] . "\t" . $regular . "\r\n";
file::forcemkdir(HDWIKI_ROOT . "/data/logs");
$handle = fopen(HDWIKI_ROOT . "/data/logs/" . date('Ym') . "_adminaccess.php", "a");
fwrite($handle, $str);
fclose($handle);
}
}
示例8: uploadfile
function uploadfile($attachment, $target, $maxsize = 1024, $is_image = 1)
{
$result = array('result' => false, 'msg' => 'upload mistake');
if ($is_image) {
$attach = $attachment;
$filesize = $attach['size'] / 1024;
if (0 == $filesize) {
$result['msg'] = '上传错误';
return $result;
}
if (substr($attach['type'], 0, 6) != 'image/') {
$result['msg'] = '格式错误';
return $result;
}
if ($filesize > $maxsize) {
$result['msg'] = '文件过大';
return $result;
}
} else {
$attach['tmp_name'] = $attachment;
}
$filedir = dirname($target);
file::forcemkdir($filedir);
if (@copy($attach['tmp_name'], $target) || @move_uploaded_file($attach['tmp_name'], $target)) {
$result['result'] = true;
$result['msg'] = '上传成功';
}
if (!$result['result'] && @is_readable($attach['tmp_name'])) {
@($fp = fopen($attach['tmp_name'], 'rb'));
@flock($fp, 2);
@($attachedfile = fread($fp, $attach['size']));
@fclose($fp);
@($fp = fopen($target, 'wb'));
@flock($fp, 2);
if (@fwrite($fp, $attachedfile)) {
@unlink($attach['tmp_name']);
$result['result'] = true;
$result['msg'] = '上传失败';
}
@fclose($fp);
}
return $result;
}
示例9: setfocusimg
function setfocusimg($img)
{
if ('' == $img) {
return '';
}
if (substr($img, 0, strlen(WIKI_URL)) == WIKI_URL) {
$img = substr($img, strlen(WIKI_URL) + 1);
}
if ("http://" == substr($img, 0, 7) && substr($img, 0, strlen(WIKI_URL)) != WIKI_URL) {
$tmpname = 'uploads/' . date("Ym") . "/" . util::random() . '.' . file::extname($img);
if ($pic_content = @util::hfopen($img)) {
file::forcemkdir(dirname($tmpname));
if (file::writetofile($tmpname, $pic_content)) {
$img = $tmpname;
}
}
}
$compress = util::image_compress($img, 's_f_', 100, 75);
if (!$compress['result']) {
return '';
}
util::image_compress($img, 'f_', 152, 114);
@unlink($tmpname);
return $compress['tempurl'];
}
示例10: doinstall
function doinstall()
{
if (isset($this->get[2]) && is_numeric($this->get[2])) {
$style_download_url = $this->setting['app_url'] . "/hdapp.php?action=download&type=template&install=1&id=" . $this->get[2] . "&url=" . WIKI_URL;
$zipcontent = @util::hfopen($style_download_url);
$tmpdir = HDWIKI_ROOT . '/data/tmp/';
file::forcemkdir($tmpdir);
$tmpname = $tmpdir . util::random(6) . '.zip';
file::writetofile($tmpname, $zipcontent);
require HDWIKI_ROOT . "/lib/zip.class.php";
require HDWIKI_ROOT . "/lib/xmlparser.class.php";
$zip = new zip();
if (!$zip->chk_zip) {
$this->message($this->view->lang['styleInstallNoZlib'], '');
}
$ziplist = @$zip->get_List($tmpname);
if (!(bool) $ziplist) {
@unlink($tmpname);
$this->message($this->view->lang['styleZipFail'], 'BACK');
}
$theme_name = $_ENV['theme']->get_theme_name($ziplist);
@$zip->Extract($tmpname, $tmpdir);
@unlink($tmpname);
//move file
$syle_path = $tmpdir . 'hdwiki';
if (is_dir(HDWIKI_ROOT . '/style/' . $theme_name)) {
@file::removedir($syle_path);
$this->message($this->view->lang['stylePathRepeat'], 'BACK');
}
@file::copydir($syle_path, HDWIKI_ROOT);
@file::removedir($syle_path);
//save db
$style_xml = HDWIKI_ROOT . '/style/' . $theme_name . '/desc.xml';
if (!is_file($style_xml)) {
$this->message($this->view->lang['styleXmlNotExist'], 'BACK');
}
$xmlnav = $_ENV['theme']->read_xml($theme_name);
$style['name'] = $xmlnav['name'];
$style['copyright'] = $xmlnav['copyright'];
$style['path'] = $theme_name;
$stylecon = $_ENV['theme']->add_check_style($style['path']);
if ($stylecon == null) {
$_ENV['theme']->add_style($style);
$this->cache->removecache('style');
$this->message($this->view->lang['styleInstallSuccess'], 'BACK');
} else {
$this->message($this->view->lang['styleDbPathRepeat'], 'index.php?admin_theme');
}
} else {
$this->message($this->view->lang['commonParametersInvalidTip'], 'index.php?admin_theme');
}
}
示例11: errorlog
function errorlog($msg, $sql)
{
$error = "<?php exit;?>" . "\t" . time() . "\t" . util::getip() . "\tMysql\t" . $_SERVER['PHP_SELF'] . "\t" . $this->errno() . "\t" . $this->error() . "\t{$sql}\n";
file::forcemkdir(HDWIKI_ROOT . "/data/logs");
@($fp = fopen(HDWIKI_ROOT . "/data/logs/" . date('Ym') . "_errorlog.php", "a"));
@flock($fp, 2);
@fwrite($fp, $error);
@fclose($fp);
}
示例12: write_css
function write_css($style)
{
$data = "#html{background:" . $style['bg_color'] . " url(" . $style['bg_imgname'] . ") repeat-x left top;}\n" . "#html body{width:950px;}\n" . "#html .bor_b-ccc,#html .col-h2{}\n" . "#html .bor-ccc,#html .columns,#html .bor-c_dl dl{border:1px " . $style['nav_framcolor'] . " solid;}\n" . "#html .inp_txt{border:1px " . $style['input_bgcolor'] . " solid;color:" . $style['input_color'] . ";}\n" . "html a{color:" . $style['link_color'] . ";}\n" . "html a:hover{color:" . $style['link_hovercolor'] . ";}\n" . "#html .link_orange a{color:" . $style['link_difcolor'] . "; text-decoration:none;}\n" . "#html .link_orange a:hover{color:" . $style['link_difcolor'] . ";text-decoration:underline;}\n" . "#html .col-h2{height:21px;line-height:21px;background:" . $style['titlebg_color'] . " url(" . $style['titbg_imgname'] . ") repeat-x left top;}";
$filedir = HDWIKI_ROOT . '/style/' . $style['path'] . '/';
file::forcemkdir($filedir);
$bytes = file::writetofile($filedir . 'mix_color.css', $data);
return $bytes > 0;
}