function doUpload(&$drive_service, &$client, &$file, &$parentFolderID, &$configObj) { //Chunk size is in bytes //Currently, resumable upload uses chunks of 1000 bytes $chunk_size = 1000; //doUpload with exponential backoff, five tries for ($n = 0; $n < 5; ++$n) { try { //Choose between media and resumable depending on file size if ($file->size > $chunk_size) { insertFileResumable($drive_service, &$client, getFileName($file->path), "", $parentFolderID, $file->type, $file->path, $configObj); } else { insertFileMedia($drive_service, getFileName($file->path), "", $parentFolderID, $file->type, $file->path, $configObj); } //If upload succeeded, return null return; } catch (Google_Exception $e) { if ($e->getCode() == 403 || $e->getCode() == 503) { $logline = date('Y-m-d H:i:s') . " Error: " . $e->getMessage() . "\n"; $logline = $logline . date('Y-m-d H:i:s') . "Retrying... \n"; fwrite($configObj->logFile, $logline); // Apply exponential backoff. usleep((1 << $n) * 1000000 + rand(0, 1000000)); } } catch (Exception $e) { $logline = date('Y-m-d H:i:s') . ": Unable to upload file.\n"; $logline = $logline . "Reason: " . $e->getCode() . " : " . $e->getMessage() . "\n"; fwrite($configObj->logFile, $logline); //If upload failed because of unrecognized error, return the file return $file; } } //If upload failed, return the file return $file; }
function initialize_page() { $post_action = ""; if (isset($_POST['submit'])) { $post_action = $_POST['submit']; } if ($post_action == "Add Document" || $post_action == "Add and Return to List") { $name = $_POST['name']; $file_type = getFileExtension($_FILES['file']['name']); $filename = slug(getFileName($_FILES['file']['name'])); $filename_string = $filename . "." . $file_type; // Check to make sure there isn't already a file with that name $possibledoc = Documents::FindByFilename($filename_string); if (is_object($possibledoc)) { setFlash("<h3>Failure: Document filename already exists!</h3>"); redirect("admin/add_document"); } $target_path = SERVER_DOCUMENTS_ROOT . $filename_string; if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { $new_doc = MyActiveRecord::Create('Documents', array('name' => $name, 'filename' => $filename_string, 'file_type' => $file_type)); $new_doc->save(); if (!chmod($target_path, 0644)) { setFlash("<h3>Warning: Document Permissions not set; this file may not display properly</h3>"); } setFlash("<h3>Document uploaded</h3>"); } else { setFlash("<h3>Failure: Document could not be uploaded</h3>"); } if ($post_action == "Add and Return to List") { redirect("admin/list_documents"); } } }
public static function upload(UploadedFile $file, $uploadPath = null) { if (is_null($uploadPath)) { $uploadPath = public_path() . '/uploads/'; } $fileName = str_slug(getFileName($file->getClientOriginalName())) . '.' . $file->getClientOriginalExtension(); //Make file name unique so it doesn't overwrite any old photos while (file_exists($uploadPath . $fileName)) { $fileName = str_slug(getFileName($file->getClientOriginalName())) . '-' . str_random(5) . '.' . $file->getClientOriginalExtension(); } $file->move($uploadPath, $fileName); return ['filename' => $fileName, 'fullpath' => $uploadPath . $fileName]; }
function loadClass($className) { global $CONFIG; if (0 == strpos($className, 'Twig')) { $file = $CONFIG['CENTRAL_PATH'] . 'vendor/Twig/lib/' . str_replace(array('_', ""), array('/', ''), $className) . '.php'; if (is_file($file)) { require $file; return; } } $fileName = getFileName($className); require getFullPath($fileName); }
function move($path, $filename, $newname = null) { $allowed = array('jpg', 'jpeg', 'pdf', 'png', 'xls', 'xlsx', 'zip'); if (file_exists($_FILES[$filename]['tmp_name'])) { if (in_array(getFileExtension(getFileName($filename)), $allowed) && $_FILES[$filename]['error'] == 0) { $uploadname = isset($newname) ? $newname : getFileName($filename); try { move_uploaded_file($_FILES[$filename]['tmp_name'], $path . $uploadname); } catch (Exception $e) { echo "Error Occurred Uploading File: " . $e->getMessage(); } } } else { throw new Exception('FILE NOT FOUND'); } }
function form($name = '', $desc = '', $screen = -1, $idn = 0) { ?> <script type="text/javascript" src="admin/files.js"> </script> <form action="<?php echo htmlentities($_SERVER['REQUEST_URI']); ?> " method="post" id="form"> <label for="shot_name">Name:</label> <input type="text" maxlength="100" size=70 name="shot_name" id="shot_name"<?php echo !empty($name) ? " value=\"{$name}\"" : ''; ?> /><br /> <label for="shot_desc">Description:</label> <input type="text" maxlength="255" size=100 name="shot_desc" id="shot_desc"<?php echo !empty($desc) ? " value=\"{$desc}\"" : ''; ?> /><br /> <label for="shot_screen_disp">Screenshot:</label> <input type="text" name="shot_screen_disp" readonly=true size=60 id="shot_screen_disp" value="<?php echo htmlentities(stripslashes(getFileName($screen))); ?> " /> <input type="hidden" name="shot_screen" id="shot_screen" value="<?php echo getFileID($screen); ?> " /><br /> <input type="button" onclick="javascript:switchVisibility('shot_screen',-1)" value='Pick a file' /><br /> <div id="shot_screen_div" style="display: none;"> <iframe src="" id="shot_screen_frame" width=600 ></iframe> </div><br /> <?php if ($idn != 0) { ?> <input type="hidden" name="id" value="<?php echo $idn; ?> " /> <?php } ?> <input type="submit" /> </form> <?php }
function devtips_extract(DevTip $tip) { global $updates_dir; $assetPath = getFileName($tip->get('date'), $tip->get('title')); $assetPath = str_replace(".markdown", "", $assetPath); # create new asset directory based on new filename if (!file_exists($updates_dir . 'images/' . $assetPath)) { mkdir($updates_dir . 'images/' . $assetPath); chmod($updates_dir . 'images/' . $assetPath, 0777); } # Download and store each asset $assets = $tip->get('assets'); $featured = null; foreach ($assets as $key => $url) { if (strpos($url, "/sponsor/") !== false) { continue; } $base = new Net_URL2('https://umaar.com/dev-tips/'); $abs = $base->resolve($url); $dest = $updates_dir . 'images/' . $assetPath . '/' . pathinfo($url)['basename']; $content = $tip->get('content'); $tip->set('content', str_replace($url, '/web/updates/images/' . $assetPath . '/' . pathinfo($url)['basename'], $content)); if (!$featured) { $tip->set('featured-image', '/web/updates/images/' . $assetPath . '/' . pathinfo($url)['basename']); } if (!file_exists($dest)) { set_time_limit(0); $fp = fopen($dest, 'w+'); //This is the file where we save the information $ch = curl_init(str_replace(" ", "%20", $abs)); //Here is the file we are downloading, replace spaces with %20 curl_setopt($ch, CURLOPT_TIMEOUT, 50); curl_setopt($ch, CURLOPT_FILE, $fp); // write curl response to file curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_exec($ch); // get curl response curl_close($ch); fclose($fp); // set proper chmod chmod($dest, 0777); } } }
function form($name = '', $desc = '', $author = '', $version = '', $platform = '', $requires = '', $screen = -1, $file = -1, $idn = -1) { ?> <script type="text/javascript" src="admin/files.js"> </script> <form action="<?php echo htmlentities($_SERVER['REQUEST_URI']); ?> " method="post" id="form"> <label for="plugin_name">Name:</label> <input type="text" maxlength="100" size=70 name="plugin_name" id="plugin_name"<?php echo !empty($name) ? " value=\"{$name}\"" : ''; ?> /><br /> <label for="plugin_desc">Description:</label> <input type="text" maxlength="255" size=100 name="plugin_desc" id="plugin_desc"<?php echo !empty($desc) ? " value=\"{$desc}\"" : ''; ?> /><br /> <label for="plugin_author">Author:</label> <input type="text" maxlength="100" name="plugin_author" id="plugin_author"<?php echo !empty($author) ? " value=\"{$author}\"" : ''; ?> /><br /> <label for="plugin_version">Version:</label> <input type="text" maxlength="20" name="plugin_version" id="plugin_version"<?php echo !empty($version) ? " value=\"{$version}\"" : ''; ?> /><br /> <label for="plugin_platform">Platform/OS:</label> <input type="text" maxlength="50" name="plugin_platform" id="plugin_platform"<?php echo !empty($platform) ? " value=\"{$platform}\"" : ''; ?> /><br /> <label for="plugin_requires">Requires:</label> <input type="text" maxlength="50" name="plugin_requires" id="plugin_requires"<?php echo !empty($requires) ? " value=\"{$requires}\"" : ''; ?> /><br /> <label for="plugin_screen_disp">Screenshot:</label> <input type="text" name="plugin_screen_disp" readonly=true size=60 id="plugin_screen_disp" value="<?php echo htmlentities(stripslashes(getFileName($screen))); ?> " /> <input type="hidden" name="plugin_screen" id="plugin_screen" value="<?php echo getFileID($screen); ?> " /><br /> <input type="button" onclick="javascript:switchVisibility('plugin_screen',-1)" value='Pick a file' /><br /> <div id="plugin_screen_div" style="display: none;"> <iframe src="" id="plugin_screen_frame" width=600 ></iframe> </div><br /> <label for="plugin_file_disp">File:</label> <input type="text" name="plugin_file_disp" readonly=true size=60 id="plugin_file_disp" value="<?php echo htmlentities(stripslashes(getFileName($file))); ?> " /> <input type="hidden" name="plugin_file" id="plugin_file" value="<?php echo getFileID($file); ?> " /><br /> <input type="button" onclick="javascript:switchVisibility('plugin_file',-1)" value='Pick a file' /><br /> <div id="plugin_file_div" style="display: none;"> <iframe src="" id="plugin_file_frame" width=600 ></iframe> </div><br /> <?php if ($idn != 0) { ?> <input type="hidden" name="id" value="<?php echo $idn; ?> " /> <?php } ?> <input type="submit" /> </form> <?php }
} } } } $zskkey = false; $kskkey = false; foreach ($zone['sec'] as $sec) { $dir = "/srv/bind/dnssec/" . $zone['soa']['origin'] . "/"; if (!file_exists($dir)) { shell_exec("mkdir -p " . $dir); } if ($sec['type'] == "ZSK" || $sec['type'] == "KSK") { if (!empty($sec['public']) && !empty($sec['private'])) { preg_match("/; This is a (key|zone)-signing key, keyid ([0-9]+), for " . $zone['soa']['origin'] . "/i", $sec['public'], $match); $filename1 = getFileName($zone['soa']['origin'], $sec['algo'], $match[2], "pub"); $filename2 = getFileName($zone['soa']['origin'], $sec['algo'], $match[2], "priv"); if (file_exists($dir . $filename1)) { unlink($dir . $filename1); } if (file_exists($dir . $filename2)) { unlink($dir . $filename2); } $handler = fOpen($dir . $filename1, "a+"); fWrite($handler, $sec['public']); fClose($handler); $handler = fOpen($dir . $filename2, "a+"); fWrite($handler, $sec['private']); fClose($handler); if (file_exists($dir . $filename1) && file_exists($dir . $filename2)) { /* fallback for missing DNSKEY record */ if ($zsk === false || $ksk === false) {
/** * Clone a page * Automatically names page id to next incremental copy eg. "slug-n" * Clone title becomes "title [copy]"" * * @param str $id page id to clone * @return mixed returns new url on succcess, bool false on failure */ function clone_page($id) { list($cloneurl, $count) = getNextFileName(GSDATAPAGESPATH, $id . '.xml'); // get page and resave with new slug and title $newxml = getPageXML($id); $newurl = getFileName($cloneurl); $newxml->url = getFileName($cloneurl); $newxml->title = $newxml->title . ' [' . sprintf(i18n_r('COPY_N', i18n_r('COPY')), $count) . ']'; $newxml->pubDate = date('r'); $status = XMLsave($newxml, GSDATAPAGESPATH . $cloneurl); if ($status) { return $newurl; } return false; }
</table></p> <?php } elseif ($_GET['action'] == 'clean') { $q = @mysql_query("SELECT * FROM `amsn_files` ORDER BY `filename`, `url`"); while ($row = mysql_fetch_assoc($q)) { $count = 0; $count = $count + mysql_num_rows(@mysql_query("SELECT id FROM `amsn_skins` WHERE screen_id={$row['id']} OR file_id={$row['id']};")); $count = $count + mysql_num_rows(@mysql_query("SELECT id FROM `amsn_plugins` WHERE screen_id={$row['id']} OR file_id={$row['id']};")); $count = $count + mysql_num_rows(@mysql_query("SELECT id FROM `amsn_screenshots` WHERE screen_id={$row['id']};")); if ($count == 0) { if ($row['filename'] != '') { unlink(getFilePath($row['filename'])); } echo "<p>Removing the file " . getFileName($row['id']) . " from the database</p>\n"; if (!mysql_query("DELETE FROM `amsn_files` WHERE id = '" . $row['id'] . "' LIMIT 1")) { echo "<p>There was an error when trying to remove the file " . getFileName($row['id']) . " from the database</p>\n"; } } } } elseif ($_GET['action'] == 'edit') { if (!mysql_num_rows($q = mysql_query("SELECT * FROM `amsn_files` ORDER BY `filename`, `url`"))) { echo "<p>There are no files yet</p>\n"; return; } if (isset($_POST['id']) && ereg('^[1-9][0-9]*$', $_POST['id']) && !mysql_num_rows($q = @mysql_query("SELECT * FROM `amsn_files` WHERE id = '" . (int) $_POST['id'] . "' LIMIT 1"))) { echo "<p>The selected item don't exists</p>\n"; return; } if ($_GET['action'] == 'edit' && isset($_POST['id'])) { if (isset($_POST['id'], $_POST['type'])) { $_POST = clean4sql($_POST);
function sendFile($filename, $contentType = null, $nameToSent = null, $mustExit = true) { global $canUseXSendFile; $stat = @LFS::stat($filename); if ($stat && @LFS::is_file($filename) && @LFS::is_readable($filename)) { $etag = sprintf('"%x-%x-%x"', $stat['ino'], $stat['size'], $stat['mtime'] * 1000000); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag || isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime']) { header('HTTP/1.0 304 Not Modified'); } else { header('Content-Type: ' . (is_null($contentType) ? 'application/octet-stream' : $contentType)); if (is_null($nameToSent)) { $nameToSent = getFileName($filename); } if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { $nameToSent = rawurlencode($nameToSent); } header('Content-Disposition: attachment; filename="' . $nameToSent . '"'); if ($mustExit && $canUseXSendFile && function_exists('apache_get_modules') && in_array('mod_xsendfile', apache_get_modules())) { header("X-Sendfile: " . $filename); } else { header('Cache-Control: '); header('Expires: '); header('Pragma: '); header('Etag: ' . $etag); header('Last-Modified: ' . date('r', $stat['mtime'])); set_time_limit(0); ignore_user_abort(!$mustExit); header('Accept-Ranges: bytes'); header('Content-Transfer-Encoding: binary'); header('Content-Description: File Transfer'); if (ob_get_level()) { while (@ob_end_clean()) { } } $begin = 0; $end = $stat['size']; if (isset($_SERVER['HTTP_RANGE'])) { if (preg_match('/bytes=\\h*(\\d+)-(\\d*)[\\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) { $begin = intval($matches[0]); if (!empty($matches[1])) { $end = intval($matches[1]); } } } $size = $end - $begin; if (PHP_INT_SIZE <= 4 && $size >= 2147483647) { passthru('cat ' . escapeshellarg($filename)); } else { if (!ini_get("zlib.output_compression")) { header('Content-Length:' . $size); } if ($size != $stat['size']) { $f = @fopen($filename, 'rb'); if ($f === false) { header("HTTP/1.0 505 Internal Server Error"); } else { header('HTTP/1.0 206 Partial Content'); header("Content-Range: bytes " . $begin . "-" . $end . "/" . $stat['size']); $cur = $begin; fseek($f, $begin, 0); while (!feof($f) && $cur < $end && !connection_aborted() && connection_status() == 0) { print fread($f, min(1024 * 16, $end - $cur)); $cur += 1024 * 16; } fclose($f); } } else { header('HTTP/1.0 200 OK'); readfile($filename); } } } } if ($mustExit) { exit(0); } else { return true; } } return false; }
* This information must remain intact. */ error_reporting(0); require_once '../../common.php'; checkSession(); switch ($_GET['action']) { case 'load': if (file_exists(DATA . "/config/" . getFileName())) { echo json_encode(getJSON(getFileName(), "config")); } else { echo json_encode(array()); } break; case 'save': if (isset($_POST['data'])) { saveJSON(getFileName(), json_decode($_POST['data']), "config"); echo '{"status":"success","message":"Data saved"}'; } else { echo '{"status":"error","message":"Missing Parameter"}'; } break; case 'isDir': if (isset($_GET['path'])) { $result = array(); $result['status'] = "success"; $result['result'] = is_dir(getWorkspacePath($_GET['path'])); echo json_encode($result); } else { echo '{"status":"error","message":"Missing Parameter"}'; } break;
public function addnew($data, $upload = true) { // dd($data); extract($data); $pathname = $upload == true ? getFileName('file') : 'default.txt'; $query = $this->db->prepare('INSERT INTO `surveys` (filename,pathname,sector_id) VALUES (:filename,:pathname,:sector)'); $query->bindParam(':filename', $filename, PDO::PARAM_STR); $query->bindParam(':pathname', $pathname, PDO::PARAM_STR); $query->bindParam(':sector', $sector, PDO::PARAM_STR); $query->execute(); getError($query); // dd(config('storage_path')); if (hasFile('file')) { move(config('storage_path_survey'), 'file'); } }
<?php include '_header.php'; $update = getUpdate($_GET['file']); $teaserblocks = $update['page']->keyExists('teaserblocks') ? $update['page']->fetch('teaserblocks') : null; if ($_POST) { $file = buildFile(); $newFileName = getFileName($_POST['date'], $_POST['title']); // delete current Markdown file unlink($updates_dir . $_GET['file']); // write new Markdown file file_put_contents($updates_dir . $newFileName, $file); chmod($updates_dir . $newFileName, 0777); //echo "<textarea style='width: 100%; height: 500px;'>"; //echo $file; //echo "</textarea>"; echo "<script>location.href = location.pathname + '?file=" . $newFileName . "';</script>"; } ?> <form action="" method="post"> <fieldset> <legend>Metadata</legend> <div> <label for="published">Published</label> <div> <input type="radio" name="published" value="true" <?php if ($update['page']->fetch('published')) { echo "checked"; } ?>
function updateWebsiteStat() { $content = ''; $splStr = ''; $splxx = ''; $filePath = ''; $fileName = ''; $url = ''; $s = ''; $nCount = ''; handlePower('更新网站统计'); //管理权限处理 connexecute('delete from ' . $GLOBALS['db_PREFIX'] . 'websitestat'); //删除全部统计记录 $content = getDirTxtList($GLOBALS['adminDir'] . '/data/stat/'); $splStr = aspSplit($content, vbCrlf()); $nCount = 1; foreach ($splStr as $key => $filePath) { $fileName = getFileName($filePath); if ($filePath != '' && left($fileName, 1) != '#') { $nCount = $nCount + 1; aspEcho($nCount . '、filePath', $filePath); doEvents(); $content = getFText($filePath); $content = replace($content, chr(0), ''); whiteWebStat($content); } } $url = getUrlAddToParam(getThisUrl(), '?act=dispalyManageHandle', 'replace'); Rw(getMsg1('更新全部统计成功,正在进入' . @$_REQUEST['lableTitle'] . '列表...', $url)); writeSystemLog('', '更新网站统计'); //系统日志 }
If nothing is printed to output.txt it is either a permission problem (make the folder this file is in writeable) or your path to the upload.php file (the 3rd paramater of the $uploader->create() function) is wrong. Make sure you use a full web path if you are having problems (such as http://www.inaflashuploader.com/uploader/upload.php)*/ session_start(); if (@$_REQUEST['cmd'] == 'del') { @unlink($_REQUEST['file']); } @extract($_GET); $album = "carausal"; if ($_SERVER['HTTP_HOST'] == 'localhost') { $pic_root = "D:\\wamp\\www\\farben\\images\\"; } else { $pic_root = $_SERVER['DOCUMENT_ROOT'] . "/farben/images/"; } $filename = getFileName($album, $_FILES['Filedata']['name']); $temp_name = $_FILES['Filedata']['tmp_name']; $error = $_FILES['Filedata']['error']; $size = $_FILES['Filedata']['size']; $ext = getFileExtension($filename); if (!is_dir($pic_root . $album)) { mkdir($pic_root . $album, 0777); chmod($pic_root . $album, 0777); } if (!$error) { if ($ext == "jpeg" || $ext == "GIF" || $ext == "gif" || $ext == "JPG" || $ext == "jpg" || $ext == "png" || $ext == "PNG" || $ext == "JPEG") { $base_info = getimagesize($temp_name); switch ($base_info[2]) { case IMAGETYPE_PNG: $img = imagecreatefrompng($temp_name); break;
<?php include_once "../../../../includes/dbUtils.php"; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <p>Page generated on:</p> <p><?php echo date('r'); ?> </p> FileName: <?php echo getFileName(); ?> M= <?php echo $_REQUEST['m']; ?> </body> </html>
$torrent->is_private(true); } $fname = getUniqueUploadedFilename($torrent->info['name'] . '.torrent'); if (isset($request['start_seeding'])) { if (is_dir($path_edit)) { $path_edit = addslash($path_edit); } $path_edit = dirname($path_edit); if ($resumed = rTorrent::fastResume($torrent, $path_edit)) { $torrent = $resumed; } $torrent->save($fname); rTorrent::sendTorrent($torrent, true, true, $path_edit, null, true, isLocalMode()); if ($resumed) { if (isset($torrent->{'rtorrent'})) { unset($torrent->{'rtorrent'}); } if (isset($torrent->{'libtorrent_resume'})) { unset($torrent->{'libtorrent_resume'}); } $torrent->save($fname); } } else { $torrent->save($fname); } @chmod($fname, $profileMask & 0666); file_put_contents(getTempDirectory() . getUser() . $taskNo . "/out", getFileName($fname)); exit(0); } exit(1); }
/** * Add new survey pdfs to storage */ public function addsurvey() { $Sectors = App('App\\Entities\\Survey')->listSectors(); if (request() == "post") { $data = $_POST; $filename = getFileName('file'); $filetype = getFileExtension($filename); $allowed = ['pdf', 'docx', 'doc', 'xlsx', 'xls']; if (hasFile('file')) { if (in_array($filetype, $allowed)) { App('App\\Entities\\Survey')->addnew($data); $notification = "Free survey database file successfully added"; } else { $notification = "Error: Only pdf,docx,doc,xlsx,xls uploads allowed!"; } } else { App('App\\Entities\\Survey')->addnew($data, false); $notification = "Free survey database file successfully added"; } redirect_to("/admin/survey", array('as' => 'notification', 'message' => $notification)); } backview('survey/add', compact('Sectors')); }
public function getHandle() { $this->handle = fopen(getFileName($prefix = 'log'), 'a'); return $this->handle; }
// If it couldn't find the parent folder's ID, skip this file if ($parentFolderID == null) { continue; } $nextID = createFile(getFileName($value->path), $parentFolderID, $value->path, true, $accessToken, $stringArray); // If the API call returns an error, handle and retry it if possible if (is_array($nextID)) { array_push($stringArray, "Retrying this file...", "<br><br>"); retryCall($nextID, getFileName($value->path), $parentFolderID, $value->path, true, $accessToken, $stringArray); } // Check to see if the file upload was successfull if (!is_array($nextID)) { $numFiles++; array_push($stringArray, "File '" . getFileName($value->path) . "' successfully uploaded", "<br>"); } else { array_push($stringArray, "File '" . getFileName($value->path) . "' NOT successfully uploaded, ", "Error: {$nextID['code']}", "<br>"); array_push($failedFiles, $value->path); } if ($numLines > 100) { file_put_contents($logName, $stringArray, FILE_APPEND); $stringArray = array(); $numLines = 0; } } array_push($stringArray, "<br>", "Successfully uploaded {$numFolders} folders and {$numFiles} files", "<br>"); array_push($stringArray, "Your AFS directory contains {$totalFolders} folders and {$totalFiles} files", "<br>"); file_put_contents($logName, $stringArray, FILE_APPEND); // If the transfer completed successfully, delete the log file if ($numFiles == $totalFiles and $numFolders == $totalFolders) { // unlink($logName); // unset($failedFiles);
break; case "csv": $count++; $filename[$count] = $csv_path . "/" . $file['name']; $basename[$count] = getFileName($file['name']); move_uploaded_file($file['tmp_name'], $filename[$count]); chmod($filename[$count], 0644); break; case "xml": /* as created by Excel 2003 */ $count++; $rowcount = $cols = 0; $dom = DOMDocument::load($file['tmp_name']); $rows = $dom->getElementsByTagName('Row'); $filename[$count] = $csv_path . "/" . $file['name']; $basename[$count] = getFileName($file['name']); if ($fp = fopen($filename[$count], "w")) { foreach ($rows as $row) { $rowcount++; unset($index, $data); $cells = $row->getElementsByTagName('Cell'); foreach ($cells as $cell) { $ind = $cell->getAttribute('Index'); if ($ind != null) { $index = $ind; } $data[$index] = $cell->nodeValue; $index++; } if (!$cols) { $cols = $index;
/** * Sends a trackback ping (= notification) for an item to on or more external sites that have been referred to by this item's content. * * For admin backend filter use only. * * @param string $message Message text * @param object $object The object of the item to send a ping for * @return string */ function sendTrackbackPing($message, $object) { $class = get_class($object); $host = htmlentities($_SERVER["HTTP_HOST"], ENT_QUOTES, 'UTF-8'); $title = ""; $text = ""; $url = ""; $title = $object->getTitle(); switch ($class) { case "ZenpageNews": $text = $object->getContent(); if (getOption("mod_rewrite")) { $url = "http://" . $host . WEBPATH . "/" . ZENPAGE_NEWS . "/" . $object->getTitlelink(); } else { $url = "http://" . $host . WEBPATH . "/index.php?p=" . ZENPAGE_NEWS . "&title=" . $object->getTitlelink(); } break; case "ZenpagePage": $text = $object->getContent(); if (getOption("mod_rewrite")) { $url = "http://" . $host . WEBPATH . "/" . ZENPAGE_PAGES . "/" . $object->getTitlelink(); } else { $url = "http://" . $host . WEBPATH . "/index.php?p=" . ZENPAGE_PAGES . "&title=" . $object->getTitlelink(); } break; case "Album": $text = $object->getDesc(); if (getOption("mod_rewrite")) { $url = "http://" . $host . WEBPATH . "/" . $object->getFolder(); } else { $url = "http://" . $host . WEBPATH . "/index.php?album=" . $object->getFolder(); } break; case "_Image": $text = $object->getDesc(); if (getOption("mod_rewrite")) { $url = "http://" . $host . WEBPATH . "/" . $object->getAlbumName() . "/" . getFileName() . getOption("mod_rewrite_suffix"); } else { $url = "http://" . $host . WEBPATH . "/index.php?album=" . $object->getAlbumName() . "&image=" . getFileName(); } break; } $url = urlencode($url); $excerpt = truncate_string($text, 255, "(...)"); $array = $this->auto_discovery($text); // debugging echo "Array with trackback URLs: <pre>"; print_r($array); echo "</pre>"; // debugging $message = ''; if ($tb_array = $this->auto_discovery($text)) { // Found trackbacks in TEXT. Looping... foreach ($tb_array as $tb_key => $tb_url) { // Attempt to ping each one... $response = parsePingResponse($this->ping($tb_url, $url, $title, $excerpt)); if (empty($response)) { // Successful ping... $message .= "<p class='messagebox'>" . sprintf(gettext("Trackback send to <em>%s</em>."), $tb_url) . "</p>\n"; } else { // Error pinging... $message .= "<p class='errorbox'>" . sprintf(gettext('Trackback to <em>%1$s</em> failed...%2$s'), $tb_url, $response) . "</p>\n"; } } } else { // No trackbacks in TEXT... $message = "<p class='errorbox'>" . gettext("No trackbacks were auto-discovered...") . "</p>\n"; $message .= "<br />" . urldecode($url); // debug only } return $message; }
* * return n/a **/ function downloadFile($file) { header("Content-type: application/force-download"); header("Content-Transfer-Encoding: Binary"); header("Content-length: " . filesize($file)); header("Content-disposition: attachment; filename=\"" . basename($file) . "\""); readfile("{$file}"); } // Set variables. $dir = '/srv/filerepo/'; $filename = ''; // Check authentication if (!checkAuth()) { header("HTTP/1.1 403 Forbidden"); exit; } // Sanitise user input by only allowing digits $getnum = filter_input(INPUT_GET, 'file', FILTER_SANITIZE_NUMBER_INT); // Process input and download file $filename = getFileName($getnum); if ($filename == '') { header('HTTP/1.0 404 Not Found'); include '404.php'; exit; } $file = $dir . $filename; downloadFile($file); redirectToPrevious();
function copyHtmlToWeb() { $webDir = ''; $toWebDir = ''; $toFilePath = ''; $filePath = ''; $fileName = ''; $fileList = ''; $splStr = ''; $content = ''; $s = ''; $s1 = ''; $c = ''; $webImages = ''; $webCss = ''; $webJs = ''; $splJs = ''; $webFolderName = ''; $jsFileList = ''; $setFileCode = ''; $nErrLevel = ''; $jsFilePath = ''; $url = ''; $setFileCode = @$_REQUEST['setcode']; //设置文件保存编码 handlePower('复制生成HTML页面'); //管理权限处理 writeSystemLog('', '复制生成HTML页面'); //系统日志 $webFolderName = $GLOBALS['cfg_webTemplate']; if (left($webFolderName, 1) == '/') { $webFolderName = mid($webFolderName, 2, -1); } if (right($webFolderName, 1) == '/') { $webFolderName = mid($webFolderName, 1, len($webFolderName) - 1); } if (inStr($webFolderName, '/') > 0) { $webFolderName = mid($webFolderName, inStr($webFolderName, '/') + 1, -1); } $webDir = '/htmladmin/' . $webFolderName . '/'; $toWebDir = '/htmlw' . 'eb/viewweb/'; CreateDirFolder($toWebDir); $toWebDir = $toWebDir . pinYin2($webFolderName) . '/'; deleteFolder($toWebDir); //删除 CreateFolder('/htmlweb/web'); //创建文件夹 防止web文件夹不存在20160504 deleteFolder($webDir); CreateDirFolder($webDir); $webImages = $webDir . 'Images/'; $webCss = $webDir . 'Css/'; $webJs = $webDir . 'Js/'; copyFolder($GLOBALS['cfg_webImages'], $webImages); copyFolder($GLOBALS['cfg_webCss'], $webCss); CreateFolder($webJs); //创建Js文件夹 //处理Js文件夹 $splJs = aspSplit(getDirJsList($webJs), vbCrlf()); foreach ($splJs as $key => $filePath) { if ($filePath != '') { $toFilePath = $webJs . getFileName($filePath); aspEcho('js', $filePath); moveFile($filePath, $toFilePath); } } //处理Css文件夹 $splStr = aspSplit(getDirCssList($webCss), vbCrlf()); foreach ($splStr as $key => $filePath) { if ($filePath != '') { $content = getFText($filePath); $content = replace($content, $GLOBALS['cfg_webImages'], '../images/'); $content = deleteCssNote($content); $content = PHPTrim($content); //设置为utf-8编码 20160527 if (lCase($setFileCode) == 'utf-8') { $content = replace($content, 'gb2312', 'utf-8'); } WriteToFile($filePath, $content, $setFileCode); aspEcho('css', $GLOBALS['cfg_webImages']); } } //复制栏目HTML $GLOBALS['isMakeHtml'] = true; $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'webcolumn where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_filePath'] = replace(getColumnUrl($rss['columnname'], 'name'), $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('导航', $GLOBALS['glb_filePath']); } } //复制文章HTML $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'articledetail where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/detail/detail' . $rss['id']); $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('文章' . $rss['title'], $GLOBALS['glb_filePath']); } } //复制单面HTML $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'onepage where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/page/page' . $rss['id']); $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('单页' . $rss['title'], $GLOBALS['glb_filePath']); } } //批量处理html文件列表 //call echo(cfg_webSiteUrl,cfg_webTemplate) //call rwend(fileList) $sourceUrl = ''; $replaceUrl = ''; $splStr = aspSplit($fileList, vbCrlf()); foreach ($splStr as $key => $filePath) { if ($filePath != '') { $filePath = $webDir . replace($filePath, '/', '_'); aspEcho('filePath', $filePath); $content = getFText($filePath); foreach ($splStr as $key => $s) { $s1 = $s; if (right($s1, 11) == '/index.html') { $s1 = left($s1, len($s1) - 11) . '/'; } $sourceUrl = $GLOBALS['cfg_webSiteUrl'] . $s1; $replaceUrl = $GLOBALS['cfg_webSiteUrl'] . replace($s, '/', '_'); //Call echo(sourceUrl, replaceUrl) '屏蔽 否则大量显示20160613 $content = replace($content, $sourceUrl, $replaceUrl); } $content = replace($content, $GLOBALS['cfg_webSiteUrl'], ''); //删除网址 $content = replace($content, $GLOBALS['cfg_webTemplate'] . '/', ''); //删除模板路径 记 //content=nullLinkAddDefaultName(content) foreach ($splJs as $key => $s) { if ($s != '') { $fileName = getFileName($s); $content = replace($content, 'Images/' . $fileName, 'js/' . $fileName); } } if (inStr($content, '/Jquery/Jquery.Min.js') > 0) { $content = replace($content, '/Jquery/Jquery.Min.js', 'js/Jquery.Min.js'); copyFile('/Jquery/Jquery.Min.js', $webJs . '/Jquery.Min.js'); } $content = replace($content, '<a href="" ', '<a href="index.html" '); //让首页加index.html createFileGBK($filePath, $content); } } //把复制网站夹下的images/文件夹下的js移到js/文件夹下 20160315 $htmlFileList = ''; $splHtmlFile = ''; $splJsFile = ''; $htmlFilePath = ''; $jsFileName = ''; $jsFileList = getDirJsNameList($webImages); $htmlFileList = getDirHtmlList($webDir); $splHtmlFile = aspSplit($htmlFileList, vbCrlf()); $splJsFile = aspSplit($jsFileList, vbCrlf()); foreach ($splHtmlFile as $key => $htmlFilePath) { $content = getFText($htmlFilePath); foreach ($splJsFile as $key => $jsFileName) { $content = regExp_Replace($content, 'Images/' . $jsFileName, 'js/' . $jsFileName); } $nErrLevel = 0; $content = handleHtmlFormatting($content, false, $nErrLevel, '|删除空行|'); //|删除空行| $content = handleCloseHtml($content, true, ''); //闭合标签 $nErrLevel = checkHtmlFormatting($content); if (checkHtmlFormatting($content) == false) { echoRed($htmlFilePath . '(格式化错误)', $nErrLevel); //注意 } //设置为utf-8编码 if (lCase($setFileCode) == 'utf-8') { $content = replace($content, '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />', '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'); } $content = PHPTrim($content); WriteToFile($htmlFilePath, $content, $setFileCode); } //images下js移动到js下 foreach ($splJsFile as $key => $jsFileName) { $jsFilePath = $webImages . $jsFileName; $content = getFText($jsFilePath); $content = PHPTrim($content); WriteToFile($webJs . $jsFileName, $content, $setFileCode); DeleteFile($jsFilePath); } copyFolder($webDir, $toWebDir); //使htmlWeb文件夹用php压缩 if (@$_REQUEST['isMakeZip'] == '1') { makeHtmlWebToZip($webDir); } //使网站用xml打包20160612 if (@$_REQUEST['isMakeXml'] == '1') { makeHtmlWebToXmlZip('/htmladmin/', $webFolderName); } //浏览地址 $url = 'http://10.10.10.57/' . $toWebDir; aspEcho('浏览', '<a href=\'' . $url . '\' target=\'_blank\'>' . $url . '</a>'); }
<?php ini_set("log_errors", 1); ini_set("display_errors", 0); error_log("INIT MAIN PAGE!"); date_default_timezone_set("Europe/Warsaw"); if (isset($_GET['tytul'])) { $title = $_GET['tytul']; } else { $title = "ofirmie"; } $fileName = getFileName($title); if (!file_exists($fileName)) { $title = "work"; $fileName = getFileName($title); } function getFileName($title) { return "t" . $title . ".htm"; }
$countColor = 1; if (isset($_POST['delete_x'])) { $error = true; if (deleteServer($_POST['idServer'])) { $messageType = "DeleteServer"; } else { $messageType = "ErrorDeleteServer"; } } elseif (isset($_POST['createSessionId'])) { /*if(!isset($_SESSION['userName']) && !isset($_SESSION['password'])) { header('Location:nxbuilder.php'); } */ $f = "resolution-" . $_POST['createServerId']; $k = "link-" . $_POST['createServerId']; $fileName = getFileName($_POST['createSessionId']); if (ereg("MSIE ([0-9].[0-9]{1,2})", $_SERVER["HTTP_USER_AGENT"])) { header("Content-Type: application/nxs"); header("Content-Disposition: inline; filename={$fileName}"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: private"); } else { header("Content-Type: application/nxs"); header("Content-Disposition: attachment; filename={$fileName}"); header("Expires: 0"); header("Pragma: no-cache"); } include "CreateSession.php"; CreateSessionFile3_0($_POST['createSessionId'], $_POST[$f], $_POST[$k]); exit;
function getWidgets() { $res = array(); echo $currFile = getFileName(); $whereStm = " WHERE ('{$currFile}' LIKE CONCAT('%',filename) OR '{$currFile}' LIKE CONCAT('%',filename,'?%') OR '{$currFile}' LIKE CONCAT('%',filename,'&%') )And (filename<>'') "; $sql = "SELECT * FROM wid_curr_widgets {$whereStm} "; $result = MYSQL_QUERY($sql); $numberOfRows = MYSQL_NUMROWS($result); if ($numberOfRows == 0) { if ($currFile == 'index.php' or $currFile == '') { $def_type = 1; } else { $def_type = 2; } $whereStm = " WHERE (type='{$def_type}')"; $ids = returnImplode_ids('wid_curr_widgets', " {$whereStm} ", 'id'); } if ($numberOfRows > 0) { $ids = returnImplode_ids('wid_curr_widgets', " {$whereStm} ", 'id'); } return $ids; }
$dir = getCurrentDir(); // if you have more complex filenames you can use the index $action = parseInputParameter($_GET['action']); // The extra functionality for twg is on an exern class to make updating much easier if (file_exists('twg_plugin.php')) { include_once 'twg_plugin.php'; reset_twg_cache($action); } // end plugin if (isset($_GET['index']) && $action != 'dir') { // file functions! if (isset($_GET['copyfolder']) && $_GET['copyfolder'] == "true") { $file = ""; // not needed for this task } else { $file = getFileName($dir); // returns an array if more than one is selected! } if ($action == 'rename') { // rename a file tfu_rename_file($dir, $file, $enable_file_rename, $keep_file_extension, $fix_utf8); } else { if ($action == 'delete') { // delete a file tfu_delete_file($file, $show_delete); } else { if ($action == 'xdelete') { // delete several files! tfu_delete_files($file, $show_delete); } else { if ($action == 'copymove') {