public function OnFileExists($pData = null) { $component = $pData['Component']; $area = $pData['Area']; $filename = $pData['Filename']; $directory = $pData['Directory']; $Dir = ASD_PATH . '_storage/components/' . $component . '/' . $area . '/' . $directory; // If the directory doesn't exist, create it. if (!is_dir($Dir)) { rmkdir($Dir); } $File = $Dir . '/' . $filename; $exists = file_exists($File); return $exists; }
<?php fopen('a', 'r'); file_put_contents("a{$b}", 'c'); file_put_contents("a{b}", 'c'); file_get_contents("a" . $b, 'c'); file_get_contents("a" . B, 'c'); // those are OK glob(__DIR__, 'r'); // 2nd is literal unlink("{$c}d"); rmkdir($e . "f");
user_note(CFIMGCACHEPATH . ' - ok', 2); flushNow(); } if (rmkdir(CFIMGTEMPPATH)) { user_note(CFIMGTEMPPATH . ' - ok', 2); flushNow(); } if (rmkdir(CFBULKUPLOADPATH)) { user_note(CFBULKUPLOADPATH . ' - ok', 2); flushNow(); } if (rmkdir(CFINCPATH)) { user_note(CFINCPATH . ' - ok', 2); flushNow(); } if (rmkdir(CFBACKUPPATH)) { user_note(CFBACKUPPATH . ' - ok', 2); flushNow(); } echo '</div>'; flushNow(); } // Check for extension if (!$Err_found) { echo '<form method="post" action="?i=db" class="ins"> <input type="submit" value="下一步:检查数据库" class="button" name="checks" /> </form>'; } else { echo '<div class="ibox">'; user_note('请先修复上面的错误后再继续', 1); echo '</div>';
if (isset($_POST['btn_enviar'])) { require "config.php"; if (isset($_POST['chk_dep'])) { define('ADODB_ASSOC_CASE', 1); require $ADODB_PATH . "/adodb.inc.php"; $dsn = "{$driver}://{$usuario}:{$contrasena}@{$servidor}/{$servicio}"; $conn = ADONewConnection($dsn); $conn->SetFetchMode(ADODB_FETCH_ASSOC); $sql = "SELECT depe_codi as DEPE_CODI from dependencia where depe_estado=1"; $rs = $conn->Execute($sql); $msgD = "Estado de dependencias:<br>"; while (!$rs->EOF) { $dep = str_pad($rs->fields['DEPE_CODI'], 3, "0", STR_PAD_LEFT); $tmp = str_replace('reinicio.php', $carpetaBodega, $_SERVER['SCRIPT_FILENAME']); $tmp .= "/{$ano}/" . $dep . "/docs"; $ok = rmkdir($tmp); if ($ok) { $msgD .= "<br>Creada dependencia {$dep}"; } else { $msgD .= "<br>Error en creación {$dep}"; } $rs->MoveNext(); } $rs->Close(); $conn = null; } if (isset($_POST['chk_sec'])) { define('ADODB_ASSOC_CASE', 1); require $ADODB_PATH . "/adodb.inc.php"; $dsn = "{$driver}://{$usuario}:{$contrasena}@{$servidor}/{$servicio}"; $conn = ADONewConnection($dsn);
function download() { // Dirs $begin = microtime(true); global $base_image_dir; $dir = $base_image_dir . 'HIRES/' . $this->dbcode . '/'; if (!rmkdir($dir)) { return false; } $tkdir = $base_image_dir . 'HIRES/TK/' . $this->dbcode . '/'; if (!rmkdir($tkdir)) { return false; } $oldumask = umask(022); // Card images echo count($this->cards) . ' cards to download to ' . $dir . "\n"; foreach ($this->cards as $card) { echo $card->name . ' : '; if ($card->secondname != '') { if (count($card->images) < 2) { die('2 images expected for tranfsorm'); } $path = $dir . card_img_by_name($card->name, 1, 1); cache_get($card->images[0], $path, true, true); $path = $dir . card_img_by_name($card->secondname, 1, 1); cache_get($card->images[1], $path, true, true); echo "\n"; // Languages foreach ($card->langs as $lang => $images) { $nbimages = count($images['images']); if ($nbimages < 1) { continue; } if ($nbimages < 2) { echo '2 images expected for tranfsorm translation' . "\n"; } $langdir = $base_image_dir . strtoupper($lang) . '/' . $this->dbcode . '/'; echo " - {$lang} : "; $path = $langdir . card_img_by_name($card->name, 1, 1); cache_get($image, $path, true, true); $path = $langdir . card_img_by_name($card->secondname, 1, 1); cache_get($image, $path, true, true); echo "\n"; } } else { foreach ($card->images as $i => $image) { $path = $dir . card_img_by_name($card->name, $i + 1, count($card->images)); cache_get($image, $path, true, true); } echo "\n"; // Languages foreach ($card->langs as $lang => $images) { if (count($images['images']) < 1) { continue; } echo " - {$lang} : "; $langdir = $base_image_dir . strtoupper($lang) . '/' . $this->dbcode . '/'; foreach ($images['images'] as $i => $image) { $path = $langdir . card_img_by_name($card->name, $i + 1, count($card->images)); cache_get($image, $path, true, true); } echo "\n"; } } } // Token images echo "\n" . count($this->tokens) . ' tokens to download to ' . $tkdir . "\n"; foreach ($this->tokens as $token) { echo $token['type'] . ' : '; $name = $token['type']; // Manage multiple tokens with the same name $same = array_filter($this->tokens, function ($tk) use($token) { return tokenpath($tk) == tokenpath($token); }); if (count($same) > 1) { if (!isset($multiple)) { $multiple = array(); } if (!isset($multiple[$name])) { $multiple[$name] = 1; } else { $multiple[$name]++; } $name .= $multiple[$name]; } // Token is an emblem if (preg_match('/Emblem (.*)/', $name, $matches)) { $found = false; foreach ($this->cards as $card) { // Search which planeswalker it is for if (split(' ', $card->types)[0] != 'Planeswalker') { // Only parse planeswalker, with information aviable continue; } $attrs = $card->attrs(); // Check card subtype if (isset($attrs->subtypes) && count($attrs->subtypes) > 0 && $attrs->subtypes[0] == strtolower($matches[1])) { $found = true; $name = 'Emblem.' . $attrs->subtypes[0]; break; } // Check transform subtype if (isset($attrs->transformed_attrs) && $attrs->transformed_attrs->subtypes[0] == strtolower($matches[1])) { $found = true; $name = 'Emblem.' . $attrs->transformed_attrs->subtypes[0]; break; } } if (!$found) { // No planeswalker found, don't DL echo "Planeswalker not found for emblem\n"; continue; } } cache_get($token['image_url'], $tkdir . tokenpath($token, $name), true, true); echo "\n"; } umask($oldumask); echo "\n" . 'Finished in ' . (microtime(true) - $begin) . ' (think about thumbnailing)'; return true; }
function resize_and_upload_image($locatieoud, $size = array("maxx", "maxy", "perc"), $locatie) { //dmv extensie bepalen... //$type = strtolower(substr($locatieoud, strrpos($locatieoud,".")+1 )); //if ($type == "jpg") { $type = "jpeg"; } //dmv MIME bepalen $info = getimagesize($locatieoud); $type = str_replace('image/', '', $info["mime"]); $createFunc = 'imagecreatefrom' . $type; $im = $createFunc($locatieoud); $w = $info[0]; $h = $info[1]; // create thumbnail if (!empty($size["perc"])) { $percentage = $size["perc"]; $tw = round($percentage / 100 * $w); $th = round($percentage / 100 * $h); } else { $tw = $size["maxx"]; if (empty($size["maxy"])) { $th = 9999999999; //er is geen limiet op de y } else { $th = $size["maxy"]; } } //$imT = imagecreatetruecolor( $tw, $th ); //als de doelresoluties op x en y groter zijn dan de resoluties van het bronbestand, dan gewoon het bronbestand tonen if ($tw >= $w and $th >= $h) { } if ($tw / $th < $th / $tw) { // wider $tmph = $h * ($tw / $w); $imT = imagecreatetruecolor($tw, $tmph); //transparancy! if ($info[2] == IMAGETYPE_GIF || $info[2] == IMAGETYPE_PNG) { $trnprt_indx = imagecolortransparent($im); // If we have a specific transparent color if ($trnprt_indx >= 0) { // Get the original image's transparent color's RGB values $trnprt_color = imagecolorsforindex($im, $trnprt_indx); // Allocate the same color in the new image resource $trnprt_indx = imagecolorallocate($imT, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']); // Completely fill the background of the new image with allocated color. imagefill($imT, 0, 0, $trnprt_indx); // Set the background color for new image to transparent imagecolortransparent($imT, $trnprt_indx); } elseif ($info[2] == IMAGETYPE_PNG) { // Turn off transparency blending (temporarily) imagealphablending($imT, false); // Create a new transparent color for image $color = imagecolorallocatealpha($imT, 0, 0, 0, 127); // Completely fill the background of the new image with allocated color. imagefill($imT, 0, 0, $color); // Restore transparency blending imagesavealpha($imT, true); } } imagecopyresampled($imT, $im, 0, 0, 0, 0, $tw, $tmph, $w, $h); // resize to width //imagecopyresampled( $imT, $temp, 0, 0, 0, $tmph/2-$th/2, $tw, $th, $tw, $th ); // crop } else { // taller $tmpw = $w * ($th / $h); $imT = imagecreatetruecolor($tmpw, $th); imagecopyresampled($imT, $im, 0, 0, 0, 0, $tmpw, $th, $w, $h); // resize to height // imagecopyresampled( $imT, $temp, 0, 0, $tmpw/2-$tw/2, 0, $tw, $th, $tw, $th ); // crop } // save the image $saveFunc = 'image' . $type; if ($type == "png") { $quality = 9; } else { $quality = 100; } rmkdir(dirname($locatie), 0777); //create dir $saveFunc($imT, $locatie, $quality); /*) { return true; } else { return false; }*/ return true; }
if ($show_html) { $B_ = "</b>"; } else { $B_ = "!"; } /* * Start of main() */ if ($show_html) { echo "<html><body>"; } $keywords = explode(",", $test_keywords); if (!count($keywords)) { die("Error: no keywords defined.{$NL}"); } if (!rmkdir($working_dir)) { die("Failed to create/open {$working_dir}{$NL}"); } $country_data = get_google_cc($test_country, $test_language); if (!$country_data) { die("Invalid country/language code specified.{$NL}"); } $ready = get_license(); if (!$ready) { die("The specified seo-proxies.com license ({$uid}) is not active. {$NL}"); } if ($LICENSE['protocol'] != "http") { die("The seo-proxies.com proxy protocol of license {$uid} is not set to HTTP, please change the protocol to HTTP. {$NL}"); } echo "{$NL}{$B} Google rank checker for {$test_website_url} initated {$B_} {$NL}{$NL}"; /*
private function _CreateDirectory($pUsername, $pDirectory) { $location = ASD_PATH . '_storage/photos/' . $pUsername . '/' . $pDirectory; if (file_exists($location)) { return $location; } if (!rmkdir($location)) { return false; } return $location; }
private function _UpdateFiles($pServer, $pVersion) { $url = $pServer . "/diffs/" . $pVersion . ".diff"; $diff = $this->_Communicate($url, array(), true); if (!$diff) { $this->_Messages[] = array("error" => true, "message" => __("Error Retrieving Diff File")); return false; } $diffData = explode("\n", $diff); if (count($diffData) == 0) { $this->_Messages[] = array("error" => true, "message" => __("Diff Empty No Files Were Updated")); return false; } foreach ($diffData as $d => $data) { list($action, $file, $md5) = explode("\t", $data); $fileURL = $pServer . '/releases/' . $pVersion . '/' . $file . '.txt'; if ($action == 'U') { $fileData = $this->_Communicate($fileURL, array(), true); } $oldFile = ASD_PATH . $file; $oldDirectory = implode("/", explode("/", ASD_PATH . $file, -1)); if (!is_dir($oldDirectory)) { if (!rmkdir($oldDirectory)) { $this->_Messages[] = array("error" => true, "message" => __("Diff Empty No Files Were Updated")); continue; } } $oldMd5 = md5($fileData); if ($action == 'U') { if ($oldMd5 != $md5) { $this->_Messages[] = array("error" => true, "message" => __("Checksums Do Not Match", array("filename" => $file, "found" => $oldMd5, "expected" => $md5))); continue; } if (!($handle = fopen($oldFile, 'w+'))) { $this->_Messages[] = array("error" => true, "message" => __("Could Not Open File", array("filename" => $file))); continue; } if (!fwrite($handle, $fileData)) { $this->_Messages[] = array("error" => true, "message" => __("Could Not Update File", array("filename" => $file))); continue; } $this->_Messages[] = array("error" => false, "message" => __("Updated File Or Directory", array("filename" => $file))); fclose($handle); } else { if ($action == 'C') { if (!is_dir(ASD_PATH . DS . $file)) { if (!rmkdir(ASD_PATH . DS . $file)) { $this->_Messages[] = array("error" => true, "message" => __("Could Not Create Directory", array("file" => $file))); continue; } else { $this->_Messages[] = array("error" => true, "message" => __("Directory Has Been Created", array("file" => $file))); } } else { $this->_Messages[] = array("error" => false, "message" => __("Directory Already Exists", array("file" => $file))); } } else { if ($action == 'D') { if (!rrmdir(ASD_PATH . DS . $file)) { $this->_Messages[] = array("error" => true, "message" => __("Could Not Delete File Or Directory", array("filename" => $file))); continue; } $this->_Messages[] = array("error" => false, "message" => __("Deleted File Or Directory", array("filename" => $file))); } } } /* echo $action, '<br />'; echo $file, '<br />'; echo $fileURL, '<br />'; echo $oldFile, '<br />'; echo "File Data: <pre>", htmlspecialchars ($fileData), '</pre><br />'; echo "Expected: ", $md5, '<br />'; echo "Actual: ", md5 ( $fileData ), '<hr />'; */ } return true; }
function thumbnail($picture, $w = "", $h = "", $thumb = 1, $crop = 0, $arrMore = array()) { $arr_duoi = array('gif', 'png', 'jpg'); $duoi = strtolower(substr($picture, strrpos($picture, ".") + 1)); if (!in_array($duoi, $arr_duoi)) { $picture = 'public/upload/nophoto/nophoto.jpg'; } $out = ""; $pre = $w; if ($h) { $pre = $w . "x" . $h; } else { $h = $w; } if (isset($arrMore['fixMin'])) { $pre .= "_fmin"; } if (isset($arrMore['fixMax'])) { $pre .= "_fmax"; } if (isset($arrMore['fixWidth'])) { $pre .= "_fw"; } if (isset($arrMore['zoomMax'])) { $pre .= "_zmax"; } if ($crop != 0) { $pre .= "_crop"; } $linkhinh = $picture; $linkhinh = str_replace("//", "/", $linkhinh); $dir = substr($linkhinh, 0, strrpos($linkhinh, "/")); $pic_name = substr($linkhinh, strrpos($linkhinh, "/") + 1); //$linkhinh = "uploads/" . $linkhinh; if ($w) { if ($thumb) { $folder_thumbs = str_replace('public/upload/', 'public/thumbs_size/', $dir . '/'); $folder_thumbs .= substr($pic_name, 0, strrpos($pic_name, ".")); $folder_thumbs .= '_' . substr($pic_name, strrpos($pic_name, ".") + 1); $file_thumbs = $folder_thumbs . "/{$pre}_" . substr($linkhinh, strrpos($linkhinh, "/") + 1); $linkhinhthumbs = SITE_PATH . $file_thumbs; //$linkhinhthumbs = SITE_PATH . "public/thumbs_size/" . $file_thumbs; if (!file_exists($linkhinhthumbs)) { rmkdir($folder_thumbs, 0777, "thumbs_size"); // thum hinh thumbs(SITE_PATH . $linkhinh, $linkhinhthumbs, $w, $h, $crop, $arrMore); } $src = URL::root() . $file_thumbs; } else { $src = URL::root() . $folder_thumbs . "/" . $pic_name; } } else { $src = URL::root() . 'uploads/' . $picture; } return $src; }
function CreateDirectory($dirpath, $dirname, $uploadpath) { //Check if folder name is valid if (!checkFolderName($dirname)) { return false; } //Check if folder path is valid if (!($dirpath = checkpath($dirpath, $uploadpath))) { return false; } //Create directory if (!rmkdir(DOCUMENTROOT . $dirpath . $dirname)) { return false; } return true; }
function rmkdir($dir) { $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { is_dir("{$dir}/{$file}") ? rmkdir("{$dir}/{$file}") : unlink("{$dir}/{$file}"); } return rmdir($dir); }
/** * 创建目录 * @param string $dir 目录 * @param string $mode 权限字串 * @param boolean $makeindex 是否创建默认索引文件 */ function rmkdir($dir, $mode = 0777, $makeindex = TRUE) { if (!is_dir($dir)) { rmkdir(dirname($dir), $mode, $makeindex); @mkdir($dir, $mode); if (!empty($makeindex)) { @touch($dir . '/index.html'); @chmod($dir . '/index.html', 0777); } } return true; }
public function _UserIcon($pUsername, $pWidth = 128, $pHeight = 128) { // Find closest resolution values $width = $this->_FindClosestValue($pWidth, array(32, 64, 128)); $height = $width; // Get the filename size identifier. switch ($width) { case 128: $size = 'm'; break; case 64: $size = 's'; break; case 32: default: $size = 't'; break; } // Check for new icons. $location = ASD_PATH . '_storage' . DS . 'photos' . DS . $pUsername . DS; $file = $location . 'profile.' . $size . '.jpg'; if (file_exists($file)) { $icon = imagecreatefromjpeg($file); } else { /* * @todo Remove this eventually once new photo system is used. * */ $legacy_file = ASD_PATH . '_storage' . DS . 'legacy' . DS . 'photos' . DS . $pUsername . DS . 'profile.jpg'; if (!file_exists($legacy_file)) { header('Content-type: image/gif'); $icon = imagecreatefromgif(ASD_PATH . 'themes/default/images/noicon.gif'); imagegif($icon) or die("Couldn't"); imagedestroy($icon); return true; } else { if (!is_dir($location)) { rmkdir($location); } if (is_writable($location)) { $icon = imagecreatefromjpeg($legacy_file); $new_icon = $this->GetSys('Image')->ResizeAndCrop($icon, $width, $height); $icon = $new_icon; imagejpeg($new_icon, $file); chmod($file, 0777); } else { header('Content-type: image/gif'); $icon = imagecreatefromgif(ASD_PATH . 'themes/default/images/noicon.gif'); imagegif($icon); imagedestroy($icon); return true; } } } // Use the legacy icon header('Content-type: image/jpeg'); imagejpeg($icon); imagedestroy($icon); return true; }