function lang($file = '', $str = '', $changed = '') { // Parametreler kontrol ediliyor. if (!is_string($file) || !is_string($str)) { return false; } $key = removeExtension($file, 'php'); $file = Config::get('Language', getLang()) . '/' . suffix($file, '.php'); $langDir = restorationPath(LANGUAGES_DIR . $file); $sysLangDir = SYSTEM_LANGUAGES_DIR . $file; global $lang; if (is_file($langDir)) { require_once $langDir; } elseif (is_file($sysLangDir)) { require_once $sysLangDir; } // Belirtilen anahtar dahil edilen // Dil dosyası içerisinde mevcutsa // İşlemlere devam et. if (isset($lang[$key][$str])) { $langstr = $lang[$key][$str]; } elseif (isset($lang[$key]) && empty($str)) { return $lang[$key]; } else { return false; } // 2. Parametre Dizi değilse // Dil dosyaları içerisinde yer alan // & işareti yerine bu parametrenin değerin ata. if (!is_array($changed)) { if (strstr($langstr, "%") && !empty($changed)) { return str_replace("%", $changed, $langstr); } else { return $langstr; } } else { // 2. Parametre dizi ise // Anahtar olarak belirtilen // İşaretler yerine karşılarında // yer alan değerleri ata. if (!empty($changed)) { $values = array(); foreach ($changed as $key => $value) { $keys[] = $key; $values[] = $value; } return str_replace($keys, $values, $langstr); } else { return $langstr; } } }
/** * @param \Iterator $iterator * @param string $basepath * @return array */ function getFiles(\Iterator $iterator, $basepath = '') { $files = []; $length = strlen($basepath) + 1; foreach ($iterator as $file) { if (!$file->isFile()) { continue; } $file = removeExtension(substr($file, $length)); if (strpos($file, '.') !== 0) { $files[] = $file; } } return $files; }
function gconfig(string $value = NULL) { global $gconfig; if (empty($gconfig)) { $configs = array_merge(Folder::files(EXTERNAL_CONFIG_DIR, 'php'), Folder::files(CONFIG_DIR, 'php'), Folder::files(INTERNAL_CONFIG_DIR, 'php')); $gconfig = []; foreach ($configs as $file) { $file = removeExtension($file); $gconfig = array_merge($gconfig, (array) Config::get($file)); } } if ($value === NULL) { return $gconfig; } return $gconfig[$value] ?? false; }
public function use(string $randomPageVariable, array $randomDataVariable = NULL, bool $randomObGetContentsVariable = false) { if (!empty(Properties::$parameters['usable'])) { $randomObGetContentsVariable = Properties::$parameters['usable']; } if (!empty(Properties::$parameters['data'])) { $randomDataVariable = Properties::$parameters['data']; } Properties::$parameters = []; $eol = EOL; $randomPageVariableExtension = extension($randomPageVariable); $randomPageVariableBaseUrl = baseUrl($randomPageVariable); $return = ''; if (!is_file($randomPageVariable)) { throw new InvalidArgumentException('Error', 'fileParameter', '1.($randomPageVariable)'); } if ($randomPageVariableExtension === 'js') { $return = '<script type="text/javascript" src="' . $randomPageVariableBaseUrl . '"></script>' . $eol; } elseif ($randomPageVariableExtension === 'css') { $return = '<link href="' . $randomPageVariableBaseUrl . '" rel="stylesheet" type="text/css" />' . $eol; } elseif (stristr('svg|woff|otf|ttf|' . implode('|', Config::get('ViewObjects', 'font')['differentFontExtensions']), $randomPageVariableExtension)) { $return = '<style type="text/css">@font-face{font-family:"' . divide(removeExtension($randomPageVariable), "/", -1) . '"; src:url("' . $randomPageVariableBaseUrl . '") format("truetype")}</style>' . $eol; } elseif ($randomPageVariableExtension === 'eot') { $return = '<style type="text/css"><!--[if IE]>@font-face{font-family:"' . divide(removeExtension($randomPageVariable), "/", -1) . '"; src:url("' . $randomPageVariableBaseUrl . '") format("truetype")}<![endif]--></style>' . $eol; } else { $randomPageVariable = suffix($randomPageVariable, '.php'); if (is_file($randomPageVariable)) { if (is_array($randomDataVariable)) { extract($randomDataVariable, EXTR_OVERWRITE, 'zn'); } if ($randomObGetContentsVariable === false) { require $randomPageVariable; } else { ob_start(); require $randomPageVariable; $randomSomethingFileContent = ob_get_contents(); ob_end_clean(); return $randomSomethingFileContent; } } } if ($randomObGetContentsVariable === false) { echo $return; } else { return $return; } }
function listDir($fileObj, $allFile, $group, $all, $dir) { foreach ($all as $key => $singleGroup) { $parentID = $singleGroup->getParent(); if ($parentID === '0') { $thisGPID = $group->getGpidByGPName($singleGroup->getGroupName()); $allPath = $fileObj->getAllPathByGPID($thisGPID['gpid']); echo "<li><span>{$singleGroup->getGroupName()}</span><ul>"; $parentNodeName = $singleGroup->getGroupName(); $gpList = $group->getGroupListByGPName($singleGroup->getGroupName()); listNextLevel($gpList, $group, $fileObj); if (is_array($allPath)) { foreach ($allPath as $pathIndex => $path) { $filename = explode("/", $path['path']); $filename = $filename[count($filename) - 1]; $filename = removeExtension($filename); echo "<li ref=\"{$path['path']}\" onclick=\"loadPDF(this)\"><span>{$filename}</span></li>"; } } echo "</ul></li>"; } } /*if(is_dir($dir)){ if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false){ foreach ($all as $key => $groupObj) { $groupObj->getParent(); } if((is_dir($dir."/".$file)) && $file!="." && $file!=".."){ echo "<li><span>$file</span><ul>"; listDir($fileobj,$group,$all,$dir."/".$file."/"); echo "</ul></li>"; }else{ if($file!="." && $file!=".."){ $fidObj=$fileobj->getFidByPath($dir.'/'.$file); $fid=$fidObj['fid']; $groupNameID=$fileobj->getFileGroup($fid); $groupName=$group->getGroupNameByGpid($groupNameID['group']); echo "<li ref=\"$dir"."$file\" onclick=\"loadPDF(this)\"><span>$file</span></li>"; } } } closedir($dh); } }*/ }
function resize_merged_files($items, $size) { $split_array = array(); // first we check if files are split and group the splited files foreach ($items as $filename) { if (is_part($filename)) { $split_array[removeExtension($filename)][] = $filename; } } foreach ($split_array as $restore => $parts) { resize_file($restore, $size, 80, basename($restore)); } }
public function something($randomPageVariable = '', $randomDataVariable = '', $randomObGetContentsVariable = false) { if (!empty($this->parameters['usable'])) { $randomObGetContentsVariable = $this->parameters['usable']; } if (!empty($this->parameters['data'])) { $randomDataVariable = $this->parameters['data']; } $this->parameters = array(); $eol = eol(); $randomPageVariableExtension = extension($randomPageVariable); $randomPageVariableBaseUrl = baseUrl($randomPageVariable); $return = ''; if (!is_file($randomPageVariable)) { return Error::set('Error', 'fileParameter', '1.(randomPageVariable)'); } $randomPageVariable = restorationPath($randomPageVariable); if ($randomPageVariableExtension === 'js') { $return = '<script type="text/javascript" src="' . $randomPageVariableBaseUrl . '"></script>' . $eol; } elseif ($randomPageVariableExtension === 'css') { $return = '<link href="' . $randomPageVariableBaseUrl . '" rel="stylesheet" type="text/css" />' . $eol; } elseif (stristr('svg|woff|otf|ttf|' . implode('|', Config::get('Font', 'differentFontExtensions')), $randomPageVariableExtension)) { $return = '<style type="text/css">@font-face{font-family:"' . divide(removeExtension($randomPageVariable), "/", -1) . '"; src:url("' . $randomPageVariableBaseUrl . '") format("truetype")}</style>' . $eol; } elseif ($randomPageVariableExtension === 'eot') { $return = '<style type="text/css"><!--[if IE]>@font-face{font-family:"' . divide(removeExtension($randomPageVariable), "/", -1) . '"; src:url("' . $randomPageVariableBaseUrl . '") format("truetype")}<![endif]--></style>' . $eol; } else { $randomPageVariable = suffix($randomPageVariable, '.php'); if (is_file($randomPageVariable)) { if (is_array($randomDataVariable)) { extract($randomDataVariable, EXTR_OVERWRITE, 'zn'); } if ($randomObGetContentsVariable === false) { require $randomPageVariable; } else { ob_start(); require $randomPageVariable; $randomContentVariable = ob_get_contents(); ob_end_clean(); return $randomContentVariable; } } } if ($randomObGetContentsVariable === false) { echo $return; } else { return $return; } }
} if (isset($_POST['action'])) { if ($_POST['action'] == "backup" && isset($_POST['label'])) { $result = minecraftBackupWorld($_REQUEST['id'], $_POST['label']); if ($result === true) { $message = "World backed up successfully."; } else { $message = $result; } } else { if ($_POST['action'] == "remove" && isset($_POST['filename'])) { minecraftServerDelete($_REQUEST['id'], $_POST['filename'], "."); $message = "Backup deleted."; } else { if ($_POST['action'] == "restore" && isset($_POST['filename'])) { $result = minecraftRestoreWorld($_REQUEST['id'], removeExtension($_POST['filename'])); if ($result === true) { $message = "The world has been restored based on the backup successfully."; } else { $message = $result; } } } } if (!isset($_SESSION['noredirect'])) { header("Location: backup.php?id=" . $_REQUEST['id'] . "&message=" . urlencode($message)); return; } } //list backups to show which ones can be deleted or restored $backups = minecraftServerList($_REQUEST['id'], "backups");
/** * Handle Caching. * * Note: Most of the hooks related to caching are called from module_parser.php, * parseTemplate(). This is because this function is a smarty callback, and gets * called multiple times for each page (separately for each include as wel as * recursive templates like [[body]], [[introduction]] and other block level tags) * The only exceptions is clear_cache(), for which we _do_ handle the hooks here. * * @see http://www.smarty.net/manual/en/section.template.cache.handler.func.php */ function pivotxCacheHandler($action, &$smarty_obj, &$cache_content, $tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) { global $PIVOTX, $compressor, $weblogmessage; // create unique cache key, if we don't have one yet. if (empty($cache_id)) { $cache_id = "tpl_" . substr(md5($tpl_file . $cache_id . $compile_id), 0, 10); } $basename = removeExtension(basename($tpl_file)); // Set the filename of our cachefile.. $cachefile = sprintf("%s%s_%s.cache", $PIVOTX['paths']['cache_path'], $cache_id, $basename); switch ($action) { case 'read': // Read a cached page from disk. This is also used for the is_cached() function. if (substr($tpl_file, 0, 3) != "db:") { if (file_exists($cachefile) && is_readable($cachefile)) { $cache_content = file_get_contents($cachefile); // debug("read cache: $tpl_file, $cache_id"); $result = true; } else { $result = false; } } else { $result = false; } break; case 'write': // save cache to database // Do not cache pages with a 'weblogmessage'. if (!empty($weblogmessage)) { return ""; } if (substr($tpl_file, 0, 3) != "db:") { // We split what's to be written to the cache in a $meta and $html part list($meta, $html) = explode("}}", $cache_content); // Execute the hooks, if present. $PIVOTX['extensions']->executeHook('after_parse', $html); // We need to rewrite before we write to the cache $os = OutputSystem::instance(); $html = $os->rewriteHtml($html); // Put $meta and $html back together.. $cache_content = $meta . "}}" . $html; // Save the file to disk.. $fp = fopen($cachefile, "wb"); fwrite($fp, $cache_content); fclose($fp); // debug("write cache: $tpl_file, $cache_id"); // We set the result to true, because regardless of whether we saved // successfully, we _did_ change the $cache_contents. $result = true; } else { // Do not cache db:123456 (these are our own recursive templates) $result = false; } break; case 'clear': // debug("clear from cache: $tpl_file, $cache_id"); // Execute the cache_clear hook, if present. $PIVOTX['extensions']->executeHook('cache_clear', $basename); $dir = dir($PIVOTX['paths']['cache_path']); while (false !== ($file = $dir->read())) { if (strpos($file, ".cache") > 0) { unlink($PIVOTX['paths']['cache_path'] . $file); } } $dir->close(); break; default: // error, unknown action $return = false; break; } return $result; }
public function use(...$fonts) { $eol = EOL; $str = "<style type='text/css'>" . $eol; $args = $this->_parameters($fonts, 'fonts'); $lastParam = $args->lastParam; $arguments = $args->arguments; $links = $args->cdnLinks; foreach ($arguments as $font) { if (is_array($font)) { $font = ''; } $f = divide($font, "/", -1); // SVG IE VE MOZILLA DESTEKLEMIYOR $fontFile = FONTS_DIR . $font; if (!is_file($fontFile)) { $fontFile = EXTERNAL_FONTS_DIR . $font; } $baseUrl = baseUrl($fontFile); if (extension($fontFile)) { if (is_file($fontFile)) { $strEx = Import::something($fontFile, '', true); break; } } if (is_file($fontFile . ".svg")) { $str .= '@font-face{font-family:"' . $f . '"; src:url("' . $baseUrl . '.svg") format("truetype")}' . $eol; } if (is_file($fontFile . ".woff")) { $str .= '@font-face{font-family:"' . $f . '"; src:url("' . $baseUrl . '.woff") format("truetype")}' . $eol; } // OTF IE VE CHROME DESTEKLEMIYOR if (is_file($fontFile . ".otf")) { $str .= '@font-face{font-family:"' . $f . '"; src:url("' . $baseUrl . '.otf") format("truetype")}' . $eol; } // TTF IE DESTEKLEMIYOR if (is_file($fontFile . ".ttf")) { $str .= '@font-face{font-family:"' . $f . '"; src:url("' . $baseUrl . '.ttf") format("truetype")}' . $eol; } // CND ENTEGRASYON $cndFont = isset($links[strtolower($font)]) ? $links[strtolower($font)] : NULL; if (!empty($cndFont)) { $str .= '@font-face{font-family:"' . divide(removeExtension($cndFont), "/", -1) . '"; src:url("' . $cndFont . '") format("truetype")}' . $eol; } // FARKLI FONTLAR $differentSet = Config::get('ViewObjects', 'font')['differentFontExtensions']; if (!empty($differentSet)) { foreach ($differentSet as $of) { if (is_file($fontFile . prefix($of, '.'))) { $str .= '@font-face{font-family:"' . $f . '"; src:url("' . $baseUrl . prefix($of, '.') . '") format("truetype")}' . $eol; } } } // EOT IE DESTEKLIYOR if (is_file($fontFile . ".eot")) { $str .= '<!--[if IE]>'; $str .= '@font-face{font-family:"' . $f . '"; src:url("' . $baseUrl . '.eot") format("truetype")}'; $str .= '<![endif]-->'; $str .= $eol; } } $str .= '</style>' . $eol; if (isset($strEx)) { $str = $strEx; } if (!empty($str)) { if ($lastParam === true) { return $str; } else { echo $str; } } else { return false; } }
public function zipExtract(string $source, string $target = NULL) : bool { $source = File::rpath($source); $target = File::rpath($target); $source = suffix($source, '.zip'); if (!file_exists($source)) { throw new FileNotFoundException($source); } if (empty($target)) { $target = removeExtension($source); } $zip = new ZipArchive(); if ($zip->open($source) === true) { $zip->extractTo($target); $zip->close(); return true; } else { return false; } }
public function do(string $fpath, array $set) : string { $filePath = trim($fpath); if (strstr($filePath, baseUrl())) { $filePath = str_replace(baseUrl(), '', $filePath); } if (!file_exists($filePath)) { throw new ImageNotFoundException('ImageProcessing', 'image:notFoundError', $filePath); } if (!$this->isImageFile($filePath)) { throw new InvalidImageFileException('ImageProcessing', 'image:notImageFileError', $filePath); } list($currentWidth, $currentHeight) = getimagesize($filePath); $width = $set["width"] ?? $currentWidth; $height = $set["height"] ?? $currentHeight; $rewidth = $set["rewidth"] ?? 0; $reheight = $set["reheight"] ?? 0; $x = $set["x"] ?? 0; $y = $set["y"] ?? 0; $quality = $set["quality"] ?? 0; if (isset($set["proheight"])) { if ($set["proheight"] < $currentHeight) { $height = $set["proheight"]; $width = round($currentWidth * $height / $currentHeight); } } if (isset($set["prowidth"])) { if ($set["prowidth"] < $currentWidth) { $width = $set["prowidth"]; $height = round($currentHeight * $width / $currentWidth); } } $rWidth = $width; $rHeight = $height; if (!empty($rewidth)) { $width = $rewidth; } if (!empty($reheight)) { $height = $reheight; } $prefix = "-" . $x . "x" . $y . "px-" . $width . "x" . $height . "size"; $this->newPath($filePath); if (!Folder::exists($this->thumbPath)) { Folder::create($this->thumbPath); } $newFile = removeExtension($this->file) . $prefix . extension($this->file, true); if (file_exists($this->thumbPath . $newFile)) { return baseUrl($this->thumbPath . $newFile); } $rFile = $this->fromFileType($filePath); $nFile = imagecreatetruecolor($width, $height); if (isset($set["prowidth"]) || isset($set["proheight"])) { $rWidth = $currentWidth; $rHeight = $currentHeight; } if (extension($filePath) === "png") { imagealphablending($nFile, false); imagesavealpha($nFile, true); $transparent = imagecolorallocatealpha($nFile, 255, 255, 255, 127); imagefilledrectangle($nFile, 0, 0, $width, $height, $transparent); } imagecopyresampled($nFile, $rFile, 0, 0, $x, $y, $width, $height, $rWidth, $rHeight); $this->createFileType($nFile, $this->thumbPath . $newFile, $quality); imagedestroy($rFile); imagedestroy($nFile); return baseUrl($this->thumbPath . $newFile); }
public function thumb($fpath = '', $set = array()) { // Parametre kontrolleri yapılıyor ------------------------------------------- if (!is_string($fpath)) { return Error::set(lang('Error', 'stringParameter', 'fpath')); } if (!is_array($set)) { $set = array(); } // --------------------------------------------------------------------------- $filePath = isset($fpath) ? trim($fpath) : ''; // Yol bilgis url eki içeriyorsa // bu ekin temizlenmesi sağlanıyor. if (strstr($filePath, baseUrl())) { $filePath = str_replace(baseUrl(), '', $filePath); } // Geçersiz yol bilgisi girilmiş ise // Durumu rapor etmesi sağlanıyor. if (!file_exists($filePath)) { $this->error = getMessage('Image', 'notFoundError', $filePath); report('Error', $this->error, 'ImageLibrary'); return false; } // Dosyanın uzantısı belirlenen uzantılır dışında // ise durumu rapor etmesi sağlanıyor. if (!$this->isImageFile($filePath)) { $this->error = getMessage('Image', 'notImageFileError', $filePath); report('Error', $this->error, 'ImageLibrary'); return false; } // Ayarlar parametresinde tanımlayan ayarlara // varsayılan değerler atanıyor. list($currentWidth, $currentHeight) = getimagesize($filePath); // WIDTH Ayarı $width = isset($set["width"]) ? $set["width"] : $currentWidth; // HEIGHT Ayarı $height = isset($set["height"]) ? $set["height"] : $currentHeight; // REWIDTH Ayarı $rewidth = isset($set["rewidth"]) ? $set["rewidth"] : 0; // REHEIGHT Ayarı $reheight = isset($set["reheight"]) ? $set["reheight"] : 0; // X Ayarı $x = isset($set["x"]) ? $set["x"] : 0; // Y Ayarı $y = isset($set["y"]) ? $set["y"] : 0; // QUALITY Ayarı $quality = isset($set["quality"]) ? $set["quality"] : 0; if (isset($set["proheight"])) { if ($set["proheight"] < $currentHeight) { /* resmi ölçeklemek istediğimiz yükseklik ve genişlik */ $height = $set["proheight"]; /* resmin yeni genişliği buluyoruz */ $width = round($currentWidth * $height / $currentHeight); } } if (isset($set["prowidth"])) { if ($set["prowidth"] < $currentWidth) { /* resmi ölçeklemek istediğimiz yükseklik ve genişlik */ $width = $set["prowidth"]; /* resmin yeni genişliği buluyoruz */ $height = round($currentHeight * $width / $currentWidth); } } $rWidth = $width; $rHeight = $height; // Yeni genişlik değerinin kontrolü yapılıyor. if (!empty($rewidth)) { $width = $rewidth; } // Yeni yükseklik değerinin kontrolü yapılıyor. if (!empty($reheight)) { $height = $reheight; } // Oluşturulacak yeni dosyanın isim bilgisi oluşturuluyor. // Bu isimlendirmede şu bilgiler yer alacak. // 1-Resmin Adı // 2-X değeri // 3-Y değeri // 4-Genişlik Değeri // 5-Yükseklik Değeri $prefix = "-" . $x . "x" . $y . "px-" . $width . "x" . $height . "size"; $this->newPath($filePath); // Dizin bilgisi kontrol ediliyor. // Eğer thumb isminde bir dizin // yoksa oluşturuluyor. if (!is_dir($this->thumbPath)) { Folder::create($this->thumbPath); } // Dosya uzantısı temizleniyor. $newFile = removeExtension($this->file) . $prefix . extension($this->file, true); // Yeni oluşturulan dosya varsa yeni dosyanın // yol ve isim bilgisi oluşturuluyor. // Ve geri dönüş değeri olarak kulllanılıyor. // Böyle bir dosya daha önce yoksa // İşlemler kaldığı yerden dosya oluşturulana // kadar devam ediyor. if (file_exists($this->thumbPath . $newFile)) { return baseUrl($this->thumbPath . $newFile); } $rFile = $this->fromFileType($filePath); $nFile = imagecreatetruecolor($width, $height); if (isset($set["prowidth"]) || isset($set["proheight"])) { $rWidth = $currentWidth; $rHeight = $currentHeight; } // Dosyanın .png uzantılı olması durumunda // Kırpma işlemlerinin transparant olması // sağlanıyor. Diğer uzantılarda transparantlık // elde edilemeyeceğinden bu işlem sadece // PNG uzantılı dosyalar için gerçekleşecektir. if (extension($filePath) === "png") { imagealphablending($nFile, false); imagesavealpha($nFile, true); $transparent = imagecolorallocatealpha($nFile, 255, 255, 255, 127); imagefilledrectangle($nFile, 0, 0, $width, $height, $transparent); } @imagecopyresampled($nFile, $rFile, 0, 0, $x, $y, $width, $height, $rWidth, $rHeight); $this->createFileType($nFile, $this->thumbPath . $newFile, $quality); imagedestroy($rFile); imagedestroy($nFile); return baseUrl($this->thumbPath . $newFile); }
function tfu_createThumb($file) { global $compression, $use_image_magic, $image_magic_path, $pdf_thumb_format; if (!preg_match("/.*\\.(p|P)(d|D)(f|F)\$/", $file)) { $name = removeExtension($file) . "-" . $_GET['tfu_width'] . 'x' . $_GET['tfu_height'] . "." . getExtension($file); resize_file($file, $_GET['tfu_width'] . 'x' . $_GET['tfu_height'], $compression, basename($file), $name); } else { if ($use_image_magic) { $name = dirname(__FILE__) . '/' . removeExtension($file) . "-" . $_GET['tfu_width'] . '.' . $pdf_thumb_format; // create a pdf thumbnail $ima = realpath($file); if (!file_exists($name)) { $ima = realpath($file); $resize = $_GET['tfu_width'] . 'x' . $_GET['tfu_height']; $command = $image_magic_path . ' -colorspace rgb "' . $ima . '[0]" -border 1x1 -quality 80 -thumbnail ' . $resize . ' "' . $name . '"'; execute_command($command); } } } }