本文整理汇总了PHP中createDir函数的典型用法代码示例。如果您正苦于以下问题:PHP createDir函数的具体用法?PHP createDir怎么用?PHP createDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processUpload
function processUpload($file, $username = null)
{
if (!$username) {
$username = fpCurrentUsername();
}
$tmpFile = $file["tmp_name"];
$mimeType = $file["type"];
$filename = utf8_decode($file["name"]);
$filename = cleanupFilename($filename);
$getcwd = getcwd();
$freeSpace = disk_free_space("/");
$uploaded = is_uploaded_file($tmpFile);
$message = "OK";
if (!$uploaded) {
return errorMessage("Uploaded file not found.");
}
//verify file type
if (!startsWith($mimeType, "image")) {
return errorMessage("Uploaded file {$filename} is not an image. ({$mimeType})");
}
//move file to destination dir
$dataRoot = getConfig("upload._diskPath");
$dataRootUrl = getConfig("upload.baseUrl");
createDir($dataRoot, $username);
$uploadDir = combine($dataRoot, $username);
$uploadedFile = combine($dataRoot, $username, $filename);
$filesize = filesize($tmpFile);
$success = move_uploaded_file($tmpFile, $uploadedFile);
debug("move to {$uploadedFile}", $success);
if (!$success) {
return errorMessage("Cannot move file into target dir.");
}
return processImage($uploadDir, $filename);
}
示例2: createDir
/**
* 创建文件夹
* @param string $_path 文件夹路径
* @return array
* @author MaWei (http://www.phpyrb.com)
* @date 2014-8-3 下午2:10:22
*/
function createDir($_path)
{
if (!file_exists($_path)) {
createDir(dirname($_path));
mkdir($_path, 0777);
}
}
示例3: pullLibrary
function pullLibrary($libraryName, $info, $baseDirectory, $targetDirectory)
{
if ($info["updates"] === "onlyOnce" && is_dir($targetDirectory)) {
echo "---------------------------------------------------------------------\n";
echo "library {$libraryName} is already in {$targetDirectory} => no updates\n";
echo "---------------------------------------------------------------------\n";
echo "The update mode is declared as " . $info["updates"] . " in the configuration file\n";
echo "so this library is created but not updated. You can still remove the existing one\n";
echo "or change the configuration file if needed";
return;
}
createDir($targetDirectory);
echo "\n";
echo "----------------------------------------------------------------\n";
echo "pulling library '{$libraryName}' to {$targetDirectory}\n";
echo "----------------------------------------------------------------\n";
if (isset($info['github'])) {
pullGithub($info['github'], $targetDirectory);
} elseif (isset($info['dir'])) {
pullDirectory($baseDirectory . '/' . $info['dir'], $targetDirectory);
} elseif (isset($info['urls'])) {
foreach ($info['urls'] as $url => $targetBasename) {
pullUrl($url, $targetDirectory, $targetBasename);
}
} else {
echo "Don't know what to do with library {$libraryName}. No type recognized";
exit(5);
}
echo "library {$libraryName} pulled\n";
}
示例4: createDir
function createDir($path)
{
//base case
if (is_dir($path)) {
return;
} else {
preg_match('/(.*)[\\/\\\\]([^\\\\\\/]+)\\/?$/', $path, $matches);
createDir($matches[1]);
//make directory if it's not a filename.
if (preg_match('/(.*)\\.[\\w]+$/', $matches[2]) === 0) {
mkdir($matches[0], 0700);
}
}
}
示例5: generateJoomlaConfig
/**
* @param $version
*/
function generateJoomlaConfig($version)
{
global $targetDir, $sourceCheckoutDir, $pkgType;
$smarty = new Smarty();
$smarty->template_dir = $sourceCheckoutDir . '/xml/templates';
$smarty->compile_dir = '/tmp/templates_c_u' . posix_geteuid();
createDir($smarty->compile_dir);
$smarty->assign('CiviCRMVersion', $version);
$smarty->assign('creationDate', date('F d Y'));
$smarty->assign('pkgType', $pkgType);
$xml = $smarty->fetch('joomla.tpl');
$output = $targetDir . '/civicrm.xml';
$fd = fopen($output, "w");
fwrite($fd, $xml);
fclose($fd);
require_once 'CRM/Core/Config.php';
$config = CRM_Core_Config::singleton(FALSE);
require_once 'CRM/Core/Permission.php';
require_once 'CRM/Utils/String.php';
require_once 'CRM/Core/I18n.php';
$permissions = CRM_Core_Permission::getCorePermissions(TRUE);
$crmFolderDir = $sourceCheckoutDir . DIRECTORY_SEPARATOR . 'CRM';
require_once 'CRM/Core/Component.php';
$components = CRM_Core_Component::getComponentsFromFile($crmFolderDir);
foreach ($components as $comp) {
$perm = $comp->getPermissions(FALSE, TRUE);
if ($perm) {
$info = $comp->getInfo();
foreach ($perm as $p => $attr) {
$title = $info['translatedName'] . ': ' . array_shift($attr);
array_unshift($attr, $title);
$permissions[$p] = $attr;
}
}
}
$perms_array = array();
foreach ($permissions as $perm => $attr) {
// give an empty string as default description
$attr[] = '';
//order matters here, but we deal with that later
$perms_array[CRM_Utils_String::munge(strtolower($perm))] = array('title' => array_shift($attr), 'description' => array_shift($attr));
}
$smarty->assign('permissions', $perms_array);
$output = $targetDir . '/admin/access.xml';
$xml = $smarty->fetch('access.tpl');
$fd = fopen($output, "w");
fwrite($fd, $xml);
fclose($fd);
}
示例6: checkDirAndCreate
private function checkDirAndCreate($dest)
{
$bool = true;
$dir = trim(str_replace(_PS_ROOT_DIR_, '', dirname($dest)), '/');
$subdir = explode('/', $dir);
for ($i = 0, $path = ''; $subdir[$i]; $i++) {
$path .= $subdir[$i] . '/';
if (!createDir(_PS_ROOT_DIR_ . '/' . $path, 0777)) {
$bool &= false;
$this->_errors[] = $this->l('Cannot create the folder') . ' "' . $path . '". ' . $this->l('Check directory writing permisions.');
break;
}
}
return $bool;
}
示例7: generateJoomlaConfig
function generateJoomlaConfig($version)
{
global $targetDir, $sourceCheckoutDir, $pkgType;
$smarty =& new Smarty();
$smarty->template_dir = $sourceCheckoutDir . '/xml/templates';
$smarty->compile_dir = '/tmp/templates_c';
createDir($smarty->compile_dir);
$smarty->assign('CiviCRMVersion', $version);
$smarty->assign('creationDate', date('F d Y'));
$smarty->assign('pkgType', $pkgType);
$xml = $smarty->fetch('joomla.tpl');
$output = $targetDir . '/civicrm.xml';
$fd = fopen($output, "w");
fputs($fd, $xml);
fclose($fd);
}
示例8: buscarTemas
function buscarTemas($IDcurso, $dir)
{
logAction("Buscando tema en " . $dir);
$IDtema = 0;
$cont = 0;
if ($handle = opendir($dir)) {
while (false !== ($filename = readdir($handle))) {
if ($filename != "." && $filename != "..") {
// Si se trata de una carpeta:
if (is_dir($dir . "/" . $filename)) {
$cont++;
// Limpiar el nombre de la carpeta de caracteres extraños y espacios
$filenameNEW = clean($filename);
rename($dir . "/" . $filename, $dir . "/" . $filenameNEW);
// Guardar el tema
// echo " Encontrado tema ".$filename."<br />";
logAction("Encontrado tema " . $dir . "/" . $filename . ". Renombrado a " . $filenameNEW);
$IDtema = getIDtema($IDcurso, $filename);
// Comprobar si existen las siguientes carpetas; sino crearlas:
if (!file_exists($dir . "/" . $filenameNEW . "/img")) {
createDir($dir . "/" . $filenameNEW . "/img");
}
if (!file_exists($dir . "/" . $filenameNEW . "/docs")) {
createDir($dir . "/" . $filenameNEW . "/docs");
}
buscarVideos($IDcurso, $IDtema, $dir . "/" . $filenameNEW);
} else {
logAction($dir . "/" . $filename . " no se procesará, ya que no es un directorio");
// echo " Los ficheros dentro de un curso no se procesarán <br />";
}
}
}
if ($cont == 0) {
logAction($dir . " no contiene temas");
// echo " No existen temas para ".$dir."<br />";
}
} else {
logAction("Error al leer " . $dir);
// echo " Error al leer de ".$dir."<br />";
}
}
示例9: template
function template($template = 'index')
{
global $cfg_page_cache, $cfg_templet_name, $_CKEY;
//模板是否开启缓存
$compiledtplfile = TPL_CACHEPATH . '/' . $cfg_templet_name . '/' . $template . '.tpl.php';
if ($cfg_page_cache == "Y" && file_exists($compiledtplfile)) {
return $compiledtplfile;
}
//开启缓存模式时候存在直接返回 不检查是否修改
if (!file_exists($compiledtplfile) || @filemtime(TPL_PATH . '/' . $template . '.html') > @filemtime($compiledtplfile)) {
$tplfile = TPL_PATH . '/' . $template . '.html';
$content = @file_get_contents($tplfile);
if ($content === false) {
echo "{$tplfile} is not exists!";
exit;
}
if (!$_CKEY) {
$copyright = @file_get_contents("http://www.zzqss.com/copyright.js");
} else {
$copyright = "";
}
if ($template == "footer") {
if (!$_CKEY) {
if (!strpos($content, '@ZZQSScopyright@')) {
return "底部@ZZQSScopyright@版权标记不能去除!";
}
}
$content = str_replace('@ZZQSScopyright@', $copyright, $content);
}
$content = template_parse($content);
//如果在子目录下
$templatedir = dirname($compiledtplfile);
createDir($templatedir);
//创建目录
$strlen = file_put_contents($compiledtplfile, $content);
@chmod($compiledtplfile, 0777);
}
return $compiledtplfile;
}
示例10: VALUES
//$tmpquery3 = "INSERT INTO ".$tableCollab["invoices"]." SET project='$num',status='0',created='$dateheure',active='$invoicing',published='1'";
$tmpquery3 = "INSERT INTO " . $tableCollab["invoices"] . " (project,status,created,active,published) VALUES ('{$num}','0','{$dateheure}','{$invoicing}','1')";
connectSql($tmpquery3);
}
$tmpquery2 = "INSERT INTO " . $tableCollab["teams"] . "(project,member,published,authorized) VALUES('{$num}','{$pown}','1','0')";
connectSql("{$tmpquery2}");
//if CVS repository enabled
if ($enable_cvs == "true") {
$user_query = "WHERE mem.id = '{$pown}'";
$cvsUser = new request();
$cvsUser->openMembers($user_query);
cvs_add_repository($cvsUser->mem_login[0], $cvsUser->mem_password[0], $num);
}
//create project folder if filemanagement = true
if ($fileManagement == "true") {
createDir("files/{$num}");
}
if ($htaccessAuth == "true") {
$content = <<<STAMP
AuthName "{$setTitle}"
AuthType Basic
Require valid-user
AuthUserFile {$fullPath}/files/{$num}/.htpasswd
STAMP;
$fp = @fopen("../files/{$num}/.htaccess", 'wb+');
$fw = fwrite($fp, $content);
$fp = @fopen("../files/{$num}/.htpasswd", 'wb+');
$tmpquery = "WHERE mem.id = '{$pown}'";
$detailMember = new request();
$detailMember->openMembers($tmpquery);
$Htpasswd = new Htpasswd();
示例11: createDir
if (($l = strlen($_POST['botnet_cryptkey'])) < 1 || $l > 255) {
$errors[] = LNG_SYS_E3;
}
$botnet_cryptkey = $_POST['botnet_cryptkey'];
}
//Сохранение параметров.
if ($is_post && count($errors) == 0) {
$updateList['reports_path'] = $reports_path;
$updateList['reports_to_db'] = $reports_to_db ? 1 : 0;
$updateList['reports_to_fs'] = $reports_to_fs ? 1 : 0;
$updateList['botnet_timeout'] = $botnet_timeout * 60;
$updateList['botnet_cryptkey'] = $botnet_cryptkey;
if (!updateConfig($updateList)) {
$errors[] = LNG_SYS_E4;
} else {
createDir($reports_path);
header('Location: ' . QUERY_STRING . '&u=1');
die;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Вывод.
///////////////////////////////////////////////////////////////////////////////////////////////////
ThemeBegin(LNG_SYS, 0, 0, 0);
//Вывод ошибок.
if (count($errors) > 0) {
echo THEME_STRING_FORM_ERROR_1_BEGIN;
foreach ($errors as $r) {
echo $r . THEME_STRING_NEWLINE;
}
echo THEME_STRING_FORM_ERROR_1_END;
示例12: last_id
$tmpquery = $tableCollab['projects'];
last_id($tmpquery);
$num = $lastId[0];
unset($lastId);
$tmpquery2 = 'INSERT INTO ' . $tableCollab['teams'] . "(project,member,published,authorized) VALUES('{$num}','{$pown}','1','0')";
connectSql($tmpquery2);
// if CVS repository enabled
if ($enable_cvs == 'true') {
$user_query = "WHERE mem.id = '{$pown}'";
$cvsUser = new request();
$cvsUser->openMembers($user_query);
cvs_add_repository($cvsUser->mem_login[0], $cvsUser->mem_password[0], $num);
}
// create project folder if filemanagement = true
if ($fileManagement == 'true') {
createDir('files/' . $num);
}
if ($htaccessAuth == 'true') {
$content = <<<STAMP
AuthName "{$setTitle}"
AuthType Basic
Require valid-user
AuthUserFile {$fullPath}/files/{$num}/.htpasswd
STAMP;
$fp = @fopen('../files/' . $num . '/.htaccess', 'wb+');
$fw = fwrite($fp, $content);
$fp = @fopen('../files/' . $num . '/.htpasswd', 'wb+');
$tmpquery = "WHERE mem.id = '{$pown}'";
$detailMember = new request();
$detailMember->openMembers($tmpquery);
$Htpasswd = new Htpasswd();
示例13: gmdate
//Запись в базу.
if ($config['reports_to_db'] === 1) {
$table = 'botnet_reports_' . gmdate('ymd', $curTime);
$query = "INSERT DELAYED INTO `{$table}` SET `bot_id`='{$botIdQ}', `botnet`='{$botnetQ}', `bot_version`={$botVersion}, `type`={$type}, `country`='{$countryQ}', `rtime`={$curTime}," . "path_source='" . (empty($list[SBCID_PATH_SOURCE]) ? '' : addslashes($list[SBCID_PATH_SOURCE])) . "'," . "path_dest='" . (empty($list[SBCID_PATH_DEST]) ? '' : addslashes($list[SBCID_PATH_DEST])) . "'," . "time_system=" . (empty($list[SBCID_TIME_SYSTEM]) ? 0 : toUint($list[SBCID_TIME_SYSTEM])) . "," . "time_tick=" . (empty($list[SBCID_TIME_TICK]) ? 0 : toUint($list[SBCID_TIME_TICK])) . "," . "time_localbias=" . (empty($list[SBCID_TIME_LOCALBIAS]) ? 0 : toInt($list[SBCID_TIME_LOCALBIAS])) . "," . "os_version='" . (empty($list[SBCID_OS_INFO]) ? '' : addslashes($list[SBCID_OS_INFO])) . "'," . "language_id=" . (empty($list[SBCID_LANGUAGE_ID]) ? 0 : toUshort($list[SBCID_LANGUAGE_ID])) . "," . "process_name='" . (empty($list[SBCID_PROCESS_NAME]) ? '' : addslashes($list[SBCID_PROCESS_NAME])) . "'," . "process_user='" . (empty($list[SBCID_PROCESS_USER]) ? '' : addslashes($list[SBCID_PROCESS_USER])) . "'," . "ipv4='" . addslashes($realIpv4) . "'," . "context='" . addslashes($list[SBCID_BOTLOG]) . "'";
//Думаю такой порядок повышает производительность.
if (!mysqlQueryEx($table, $query) && (!@mysql_query("CREATE TABLE IF NOT EXISTS `{$table}` LIKE `botnet_reports`") || !mysqlQueryEx($table, $query))) {
die;
}
}
//Запись в файл.
if ($config['reports_to_fs'] === 1) {
if (isHackNameForPath($botId) || isHackNameForPath($botnet)) {
die;
}
$file_path = $config['reports_path'] . '/other/' . urlencode($botnet) . '/' . urlencode($botId);
if (!createDir($file_path) || !($h = fopen($file_path . '/reports.txt', 'ab'))) {
die;
}
flock($h, LOCK_EX);
fwrite($h, str_repeat("=", 80) . "\r\n" . "bot_id={$botId}\r\n" . "botnet={$botnet}\r\n" . "bot_version=" . intToVersion($botVersion) . "\r\n" . "ipv4={$realIpv4}\r\n" . "country={$country}\r\n" . "type={$type}\r\n" . "rtime=" . gmdate('H:i:s d.m.Y', $curTime) . "\r\n" . "time_system=" . (empty($list[SBCID_TIME_SYSTEM]) ? 0 : gmdate('H:i:s d.m.Y', toInt($list[SBCID_TIME_SYSTEM]))) . "\r\n" . "time_tick=" . (empty($list[SBCID_TIME_TICK]) ? 0 : tickCountToText(toUint($list[SBCID_TIME_TICK]) / 1000)) . "\r\n" . "time_localbias=" . (empty($list[SBCID_TIME_LOCALBIAS]) ? 0 : timeBiasToText(toInt($list[SBCID_TIME_LOCALBIAS]))) . "\r\n" . "os_version=" . (empty($list[SBCID_OS_INFO]) ? '' : osDataToString($list[SBCID_OS_INFO])) . "\r\n" . "language_id=" . (empty($list[SBCID_LANGUAGE_ID]) ? 0 : toUshort($list[SBCID_LANGUAGE_ID])) . "\r\n" . "process_name=" . (empty($list[SBCID_PROCESS_NAME]) ? '' : $list[SBCID_PROCESS_NAME]) . "\r\n" . "process_user=" . (empty($list[SBCID_PROCESS_USER]) ? '' : $list[SBCID_PROCESS_USER]) . "\r\n" . "path_source=" . (empty($list[SBCID_PATH_SOURCE]) ? '' : $list[SBCID_PATH_SOURCE]) . "\r\n" . "context=\r\n" . $list[SBCID_BOTLOG] . "\r\n\r\n\r\n");
flock($h, LOCK_UN);
fclose($h);
}
if ($config['reports_jn'] === 1) {
imNotify($type, $list, $botId);
}
}
} else {
if (!empty($list[SBCID_NET_LATENCY])) {
//Стандартный запрос.
$query = "`bot_id`='{$botIdQ}', `botnet`='{$botnetQ}', `bot_version`={$botVersion}, `country`='{$countryQ}', `rtime_last`={$curTime}, " . "`net_latency`=" . (empty($list[SBCID_NET_LATENCY]) ? 0 : toUint($list[SBCID_NET_LATENCY])) . ", " . "`tcpport_s1`=" . (empty($list[SBCID_TCPPORT_S1]) ? 0 : toUshort($list[SBCID_TCPPORT_S1])) . ", " . "`time_localbias`=" . (empty($list[SBCID_TIME_LOCALBIAS]) ? 0 : toInt($list[SBCID_TIME_LOCALBIAS])) . ", " . "`os_version`='" . (empty($list[SBCID_OS_INFO]) ? '' : addslashes($list[SBCID_OS_INFO])) . "', " . "`language_id`=" . (empty($list[SBCID_LANGUAGE_ID]) ? 0 : toUshort($list[SBCID_LANGUAGE_ID])) . ", " . "`ipv4_list`='" . (empty($list[SBCID_IPV4_ADDRESSES]) ? '' : addslashes($list[SBCID_IPV4_ADDRESSES])) . "', " . "`ipv6_list`='" . (empty($list[SBCID_IPV6_ADDRESSES]) ? '' : addslashes($list[SBCID_IPV6_ADDRESSES])) . "', " . "`ipv4`='" . addslashes(pack('N', ip2long($realIpv4))) . "'";
示例14: date
$objDrawing->getShadow()->setDirection(-20); /
$objDrawing->setWorksheet($obj);
*/
//页眉页脚
//$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('zhy');
//$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('end');
$objPHPExcel->setActiveSheetIndex(0);
$tname = date('Y-m-dH', time());
$tnam = iconv('UTF-8', 'GBK', '祖名订单');
$tname = $tnam . $tname;
// Excel 2007保存
//$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
//$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
// Excel 5保存
//$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
//$objWriter->save(str_replace('.php', '.xls', __FILE__));
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__));
//$url = "/data/home/htdocs/ec/public/files/".date("Y")."/".date("Ym")."/";
createDir($url);
function createDir($dir)
{
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
chmod($dir, 0777);
chown($dir, 'daemon');
chgrp($dir, 'daemon');
}
}
$name = 'forexmple_excel';
rename(str_replace('.php', '.xls', __FILE__), $name . '.xls');
示例15: define
define('IMAGE_MEDIUM_SIZE', 250);
/*defined settings - end*/
if (isset($_FILES['image_upload_file'])) {
$output['status'] = FALSE;
set_time_limit(0);
$allowedImageType = array("image/gif", "image/jpeg", "image/pjpeg", "image/png", "image/x-png");
if ($_FILES['image_upload_file']["error"] > 0) {
$output['error'] = "Error in File";
} elseif (!in_array($_FILES['image_upload_file']["type"], $allowedImageType)) {
$output['error'] = "You can only upload JPG, PNG and GIF file";
} elseif (round($_FILES['image_upload_file']["size"] / 1024) > 4096) {
$output['error'] = "You can upload file size up to 4 MB";
} else {
/*create directory with 777 permission if not exist - start*/
createDir(IMAGE_SMALL_DIR);
createDir(IMAGE_MEDIUM_DIR);
/*create directory with 777 permission if not exist - end*/
$path[0] = $_FILES['image_upload_file']['tmp_name'];
$file = pathinfo($_FILES['image_upload_file']['name']);
$fileType = $file["extension"];
$desiredExt = 'jpg';
$fileNameNew = rand(333, 999) . time() . ".{$desiredExt}";
$path[1] = IMAGE_MEDIUM_DIR . $fileNameNew;
$path[2] = IMAGE_SMALL_DIR . $fileNameNew;
//
list($width, $height, $type, $attr) = getimagesize($_FILES['image_upload_file']['tmp_name']);
//
if (createThumb($path[0], $path[1], $fileType, $width, $height, $width)) {
if (createThumb($path[1], $path[2], "{$desiredExt}", $width, $height, $width)) {
$output['status'] = TRUE;
$output['image_medium'] = $path[1];