/** * Path in urls configuration to key. * Override if necessary. * @return array of keys */ protected function getConfigKeys() { $path = explode('\\', strToLower(get_class($this))); $path = array_splice($path, 1); // remove first (Csfd) return $path; }
/** * Get the Solr field associated with a particular browse action. * * @param string $action Browse action * @param string $backup Backup browse action if no match is found for $action * * @return string */ public function getSolrField($action, $backup = null) { $action = strToLower($action); $backup = strToLower($backup); switch ($action) { case 'dewey': return 'dewey-hundreds'; case 'lcc': return 'callnumber-first'; case 'author': return 'authorStr'; case 'topic': return 'topic_facet'; case 'genre': return 'genre_facet'; case 'region': return 'geographic_facet'; case 'era': return 'era_facet'; } if ($backup == null) { return $action; } return $this->getSolrField($backup); }
public function __construct($url, array $args = NULL, $method = self::GET, $cookie = NULL) { self::$_dbgCount++; $headers = ['Content-type: application/x-www-form-urlencoded']; if ($cookie) { $headers[] = "Cookie: {$cookie}"; } $polo = ['http' => ['method' => $method, 'header' => implode("\r\n", $headers), 'ignore_errors' => TRUE]]; if ($args) { $polo['http']['content'] = http_build_query($args); } list($this->content, $rawHeaders) = $this->fileGetContents($url, NULL, stream_context_create($polo)); if ($this->content === FALSE) { list($res) = $this->fileGetContents('http://google.com'); if ($res === FALSE) { throw new Exception('Request failed. Your internet connection is down.', Exception::NO_CONNECTION); } else { throw new Exception('Request failed. You have been blacklisted by CSFD firewall, which usually lasts for about a day.', Exception::BLOCKED); } } $this->statusCode = (int) substr($rawHeaders[0], strlen('HTTP/1.1 ')); array_shift($rawHeaders); $headers = []; foreach ($rawHeaders as $header) { $p = strpos($header, ':'); if ($p === FALSE) { // ignore status header from redirected request continue; } $key = strToLower(substr($header, 0, $p)); $value = trim(substr($header, $p + 1)); $headers[$key][] = $value; } $this->headers = $headers; }
function __construct($table) { $class = get_class($this); print_r(strToLower($class)); echo "\n"; parent::__construct($table); }
/** * \brief Metoda mapujaca wywolania metod w formacie load[typKonfiguracji] * * Do stwierdzenia czy zazadano wywolania metody ladujacej konfiguracje o * podanym formacie uzyto wyrazen regularnych. * * \param $name Nazwa wywoˆywanej metody * \param $args Tablica z parametrami wywolywanej metody */ public function __call($name, $args) { if (ereg('load(.*)', $name, $arr)) { return $this->load($args[0], strToLower($arr[1])); } return false; }
function cmpLang($a, $b) { if ($a == $b) { return 0; } return strtolower($a->TranslatedName) < strToLower($b->TranslatedName) ? -1 : 1; }
function onOpen() { $key = $this->getAttribute('key'); $obj = $this->getDocument()->getVariable($key); if(is_object($obj) || is_array($obj)) { foreach($obj as $k=>$v) { $this->getDocument()->setVariable($k, $v); } if(is_object($obj)){ // Loop thru each method to detect it's a getter and include its ret value $rClass = new ReflectionClass($obj); foreach($rClass->getMethods() as $rMethod){ ($mn = $rMethod->getName()); if($rMethod->isPublic() && ('get' === substr($mn,0,3)) && (0 == count($rMethod->getParameters()))) { $var = subStr($mn,3); //extract the variable name $var[0] = strToLower($var[0]); //lower first letter case $this->getDocument()->setVariable($var, $rMethod->invoke($obj) ); } } } return self::PROCESS_BODY; } return self::SKIP_BODY; }
function autoloadFields($class) { if (strToLower(left($class, 5)) !== 'field') { return; } require_once jailpath(DIAMONDMVC_ROOT . '/classes/fields', strToLower(substr($class, 5)) . '.php'); }
/** * @return string * @param string $namespace */ public static function namespaceToName($namespace) { $result = preg_replace('/' . preg_quote(self::MODULE_SUFFIX) . '$/', '', $namespace); $result = preg_replace('/(.)([A-Z])/', '\\1' . self::MODULE_NAME_SEPARATOR . '\\2', $result); $result = strToLower($result); return $result; }
function draw_array($array, $nice = false) { global $_josh; if (!is_array($array)) { return false; } $return = '<table cellspacing="1" style="background-color:#ccc;color:#333;border:0px;">'; //if (!$nice) ksort($array); foreach ($array as $key => $value) { $key = urldecode($key); if ($nice && strToLower($key) == 'j') { continue; } //$value = format_quotes($value); if (strToLower($key) == 'email') { $value = '<a href="mailto:' . $value . '">' . $value . '</a>'; } if (is_array($value)) { $value = draw_array($value, $nice); } $return .= '<tr><td style="background-color:#eee;"><b>'; $return .= $nice ? format_text_human($key) : $key; $return .= ' </b></td><td style="background-color:#fff;">'; $return .= is_object($value) ? 'object value' : $value; $return .= '</td></tr>'; } $return .= '</table>'; return $return; }
/** * [Describe function...] * * @return [type] ... */ function main() { global $LANG; $this->content .= $this->main_parse_html($this->modData['openKeys']); // if no HTTP input conversion is configured, the input was uft-8 (urlencoded). $fromCharSet = 'utf-8'; // if conversion was done, the input is encoded in mbstring.internal_encoding if (in_array('mbstring', get_loaded_extensions()) && ini_get('mbstring.encoding_translation')) { $fromCharSet = strToLower(ini_get('mbstring.internal_encoding')); } $clientInfo = t3lib_div::clientInfo(); // the charset of the content element, possibly overidden by forceCharset $toCharSet = t3lib_div::_GP('charset') ? t3lib_div::_GP('charset') : 'iso-8859-1'; // IE wants it back in utf-8 if ($clientInfo['BROWSER'] = 'msie') { $toCharSet = 'utf-8'; } elseif ($clientInfo['SYSTEM'] = 'win') { // if the client is windows the input may contain windows-1252 characters; if (strToLower($toCharSet) == 'iso-8859-1') { $toCharSet = 'Windows-1252'; } } // convert to requested charset $this->content = $LANG->csConvObj->conv($this->content, $fromCharSet, $toCharSet); header('Content-Type: text/plain; charset=' . $toCharSet); }
public function authenticate() { $usersAR = Users::model()->getAllUsers(); // var_dump ($usersAR); $Users = array(); foreach ($usersAR as $user) { $Users[$user->username] = ''; } /* $Users=array( // username => password 'irma'=>'', 'robert'=>'', 'geli'=>'', 'georg'=>'', 'theresia'=>'', 'josef'=>'', 'admin'=>'', ); */ if (!isset($Users[strToLower($this->username)])) { echo "Username not found: " . strToLower($this->username); echo "<br/>Please go back and try again."; $this->errorCode = self::ERROR_USERNAME_INVALID; //elseif($Users[$this->username]!==$this->password) // $this->errorCode=self::ERROR_PASSWORD_INVALID; } else { $this->errorCode = self::ERROR_NONE; $userID = Yii::app()->db->createCommand()->select('u.userID')->from('Users u')->where('u.username=:username', array(':username' => strToLower($this->name)))->queryRow(); $this->_id = $userID; } return !$this->errorCode; }
function runTests($path, Container $container) { global $argv; $tests = $argv; array_shift($tests); foreach (file_get_php_classes($path) as $class) { if (!is_subclass_of($class, TestCase::class)) { continue; } /** @var TestCase $test */ $test = new $class($container); if (!$tests) { $test->run(); } $first = TRUE; foreach ($test->getTests() as $method) { foreach ($tests as $name) { if (strpos(strToLower($method), strToLower($name)) !== FALSE) { if (!$first) { echo "\n"; } echo "[01;33m{$method}[0m\n"; $test->runTest($method); $first = FALSE; } } } } }
function tdo($attr = '') { $value = array(); foreach (split('=', preg_replace("/(\\S+)(\\s)?=(\\s)?/", "PAR_" . "\\1" . "=", $attr)) as $item) { if (ereg('^PAR_', $item)) { $key = ereg_replace('^PAR_', '', $item); $value[$key] = array(); } else { foreach (split(' ', preg_replace("/[\"\\']/", '', $item)) as $i) { if (ereg('^PAR_', $i)) { $key = eregi_replace('^PAR_', '', strToLower($i)); $value[$key] = array(); } else { $value[$key][] = $i; } } } } $value["class"][] = "zebra"; foreach ($value as $key => $values) { $a[$key] = join(' ', $values); } $this->prt2("\n <td " . joinX(" ", $a, "'") . ">"); $this->td++; }
function cmpForumLang($a, $b) { if ($a == $b) { return 0; } return strtolower($a->Name) < strToLower($b->Name) ? -1 : 1; }
/** * @param CommandSender $sender * @param Command $command * @param string $commandAlias * @param array $args * * @return bool */ public function onCommand(CommandSender $sender, Command $command, $commandAlias, array $args) { if (strToLower($command) === $this->plugin->getDatabase()->get("command-name")) { // TODO: 명령어만 친 경우 if (!isset($args[0])) { $sender->sendMessage($this->plugin->getDatabase()->get("help-message")); return true; } switch (strToLower($args[0])) { //TODO: '/예제 어쩌구' case $this->plugin->getDatabase()->get("hello-world"): $sender->sendMessage($this->plugin->getDatabase()->get("hello-world-result")); break; // TODO: '/예제 저쩌구' // TODO: '/예제 저쩌구' case $this->plugin->getDatabase()->get("dlrow-olleh"): $sender->sendMessage($this->plugin->getDatabase()->get("dlrow-olleh-result")); break; // TODO: 잘못된 명령어를 입력한 경우 // TODO: 잘못된 명령어를 입력한 경우 default: $sender->sendMessage($this->plugin->getDatabase()->get("wrong-command")); break; } } return true; }
/** * Tests that all classes are cased properly. * * This helps avoid __autoload problems when working * locally on a case insensatie system */ public function lintClassCase($config) { $nodes = $config->xPath('//class'); $errors = array(); foreach ($nodes as $node) { $str_node = (string) $node; if (strpos($str_node, '/') !== false) { if ($str_node != strToLower($str_node)) { $errors[] = 'URI [' . $str_node . '] must be all lowercase;'; } } else { if (strpos($str_node, '_') !== false) { $parts = preg_split('{_}', $str_node, 4); foreach ($parts as $part) { if (ucwords($part) != $part) { $errors[] = "Class [{$str_node}] does not have proper casing. Each_Word_Must_Be_Leading_Cased."; } } } else { $errors[] = 'Class [' . $str_node . '] doesn\'t loook like a class'; } } } if (count($errors) > 0) { $this->fail(implode("\n", $errors)); } }
/** * Generates bin/magento command files * This command generates the necessary files and configuration * for a new command for Magento 2's bin/magento command line program. * * pestle.phar Pulsestorm_Generate Example * * Creates * app/code/Pulsestorm/Generate/Command/Example.php * app/code/Pulsestorm/Generate/etc/di.xml * * @command generate_command * @argument module_name In which module? [Pulsestorm_Helloworld] * @argument command_name Command Name? [Testbed] */ function pestle_cli($argv) { $module_info = getModuleInformation($argv['module_name']); $namespace = $module_info->vendor; $module_name = $module_info->name; $module_shortname = $module_info->short_name; $module_dir = $module_info->folder; $command_name = $argv['command_name']; // $command_name = input("Command Name?", 'Testbed'); output($module_dir); createPhpClass($module_dir, $namespace, $module_shortname, $command_name); $path_di_xml = createDiIfNeeded($module_dir); $xml_di = simplexml_load_file($path_di_xml); //get commandlist node $nodes = $xml_di->xpath('/config/type[@name="Magento\\Framework\\Console\\CommandList"]'); $xml_type_commandlist = array_shift($nodes); if (!$xml_type_commandlist) { throw new Exception("Could not find CommandList node"); } $argument = simpleXmlAddNodesXpath($xml_type_commandlist, '/arguments/argument[@name=commands,@xsi:type=array]'); $full_class = $namespace . '\\' . $module_shortname . '\\Command\\' . $command_name; $item_name = str_replace('\\', '_', strToLower($full_class)); $item = $argument->addChild('item', $full_class); $item->addAttribute('name', $item_name); $item->addAttribute('xsi:type', 'object', 'http://www.w3.org/2001/XMLSchema-instance'); $xml_di = formatXmlString($xml_di->asXml()); writeStringToFile($path_di_xml, $xml_di); }
function autoloadEvents($class) { if (strToLower(right($class, 5)) !== 'event') { return; } require_once jailpath(DIAMONDMVC_ROOT . '/classes/events', strToLower(substr($class, 0, strlen($class) - 5)) . '.php'); }
function mainAutoLoader($class) { // Exceptions werden leicht besonders behandelt. if (right($class, 9) === 'Exception') { $file = DIAMONDMVC_ROOT . "/exceptions/{$class}.php"; } else { $class = strToLower($class); if (left($class, 10) === 'controller' and $class !== 'controller') { $class = substr($class, 10); $file = DIAMONDMVC_ROOT . "/controllers/{$class}.php"; } else { if (left($class, 5) === 'model' and $class !== 'model') { $class = substr($class, 5); $file = DIAMONDMVC_ROOT . "/models/{$class}.php"; } else { if (left($class, 6) === 'module' and $class !== 'module') { $class = substr($class, 6); $file = DIAMONDMVC_ROOT . "/modules/{$class}/{$class}.php"; } else { $file = DIAMONDMVC_ROOT . "/lib/class_{$class}.php"; } } } } if (file_exists($file)) { include_once $file; } }
function createPathFromNamespace($namespace) { $parts = explode('\\', $namespace); $path_dir = strToLower('modules/' . implode('/', $parts)); $path_full = $path_dir . '/module.php'; return $path_full; }
/** * Generates plugin XML * This command generates the necessary files and configuration * to "plugin" to a preexisting Magento 2 object manager object. * * pestle.phar generate_plugin_xml Pulsestorm_Helloworld 'Magento\Framework\Logger\Monolog' 'Pulsestorm\Helloworld\Plugin\Magento\Framework\Logger\Monolog' * * @argument module_name Create in which module? [Pulsestorm_Helloworld] * @argument class Which class are you plugging into? [Magento\Framework\Logger\Monolog] * @argument class_plugin What's your plugin class name? [<$module_name$>\Plugin\<$class$>] * @command generate_plugin_xml */ function pestle_cli($argv) { // $module_info = askForModuleAndReturnInfo($argv); $module_info = getModuleInformation($argv['module_name']); $class = $argv['class']; $class_plugin = $argv['class_plugin']; $path_di = $module_info->folder . '/etc/di.xml'; if (!file_exists($path_di)) { $xml = simplexml_load_string(getBlankXml('di')); writeStringToFile($path_di, $xml->asXml()); output("Created new {$path_di}"); } $xml = simplexml_load_file($path_di); // $plugin_name = strToLower($module_info->name) . '_' . underscoreClass($class); // simpleXmlAddNodesXpath($xml, // "/type[@name=$class]/plugin[@name=$plugin_name,@type=$class_plugin]"); $type = $xml->addChild('type'); $type->addAttribute('name', $class); $plugin = $type->addChild('plugin'); $plugin->addAttribute('name', strToLower($module_info->name) . '_' . underscoreClass($class)); $plugin->addAttribute('type', $class_plugin); writeStringToFile($path_di, formatXmlString($xml->asXml())); output("Added nodes to {$path_di}"); $path_plugin = getPathFromClass($class_plugin); $body = implode("\n", [' //function beforeMETHOD($subject, $arg1, $arg2){}', ' //function aroundMETHOD($subject, $procede, $arg1, $arg2){return $proceed($arg1, $arg2);}', ' //function afterMETHOD($subject, $result){return $result;}']); $class_definition = str_replace('<$body$>', "\n{$body}\n", createClassTemplate($class_plugin)); writeStringToFile($path_plugin, $class_definition); output("Created file {$path_plugin}"); }
public static function decode($source) { $num = sizeof(self::$bArr); $len = strlen($source); $out = 0; if (3 > $len) { throw new \Exception("Given code ({$source}} is too short; at least 3 letters expected."); } if (1 != $len % 2) { throw new \Exception("Wrong code ({$source}} given."); } if ($len != $num * 2 - 1) { throw new \Exception("Given code ({$source}} doesn't match given number size."); } $tmp = array(); for ($i = 0; $i < $len; $i += 2) { array_unshift($tmp, strToLower($source[$i])); } $exp = 1; foreach ($tmp as $i => $v) { $p = strpos(self::$bArr[$i], $v); if (false === $p) { $v = strToUpper($v); throw new \Exception("Index \"{$v}\" not found in ({$source}), at least 2 required."); } $out += $p * $exp; $exp = $exp * 20; } $p = strpos(self::$aArr, strToLower($source[1])); if ($p != $out % 5) { throw new \Exception("Control number in ({$source}) doesn't match."); } return $out; }
static function factory($cn, \cherry\Mvc\Request $req) { \Cherry\Log(\Cherry\LOG_DEBUG, "Invoking controller: %s", $cn); // Check the namespace $app = \cherry\Application::getInstance(); $cfg = $app->getConfiguration('application', 'application'); $ns = $cfg['namespace']; if (substr($cn, 0, strlen($ns)) == $ns) { $cpath = explode('\\', strToLower($cn)); $fpath = CHERRY_APP . _DS_ . 'application' . _DS_ . join(_DS_, array_slice($cpath, 2)); } else { $fpath = strToLower($cn); } $fpath = str_replace('\\', DIRECTORY_SEPARATOR, $fpath); if (substr($fpath, -10, 10) == 'controller') { $fpath = substr($fpath, 0, strlen($fpath) - 10); } $fpath .= '.php'; if (file_exists($fpath)) { require_once $fpath; $cobj = new $cn($req); return $cobj; } else { throw new \Exception("Could not include file; " . $fpath); } }
public static function getBrowser() { $browsers = "mozilla msie gecko firefox "; $browsers .= "konqueror safari netscape navigator "; $browsers .= "opera mosaic lynx amaya omniweb"; $browsers = explode(" ", $browsers); $nua = strToLower($_SERVER['HTTP_USER_AGENT']); $res = array(); $l = strlen($nua); for ($i = 0; $i < count($browsers); $i++) { $browser = $browsers[$i]; $n = stristr($nua, $browser); if (strlen($n) > 0) { $res["version"] = ""; $res["browser"] = $browser; $j = strpos($nua, $res["browser"]) + $n + strlen($res["browser"]) + 1; for (; $j <= $l; $j++) { $s = substr($nua, $j, 1); if (is_numeric($res["version"] . $s)) { $res["version"] .= $s; } break; } } } return $res; }
public function onCommand(CommandSender $sender, Command $command, $commandAlias, array $args) { if (!$this->isEnabled() or !$sender->hasPermission("PMSocket.commands")) { return false; } if (!isset($args[0])) { $sender->sendMessage(TextFormat::GOLD . "/pmsocket password <password>"); return true; } switch (strToLower($args[0])) { case "password": if (!isset($args[1])) { $sender->sendMessage(TextFormat::GOLD . "[PMSocket] /pmsocket password <password>"); return true; } array_shift($args); $this->db["password"] = implode(" ", $args); $sender->sendMessage(TextFormat::GOLD . "[PMSocket] The password has been registered!"); if ($this->resender == null) { $this->registerAttachment(); } break; } return true; }
function conv_ringtone($infile, $outbase) { /* $outfile = $outbase .'.wav'; */ $outfile = $outbase . '.mp3'; if (strToLower(subStr($infile, -4, 4)) === '.mp3') { if (fileSize($infile) <= 1000000) { # 1 MB if (!@copy($infile, $outfile)) { return false; } return $outfile; } } /* if (is_executable( '/usr/local/bin/mpg123' )) $mpg123 = '/usr/local/bin/mpg123'; elseif (is_executable( '/usr/bin/mpg123' )) $mpg123 = '/usr/bin/mpg123'; elseif (is_executable( '/bin/mpg123' )) $mpg123 = '/bin/mpg123'; else $mpg123 = 'mpg123'; if (strToLower(subStr($infile, -4, 4)) === '.mp3') { # convert mp3 to wav first $wavfile = $infile .'.wav'; $cmd = $mpg123 .' -m -w - -n 1000 -q '. qsa($infile) .' > '. qsa($wavfile) .' 2>>/dev/null'; # cuts file after 1000 frames (around 2.3 MB, depending on the rate) # don't use -r 8000 as that doesn't really work for VBR encoded MP3s @exec($cmd, $out, $err); if ($err != 0) { if (is_file($wavfile)) @unlink( $wavfile ); return false; } $infile = $wavfile; $rm_tmp = $wavfile; } else $rm_tmp = false; $cmd = 'sox '. qsa($infile) .' -r 8000 -c 1 -w '. qsa($outfile) .' trim 0 125000s 2>>/dev/null'; # WAV, PCM, 8 kHz, 16 bit, mono # "The time for loading the file should not be longer then 3 seconds. # Size < 250 KByte." # cuts file after 125000 samples (around 245 kB, 15 secs) @exec($cmd, $out, $err); if ($err != 0) { # $err == 2 would be unknown format if (is_file($outfile)) @unlink( $outfile ); if ($rm_tmp && is_file($rm_tmp)) @unlink($rm_tmp); return false; } return $outfile; */ //return false; return null; # not implemented }
/** * Ns\FooBar => foo-bar * @return string */ public function getShortEntityName() { $fqn = $this->repository->getEntityClassName(); $class = substr($fqn, strrpos($fqn, '\\') + 1); return preg_replace_callback('~[A-Z]~', function ($c) { return '-' . strToLower($c); }, lcFirst($class)); }
public function __construct($parent, $type = null) { parent::__construct($parent); $this->_type = strToLower(!empty($type) ? $type : $_SERVER['REQUEST_METHOD']); $this->_protect = $this->get('/Config/Request/protect_' . $this->_type, $this->get('/Config/Request/protect', true)); $this->_verify = $this->get('/Config/Request/verify_' . $this->_type, $this->get('/Config/Request/verify', true)); $this->_collect(); }
function __construct($fileName = null) { if ($fileName) { $this->fileName = $fileName; $this->extension = strToLower(File::getExtension($fileName)); $this->load(); } }