/** * function for checking if your are denying people * from e.g. admin areas of your module. */ function dev_test_access($options = null) { $files = file::getFileListRecursive(conf::pathModules(), "*module.php"); foreach ($files as $val) { $class_path = "modules" . str_replace(conf::pathModules(), '', $val); $class_path = str_replace('.php', '', $class_path); $class = str_replace('/', "\\", $class_path); $ary = get_class_methods($class); if (!is_array($ary)) { continue; } $call_paths = dev_get_actions($ary, $class_path); foreach ($call_paths as $path) { $url = conf::getSchemeWithServerName() . "{$path}"; $curl = new mycurl($url); $curl->createCurl(); echo $curl->getHttpStatus(); common::echoMessage(" Status code recieved on: {$url}"); } } }
/** * Images are stored in database. * @param type $url * @return boolean */ public function checkImage($url) { $id = direct::fragment(2, $url); $title = direct::fragment(3, $url); $path = "/images/{$id}/{$title}"; $save_path = conf::getFullFilesPath($path); $web_path = conf::getWebFilesPath($path); $image_url = conf::getSchemeWithServerName() . $url; $code = headers::getReturnCode($image_url); if ($code != 200) { log::error("Could not get file content (image). Got: {$code} " . $image_url); return false; } return $url; }
/** * Images are stored in database. * @param type $url * @return boolean */ public function saveImage($url) { $id = direct::fragment(2, $url); $title = direct::fragment(3, $url); $title = rawurlencode($title); $path = "/images/{$id}/{$title}"; $save_path = conf::getFullFilesPath($path); $web_path = conf::getSchemeWithServerName() . conf::getWebFilesPath($path); $code = headers::getReturnCode($web_path); if ($code != '200') { log::error("Could not get file content (image). Got: {$code} " . $web_path . ' in ' . __CLASS__); return false; } return $save_path; }
/** * set canonical link rel * @param string $canon path without server scheme and name */ public static function setCanonical($canon) { $canon = conf::getSchemeWithServerName() . $canon; $str = "<link rel=\"canonical\" href=\"{$canon}\" />\n"; self::setMetaAsStr($str); }
protected function saveImage($url) { $id = direct::fragment(2, $url); $title = direct::fragment(3, $url); $path = "/images/{$id}/{$title}"; $save_path = conf::getFullFilesPath($path); $web_path = conf::getWebFilesPath($path); $image_url = conf::getSchemeWithServerName() . $url; $code = headers::getReturnCode($image_url); if ($code != 200) { log::error("Could not get file content (image). Got: {$code} " . $image_url); return ''; } else { $file = file_get_contents($image_url); } // make dir $dir = dirname($path); file::mkdir($dir); file_put_contents($save_path, $file); return $web_path; }