function deleteall($dename) { if (!$dename == "") { $udename = $dename; $dename = iconv("UTF-8", "GBK", $dename); if (is_dir($dename)) { if (is_empty_dir($dename)) { rmdir($dename); echo "<span>" . $udename . " 已经被删除</span><br>"; } else { deltree($dename); rmdir($dename); echo "<span>" . $udename . " 已经被删除</span><br>"; } } else { if (@unlink($dename)) { echo '<span>' . $udename . " 已经被删除</span><br>"; } else { echo "<span class='error'>无法删除文件:{$udename} ,可能是文件不存在!</span><br>"; } } } }
function upload1() { // Config.php is the main configuration file. include '../config.php'; // Language file. include "../lang/{$language}"; // Name of page for links, title, and logout. $logout = "admin_Flyers.php"; $page_name = "upload"; // Include header if "on" in config.php. if ($head == "on") { include "header.php"; } // Upload file form. echo "<script type=\"text/javascript\">\nfunction showIcon() {\nwindow.setTimeout('showProgress()', 0);\n}\nfunction showProgress() {\ndocument.getElementById('progressImg').style.display = 'inline';\n}\n</script>\n<table class=\"upload\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n<tr>\n<td colspan=\"6\">\n<form action=\"admin_Flyers.php\" method=\"post\" enctype=\"multipart/form-data\">\n<div id =\"upload_popup\">\n<input type=\"hidden\" name=\"cmd\" value=\"upload2\" /> <input type=\"file\" name=\"ftp_file\" />\n<br /><br />\n<input type=\"submit\" name=\"submit\" onclick=\"showIcon();\" value=\"{$l_upload1}\" />\n</div>\n<div class=\"progress\" id=\"progressImg\"> \n<img src=\"../{$datadir}/progress.gif\" alt=\"{$l_upload21}\" />\n</div>\n</form>\n</td>\n</tr>"; // Hide file listing from logged in users. if ($hide == "on") { echo "</table>"; } else { echo "<tr>"; // <td> colspan for rename/delete on/off. if ($rename_file == "off" && $delete_file == "off") { echo "<td colspan=\"4\">"; } elseif ($rename_file == "off") { echo "<td colspan=\"5\">"; } elseif ($delete_file == "off") { echo "<td colspan=\"5\">"; } else { echo "<td colspan=\"6\">"; } echo "\n<hr />\n{$p}\n<b>{$l_upload2}</b>\n{$p2}\n<hr />\n</td>\n</tr>\n</table>\n<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" id=\"upload-point\" class=\"tablesorter\">\n<thead>\n<tr>\n<th class=\"uploadlistname\"><b>{$l_upload3}</b></th>\n<th class=\"uploadlistsize\"><b>{$l_upload4}</b></th>\n<th class=\"uploadlistmod\"><b>{$l_upload5}</b></th>"; // Rename file on/off. if ($rename_file == "on") { echo "\n<th class=\"uploadlistrename\"><b>{$l_upload6}</b></th>"; } else { } // Delete file on/off. if ($delete_file == "on") { echo "\n<th class=\"uploadlistdelete\"><b>{$l_upload7}</b></th>"; } else { } echo "<th class=\"uploadlistloc\"><b>{$l_upload8}</b></th>\n</tr>\n</thead>\n<tfoot>\n<tr>\n<th class=\"uploadlistname\"><b>{$l_upload3}</b></th>\n<th class=\"uploadlistsize\"><b>{$l_upload4}</b></th>\n<th class=\"uploadlistmod\"><b>{$l_upload5}</b></th>"; // Rename file on/off. if ($rename_file == "on") { echo "\n<th class=\"uploadlistrename\"><b>{$l_upload6}</b></th>"; } else { } // Delete file on/off. if ($delete_file == "on") { echo "\n<th class=\"uploadlistdelete\"><b>{$l_upload7}</b></th>"; } else { } echo "<th class=\"uploadlistloc\"><b>{$l_upload8}</b></th>\n</tr>\n</tfoot>\n<tbody>"; } // Path from Upload-Point directory to upload directory $upload_dir = $_SERVER['DOCUMENT_ROOT'] . "/{$fileupload_Flyers_dir_name}"; // Create upload directory if it doesn't exist. if (!is_dir($upload_dir)) { if (!mkdir($upload_dir)) { die("{$l_upload11}"); } if (!chmod($upload_dir, 0755)) { die("{$l_upload12}"); } } // File listing code. if ($hide == "on") { } else { if (is_empty_dir($upload_dir) == true) { echo "</table>"; } elseif (is_empty_dir($upload_dir) == false) { // List files in the upload directory. $dir_handle = opendir($upload_dir); if ($dir_handle) { while (false !== ($file = readdir($dir_handle))) { $upload_files = "{$upload_dir}/{$file}"; if (is_file($upload_files) && ($file != ".htaccess" && $file != $up_ignore1 && $file != $up_ignore2 && $file != $up_ignore3 && $file != $up_ignore4 && $file != $up_ignore5)) { $upload_name_sort[] = $file; } } sort($upload_name_sort); foreach ($upload_name_sort as $file) { echo "\n<tr>\n<td class=\"uploadlistname\">{$file}</td>\n<td class=\"uploadlistsize\">" . upload_file_size("{$upload_dir}/{$file}") . "</td>\n<td class=\"uploadlistmod\">" . date("m(M) d Y - H:i:s", filemtime("{$upload_dir}/{$file}")) . "</td>"; // Rename file on/off. if ($rename_file == "on") { echo "\n<td class=\"uploadlistrename\">\n<form action=\"admin_Flyers.php\" method=\"post\">\n{$p}\n<input type=\"hidden\" name=\"file\" value=\"{$file}\" />\n<input type=\"hidden\" name=\"pg\" value=\"{$pg}\" />\n<input type=\"hidden\" name=\"cmd\" value=\"upload_rename\" />\n<input type=\"text\" name=\"upload_newname\" value=\"{$file}\" />\n<input name=\"submit\" type=\"submit\" value=\"{$l_upload6}\" />\n{$p2}\n</form>\n</td>"; } else { } // Delete file on/off. if ($delete_file == "on") { echo "\n<td class=\"uploadlistdelete\">\n<form action=\"admin_Flyers.php\" method=\"post\">\n{$p}\n<input type=\"hidden\" name=\"file\" value=\"{$file}\" />\n<input type=\"hidden\" name=\"pg\" value=\"{$pg}\" />\n<input type=\"hidden\" name=\"cmd\" value=\"upload_delete\" />\n<input name=\"submit\" type=\"submit\" value=\"{$l_upload7}\" />\n{$p2}\n</form>\n</td>"; } else { } echo "\n<td class=\"uploadlistloc\"><a href=\"http://" . $_SERVER['HTTP_HOST'] . "/{$fileupload_Flyers_dir_name}/{$file}\"><i>http://" . $_SERVER['HTTP_HOST'] . "/{$fileupload_Flyers_dir_name}/{$file}</i></a></td>\n</tr>"; } } closedir($dir_handle); echo "\n</tbody>\n</table>\n"; } } // Include footer if "on" in config.php. if ($head == "on") { include "footer.php"; } }
function upload1() { // Config.php is the main configuration file. include 'config.php'; // Language file. include "lang/{$language}"; // Name of page for links, title, and logout. $logout = "DoorHangers.php"; $page_name = "upload"; // Include header if "on" in config.php. if ($head == "on") { include "header.php"; } // Upload file form. echo "<script type=\"text/javascript\">\nfunction showIcon() {\nwindow.setTimeout('showProgress()', 0);\n}\nfunction showProgress() {\ndocument.getElementById('progressImg').style.display = 'inline';\n}\n</script>\n{$p}\n{$UploadDoorHangersPageTitle}\n{$p2}\n<table class=\"upload\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n<tr>\n<td colspan=\"6\">\n<form action=\"DoorHangers.php\" method=\"post\" enctype=\"multipart/form-data\">\n<div id =\"upload_popup\">\n<input type=\"hidden\" name=\"cmd\" value=\"upload2\" /> <input type=\"file\" name=\"ftp_file\" />\n<br /><br />\n<input type=\"submit\" name=\"submit\" onclick=\"showIcon();\" value=\"{$l_upload1}\" />\n</div>\n<div class=\"progress\" id=\"progressImg\"> \n<img src=\"{$datadir}/progress.gif\" alt=\"{$l_upload21}\" />\n</div>\n</form>\n</td>\n</tr>"; // Hide file listing from logged in users. if ($hide == "on") { echo "</table>"; } else { echo "<tr>"; // <td> colspan for rename/delete on/off. if ($rename_file == "off" && $delete_file == "off") { echo "<td colspan=\"4\">"; } elseif ($rename_file == "off") { echo "<td colspan=\"5\">"; } elseif ($delete_file == "off") { echo "<td colspan=\"5\">"; } else { echo "<td colspan=\"6\">"; } echo "\n<hr />\n{$p}\n{$Footer}\n{$p2}\n<hr />\n</td>\n</tr>\n</table>\n<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" id=\"upload-point\" class=\"tablesorter\">\n<tbody>"; } // Create upload directory if it doesn't exist. if (!is_dir($upload_dir)) { } // File listing code. if ($hide == "on") { } else { if (is_empty_dir($upload_dir) == true) { echo "</table>"; } elseif (is_empty_dir($upload_dir) == false) { // Delete file on/off. if ($delete_file == "on") { echo "\n<td class=\"uploadlistdelete\">\n<form action=\"DoorHangers.php\" method=\"post\">\n{$p}\n<input type=\"hidden\" name=\"file\" value=\"{$file}\" />\n<input type=\"hidden\" name=\"pg\" value=\"{$pg}\" />\n<input type=\"hidden\" name=\"cmd\" value=\"upload_delete\" />\n<input name=\"submit\" type=\"submit\" value=\"{$l_upload7}\" />\n{$p2}\n</form>\n</td>"; } else { } echo "\n<td class=\"uploadlistloc\"><a href=\"http://" . $_SERVER['HTTP_HOST'] . "/{$fileupload_DoorHangers_dir_name}/{$file}\"><i>http://" . $_SERVER['HTTP_HOST'] . "/{$fileupload_DoorHangers_dir_name}/{$file}</i></a></td>\n</tr>"; } } "\n</tbody>\n</table>\n"; }
function deltree($pathdir) { $d = dir($pathdir); while ($a = $d->read()) { if (is_file($pathdir . '/' . $a) && $a != '.' && $a != '..') { unlink($pathdir . '/' . $a); } //如果是文件就直接删除 if (is_dir($pathdir . '/' . $a) && $a != '.' && $a != '..') { //如果是目录 if (!is_empty_dir($pathdir . '/' . $a)) { //如果不是,调用自身,不过是原来的路径+他下级的目录名 deltree($pathdir . '/' . $a); } if (is_empty_dir($pathdir . '/' . $a)) { //如果是空就直接删除 rmdir($pathdir . '/' . $a); } } } $d->close(); }
* Date: 14-10-11 * Time: 下午3:38 */ ini_set('max_execution_time', 864000); // 1.1 设置每个文件的最大行数 $fileLines = 1001; $ipDataFile = 'ip.data'; $ipDir = 'ip_dir2'; if (!is_dir($ipDir)) { if (!mkdir($ipDir, 0777)) { die('Permission deny! no right to mkdir ip_dir.'); } else { chmod($ipDir, 0777); } } if (!is_empty_dir($ipDir)) { die('Error: There are some files in dir - ' . $ipDir); } // 2.1 计算行数 $res = exec("wc -l {$ipDataFile}"); $arrInfo = array_filter(explode(" ", $res)); list($totalNum, $fileName) = array_values($arrInfo); $ipHandle = fopen($ipDataFile, 'r'); $lineNum = 0; $lastLineStr = ''; while ($lineStr = fgets($ipHandle)) { ++$lineNum; $fname = $ipDir . "/data." . intval($lineNum / $fileLines) . '.ip'; if ($lineStr === false) { print 'false.'; } else {
function ListFolder($rootFolder, $folderPrefix, $animatedfolderprefix, $supported_files, $unwantedFolder, $original_file_folder, $displayModuleName, $ReturnAttr, $empty_file_tag) { $fileModified = ""; $fileSize = ""; $modified = ""; if (!isset($xmlTreeFile)) { $xmlTreeFile = ''; } if (!isset($xmlTreeFolder)) { $xmlTreeFolder = ''; } if (!isset($Return)) { $Return = ''; } $dir_handle = @opendir($rootFolder) or die("Unable to open" . $rooFolder); //Open the root directory $dirname = end(explode("/", $rootFolder)); while (false !== ($file = readdir($dir_handle))) { //Read the root directory if ($file != "." && $file != ".." && $file != $unwantedFolder && $file != $original_file_folder) { if (is_dir($rootFolder . "/" . $file)) { //Check whether the file is a directory or not $tempPath = $rootFolder . "/" . $file; if (file_exists($file)) { $modified = date("F d Y H:i:s.", filemtime($file)); dirSize($file); } $checkFolder = substr($file, 0, 6); if ($checkFolder == $folderPrefix || $checkFolder == $animatedfolderprefix) { $emptyFolderCheckFlag = is_empty_dir($rootFolder . "/" . $file, $displayModuleName); if ($emptyFolderCheckFlag) { $ConversionStatus = check_conversion_status($rootFolder . "/Log" . substr($file, 6, strlen($file)) . ".txt"); // $ConversionStatus ='Test'; $xmlTreeFile .= "<files label='" . substr($file, 6, strlen($file)) . "' path='" . $tempPath . "' cDate='" . $modified . "' status='" . $ConversionStatus . "' fSize='" . $fileSize . "'></files>"; } else { $xmlTreeFile .= "<files label='" . substr($file, 6, strlen($file)) . "' path='" . $tempPath . "' cDate='" . $modified . "' status='conversion is completed' fSize='" . $fileSize . "'></files>"; } //echo "<pre>".htmlentities($xmlTreeFile)."</pre>"; $emptyFolderCheckFlag = false; //return; } else { $xmlTreeFolder .= "<folder label='" . $file . "' path='" . $tempPath . "' status='conversion is complet' cDate='" . $modified . "' fSize='" . $fileSize . "'>"; $emptyFolderCheckFlag = is_empty_dir($rootFolder . "/" . $file, $displayModuleName); if ($emptyFolderCheckFlag) { $xmlTreeFolder .= getEmptyFileTag($empty_file_tag); } $xmlTreeFolder .= ListFolder($rootFolder . "/" . $file, $folderPrefix, $animatedfolderprefix, $supported_files, $unwantedFolder, $original_file_folder, $displayModuleName, $Return, $empty_file_tag); $xmlTreeFolder .= "</folder>"; } } else { $newFile = $file; $fPath = $rootFolder . "/" . $file; if (file_exists($newFile)) { $fileModified = date("F d Y H:i:s.", filemtime($newFile)); $fileSize = filesize($newFile); } $path_info = pathinfo($file); $fileExtension = $path_info['extension']; // get file extension $file = substr($file, 0, -4); for ($i = 0; $i < count($supported_files); $i++) { if ($fileExtension == $supported_files[$i]) { $xmlTreeFile .= "<files label='" . $file . "' path='" . $fPath . "' cDate='" . $fileModified . "' fSize='" . $fileSize . "'></files>"; } } } } } $Return = $xmlTreeFolder . $xmlTreeFile; closedir($dir_handle); return $Return; }
#!/usr/bin/php <?php // Load shared functions. require_once dirname(__FILE__) . '/shared.php'; $config_template = realpath($argv[1]); $repository_root = realpath($argv[2]); $source_dir = $argv[3]; $absolute_source_dir = $repository_root . '/' . $source_dir; $elements = explode('/', $source_dir); $project = array_pop($elements); $destination_dir = $argv[4]; // If the source_dir is an empty directory, skip it; cvs2git barfs on these. if (is_empty_dir($absolute_source_dir)) { git_log("Skipping empty source directory '{$absolute_source_dir}'."); exit; } if (!is_cvs_dir($absolute_source_dir)) { git_log("Skipping non CVS source directory '{$absolute_source_dir}'."); exit; } // If the target destination dir exists already, remove it. if (file_exists($destination_dir) && is_dir($destination_dir)) { passthru('rm -Rf ' . escapeshellarg($destination_dir)); } // Create the destination directory. $ret = 0; passthru('mkdir -p ' . escapeshellarg($destination_dir), $ret); if (!empty($ret)) { git_log("Failed to create output directory at {$destination_dir}, project import will not procede.", 'WARN', $project); exit; }
function ListFolder($rootFolder, $ReturnAttr, $instituteArr, $courseArr, $classArr, $moderatorArr) { $folderArr = ""; $folderArrCnt = ""; $dir_handle = ""; $dirname = ""; $parentFolder = ""; $fPath = ""; $Return = ""; $xmlTreeFile = isset($xmlTreeFile) ? $xmlTreeFile : ''; $xmlTreeFolder = isset($xmlTreeFolder) ? $xmlTreeFolder : ''; //echo $rootFolder; exit; $dir_handle = @opendir($rootFolder) or die(returnXML("Unable to open the directory")); //Open the root directory $dirname = end(explode("/", $rootFolder)); while (false !== ($file = readdir($dir_handle))) { //Read the root directory $fileLabel = ""; $fileSize = ""; $modified = ""; $isModerator = "N"; // default value set for is_moderator to N (means not a moderator) $showFolder = true; $icon = ""; $unfold = 0; $tempPath = $rootFolder . "/" . $file; $folderArr = explode("/", $tempPath); $folderArrCnt = count($folderArr); $parentFolder = trim($folderArr[$folderArrCnt - 2]); if ($parentFolder == "institutes") { $fileLabel = isset($instituteArr[$file]) ? $instituteArr[$file] : "Doc {$file}"; if (!array_key_exists($file, $instituteArr)) { $showFolder = false; } } else { if ($parentFolder == "courses") { $fileLabel = isset($courseArr[$file]) ? $courseArr[$file] : "Course {$file}"; if (!array_key_exists($file, $courseArr)) { $showFolder = false; } } else { if ($parentFolder == "classes") { $fileLabel = isset($classArr[$file]) ? $classArr[$file] : "Class {$file}"; if (!array_key_exists($file, $classArr)) { $showFolder = false; } } else { $fileLabel = $file; } } } if ($file != "." && $file != ".." && $showFolder && $file != '@@-Thumbnails-@@' && $file != '@@-OriginalDocs-@@') { if (is_dir($rootFolder . "/" . $file)) { //Check whether the file is a directory or not $checkFolder = substr($file, 0, 6); $modified = date("F d Y H:i:s.", @filemtime($tempPath)); //$fileSize = convertSize(getFileSize($tempPath)); // get file size in KB or B $isModerator = isset($moderatorArr[$file]) ? $moderatorArr[$file] : $isModerator; if ($file != "courses" && $file != "classes") { if ($checkFolder == '_sfp__') { $xmlTreeFile .= "<files id='" . $file . "'label='" . substr($file, 6, strlen($file)) . "' path='" . $tempPath . "' cDate='" . $modified . "' fSize='" . $fileSize . "' type='file'></files>"; $emptyFolderCheckFlag = false; } else { $xmlTreeFolder .= "<folder id='" . $file . "' label='" . $fileLabel . "' path='" . $tempPath . "' cDate='" . $modified . "' fSize='" . $fileSize . "' is_moderator='" . $isModerator . "' type='" . $parentFolder . "'>"; $emptyFolderCheckFlag = is_empty_dir($tempPath); } } if ($emptyFolderCheckFlag) { $xmlTreeFolder .= "<emptyFolder label=\" - No documents - \" path='" . $tempPath . "' type='No Documents'></emptyFolder>"; } else { if ($checkFolder != '_sfp__') { $rootFolder = substr($rootFolder, -1, 1) == "/" ? substr($rootFolder, 0, -1) : $rootFolder; //exit; $xmlTreeFolder .= ListFolder($rootFolder . "/" . $file, $Return, $instituteArr, $courseArr, $classArr, $moderatorArr); } } if ($file != "courses" && $file != "classes" && $checkFolder != '_sfp__') { $xmlTreeFolder .= "</folder>"; } } else { //$fileSize = convertSize(getFileSize($tempPath)); // get file size in KB or B $file = str_replace('.swf', '', $file); $modified = date("F d Y H:i:s.", @filemtime($tempPath)); $xmlTreeFile .= "<files label='" . $file . "' path='" . $tempPath . "' cDate='" . $modified . "' fSize='" . $fileSize . "' type='file'></files>"; } } } $Return = $xmlTreeFolder . $xmlTreeFile; closedir($dir_handle); return $Return; }
function db_delete_pic_local($pic_id, $db_query) { global $DIR_HOME, $DIR_TH, $DIR_IMAGE; $stmt = "SELECT image_local_path, th_local_path FROM pics_local WHERE pic_id={$pic_id}"; $rs = executeQuery(Bnumber(), $db_query, $stmt); $row = mysql_fetch_row($rs); $image_local_path = $row[0]; $th_local_path = $row[1]; // DELETE THUMBNAIL /* print "\n"; print "0_$image_local_path\n"; print "1_" . DIR_IMAGES . $image_local_path . "\n"; print "2_" . DIR_IMAGES . dirname($image_local_path) . "\n"; print "3_$th_local_path\n"; print "4_" . DIR_THUMBS . $th_local_path . "\n"; print "5_" . DIR_THUMBS . dirname($th_local_path) . "\n"; */ if ($th_local_path != "" && is_file(DIR_THUMBS . $th_local_path)) { if (unlink(DIR_THUMBS . $th_local_path) === FALSE) { BUG("044", "unlink"); } if (is_empty_dir(DIR_THUMBS . dirname($th_local_path))) { if (rmdir(DIR_THUMBS . dirname($th_local_path)) === FALSE) { BUG("020", "rmdir"); } } } // DELETE IMAGE if ($image_local_path != "" && is_file(DIR_IMAGES . $image_local_path)) { if (unlink(DIR_IMAGES . $image_local_path) === FALSE) { BUG("045", "unlink"); } if (is_empty_dir(DIR_IMAGES . dirname($image_local_path))) { if (rmdir(DIR_IMAGES . dirname($image_local_path)) === FALSE) { BUG("021", "rmdir"); } } } $stmt = "DELETE FROM pics_local WHERE pic_id={$pic_id}"; executeNonQuery(Bnumber(), $db_query, $stmt); return TRUE; }
function deleteall($dename) { if (!$dename == "") { $udename = $dename; $dename = iconv("UTF-8", "GBK", $dename); if (is_dir($dename)) { if (is_empty_dir($dename)) { rmdir($dename); echo "<span>" . $udename . " have been deleted</span><br>"; } else { deltree($dename); rmdir($dename); echo "<span>" . $udename . " have been deleted</span><br>"; } } else { if (@unlink($dename)) { echo '<span>' . $udename . " have been deleted</span><br>"; } else { echo "<span class='error'>Unable to delete " . $udename . "!</span><br>"; } } } }