function openfire_authenticate($user, $username, $password) { global $openfire; $openfire->of_logInfo("openfire_authenticate 1 " . $username . " " . $password); if (!openfire_wants_to_login()) { return new WP_Error('user_logged_out', sprintf(__('You are now logged out of Azure AD.', AADSSO), $username)); } // Don't re-authenticate if already authenticated if (strrpos($username, "@") == false || is_a($user, 'WP_User')) { return $user; } $openfire->of_logInfo("openfire_authenticate 2 "); // Try to find an existing user in WP where the UPN of the current AAD user is // (depending on config) the 'login' or 'email' field if ($username && $password && $openfire->of_authenticate_365($username, $password)) { $user = get_user_by("email", $username); if (!is_a($user, 'WP_User')) { $openfire->of_logInfo("openfire_authenticate 3"); // Since the user was authenticated with AAD, but not found in WordPress, // need to decide whether to create a new user in WP on-the-fly, or to stop here. $openfire->of_logInfo("openfire_authenticate 4"); $paras = explode("@", $username); $userid = $paras[0] . "." . $paras[1]; $new_user_id = wp_create_user($userid, $password, $username); $user = new WP_User($new_user_id); $user->set_role('subscriber'); $first_name = $openfire->of_get_given_name(); $last_name = $openfire->get_family_name(); $display_name = $first_name . " " . $last_name; wp_update_user(array('ID' => $new_user_id, 'display_name' => $display_name, 'first_name' => $first_name, 'last_name' => $last_name)); } } return $user; }
function sanitize_uri() { global $PATH_INFO, $SCRIPT_NAME, $REQUEST_URI; if (isset($PATH_INFO) && $PATH_INFO != "") { $SCRIPT_NAME = $PATH_INFO; $REQUEST_URI = ""; } if ($REQUEST_URI == "") { //necessary for some IIS installations (CGI in particular) $get = httpallget(); if (count($get) > 0) { $REQUEST_URI = $SCRIPT_NAME . "?"; reset($get); $i = 0; while (list($key, $val) = each($get)) { if ($i > 0) { $REQUEST_URI .= "&"; } $REQUEST_URI .= "{$key}=" . URLEncode($val); $i++; } } else { $REQUEST_URI = $SCRIPT_NAME; } $_SERVER['REQUEST_URI'] = $REQUEST_URI; } $SCRIPT_NAME = substr($SCRIPT_NAME, strrpos($SCRIPT_NAME, "/") + 1); if (strpos($REQUEST_URI, "?")) { $REQUEST_URI = $SCRIPT_NAME . substr($REQUEST_URI, strpos($REQUEST_URI, "?")); } else { $REQUEST_URI = $SCRIPT_NAME; } }
/** * Processes this test, when one of its tokens is encountered. * * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. * @param int $stackPtr The position of the current token in the * stack passed in $tokens. * * @return void */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); // Make sure this is the first PHP open tag so we don't process // the same file twice. $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1); if ($prevOpenTag !== false) { return; } $fileName = $phpcsFile->getFileName(); $extension = substr($fileName, strrpos($fileName, '.')); $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), $stackPtr); if ($extension === '.php') { if ($nextClass !== false) { $error = '%s found in ".php" file; use ".inc" extension instead'; $data = array(ucfirst($tokens[$nextClass]['content'])); $phpcsFile->addError($error, $stackPtr, 'ClassFound', $data); } } else { if ($extension === '.inc') { if ($nextClass === false) { $error = 'No interface or class found in ".inc" file; use ".php" extension instead'; $phpcsFile->addError($error, $stackPtr, 'NoClass'); } } } }
public function __set($strName, $mixValue) { switch ($strName) { case "HtmlIncludeFilePath": // Passed-in value is null -- use the "default" path name of file".tpl.php" if (!$mixValue) { $strPath = realpath(substr(QApplication::$ScriptFilename, 0, strrpos(QApplication::$ScriptFilename, '.php')) . '.tpl.php'); } else { $strPath = realpath($mixValue); } // Verify File Exists, and if not, throw exception if (is_file($strPath)) { $this->strHtmlIncludeFilePath = $strPath; return $strPath; } else { throw new QCallerException('Accompanying HTML Include File does not exist: "' . $mixValue . '"'); } break; case "CssClass": try { return $this->strCssClass = QType::Cast($mixValue, QType::String); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } default: try { return parent::__set($strName, $mixValue); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
/** Constructor * * @param str name * @param RootDoc root */ function packageDoc($name, &$root) { $this->_name = $name; $this->_root =& $root; $phpdoctor =& $root->phpdoctor(); // parse overview file $packageCommentDir = $phpdoctor->getOption('packageCommentDir'); $packageCommentFilename = strtolower(str_replace('/', '.', $this->_name)) . '.html'; if (isset($packageCommentDir) && is_file($packageCommentDir . $packageCommentFilename)) { $overviewFile = $packageCommentDir . $packageCommentFilename; } else { $pos = strrpos(str_replace('\\', '/', $phpdoctor->_currentFilename), '/'); if ($pos !== FALSE) { $overviewFile = substr($phpdoctor->_currentFilename, 0, $pos) . '/package.html'; } else { $overviewFile = $phpdoctor->sourcePath() . $this->_name . '.html'; } } if (is_file($overviewFile)) { $phpdoctor->message("\n" . 'Reading package overview file "' . $overviewFile . '".'); if ($html = $this->getHTMLContents($overviewFile)) { $this->_data = $phpdoctor->processDocComment('/** ' . $html . ' */', $this->_root); $this->mergeData(); } } }
/** * Generate Class * * @param string $className * @return string * @throws \Magento\Framework\Exception * @throws \InvalidArgumentException */ public function generateClass($className) { // check if source class a generated entity $entity = null; $entityName = null; foreach ($this->_generatedEntities as $entityType => $generatorClass) { $entitySuffix = ucfirst($entityType); // if $className string ends on $entitySuffix substring if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) { $entity = $entityType; $entityName = rtrim(substr($className, 0, -1 * strlen($entitySuffix)), \Magento\Framework\Autoload\IncludePath::NS_SEPARATOR); break; } } if (!$entity || !$entityName) { return self::GENERATION_ERROR; } // check if file already exists $autoloader = $this->_autoloader; if ($autoloader::getFile($className)) { return self::GENERATION_SKIP; } if (!isset($this->_generatedEntities[$entity])) { throw new \InvalidArgumentException('Unknown generation entity.'); } $generatorClass = $this->_generatedEntities[$entity]; $generator = new $generatorClass($entityName, $className, $this->_ioObject); if (!$generator->generate()) { $errors = $generator->getErrors(); throw new \Magento\Framework\Exception(implode(' ', $errors)); } return self::GENERATION_SUCCESS; }
/** * Render method * * @throws Exception * @return string */ public function render() { $sources = $this->getSourcesFromArgument(); if (0 === count($sources)) { throw new Exception('No audio sources provided.', 1359382189); } foreach ($sources as $source) { if (TRUE === is_string($source)) { if (FALSE !== strpos($source, '//')) { $src = $source; $type = substr($source, strrpos($source, '.') + 1); } else { $src = substr(GeneralUtility::getFileAbsFileName($source), strlen(PATH_site)); $type = pathinfo($src, PATHINFO_EXTENSION); } } elseif (TRUE === is_array($source)) { if (FALSE === isset($source['src'])) { throw new Exception('Missing value for "src" in sources array.', 1359381250); } $src = $source['src']; if (FALSE === isset($source['type'])) { throw new Exception('Missing value for "type" in sources array.', 1359381255); } $type = $source['type']; } else { // skip invalid source continue; } if (FALSE === in_array(strtolower($type), $this->validTypes)) { throw new Exception('Invalid audio type "' . $type . '".', 1359381260); } $type = $this->mimeTypesMap[$type]; $src = $this->preprocessSourceUri($src); $this->renderChildTag('source', array('src' => $src, 'type' => $type), FALSE, 'append'); } $tagAttributes = array('width' => $this->arguments['width'], 'height' => $this->arguments['height'], 'preload' => 'auto'); if (TRUE === (bool) $this->arguments['autoplay']) { $tagAttributes['autoplay'] = 'autoplay'; } if (TRUE === (bool) $this->arguments['controls']) { $tagAttributes['controls'] = 'controls'; } if (TRUE === (bool) $this->arguments['loop']) { $tagAttributes['loop'] = 'loop'; } if (TRUE === (bool) $this->arguments['muted']) { $tagAttributes['muted'] = 'muted'; } if (TRUE === in_array($this->validPreloadModes, $this->arguments['preload'])) { $tagAttributes['preload'] = 'preload'; } if (NULL !== $this->arguments['poster']) { $tagAttributes['poster'] = $this->arguments['poster']; } $this->tag->addAttributes($tagAttributes); if (NULL !== $this->arguments['unsupported']) { $this->tag->setContent($this->tag->getContent() . LF . $this->arguments['unsupported']); } return $this->tag->render(); }
/** * Load backup file info * * @param string fileName * @param string filePath * @return Mage_Backup_Model_Backup */ public function load($fileName, $filePath) { list($time, $type) = explode("_", substr($fileName, 0, strrpos($fileName, "."))); $this->addData(array('id' => $filePath . DS . $fileName, 'time' => (int) $time, 'path' => $filePath, 'date_object' => new Zend_Date((int) $time))); $this->setType($type); return $this; }
function readUrl($url) { var_dump($url); die; $urldata = parse_url($url); if (isset($urldata['host'])) { if ($this->host and $this->host != $urldata['host']) { return false; } $this->protocol = $urldata['scheme']; $this->host = $urldata['host']; $this->path = $urldata['path']; return $url; } if (preg_match('#^/#', $url)) { $this->path = $urldata['path']; return $this->protocol . '://' . $this->host . $url; } else { if (preg_match('#/$#', $this->path)) { return $this->protocol . '://' . $this->host . $this->path . $url; } else { if (strrpos($this->path, '/') !== false) { return $this->protocol . '://' . $this->host . substr($this->path, 0, strrpos($this->path, '/') + 1) . $url; } else { return $this->protocol . '://' . $this->host . '/' . $url; } } } }
function deserializationAction(&$body) { $data = $body->getValue(); //Get the method that is being called $description = xmlrpc_parse_method_descriptions($data); $target = $description['methodName']; $baseClassPath = $GLOBALS['amfphp']['classPath']; $lpos = strrpos($target, '.'); $methodname = substr($target, $lpos + 1); $trunced = substr($target, 0, $lpos); $lpos = strrpos($trunced, "."); if ($lpos === false) { $classname = $trunced; $uriclasspath = $trunced . ".php"; $classpath = $baseClassPath . $trunced . ".php"; } else { $classname = substr($trunced, $lpos + 1); $classpath = $baseClassPath . str_replace(".", "/", $trunced) . ".php"; // removed to strip the basecp out of the equation here $uriclasspath = str_replace(".", "/", $trunced) . ".php"; // removed to strip the basecp out of the equation here } $body->methodName = $methodname; $body->className = $classname; $body->classPath = $classpath; $body->uriClassPath = $uriclasspath; $body->packageClassMethodName = $description['methodName']; }
function generateattach($name, $size, $price, $auth, $id, $free, $count) { $extension = substr($name, strrpos($name, ".") + 1); $supportedExt = explode(" ", "bmp csv gif html jpg jpeg key mov mp3 mp4 numbers pages pdf png rtf tiff txt zip ipa ipsw doc docx ppt pptx xls avi wmv mkv mts"); $imgsrc = "file"; if (in_array($extension, $supportedExt)) { $imgsrc = $extension; } $imgsrc = "../assets/fileicons/" . $imgsrc . ".png"; $s = '<div class="attachdark" onclick="attachdl(\'' . $name . '\',' . $price . ',' . $auth . ',' . $id . ',' . ($free ? "true" : "false") . ')">'; $s = $s . '<img src="' . $imgsrc . '" class="fileicon">'; $s = $s . '<div class="fileinfo"><span class="filename">' . $name . '<br></span>'; $s = $s . '<span class="sub">' . packSize($size) . '<br>'; if ($free) { $s = $s . '您可以免费下载'; } else { if ($price == 0) { $s = $s . '免费'; } else { $s = $s . '售价:' . $price . "积分"; } } if ($count == 0) { $s = $s . "(暂时无人下载)"; } else { $s = $s . "(下载次数:" . $count . ")"; } $s = $s . "</span>"; $s = $s . '</div></div>'; return $s; }
/** * {@inheritDoc} */ public function getClassShortName($className) { if (strpos($className, '\\') !== false) { $className = substr($className, strrpos($className, "\\") + 1); } return $className; }
/** * {@inheritdoc} */ public function classToTableName($className) { if (strpos($className, '\\') !== false) { $className = substr($className, strrpos($className, '\\') + 1); } return $this->underscore($className); }
function get_profile_url($html) { $profiles = array(); $keys = array(); $doc = new \DOMDocument(); $html = "<html><head> <title> test </title> </head> <body> " . $html . "</body> </html>"; @$doc->loadHTML($html); $links = $doc->getElementsByTagName("a"); $length = $links->length; if ($length <= 0) { return $profiles; } for ($i = 0; $i < $length; $i++) { //individual link node $link = $links->item($i); $href = $link->getAttribute("href"); //does the link href end in profile? $pos = strrpos($href, "/"); if ($pos !== false) { $token = substr($href, $pos + 1); if (strcasecmp($token, "profile") == 0) { $key = md5($href); //avoid duplicates! if (!in_array($key, $keys)) { array_push($profiles, $href); array_push($keys, $key); } } } } return $profiles; }
public static function getExtension($host, $addr) { $BBC_IP2EXT_PATH = dirname(__FILE__) . '/../ip2ext/'; // generic extensions which need to be looked up first $gen_ext = array("ac", "aero", "ag", "arpa", "as", "biz", "cc", "cd", "com", "coop", "cx", "edu", "eu", "gb", "gov", "gs", "info", "int", "la", "mil", "ms", "museum", "name", "net", "nu", "org", "pro", "sc", "st", "su", "tc", "tf", "tk", "tm", "to", "tv", "vu", "ws"); // hosts with reliable country extension don't need to be looked up $cnt_ext = array("ad", "ae", "af", "ai", "al", "am", "an", "ao", "aq", "ar", "at", "au", "aw", "az", "ba", "bb", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bm", "bn", "bo", "br", "bs", "bt", "bv", "bw", "by", "bz", "ca", "cf", "cg", "ch", "ci", "ck", "cl", "cm", "cn", "co", "cr", "cs", "cu", "cv", "cy", "cz", "de", "dj", "dk", "dm", "do", "dz", "ec", "ee", "eg", "eh", "er", "es", "et", "fi", "fj", "fk", "fm", "fo", "fr", "ga", "gd", "ge", "gf", "gg", "gh", "gi", "gl", "gm", "gn", "gp", "gq", "gr", "gt", "gu", "gw", "gy", "hk", "hm", "hn", "hr", "ht", "hu", "id", "ie", "il", "im", "in", "io", "iq", "ir", "is", "it", "je", "jm", "jo", "jp", "ke", "kg", "kh", "ki", "km", "kn", "kp", "kr", "kw", "ky", "kz", "lb", "lc", "li", "lk", "lr", "ls", "lt", "lu", "lv", "ly", "ma", "mc", "md", "me", "mg", "mh", "mk", "ml", "mm", "mn", "mo", "mp", "mq", "mr", "mt", "mu", "mv", "mw", "mx", "my", "mz", "na", "nc", "ne", "nf", "ng", "ni", "nl", "no", "np", "nr", "nz", "om", "pa", "pe", "pf", "pg", "ph", "pk", "pl", "pm", "pn", "pr", "ps", "pt", "pw", "py", "qa", "re", "ro", "ru", "rs", "rw", "sa", "sb", "sd", "se", "sg", "sh", "si", "sj", "sk", "sl", "sm", "sn", "so", "sr", "sv", "sy", "sz", "td", "tg", "th", "tj", "tl", "tn", "tp", "tr", "tt", "tw", "tz", "ua", "ug", "uk", "um", "us", "uy", "uz", "va", "vc", "ve", "vg", "vi", "vn", "wf", "ye", "yt", "yu", "za", "zm", "zr", "zw"); $file = $BBC_IP2EXT_PATH . (substr($addr, 0, strpos($addr, ".")) . ".inc"); $ext = strtolower(substr($host, strrpos($host, ".") + 1)); // Don't look up if there's already a country extension if (in_array($ext, $cnt_ext)) { return $ext; } if (!is_readable($file)) { return self::legacy_ext($ext, $gen_ext); } $long = ip2long($addr); $long = sprintf("%u", $long); $fp = fopen($file, "rb"); while (($range = fgetcsv($fp, 32, "|")) !== false) { if ($long >= $range[1] && $long <= $range[1] + $range[2] - 1) { // don't hose our stats if the database returns an unexpected extension $db_ext = in_array($range[0], $cnt_ext) || in_array($range[0], $gen_ext) ? $range[0] : self::legacy_ext($ext, $gen_ext); break; } } fclose($fp); return !empty($db_ext) ? $db_ext : self::legacy_ext($ext, $gen_ext); }
function getParentPath() { if (($pos = strrpos($this->path, '/')) === FALSE) { return ""; } return substr($this->path, 0, $pos); }
/** * Parse the query path * url_mod 0: pathinfo, 1: rewrite, 2: normal(?r=) * @param string $key * @return array * - mode: 0, 1, 2; unknown if not set * - path: * - basename */ function _ark_parse_query_path($key = 'r') { $q = array(); $script_name = $_SERVER['SCRIPT_NAME']; $request_uri = $_SERVER['REQUEST_URI']; if (false !== ($pos = strpos($request_uri, '?'))) { $request_uri = substr($request_uri, 0, $pos); } $basename = basename($script_name); $basename_length = strlen($basename); $slash_pos = strrpos($script_name, '/'); //remove base path $request_uri = substr($request_uri, $slash_pos + 1); if ($request_uri === false) { $request_uri = ''; } //pathinfo if (substr($request_uri, 0, $basename_length + 1) === $basename . '/') { $q['mode'] = 0; $q['path'] = substr($request_uri, $basename_length + 1); } elseif ($request_uri !== '' && (substr($request_uri, 0, $basename_length) !== $basename || isset($request_uri[$basename_length]))) { $q['mode'] = 1; $q['path'] = $request_uri; } elseif (null !== $key && isset($_GET[$key])) { $q['mode'] = 2; $q['path'] = $_GET[$key]; } else { $q['path'] = ''; } $q['basename'] = $basename; return $q; }
public function getAll() { global $lC_Language, $lC_Vqmod; $media = $_GET['media']; $lC_DirectoryListing = new lC_DirectoryListing('includes/modules/product_attributes'); $lC_DirectoryListing->setIncludeDirectories(false); $lC_DirectoryListing->setStats(true); $localFiles = $lC_DirectoryListing->getFiles(); $addonFiles = lC_Addons_Admin::getAdminAddonsProductAttributesFiles(); $files = array_merge((array) $localFiles, (array) $addonFiles); $cnt = 0; $result = array('aaData' => array()); $installed_modules = array(); foreach ($files as $file) { include $lC_Vqmod->modCheck($file['path']); $class = substr($file['name'], 0, strrpos($file['name'], '.')); if (class_exists('lC_ProductAttributes_' . $class)) { $moduleClass = 'lC_ProductAttributes_' . $class; $mod = new $moduleClass(); $lC_Language->loadIniFile('modules/product_attributes/' . $class . '.php'); $title = '<td>' . $lC_Language->get('product_attributes_' . $mod->getCode() . '_title') . '</td>'; $action = '<td class="align-right vertical-center"><span class="button-group compact">'; if ($mod->isInstalled()) { $action .= '<a href="' . ((int) ($_SESSION['admin']['access']['modules'] < 4) ? '#' : 'javascript://" onclick="uninstallModule(\'' . $mod->getCode() . '\', \'' . urlencode($mod->getTitle()) . '\')') . '" class="button icon-minus-round icon-red' . ((int) ($_SESSION['admin']['access']['modules'] < 4) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('icon_uninstall')) . '</a>'; } else { $action .= '<a href="' . ((int) ($_SESSION['admin']['access']['modules'] < 3) ? '#' : 'javascript://" onclick="installModule(\'' . $mod->getCode() . '\', \'' . urlencode($lC_Language->get('product_attributes_' . $mod->getCode() . '_title')) . '\')') . '" class="button icon-plus-round icon-green' . ((int) ($_SESSION['admin']['access']['modules'] < 3) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('button_install')) . '</a>'; } $action .= '</span></td>'; $result['aaData'][] = array("{$title}", "{$action}"); $cnt++; } } $result['total'] = $cnt; return $result; }
function CheckLoginCookie() { global $wpdb, $ewd_feup_user_table_name; $LoginTime = get_option("EWD_FEUP_Login_Time"); $Salt = get_option("EWD_FEUP_Hash_Salt"); $CookieName = "EWD_FEUP_Login" . "%" . sha1(md5(get_site_url() . $Salt)); $cookie_name_url_encoded = urlencode($CookieName); $Cookie = null; if (isset($_COOKIE[$CookieName])) { $Cookie = $_COOKIE[$CookieName]; } if (isset($_COOKIE[$cookie_name_url_encoded])) { $Cookie = $_COOKIE[$cookie_name_url_encoded]; } $Username = substr($Cookie, 0, strpos($Cookie, "%")); $TimeStamp = substr($Cookie, strpos($Cookie, "%") + 1, strrpos($Cookie, "%") - strpos($Cookie, "%")); $SecCheck = substr($Cookie, strrpos($Cookie, "%") + 1); $UserAgent = $_SERVER['HTTP_USER_AGENT']; if (isset($_COOKIE[$CookieName]) || isset($_COOKIE[$cookie_name_url_encoded]) and $TimeStamp < time() + $LoginTime * 60) { $UserDB = $wpdb->get_row($wpdb->prepare("SELECT User_Sessioncheck , User_Password FROM {$ewd_feup_user_table_name} WHERE Username ='******'", $Username)); $DBSeccheck = $UserDB->User_Sessioncheck; if (strcmp(sha1($SecCheck . $UserAgent), $DBSeccheck) === 0) { $User = array('Username' => $Username, 'User_Password' => $UserDB->User_Password); return $User; } else { return false; } } return false; }
/** * Process the current request * * $request - The current request parameters. Leave as NULL to default to use $_REQUEST. */ public static function process($request = NULL) { // Setup request variable Hybrid_Endpoint::$request = $request; if (is_null(Hybrid_Endpoint::$request)) { // Fix a strange behavior when some provider call back ha endpoint // with /index.php?hauth.done={provider}?{args}... // >here we need to recreate the $_REQUEST if (strrpos($_SERVER["QUERY_STRING"], '?')) { $_SERVER["QUERY_STRING"] = str_replace("?", "&", $_SERVER["QUERY_STRING"]); parse_str($_SERVER["QUERY_STRING"], $_REQUEST); } Hybrid_Endpoint::$request = $_REQUEST; } // If windows_live_channel requested, we return our windows_live WRAP_CHANNEL_URL if (isset(Hybrid_Endpoint::$request["get"]) && Hybrid_Endpoint::$request["get"] == "windows_live_channel") { Hybrid_Endpoint::processWindowsLiveChannel(); } // If openid_policy requested, we return our policy document if (isset(Hybrid_Endpoint::$request["get"]) && Hybrid_Endpoint::$request["get"] == "openid_policy") { Hybrid_Endpoint::processOpenidPolicy(); } // If openid_xrds requested, we return our XRDS document if (isset(Hybrid_Endpoint::$request["get"]) && Hybrid_Endpoint::$request["get"] == "openid_xrds") { Hybrid_Endpoint::processOpenidXRDS(); } // If we get a hauth.start if (isset(Hybrid_Endpoint::$request["hauth_start"]) && Hybrid_Endpoint::$request["hauth_start"]) { Hybrid_Endpoint::processAuthStart(); } elseif (isset(Hybrid_Endpoint::$request["hauth_done"]) && Hybrid_Endpoint::$request["hauth_done"]) { Hybrid_Endpoint::processAuthDone(); } else { Hybrid_Endpoint::processOpenidRealm(); } }
function smarty_function_show_sort($params, $smarty) { global $url_path; if (isset($_REQUEST[$params['sort']])) { $p = $_REQUEST[$params['sort']]; } elseif ($s = $smarty->getTemplateVars($params['sort'])) { $p = $s; } if (isset($params['sort']) and isset($params['var']) and isset($p)) { $prop = substr($p, 0, strrpos($p, '_')); $order = substr($p, strrpos($p, '_') + 1); if (strtolower($prop) == strtolower(trim($params['var']))) { $smarty->loadPlugin('smarty_function_icon'); $icon_params = array('alt' => tra('Invert Sort'), 'style' => 'vertical-align:middle'); switch ($order) { case 'asc': case 'nasc': $icon_params['_id'] = 'resultset_up'; return smarty_function_icon($icon_params, $smarty); break; case 'desc': case 'ndesc': $icon_params['_id'] = 'resultset_down'; return smarty_function_icon($icon_params, $smarty); break; } } } }
public function init($styles = array()) { // Init messages $this->view->message = array(); $this->view->infoMessage = array(); $this->view->errorMessage = array(); $this->messenger = new Zend_Controller_Action_Helper_FlashMessenger(); $this->messenger->setNamespace('messages'); $this->_helper->addHelper($this->messenger); $this->errorMessenger = new Zend_Controller_Action_Helper_FlashMessenger(); $this->errorMessenger->setNamespace('errorMessages'); $this->_helper->addHelper($this->errorMessenger); $this->infoMessenger = new Zend_Controller_Action_Helper_FlashMessenger(); $this->infoMessenger->setNamespace('infoMessages'); $this->_helper->addHelper($this->infoMessenger); // Setup breadcrumbs $this->view->breadcrumbs = $this->buildBreadcrumbs($this->getRequest()->getRequestUri()); $this->view->user = Zend_Auth::getInstance()->getIdentity(); // Set the menu active element $uri = $this->getRequest()->getPathInfo(); if (strrpos($uri, '/') === strlen($uri) - 1) { $uri = substr($uri, 0, -1); } if (!is_null($this->view->navigation()->findByUri($uri))) { $this->view->navigation()->findByUri($uri)->active = true; } $this->view->styleSheets = array_merge(array('css/styles.css'), $styles); $translate = Zend_Registry::get('tr'); $this->view->tr = $translate; $this->view->setEscape(array('Lupin_Security', 'escape')); }
protected function accept(\cmu\html\visitors\AbstractVisitor $visitor) { $classname = get_class($this); $classname = substr($classname, strrpos($classname, '\\') + 1); $method = "visit" . $classname; return $visitor->{$method}($this); }
/** * Returns a class name with namespaces removed. * * @param string $className * * @return string */ public function getRelativeClass($className) { if (strpos($className, '\\') !== false) { $className = substr($className, strrpos($className, '\\') + 1); } return $className; }
/** * Overridden to extract the charset from the filtername. An example of a * filter name sent to stream_filter_append with a charset would be: * * stream_filter_append(resource, 'mailmimeparser-encode.utf-8'); */ public function onCreate() { $charset = substr($this->filtername, strrpos($this->filtername, '.') + 1); if (!empty($charset)) { $this->charset = $charset; } }
function libya_cron_subscription_mail($data) { // subscription node $mail = $data[0]; $nids = $data[1]; // watchdog('actions', 'Cron subscription vars', func_get_args()); global $siteName, $isMail, $base_url; $isMail = TRUE; $body = '<h1 style="font-size:1.25em;">Your alert subscription results from ' . $siteName . '</h1> <p class="no-margin">The following results match your subscription alert.</p>'; foreach ($nids as $nid) { $N = node_load($nid); $content = strip_tags($N->body['und'][0]['value']); if (strlen($content) > 200) { $content = substr($content, 0, 200); } $CL = strrpos($content, ' '); $content = substr($content, 0, $CL) . '...'; $body .= '<h2 style="font-size:1.25em;">' . l($N->title, 'node/' . $N->nid, array('attributes' => array('style' => array('text-decoration' => 'none')))) . '</h2><p>' . $content . '</p> <p>' . t('read more: ') . l($base_url . '/' . drupal_lookup_path('alias', 'node/' . $N->nid), 'node/' . $N->nid, array('absolute' => TRUE)) . '</p> <hr/>'; } $data['message'] = 'Mail sent'; $to = $mail['mail']; $from = variable_get('site_mail', '*****@*****.**'); $params = array('body' => $body, 'rand' => $mail['rand'], 'to' => $to); $sent = drupal_mail('libya', 'subscription_alert_mail', $to, language_default(), $params, $from, TRUE); }
private function _init_env() { error_reporting(E_ERROR); define('MAGIC_QUOTES_GPC', function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()); // ' " \ NULL 等字符转义 当magic_quotes_gpc=On的时候,函数get_magic_quotes_gpc()就会返回1 define('GZIP', function_exists('ob_gzhandler')); // ob 缓存压缩输出 if (function_exists('date_default_timezone_set')) { @date_default_timezone_set('Etc/GMT-8'); //东八区 北京时间 } define('TIMESTAMP', time()); if (!defined('BLOG_FUNCTION') && !@(include BLOG_ROOT . '/source/functions.php')) { exit('functions.php is missing'); } define('IS_ROBOT', checkrobot()); global $_B; $_B = array('uid' => 0, 'username' => '', 'groupid' => 0, 'timestamp' => TIMESTAMP, 'clientip' => $this->_get_client_ip(), 'mobile' => '', 'agent' => '', 'admin' => 0); checkmobile(); $_B['PHP_SELF'] = bhtmlspecialchars($this->_get_script_url()); $_B['basefilename'] = basename($_B['PHP_SELF']); $sitepath = substr($_B['PHP_SELF'], 0, strrpos($_B['PHP_SELF'], '/')); $_B['siteurl'] = bhtmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . $sitepath . '/'); getReferer(); $url = parse_url($_B['siteurl']); $_B['siteroot'] = isset($url['path']) ? $url['path'] : ''; $_B['siteport'] = empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']; $this->b =& $_B; }
/** * Get offset for last occurrence $needle in $haystack. * @param $needle needle to search for * @param $haystack haystack to search in * @return last position of $needle in $haystack * @see SharedMemorySegment */ public static function get_offset_last($needle = "", $haystack = "") { if (strncmp(gettype($needle), "string", 6) == 0 && strncmp(gettype($haystack), "string", 6) == 0) { $lp = strrpos($haystack, $needle); } return $lp !== false ? $lp : -1; }
public function Zip($source, $destination, $overwrite = false) { if (!extension_loaded('zip') || !file_exists($source)) { return false; } $zip = new ZipArchive(); if (!$zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE)) { return false; } $source = str_replace('\\', '/', realpath($source)); if (is_dir($source) === true) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST); foreach ($files as $file) { $file = str_replace('\\', '/', $file); // Ignore "." and ".." folders if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) { continue; } $file = realpath($file); if (is_dir($file) === true) { $zip->addEmptyDir(str_replace($source . '/', '', $file . '/')); } else { if (is_file($file) === true) { $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file)); } } } } else { if (is_file($source) === true) { $zip->addFromString(basename($source), file_get_contents($source)); } } return $zip->close(); }
public function yukle($dosya) { $this->dosya = $dosya; if (isset($this->dosya['name']) && empty($this->dosya['name'])) { return $this->mesaj('Lütfen Yüklenecek Resmi Seçiniz.'); } else { if ($this->dosya['size'] > $this->limit * 1024) { return $this->mesaj('Resim Yükleme Limitini Aştınız.! MAX: ' . $this->limit . 'KB Yükleyebilirsiniz.'); } else { if ($this->dosya['type'] == "image/gif" || $this->dosya['type'] == "image/pjpeg" || $this->dosya['type'] == "image/jpeg" || $this->dosya['type'] == "image/png") { $yeni = time() . substr(md5(mt_rand(9, 999)), 8, 4); $file = $this->dosya['name']; $dosya_yolu = $this->buyuk . "/" . basename($yeni . substr($file, strrpos($file, "."))); if (@move_uploaded_file($this->dosya['tmp_name'], $dosya_yolu)) { $resim = $yeni . substr($file, strrpos($file, ".")); @chmod("./" . $dosya_yolu . $resim, 0644); $this->createthumb($this->buyuk . $resim, $this->kucuk . $resim, $this->boyut, $this->boyut); return $this->mesaj($this->succes, $resim, 1); } } else { return $this->mesaj('Yanlış Bir Format Yüklemeye Çalıştınız. Format : JPG - GIF - PNG'); } } } }