function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) { /** @var ResponseInterface $response */ $response = $next(); $lang = $this->locale->locale(); // The check for app->translation is made here instead of conditionally adding this middleware // because loaded modules can change this setting. if (!$this->settings->translation || !$lang) { return $response; } if (!isset(self::$translation[$lang])) { // Load and merge all translation files now. self::$translation[$lang] = []; $trans =& self::$translation[$lang]; $folders = $this->settings->languageFolders; foreach ($folders as $folder) { $path = "{$folder}/{$lang}.ini"; $newTrans = fileExists($path) ? parse_ini_file($path) : null; if ($newTrans) { $trans = array_merge($trans, $newTrans); } } if (!$trans) { $paths = array_map(function ($path) { return "<li>" . ErrorConsole::shortFileName($path); }, $folders); throw new ConfigException("A translation file for language <b>{$lang}</b> was not found.\n<p>Search paths:\n<ul>" . implode('', $paths) . "</ul>", FlashType::ERROR); } } $out = preg_replace_callback(self::FIND_TRANS_KEY, function ($args) use($lang) { $a = $args[1]; return empty(self::$translation[$lang][$a]) ? '$' . $a : preg_replace('#\\r?\\n#', '<br>', self::$translation[$lang][$a]); }, $response->getBody()); return $response->withBody($this->responseFactory->makeBody($out)); }
function theSkeletonDirectory() { $directory = getBowerDirectory() . 'skeleton-css/'; if (!fileExists($directory)) { consoleLog("You seem to be missing the 'skeleton-css' folder", 'error'); } print $directory; }
function showPhoto($picture = NULL, $param = NULL) { // usable parameters for photo display $height = isset($param['height']) ? $param['height'] : 100; $width = isset($param['width']) ? $param['width'] : 100; $id = isset($param['id']) ? $param['id'] : FALSE; $align = isset($param['align']) ? $param['align'] : "absmiddle"; $check = isset($param['check']) ? $param['check'] : FALSE; $nocache = isset($param['nocache']) ? $param['nocache'] : FALSE; // TRUE = disable caching, add time string to image url $title = isset($param['title']) ? $param['title'] : "User's Photo"; $class = isset($param['class']) ? $param['class'] : "user-photo"; if (isset($picture) && strlen(trim($picture)) > 0) { $remote = stristr($picture, 'http'); // do a check here to see if image is from twitter / facebook / remote URL if (!$remote) { if ($nocache) { $picture = $picture . '?t=' . md5(time()); } // only if $nocache is TRUE $path = site_url(RES_DIR . '/user/profile/' . $picture); //. -- disabled time attachment, no need to break cache } else { $path = $picture; // request proper cropped size from facebook for this photo if (stripos($path, 'graph.facebook.com')) { $path .= '?width=' . $width . '&height=' . $height; // this appends size requirements to facebook image } // request bigger photo from twitter if (stripos($path, 'twimg.com')) { if ($height > 75) { $path = str_replace('_normal', '_bigger', $path); // this forces _bigger 73x73 sized image (over default 48x48), no custom crop offered } if ($height < 25) { $path = str_replace('_normal', '_mini', $path); // this forces _mini 24x24 sized image (over default 48x48), no custom crop offered } } } if ($check && !$remote) { if (!fileExists($path)) { $title = "Photo not found! "; $path = site_url(RES_DIR . '/img/default-person.png'); } } } else { $path = site_url(RES_DIR . '/img/default-person.png'); } return '<img ' . ($id ? 'id="' . $id . '"' : '') . ' src="' . $path . '" height="' . $height . '" width="' . $width . '" title="' . $title . '" alt="' . $title . '" class="' . $class . '">'; }
function fileValid($bucket, $file, $interval) { syslog(LOG_DEBUG, "fileValid: file " . $file); try { if (fileExists($bucket, $file)) { $mTime = lastModifiedTime($bucket, $file); $date = new DateTime(); $curTime = $date->getTimestamp(); if ($curTime - $mTime < $interval) { return true; } } return false; } catch (Exception $e) { syslog(LOG_ERR, $e->getMessage()); return false; } }
function fileUpload($imgFile) { $file_path = $_SESSION['rootDir'] . '/images/gallery/' . basename($imgFile["name"]); if (fileExists($file_path)) { if (move_uploaded_file($imgFile["tmp_name"], $file_path)) { resizeImage($file_path); return 'images/gallery/' . basename($imgFile["name"]); } else { $_SESSION['status'] = 'error'; $_SESSION['flashData'] = 'File can not be uploaded'; header('location:' . baseUrl . 'admin/gallery/'); exit; } } else { $_SESSION['status'] = 'error'; $_SESSION['flashData'] = 'Same file cannot be uploaded twice'; header('location:' . baseUrl . 'admin/gallery/'); } }
function refreshJSCache() { $dest = listFilesFromType("html", "php"); $avFuncs = array(); $needFuncs = array(); $destFiles = array(); foreach ($dest as $file) { $destPath = "html/" . getScriptJS($file); if (!in_array($destPath, $destFiles)) { $destFiles[] .= $destPath; $avFuncs = listAvailableFunctions("scripts/source/script.js"); $needFuncs = listNeededFunctions($file, $avFuncs); $needFuncs = listDependences($needFuncs, $avFuncs); $source = getFunctionsSrc($needFuncs, $avFuncs); if (count($needFuncs) != 0) { if (fileExists($destPath)) { if (@unlink($destPath)) { echo start_comment . "File " . $destPath . " unlinked !" . end_comment . "\n"; } } $handleW = @fopen($destPath, "w"); if ($handleW) { fwrite($handleW, $source); echo start_comment . "File " . $destPath . " done !" . end_comment . "\n"; foreach ($needFuncs as $function) { echo start_comment . $function . end_comment . "\n"; } } else { echo "error khudsf87098df<br>"; } @fclose($handleW); } } } }
foreach ($amenu as $m => $k) { natcasesort($k); foreach ($k as $l) { ${$m} .= $l; } } if (empty($rootmenu)) { $radmin1 = '/*'; $radmin2 = '*/'; } if (empty($settingsmenu)) { $adminc1 = '/*'; $adminc2 = '*/'; } if (function_exists('fsockopen')) { $dzcp_v = fileExists("http://www.dzcp.de/version.txt"); if ($dzcp_v <= _version) { $version = '<b>' . _akt_version . ': <span class="fontGreen">' . _version . '</span></b>'; $old = ""; } else { $version = "<a href=\"http://www.dzcp.de\" target=\"_blank\" title=\"external Link: www.dzcp.de\"><b>" . _akt_version . ":</b> <span class=\"fontRed\">" . _version . "</span></a>"; $old = "_old"; } $dzcp_news = @file_get_contents('http://www.dzcp.de/dzcp_news.php'); } if (@file_exists(basePath . "/_installer") && $chkMe == 4) { $index = _installdir; } else { $index = show($dir . "/admin", array("head" => _config_head, "forumkats" => $fkats, "newskats" => $nkats, "version" => $version, "old" => $old, "dbase" => _stats_mysql, "einst" => _config_einst, "content" => _content, "newsticker" => '<div style="padding:3px">' . (empty($dzcp_news) ? '' : '<b>DZCP News:</b><br />') . '<marquee direction="right" scrollamount="5" scrolldelay="10" onmouseover="this.stop()" onmouseout="this.start()">' . $dzcp_news . '</marquee></div>', "rootadmin" => _rootadmin, "rootmenu" => $rootmenu, "settingsmenu" => $settingsmenu, "contentmenu" => $contentmenu, "radmin1" => $radmin1, "radmin2" => $radmin2, "adminc1" => $adminc1, "adminc2" => $adminc2, "show" => $show)); } }
case "upload": if (isset($_POST['dir'])) { upload($_POST['dir']); } break; case "uploadSmart": uploadSmart(); break; case "uploadAuth": if (isset($_POST['path'])) { uploadAuth($_POST['path']); } break; case "fileExists": if (isset($_POST['path'])) { fileExists($_POST['path']); } break; case "thumbnail": if (isset($_POST['fileid'])) { thumbnail($_POST['fileid']); } break; case "newPassword": if (isset($_POST['currentPassword'], $_POST['newPassword'])) { newPassword($_POST['currentPassword'], $_POST['newPassword']); } break; case "getThumb": if (isset($_GET['path'], $_GET['filename'])) { getThumb($_GET['path'], $_GET['filename']);
} //echo "Breite: ".$breite_neu.", Höhe: ".$hoehe_neu; if ($breite_neu < $hoehe_neu) { //falls die Ausrichtung falsch in den EXIF-Daten gespeichert wurde, kann das Vorschau-Bild nachtraeglich gedreht werden: echo "\n\t\t\t\t<TD align='center' colspan='1' width = '130px' style= 'padding-top:2px; padding-bottom:2px;'>\n\t\t\t\t<img src='{$inst_path}/pic2base/bin/share/images/no_pic.gif' width='124' height='0' />\n\t\t\t\t<div id='pic{$pic_id}'>\n\t\t\t\t<SPAN style='cursor:pointer;' onClick='rotPrevPic(\"8\", \"{$FileNameV}\", \"{$pic_id}\", \"{$fs_hoehe}\")'><img src=\"{$inst_path}/pic2base/bin/share/images/90-ccw.gif\" width=\"8\" height=\"8\" style='margin-right:10px;' title='Vorschaubild 90° links drehen' /></span>"; getHQPreviewNow($pic_id, $hoehe_neu, $breite_neu, $base_file, isset($kat_id), $mod, $form_name); echo "\n\t\t\t\t<SPAN style='cursor:pointer;' onClick='rotPrevPic(\"6\", \"{$FileNameV}\", \"{$pic_id}\", \"{$fs_hoehe}\")'><img src=\"{$inst_path}/pic2base/bin/share/images/90-cw.gif\" width=\"8\" height=\"8\" style='margin-left:10px;' title='Vorschaubild 90° rechts drehen' /></span>\n\t\t\t\t</div>\n\t\t\t\t</TD>"; } else { echo "<TD align='center' colspan='1' width = '130px' style= 'padding-top:2px; padding-bottom:2px;'>\n\t\t\t\t<div id='pic{$pic_id}'>"; getHQPreviewNow($pic_id, $hoehe_neu, $breite_neu, $base_file, isset($kat_id), $mod, $form_name); echo "\n\t\t\t\t</div>\n\t\t\t\t</TD>"; } //Erzeugung der Download-Icons: $Owner = mysql_result($result6, $i6, 'Owner'); //Pruefung, ob diese Datei bereits im Download-Ordner des angemeldeten Users liegt. Wenn nicht: Download-Icon mit link zur Kopier-Routine; wenn ja: selected-Icon mit Link zur L�sch-Routine: $check = fileExists($FileName, $c_username); if ($check > '0') { //Die Datei befindet sich im Download-Ordner des Users und wird mit Klick auf das Icon geloescht: $icon[$i6] = "\n\t\t\t\t<TD align='center' width='43'>\n\t\t\t\t<div id='box{$pic_id}'>\n\t\t\t\t<SPAN style='cursor:pointer;' onClick='delPicture(\"{$FileName}\",\"{$c_username}\",\"{$pic_id}\")'>\n\t\t\t\t<img src='{$inst_path}/pic2base/bin/share/images/selected.gif' width='12' height='12' hspace='0' vspace='0'/>\n\t\t\t\t</SPAN>\t\n\t\t\t\t</div>\n\t\t\t\t</TD>"; } else { //echo $Owner.", ".$user_id; //Die Datei befindet sich nicht im Download-Ordner des Users und wird mit Klick auf das Icon dort hin kopiert: if (hasPermission($c_username, 'adminlogin') or hasPermission($c_username, 'downloadpic')) { $icon[$i6] = "\n\t\t\t\t\t<TD align='center'width='43'>\n\t\t\t\t\t<div id='box{$pic_id}'>\n\t\t\t\t\t<SPAN style='cursor:pointer;' onClick='copyPicture(\"{$FileName}\",\"{$c_username}\",\"{$pic_id}\")'><img src='{$inst_path}/pic2base/bin/share/images/download.gif' width='12' height='12' hspace='0' vspace='0' title='Bild in den Download-Ordner kopieren'/></SPAN>\n\t\t\t\t\t</div>\t\n\t\t\t\t\t</TD>"; } else { $icon[$i6] = "<TD align='center' width='43'><BR></TD>"; } } } //Leer-Raum mit Leer-Zellen auffuellen (Zelle mit Dummy-Bild zur Streckung gefuellt), wenn Bilder gefunden wurden: if ($num6_1 > '0') {
<!DOCTYPE > <html> <head> <meta charset="utf-8" /> <title>数据录入</title> </head> <body> <?php $select = $_GET['data_select']; $key = $_GET['data_key']; $value = $_GET['data_value']; $fileName = '../data/dataInfo.json'; require_once '../tool/file.tool.php'; fileExists($fileName, "[[],[],[],[],[]]"); $file = file_get_contents($fileName); $json = json_decode($file); $jsonS = $json[$select]; $length = count($jsonS); $json[$select][$length] = array('key' => $key, 'value' => $value); $json2 = json_encode($json); file_put_contents($fileName, $json2); ?> <h1 id='show'>数据录入中,5秒后回到首页 </h1> <script> var oShow = document.getElementById('show'); var count = 0;
/** * Registers a module's macros directory, along with any immediate sub-directories. * * @param ModuleInfo $moduleInfo * @return $this */ function registerMacros(ModuleInfo $moduleInfo) { $path = "{$this->kernelSettings->baseDirectory}/{$moduleInfo->path}/{$this->moduleMacrosPath}"; if (fileExists($path)) { $all = FilesystemFlow::from($path)->onlyDirectories()->keys()->all(); array_unshift($all, $path); $this->macrosDirectories = array_merge($all, $this->macrosDirectories); } return $this; }
function deleteImage($fileName = "") { if ($fileName != "") { if (fileExists($fileName . ".gif")) { @unlink($fileName . ".gif"); return True; } } elseif (isset($_SESSION['userCheck'])) { if (fileExists($_SESSION['userCheck'] . ".gif")) { @unlink($_SESSION['userCheck'] . ".gif"); } unset($_SESSION['userCheck']); return True; } else { return False; } }
public function importTableHeaderFromCSV($file) { $filename = $file . ".csv"; if (!fileExists($filename) and $this->entityexist($file)) { echo "import can only in a new table"; die; } $CSVHandler = new CSVHandler($filename); $CSVHandler->countColumns(); $data = $CSVHandler->getHeaders(); $HelperFunctions = new HelperFunctions(); $data = $HelperFunctions->array_trim($data); $Evaluator = new Evaluator(); $date = array_filter($data, $Evaluator->returnOnlyLettersNumbersUnderscore($data)); $sql = "CREATE TABLE IF NOT EXISTS ` " . $file . " ` ("; for ($i = 0; $i <= $CSVHandler->countColumns(); $i++) { if ($i == 0) { $sql .= "`" . $data[$i] . "` int(11) NOT NULL auto_increment"; } $sql .= "`" . $data[$i] . "` varchar(255) NOT NULL default ''"; if ($i == 0) { $sql .= "PRIMARY KEY (`" . $data[$i] . "`)"; } } $sql .= ")"; $result = $this->executeGenericStatement($sql); if (empty($result)) { return NULL; } }
function requirePackage($package, $file) { if (fileExists('/app/packages/' . $package . '/' . $file)) { require_once path('/app/packages/' . $package . '/' . $file); } else { display_error('The file ' . path('/app/packages/' . $package . '/' . $file) . ' does not exist'); } }
/** * Shows users photo * @param string $picture Description * @param Array $param Array with parameters to be included in the generated img tag (height, width, id, check, nocache, title, class) * @return string */ function showPhoto($picture = NULL, $param = NULL, $path = null, $defaultPath = null) { if (!is_array($param)) { $param = array(); } if (!$path) { $path = base_url() . RES_DIR . '/user/profile/'; } if (!$defaultPath) { $defaultPath = base_url() . RES_DIR . '/img/user.png'; } // usable parameters for photo display $check = isset($param['check']) ? $param['check'] : FALSE; $nocache = isset($param['nocache']) ? $param['nocache'] : FALSE; // TRUE = disable caching, add time string to image url unset($param['check'], $param['nocache']); $height = isset($param['height']) ? (int) $param['height'] : 100; $width = isset($param['width']) ? (int) $param['width'] : 100; $param['alt'] = isset($param['alt']) ? trim($param['alt']) : ''; if (isset($picture) && strlen(trim($picture)) > 0) { $remote = stristr($picture, 'http'); // do a check here to see if image is from twitter / facebook / remote URL if (!$remote) { if ($nocache) { $picture = $picture . (strpos($path, '?') === false ? '?' : '&') . 't=' . md5(time()); } // only if $nocache is TRUE $path .= $picture; //. -- disabled time attachment, no need to break cache } else { $path = $picture; // request proper cropped size from facebook for this photo if (stripos($path, 'graph.facebook.com')) { $path .= (strpos($path, '?') === false ? '?' : '&') . 'width=' . $width . '&height=' . $height; // this appends size requirements to facebook image } // request bigger photo from twitter if (stripos($path, 'twimg.com')) { if ($height > 75) { $path = str_replace('_normal', '_bigger', $path); // this forces _bigger 73x73 sized image (over default 48x48), no custom crop offered } if ($height < 25) { $path = str_replace('_normal', '_mini', $path); // this forces _mini 24x24 sized image (over default 48x48), no custom crop offered } } } if ($check && !$remote) { if (!fileExists($path)) { $title = "Imagen no encontrada! "; $path = $defaultPath; } } } else { $path = $defaultPath; } $param['src'] = $path; $output = "<img "; foreach ($param as $key => $value) { $output .= $key . '="' . $value . '" '; } $output .= "/>"; return $output; }
function generateGeoImageArray($pic_id_arr, $userName, $uID, $softwareRoot) { //$start1 = microtime(); //Startzeit-Variable zur Laufzeitermittlung //flush(); include $softwareRoot . '/bin/share/db_connect1.php'; $res = ""; $num_pic = count($pic_id_arr); //Gesamtzahl der gefundenen Bilder for ($imageArrayIndex = 0; $imageArrayIndex < $num_pic; $imageArrayIndex++) { $res1 = mysql_query("SELECT * FROM {$table2} WHERE pic_id = '{$pic_id_arr[$imageArrayIndex]}'"); $fileName = mysql_result($res1, 0, 'FileName'); $fileNamePrefix = str_replace('.jpg', '', $fileName); $ratio = mysql_result($res1, 0, 'ExifImageWidth') / mysql_result($res1, 0, 'ExifImageHeight'); if (mysql_result($res1, 0, 'Orientation') >= '5') { $ratio = 1.0 / $ratio; } $downloadStatus = 0; //Erzeugung der Download-Icons: $Owner = mysql_result($res1, 0, 'Owner'); $check = fileExists($fileNamePrefix, $uID); if ($check > 0) { //Die Datei befindet sich im Download-Ordner des Users und wird mit Klick auf das Icon geloescht: $downloadStatus = 100; } else { //Die Datei befindet sich nicht im Download-Ordner des Users und wird mit Klick auf das Icon dort hin kopiert: if ($uID == $Owner and hasPermission($uID, 'downloadmypics', $softwareRoot) or hasPermission($uID, 'downloadallpics', $softwareRoot)) { if (directDownload($uID, $softwareRoot)) { $downloadStatus = 1; } else { $downloadStatus = 2; } } else { $downloadStatus = 0; } } $res .= 'imageArray.push({fileName: "' . $fileNamePrefix . '", ratio: ' . $ratio . ', id: "' . $fileNamePrefix . '", downloadStatus: ' . $downloadStatus . ', Owner: ' . $Owner . '}); '; } return $res; }
<?php date_default_timezone_set('Asia/ShangHai'); $time = time(); $filename = "../data/record.json"; require_once '../tool/file.tool.php'; fileExists($filename, '[{"datetime":0}]'); $json_string = file_get_contents($filename); $json2 = json_decode($json_string, true); $a = $json2[0]['datetime']; $b = $a - $time; $c = 'false'; if ($b < -86400) { $json2[0]['datetime'] = $time; $json = json_encode($json2); file_put_contents($filename, $json); $c = 'true'; } else { $d = date('Ymd', $time); $f = date('Ymd', $a); $e = $f - $d; if ($e < 0) { $json2[0]['datetime'] = $time; $json = json_encode($json2); file_put_contents($filename, $json); $c = 'true'; } } echo $c; ?>
function checkIfFileExists($file) { return fileExists($file); }
break; } $sql = "SELECT T_topography.Is_public, T_file.Path, T_topography.Enabled "; $sql .= "FROM `" . $_SESSION['Application_host'] . "`.`T_topography` "; $sql .= "INNER JOIN `" . $_SESSION['Application_host'] . "`.`J_topo_file` ON J_topo_file.Id_topography = T_topography.Id "; $sql .= "INNER JOIN `" . $_SESSION['Application_host'] . "`.`T_file` ON T_file.Id = J_topo_file.Id_file "; $sql .= "WHERE T_file.Id_author = " . $topo_usr_id . " AND T_topography.Id = " . $topo_id . " AND T_file.Path LIKE '%u" . $topo_usr_id . "_t" . $topo_id . "_r" . $random_id . "%' "; $data = getDataFromSQL($sql, __FILE__, $frame, __FUNCTION__); if ($data['Count'] < 1) { $code_err = 2; break; } // MANQUE LE CAS OU LA PERSONNE CONNECTEE NE DEVRAIS PAS POUVOIR VOIR LA TOPO !!! if (USER_IS_CONNECTED || $data[0]['Is_public'] == 'YES' && $data[0]['Enabled'] == 'YES') { $filename = basename($data[0]['Path']); if (!fileExists($filename)) { $code_err = 3; break; } /*$kind = (exif_imagetype($filename)) ? 'image' : 'application'; header('Content-Type: '.$kind.'/'.strtolower(getFileExtension($filename)));*/ header('Content-Type: image/' . strtolower(getFileExtension($filename))); readfile($filename); } else { $code_err = 4; break; } break; default: $code_err = 100; break;
function generateImageArray($sqlResult, $userName, $uID, $softwareRoot) { $res = ""; $sqlResultNumRows = mysql_num_rows($sqlResult); for ($imageArrayIndex = 0; $imageArrayIndex < $sqlResultNumRows; $imageArrayIndex++) { $fileName = mysql_result($sqlResult, $imageArrayIndex, 'FileName'); $fileNamePrefix = str_replace('.jpg', '', $fileName); /* $ratio = (mysql_result($sqlResult, $imageArrayIndex, 'ExifImageWidth') / mysql_result($sqlResult, $imageArrayIndex, 'ExifImageHeight')); if (mysql_result($sqlResult, $imageArrayIndex, 'Orientation') >= '5') { $ratio = 1.0 / $ratio; } */ if (mysql_result($sqlResult, $imageArrayIndex, 'ExifImageHeight') !== '0') { $ratio = mysql_result($sqlResult, $imageArrayIndex, 'ExifImageWidth') / mysql_result($sqlResult, $imageArrayIndex, 'ExifImageHeight'); if (mysql_result($sqlResult, $imageArrayIndex, 'Orientation') >= '5') { $ratio = 1.0 / $ratio; } } else { $ratio = 1; // hier ggf. Mail an Admin versenden } $downloadStatus = 0; //Erzeugung der Download-Icons: $Owner = mysql_result($sqlResult, $imageArrayIndex, 'Owner'); $check = fileExists($fileName, $uID); if ($check > 0) { //Die Datei befindet sich im Download-Ordner des Users und wird mit Klick auf das Icon geloescht: $downloadStatus = 100; } else { //Die Datei befindet sich nicht im Download-Ordner des Users und wird mit Klick auf das Icon dort hin kopiert: if ($uID == $Owner and hasPermission($uID, 'downloadmypics', $softwareRoot) or hasPermission($uID, 'downloadallpics', $softwareRoot)) { if (directDownload($uID, $softwareRoot)) { $downloadStatus = 1; } else { $downloadStatus = 2; } } else { $downloadStatus = 0; } } $res .= 'imageArray.push({fileName: "' . $fileNamePrefix . '", ratio: ' . $ratio . ', id: "' . mysql_result($sqlResult, $imageArrayIndex, 'pic_id') . '", downloadStatus: ' . $downloadStatus . ', Owner: ' . $Owner . '}); '; } return $res; }
/** * Finds the location of a trial type's files. Returns either an array of file * paths or the boolean false if the type cannot be found. * @param string $trialTypeName The name of the trial type * @return mixed */ function getTrialTypeFiles($trialTypeName) { global $_PATH; // convert user inputs to lowercase; e.g. 'Likert' === 'likert' $trialType = strtolower(trim($trialTypeName)); // initialize a static variable to cache the results, so that we can run // the function multiple times and efficiently get our data back static $trialTypes = array(); if (isset($trialTypes[$trialType])) { return $trialTypes[$trialType]; } // as it stands, we have two places where trial types can be found // we will search the Experiment/ folder first, so that if we find // the trial type, we won't have to look in the Code/ folder // this way, the Experiment/ trial types will overwrite the Code/ types $customDisplay = $_PATH->get('custom trial display', 'relative', $trialType); $normalDisplay = $_PATH->get('trial display', 'relative', $trialType); if (fileExists($customDisplay)) { $pre = 'custom trial '; } elseif (fileExists($normalDisplay)) { $pre = 'trial '; } else { return false; } $files = array('display', 'scoring', 'helper', 'script', 'style'); $foundFiles = array(); foreach ($files as $file) { $path = $_PATH->get($pre . $file, 'relative', $trialType); $existingPath = fileExists($path); if ($existingPath !== false) { $foundFiles[$file] = $existingPath; } } if (!isset($foundFiles['scoring'])) { $foundFiles['scoring'] = $_PATH->get('default scoring'); } if (!isset($foundFiles['helper'])) { $foundFiles['helper'] = $_PATH->get('default helper'); } return $foundFiles; }
<?php header('Content-type: application/json'); chdir("../.."); chdir("database"); require_once "files.php"; chdir(".."); require_once "configuration.php"; /** * DESCRIPTION: Gets the file id from the database * PARAMETERS: api/files/getId.php <apikey> <path> <user> */ if (isset($_GET['apikey']) and isset($_GET['path']) and isset($_GET['user'])) { $auth = (string) $_GET['apikey']; if ($auth != $apikey) { echo json_encode(array("result" => "permissionDenied")); } else { $path = (string) $_GET['path']; $user = (string) $_GET['user']; if (fileExists($path, $user)) { $id = getFileId($user, $path); echo json_encode(array("result" => "ok", "id" => $id)); } else { echo json_encode(array("result" => "invalidFile")); } } } else { echo json_encode(array("result" => "missingParams")); }
function fileUpload($imgFile) { $imgName = basename($imgFile['name']); $finalName = preg_replace('/\\s+/', '', $imgName); $file_path = $_SESSION['rootDir'] . '/images/trip/' . $finalName; if (fileExists($file_path)) { if (move_uploaded_file($imgFile["tmp_name"], $file_path)) { resizeImage($file_path); return 'images/trip/' . $finalName; } else { $_SESSION['status'] = 'error'; $_SESSION['flashData'] = 'File can not be uploaded'; header('location:' . baseUrl . 'admin/addTrip'); exit; } } else { $_SESSION['status'] = 'error'; $_SESSION['flashData'] = 'Same file cannot be uploaded twice'; header('location:' . baseUrl . 'admin/addTrip'); } }
if (strcasecmp($x[0], 'HTTP/1.1 200 OK') != 0) { $x = $x['content-length'][1]; } else { $x = $x['content-length']; } } else { $x = @filesize($url); } return $x; } $fileSize = getFileSize($file_url); function fileExists($path) { return @fopen($path, "r") == true; } if (!fileExists($file_url)) { die("<br> The file <b>" . $file_url . "</b> doesn't exist; check the URL"); } //This will set the Content-Type to the appropriate setting for the file switch ($file_extension) { case 'mp3': $content_type = 'audio/mpeg'; break; case 'mp4a': $content_type = 'audio/mp4'; break; case 'wav': $content_type = 'audio/x-wav'; break; case 'ogg': $content_type = 'audio/ogg';
* echo "done" */ // FB usually resets search quotas after 1 hr. Do every search at least 1 hr apart. $interval = 3600; // 1 hr $proceed = true; if (fileExists($bucket, $eventsFile)) { $mTime = lastModifiedTime($bucket, $eventsFile); $date = new DateTime(); $curTime = $date->getTimestamp(); if ($curTime - $mTime < $interval) { $proceed = false; } } if ($proceed) { if (fileExists($bucket, $pagesFile)) { $mTime = lastModifiedTime($bucket, $pagesFile); $date = new DateTime(); $curTime = $date->getTimestamp(); if ($curTime - $mTime < $interval) { $proceed = false; } } } if ($proceed) { $pages = array(); fbBatchSearch($pages, $fb, $pageSearchStrings, 'nextFullBatchPages', 'validatePage'); $pagesContent = json_encode($pages); if (storeGCS($pagesContent, $bucket, $pagesFile) != 0) { syslog(LOG_ERR, "Failed to store " . $pagesFile); }