本文整理汇总了PHP中file::createaccessfile方法的典型用法代码示例。如果您正苦于以下问题:PHP file::createaccessfile方法的具体用法?PHP file::createaccessfile怎么用?PHP file::createaccessfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::createaccessfile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doupload
function doupload()
{
@header('Content-type: text/html; charset=' . WIKI_CHARSET);
$did = $this->post['did'] ? $this->post['did'] : 0;
if (!$this->setting['attachment_open']) {
exit;
}
$okfile = '';
$this->setting['coin_download'] = isset($this->setting['coin_download']) ? $this->setting['coin_download'] : 10;
$count = count($_FILES['attachment']['name']);
for ($i = 0; $i < $count; $i++) {
if (!(bool) $_FILES['attachment']['name'][$i]) {
continue;
}
$size = $_FILES['attachment']['size'][$i] / 1024;
$name = $_FILES['attachment']['name'][$i];
$attachment_type = $_ENV['attachment']->get_attachment_type();
$filetype = strtolower(substr($name, strrpos($name, ".") + 1));
if ($attachment_type[0] != '*' && !in_array($filetype, $attachment_type)) {
echo '<script>parent.Attachment.error("' . $name . ': ' . $this->view->lang['attachTypeError'] . '");</script>';
continue;
}
if ($size > $this->setting['attachment_size'] || empty($size)) {
echo '<script>parent.Attachment.error("' . $name . ': ' . $this->view->lang['attachSizeError2'] . '");</script>';
continue;
}
$destfile = 'data/attachment/' . date('y-m') . '/' . date('Y-m-d') . '_' . util::random(10) . '.attach';
file::createaccessfile('data/attachment/' . date('y-m') . '/');
$result = file::uploadfile($_FILES['attachment']['tmp_name'][$i], $destfile, $this->setting['attachment_size'], 0);
if ($result) {
$okfile .= $name . '|';
$coindown = $this->post['coin_download'][$i];
if (empty($coindown) || !is_numeric($coindown)) {
$coindown = 0;
} else {
if (0 > $coindown) {
$coindown = 0;
} else {
if ($this->setting['coin_download'] < $coindown) {
$coindown = $this->setting['coin_download'];
}
}
}
$_ENV['attachment']->add_attachment($this->user['uid'], $did, $name, $destfile, $this->post['attachmentdesc'][$i], $filetype, 0, $coindown);
}
}
echo '<script>';
if ($okfile) {
echo 'parent.Attachment.addok("' . $okfile . '");';
}
echo '</script>';
}
示例2: 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>", '');
}
//.........这里部分代码省略.........
示例3: upload_attachment
function upload_attachment($did)
{
if (!$this->base->setting['attachment_open']) {
return false;
}
$count = count($_FILES['attachment']['name']);
for ($i = 0; $i < $count; $i++) {
if (!(bool) $_FILES['attachment']['name'][$i]) {
continue;
}
$attachment_type = $this->get_attachment_type();
$filetype = strtolower(substr($_FILES['attachment']['name'][$i], strrpos($_FILES['attachment']['name'][$i], ".") + 1));
if (!in_array($filetype, $attachment_type)) {
$message .= $_FILES['attachment']['name'][$i] . $this->base->view->lang['attachTypeError'] . "<br />";
continue;
}
if ($this->base->setting['attachment_size'] < $_FILES['attachment']['size'][$i] / 1024) {
$message .= $_FILES['attachment']['name'][$i] . $this->base->view->lang['attachSizeError'] . "<br />";
continue;
}
$destfile = 'data/attachment/' . date('y-m') . '/' . date('Y-m-d') . '_' . util::random(10) . '.attach';
file::createaccessfile('data/attachment/' . date('y-m') . '/');
$result = file::uploadfile($_FILES['attachment']['tmp_name'][$i], $destfile, $this->base->setting['attachment_size'], 0);
if ($result) {
$_ENV['attachment']->add_attachment($this->base->user['uid'], $did, $_FILES['attachment']['name'][$i], $destfile, $this->base->post['attachmentdesc'][$i], $filetype, 0);
}
}
return $message;
}