private function return_RV($str) { /* If the second letter is a consonant, RV is the region after the next following vowel, or if the first two letters are vowels, RV is the region after the next consonant, and otherwise (consonant-vowel case) RV is the region after the third letter. But RV is the end of the word if these positions cannot be found. example, m a c h o [ho] o l i v a [va] t r a b a j o [bajo] � u r e o [eo] prezzo sprezzante */ if (strlen($str) < 2) { return ''; } //$str; if (in_array($str[1], $this->consonanti)) { $str = substr($str, 2); $str = strpbrk($str, implode($this->vocali)); return substr($str, 1); //secondo me devo mettere 1 } else { if (in_array($str[0], $this->vocali) && in_array($str[1], $this->vocali)) { $str = strpbrk($str, implode($this->consonanti)); return substr($str, 1); } else { if (in_array($str[0], $this->consonanti) && in_array($str[1], $this->vocali)) { return substr($str, 3); } } } }
/** * Checks for allowed characters * @see Zend\Validator\Barcode.AbstractAdapter::checkChars() */ public function checkChars($value) { $first = $value[0]; if (strpbrk($value, 'ABCD') !== false) { $first = $value[0]; if (strpbrk($first, 'ABCD') === false) { // Missing start char return false; } $last = substr($value, -1, 1); if (strpbrk($last, 'ABCD') === false) { // Missing stop char return false; } $value = substr($value, 1, -1); } $chars = $this->_characters; $this->_characters = '0123456789-$:/.+'; $result = parent::checkChars($value); $this->_characters = $chars; return $result; }
/** * @param string $field * @return string */ public static function createEntityPrefix($field) { $fullField = $field; $prefix = $field[0]; if (false !== ($pos = strpos($field, '_'))) { // snake_case do { $field = substr($field, $pos + 1); $prefix .= $field[0]; $pos = strpos($field, '_'); } while (false !== $pos); } else { // camelCase $camel = strpbrk($field, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'); while (0 < strlen($camel) && strlen($camel) < strlen($field)) { $prefix .= strtolower($camel[0]); $field = $camel; $camel = substr($camel, 1); $camel = strpbrk($camel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'); } } $number = 0; do { $result = $prefix . '_' . $number; if (!isset(self::$tableWidePrefixes[$result])) { self::$tableWidePrefixes[$result] = $fullField; break; } elseif (self::$tableWidePrefixes[$result] === $fullField) { break; } elseif (self::$tableWidePrefixes[$result] !== $fullField) { $number++; } } while (true); return $result; }
function sendEmail($nombre) { $saludo = ""; if (strpbrk($nombre)) { $message = ""; } }
public function line($text) { $markup = ''; $unexaminedText = $text; $markerPosition = 0; while ($excerpt = strpbrk($unexaminedText, $this->inlineMarkerList)) { $marker = $excerpt[0]; $markerPosition += strpos($unexaminedText, $marker); $Excerpt = array('text' => $excerpt, 'context' => $text); foreach ($this->InlineTypes[$marker] as $inlineType) { $Inline = $this->{'inline' . $inlineType}($Excerpt); if (!isset($Inline)) { continue; } if (isset($Inline['position']) and $Inline['position'] > $markerPosition) { continue; } if (!isset($Inline['position'])) { $Inline['position'] = $markerPosition; } $unmarkedText = substr($text, 0, $Inline['position']); $markup .= $this->unmarkedText($unmarkedText); $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']); $text = substr($text, $Inline['position'] + $Inline['extent']); $unexaminedText = $text; $markerPosition = 0; continue 2; } $unexaminedText = substr($excerpt, 1); $markerPosition++; } $markup .= $this->unmarkedText($text); return $markup; }
function SetUpForm($Character) { WriteHeaders(); echo "\n <div class = \"top\">\n\t Music - Alex Ash and Brett Akey\n\t</div>\n <div class = \"bigpiece\">\n\t <div class = \"leftpiece\"> \n\t \n <p>"; if (strpbrk($Character, "H")) { echo "<form action=? method=post>"; DisplayButton("nextPage", "Home", "WelcomePage"); echo "</form>"; } if (strpbrk($Character, "F")) { echo "<form action=? method=post>"; DisplayButton("nextPage", "Find Record", "FoundRecord"); echo "</form>"; } echo "<form action=? method=post>"; if (strpbrk($Character, "S")) { echo "<input type=submit name=\"nextPage\" class=\"submit\" value=\"Save\"> "; } if (strpbrk($Character, "C")) { echo "<form action=? method=post>"; DisplayButton("nextPage", "Save Changes", "ChangesMade"); echo "</form>"; } elseif (!strpbrk($Character, "S") && !strpbrk($Character, "H")) { DisplayButton("nextPage", "Create Table", "CreateTable"); DisplayButton("nextPage", "Add Record", "EnterData"); DisplayButton("nextPage", "Modify Record", "ModifyRecord"); DisplayButton("nextPage", "Display Data", "DisplayData"); } echo " </p>\n\t </div>\n\t <div class = \"middlepiece\" >\t \n\t "; }
/** * Create XML definition on an AMF service class * * @param string $serviceClass Service class name * @param array $options invocation options * @return string XML with service class introspection */ public function introspect($serviceClass, $options = array()) { $this->_options = $options; if (strpbrk($serviceClass, '\\/<>')) { return $this->_returnError('Invalid service name'); } // Transform com.foo.Bar into com_foo_Bar $serviceClass = str_replace('.' , '_', $serviceClass); // Introspect! if (!class_exists($serviceClass)) { require_once 'Zend/Loader.php'; Zend_Loader::loadClass($serviceClass, $this->_getServicePath()); } $serv = $this->_xml->createElement('service-description'); $serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008'); $this->_types = $this->_xml->createElement('types'); $this->_ops = $this->_xml->createElement('operations'); $r = Zend_Server_Reflection::reflectClass($serviceClass); $this->_addService($r, $this->_ops); $serv->appendChild($this->_types); $serv->appendChild($this->_ops); $this->_xml->appendChild($serv); return $this->_xml->saveXML(); }
protected function checkDbPassword() { /** @global CDataBase $DB */ global $DB; $password = $DB->DBPassword; $sign = ",.#!*%$:-"; $dit = "1234567890"; if(trim($password) == "") { $this->addUnformattedDetailError("SECURITY_SITE_CHECKER_DB_EMPTY_PASS", CSecurityCriticalLevel::HIGHT); } else { if($password == strtolower($password)) { $this->addUnformattedDetailError("SECURITY_SITE_CHECKER_DB_SAME_REGISTER_PASS", CSecurityCriticalLevel::HIGHT); } if(strpbrk($password, $sign) === false) { $this->addUnformattedDetailError("SECURITY_SITE_CHECKER_DB_NO_SIGN_PASS", CSecurityCriticalLevel::HIGHT); } if(strpbrk($password, $dit) === false) { $this->addUnformattedDetailError("SECURITY_SITE_CHECKER_DB_NO_DIT_PASS", CSecurityCriticalLevel::HIGHT); } if (strlen($password)<8) { $this->addUnformattedDetailError("SECURITY_SITE_CHECKER_DB_MIN_LEN_PASS", CSecurityCriticalLevel::HIGHT); } } }
public function change() { if (!isset($_SESSION['UserID'])) { redirect('Login/logout'); } //Create new user and load its data $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } //If user did not load, logout the session if ($user->isGuest()) { redirect('Mainpage'); } //If not a student, redirect to mainpage $oldpw = $this->input->post('oldpw'); $newpw = $this->input->post('newpw'); $newpw2 = $this->input->post('newpw2'); if (!$user->authenticate($oldpw)) { $this->load->view('changePassword', array('user' => $user, 'error' => TRUE)); } elseif ($newpw != $newpw2) { $this->load->view('changePassword', array('user' => $user, 'error2' => TRUE)); } elseif (strpbrk($newpw, '!@#$%&*-+=1234567890') === FALSE || strlen($newpw) < 8) { $this->load->view('changePassword', array('user' => $user, 'error3' => TRUE)); } elseif (strpbrk($newpw, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') === FALSE || strlen($newpw) < 8) { $this->load->view('changePassword', array('user' => $user, 'error3' => TRUE)); } else { $user->setPassword($newpw); $user->update(); $this->load->view('changePassword', array('user' => $user, 'success' => TRUE)); } }
/** * @param string $str * @param string $minlength * @param string $maxlength * @param int $baseerrcode * @return int */ function parse($str, $minlength = USER_MINLENGTH, $maxlength = USER_MAXLENGTH, $baseerrcode = 0) { $validchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_."; if ($str == '') { return 1 + $baseerrcode; } $length = strlen($str); if ($length < $minlength) { return 2 + $baseerrcode; } if ($length > $maxlength) { return 3 + $baseerrcode; } if (strpos($str, "__") !== false || strpos($str, "..") !== false || strpos($str, "_.") !== false || strpos($str, "._") !== false) { return 4 + $baseerrcode; } if (strpos($str, ".") === 0 || strpos($str, "_") === 0 || strpos($str, ".") === $length - 1 || strpos($str, "_") === $length - 1) { return 4 + $baseerrcode; } for ($i = 0; $i < $length; $i++) { if (strpbrk($str[$i], $validchars) === false) { return 4 + $baseerrcode; } } return 0; }
/** * {@inheritDoc} */ public function resolve($name) { if ($this->isLfiProtectionOn() && preg_match('#\\.\\.[\\\\/]#', $name)) { return null; } if (strpbrk($name, '[]*?') === false) { //skip files that don't look like globs return null; } foreach ($this->getPaths() as $path) { $joinedPath = $path . $name; $glob = glob($joinedPath); if (count($glob)) { // Get the mime type of the first file and assume its the same for all the rest (not ideal). // @todo Maybe this could be refactored into a MimeResolver $filePath = current($glob); $file = new SplFileInfo($filePath); $mimeType = $this->getMimeResolver()->getMimeType($file->getRealPath()); $asset = new GlobAsset($joinedPath); $asset->mimetype = $mimeType; return $asset; } } return null; }
function scanpassword($password) { $lower = false; $upper = false; $specialchar = false; $number = false; $possibilities = 0; $special = '!@#$%&*<>-_!@#$%&*<>-_'; for ($i = 0; $i < strlen($password); $i++) { if (preg_match("/[a-z]/", $password[$i]) && !$lower) { $possibilities += 26; $lower = true; } if (preg_match('/[A-Z]/', $password[$i]) && !$upper) { $possibilities += 26; $upper = true; } if (preg_match('/[0-9]/', $password[$i]) && !$number) { $possibilities += 10; $number = true; } if (strpbrk($password[$i], $special) && !$specialchar) { $possibilities += 15; $specialchar = true; } } $product['product'] = pow($possibilities, strlen($password)) / 4000000000; $product['possibilities'] = $possibilities; $product['quantity'] = strlen($password); $objPeriod = new Period(); $product['possibilities'] = $objPeriod->mountPossibilities($product); return $product; }
function extraireMots($dictee, $nbcar = 5, $mot = '') { $dictee = str_replace("\n", " ", $dictee); $tableau = explode(' ', $dictee); $nbmots = count($tableau); $dictionnaire = []; foreach ($tableau as $mots) { $mots = rtrim($mots, ','); $mots = rtrim($mots, '.'); $mots = rtrim($mots, ':'); $mots = ltrim($mots, '"'); if (strpbrk($mots, "-") != false) { $motComposes = explode('-', $mots); if (mb_strlen($motComposes[0]) >= $nbcar) { $dictionnaire[] = $motComposes[0]; } if (mb_strlen($motComposes[1]) >= $nbcar) { $dictionnaire[] = $motComposes[1]; } } elseif (mb_strlen($mots) >= $nbcar) { $dictionnaire[] = $mots; } } $motPresent = in_array($mot, $dictionnaire); $resultat = array($nbmots, $dictionnaire, $motPresent); return $resultat; }
/** * @param $handle * @param $fields * @param string $delimiter * @param string $enclosure * @param bool $useArrayKey * @param string $escape */ public static function putCSV($handle, $fields, $delimiter = ',', $enclosure = '"', $useArrayKey = false, $escape = '\\') { $first = 1; foreach ($fields as $key => $field) { if ($first == 0) { fwrite($handle, $delimiter); } if ($useArrayKey) { $f = str_replace($enclosure, $enclosure . $enclosure, $key); } else { $field = EXPORT_ENCODE_FUNCTION != "none" && function_exists(EXPORT_ENCODE_FUNCTION) ? call_user_func(EXPORT_ENCODE_FUNCTION, $field) : $field; $f = str_replace($enclosure, $enclosure . $enclosure, $field); } if ($enclosure != $escape) { $f = str_replace($escape . $enclosure, $escape, $f); } if (strpbrk($f, " \t\n\r" . $delimiter . $enclosure . $escape) || strchr($f, "")) { fwrite($handle, $enclosure . $f . $enclosure); } else { fwrite($handle, $f); } $first = 0; } fwrite($handle, "\n"); }
/** * Map route to all public controller method * * with * Route::get('/prefix', 'ClassController') * * this will map * GET domain.com/prefix -> ClassController::getIndex * POST domain.com/prefix -> ClassCOntroller::postIndex * PUT domain.com/prefix -> ClassCOntroller::putIndex */ public static function controller() { $arguments = func_get_args(); $path = $arguments[0]; $controller = end($arguments); $class = new \ReflectionClass($controller); $controllerMethods = $class->getMethods(\ReflectionMethod::IS_PUBLIC); $uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; foreach ($controllerMethods as $method) { if (substr($method->name, 0, 2) != '__') { $methodName = $method->name; $callable = $arguments; $pos = strcspn($methodName, $uppercase); $httpMethod = substr($methodName, 0, $pos); $ctrlMethod = lcfirst(strpbrk($methodName, $uppercase)); if ($ctrlMethod == 'index') { $pathMethod = $path; } else { if ($httpMethod == 'get') { $pathMethod = "{$path}/{$ctrlMethod}(/:params+)"; } else { $pathMethod = "{$path}/{$ctrlMethod}"; } } //put edited pattern to the top stack array_shift($callable); array_unshift($callable, $pathMethod); //put edited controller to the bottom stack array_pop($callable); array_push($callable, "{$controller}:{$methodName}"); call_user_func_array(array(self::$slim, $httpMethod), $callable); } } }
/** * Class constructor. * * @param string $metadataUrl The URL of the plugin's metadata file. * @param string $pluginFile Fully qualified path to the main plugin file. * @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug. * @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks. * @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'. * @param string $muPluginFile Optional. The plugin filename relative to the mu-plugins directory. */ public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') { $this->metadataUrl = $metadataUrl; $this->pluginAbsolutePath = $pluginFile; $this->pluginFile = plugin_basename($this->pluginAbsolutePath); $this->muPluginFile = $muPluginFile; $this->slug = $slug; $this->optionName = $optionName; $this->debugMode = (bool) constant('WP_DEBUG'); //If no slug is specified, use the name of the main plugin file as the slug. //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'. if (empty($this->slug)) { $this->slug = basename($this->pluginFile, '.php'); } if (empty($this->optionName)) { $this->optionName = 'external_updates-' . $this->slug; } //Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume //it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir). if (strpbrk($this->pluginFile, '/\\') === false && $this->isUnknownMuPlugin()) { $this->muPluginFile = $this->pluginFile; } $this->scheduler = $this->createScheduler($checkPeriod); $this->upgraderStatus = new PucUpgraderStatus_3_0(); $this->installHooks(); }
/** * Class constructor. * * @param string $metadataUrl The URL of the plugin's metadata file. * @param string $pluginFile Fully qualified path to the main plugin file. * @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug. * @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks. * @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'. * @param string $muPluginFile Optional. The plugin filename relative to the mu-plugins directory. */ public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') { $this->metadataUrl = $metadataUrl; $this->pluginAbsolutePath = $pluginFile; $this->pluginFile = plugin_basename($this->pluginAbsolutePath); $this->muPluginFile = $muPluginFile; $this->slug = $slug; $this->optionName = $optionName; $this->debugMode = (bool) constant('WP_DEBUG'); //If no slug is specified, use the name of the main plugin file as the slug. //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'. if (empty($this->slug)) { $this->slug = basename($this->pluginFile, '.php'); } //Plugin slugs must be unique. $slugCheckFilter = 'puc_is_slug_in_use-' . $this->slug; $slugUsedBy = apply_filters($slugCheckFilter, false); if ($slugUsedBy) { $this->triggerError(sprintf('Plugin slug "%s" is already in use by %s. Slugs must be unique.', htmlentities($this->slug), htmlentities($slugUsedBy)), E_USER_ERROR); } add_filter($slugCheckFilter, array($this, 'getAbsolutePath')); if (empty($this->optionName)) { $this->optionName = 'external_updates-' . $this->slug; } //Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume //it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir). if (strpbrk($this->pluginFile, '/\\') === false && $this->isUnknownMuPlugin()) { $this->muPluginFile = $this->pluginFile; } $this->scheduler = $this->createScheduler($checkPeriod); $this->upgraderStatus = new PucUpgraderStatus_3_1(); $this->installHooks(); }
/** * Quote the cookie value if it is not already quoted and it contains * problematic characters. * * @param string $value Value that may or may not need to be quoted * * @return string */ public static function getCookieValue($value) { if (substr($value, 0, 1) !== '"' && substr($value, -1, 1) !== '"' && strpbrk($value, ';,')) { $value = '"' . $value . '"'; } return $value; }
function makeButton() { global $sabnzbd_ip; global $sabnzbd_port; global $sabnzbd_api; $sabnzbdXML = simplexml_load_file('http://' . $sabnzbd_ip . ':' . $sabnzbd_port . '/api?mode=qstatus&output=xml&apikey=' . $sabnzbd_api); if ($sabnzbdXML->state == 'Downloading') { $speed = $sabnzbdXML->speed; if (strpbrk($speed, 'K')) { // This converts the speed from KBps or MBps to Mbps $convertedSpeed = number_format(substr($speed, 0, strlen($speed) - 2) * 8 / 1024, 1); } else { $convertedSpeed = number_format(substr($speed, 0, strlen($speed) - 2) * 8, 0); } $icon = '<i class="icon-' . ($this->status ? 'download-alt' : 'remove') . ' icon-white"></i>'; $txt = $this->status ? $convertedSpeed . 'Mb' : 'Offline'; } else { $icon = '<i class="icon-' . ($this->status ? 'ok' : 'remove') . ' icon-white"></i>'; $txt = $this->status ? 'Online' : 'Offline'; } $btn = $this->status ? 'success' : 'warning'; $prefix = $this->url == "" ? '<button style="width:62px" class="btn btn-xs btn-' . $btn . ' disabled">' : '<a href="' . $this->url . '" style="width:62px" class="btn btn-xs btn-' . $btn . '">'; $suffix = $this->url == "" ? '</button>' : '</a>'; return $prefix . $icon . " " . $txt . $suffix; }
public function display(array $data, $template = null, $return = false) { $view = waSystem::getInstance()->getView(); if ($template === null) { $template = ucfirst($this->action); } if (strpbrk($template, '/:') === false) { $match = array(); preg_match("/[A-Z][^A-Z]+/", get_class($this), $match); $template = $this->getPluginRoot() . 'templates/actions/' . strtolower($match[0]) . "/" . $match[0] . $template . $view->getPostfix(); } // assign vars $view->assign($data); if ($this->layout && $this->layout instanceof waLayout) { // assign result to layout $this->layout->setBlock('content', $view->fetch($template)); $this->layout->display(); } else { // send headers $this->getResponse()->sendHeaders(); // display if ($return) { return $view->fetch($template); } else { $view->display($template); } } }
function setUpForm($buttons) { WriteHeaders("Music, Real Ortelli", "Music"); echo "<div class = \"bigpiece\">"; echo "<form action = \"?\" method=\"POST\">"; echo "<div class = \"leftpiece\">"; if (strpbrk("{$buttons}", "S")) { DisplayButton("button", "Save", "", "Save", "save"); } if (strpbrk("{$buttons}", "H")) { DisplayButton("button", "Home", "", "Home", "home"); } if (strpbrk("{$buttons}", "A")) { DisplayButton("button", "Add Record", "", "Add Record", "addRecord"); } if (strpbrk("{$buttons}", "C")) { DisplayButton("button", "Create Table", "", "Create Table", "createTable"); } if (strpbrk("{$buttons}", "M")) { DisplayButton("button", "Modify Record", "", "Modify Record", "modifyRecord"); } if (strpbrk("{$buttons}", "D")) { DisplayButton("button", "Display Data", "", "Display Data", "displayData"); } if (strpbrk("{$buttons}", "F")) { DisplayButton("button", "Find Record", "", "Find Record", "findRecord"); } if (strpbrk("{$buttons}", "K")) { DisplayButton("button", "Save Changes", "", "Save Changes", "saveChanges"); } echo "</div>"; echo "<div class = \"middlepiece\">"; }
/** * Parses a DNUMBER token like PHP would. * * @param string $str A string number * * @return float The parsed number */ public static function parse($str) { // if string contains any of .eE just cast it to float if (false !== strpbrk($str, '.eE')) { return (double) $str; } // otherwise it's an integer notation that overflowed into a float // if it starts with 0 it's one of the special integer notations if ('0' === $str[0]) { // hex if ('x' === $str[1] || 'X' === $str[1]) { return hexdec($str); } // bin if ('b' === $str[1] || 'B' === $str[1]) { return bindec($str); } // oct // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9) // so that only the digits before that are used return octdec(substr($str, 0, strcspn($str, '89'))); } // dec return (double) $str; }
/** * Class constructor. * * @param string $metadata_url The URL of the plugin's metadata file. * @param string $path_to_main_plugin_file Fully qualified path to the main plugin file. * @param string $slug The plugin's 'slug'. If not specified, the filename part of $path_to_main_plugin_file sans '.php' will be used as the slug. * @param integer $check_period How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks. * @param string $option_db_name Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'. * @param string $mu_path_to_main_plugin_file Optional. The plugin filename relative to the mu-plugins directory. */ public function __construct($metadata_url, $path_to_main_plugin_file, $slug = '', $check_period = 12, $option_db_name = '', $mu_path_to_main_plugin_file = '') { $this->metadata_url = $metadata_url; $this->pluginAbsolutePath = $path_to_main_plugin_file; $this->path_to_main_plugin_file = plugin_basename($this->pluginAbsolutePath); $this->mu_path_to_main_plugin_file = $mu_path_to_main_plugin_file; $this->check_period = $check_period; $this->slug = $slug; $this->option_db_name = $option_db_name; $this->debugMode = defined('WP_DEBUG') && WP_DEBUG; //If no slug is specified, use the name of the main plugin file as the slug. //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'. if (empty($this->slug)) { $this->slug = basename($this->path_to_main_plugin_file, '.php'); } if (empty($this->option_db_name)) { $this->option_db_name = $this->slug . '_updates'; } //Backwards compatibility: If the plugin is a mu-plugin but no $mu_path_to_main_plugin_file is specified, assume //it's the same as $path_to_main_plugin_file given that it's not in a subdirectory (WP only looks in the base dir). if (empty($this->mu_path_to_main_plugin_file) && strpbrk($this->path_to_main_plugin_file, '/\\') === false && $this->isMuPlugin()) { $this->mu_path_to_main_plugin_file = $this->path_to_main_plugin_file; } $this->installHooks(); }
/** * Checks for allowed characters * @see Zend\Validator\Barcode.AbstractAdapter::checkChars() */ public function hasValidCharacters($value) { if (strpbrk($value, 'ABCD')) { $first = $value[0]; if (!strpbrk($first, 'ABCD')) { // Missing start char return false; } $last = substr($value, -1, 1); if (!strpbrk($last, 'ABCD')) { // Missing stop char return false; } $value = substr($value, 1, -1); } elseif (strpbrk($value, 'TN*E')) { $first = $value[0]; if (!strpbrk($first, 'TN*E')) { // Missing start char return false; } $last = substr($value, -1, 1); if (!strpbrk($last, 'TN*E')) { // Missing stop char return false; } $value = substr($value, 1, -1); } $chars = $this->getCharacters(); $this->setCharacters('0123456789-$:/.+'); $result = parent::hasValidCharacters($value); $this->setCharacters($chars); return $result; }
public static function stringNeedsQuoted($s) { if (strpbrk($s, ";:,")) { return true; } return false; }
/** * @param string $enc_data * @param string $salt * @return bool|mixed */ function decrypt_gpg($enc_data, $salt) { if (!function_exists("gnupg_init") || !function_exists("gnupg_adddecryptkey") || !function_exists("gnupg_decrypt") || !function_exists("gnupg_geterror")) { error_log("Required GnuPG functions not available. Bypassing password RSA decryption..."); return $enc_data; } if (!defined('SYNAPP_GPG_KEY_FINGERPRINT')) { error_log("Missing required GnuPG settings. Bypassing password RSA decryption..."); return $enc_data; } if (defined('CRYPT_BYPASS') && (CRYPT_BYPASS === true || strtolower(CRYPT_BYPASS) === "1" || strtolower(CRYPT_BYPASS) === "true" || strtolower(CRYPT_BYPASS) === "on")) { return $enc_data; } $res = gnupg_init(); $env = getenv('GNUPGHOME'); if (!gnupg_adddecryptkey($res, SYNAPP_GPG_KEY_FINGERPRINT, "")) { $error = gnupg_geterror($res); error_log("Error trying to add decryption key on " . $env); error_log($error); } if (($dec_data = gnupg_decrypt($res, $enc_data)) === false) { $error = gnupg_geterror($res); error_log("Error trying to use decryption key on " . $env); error_log($error); } $dec_data_saltless = preg_replace('/' . preg_quote($salt, '/') . '$/', '', $dec_data); if ($dec_data_saltless === $dec_data) { return false; } $dec_out = preg_replace('/' . preg_quote(strpbrk($dec_data_saltless, '@'), '/') . '$/', '', $dec_data_saltless); return $dec_out; }
/** * Create XML definition on an AMF service class * * @param string $serviceClass Service class name * @param array $options invocation options * @return string XML with service class introspection */ public function introspect($serviceClass, $options = array()) { $this->_options = $options; if (strpbrk($serviceClass, '\\/<>')) { return $this->_returnError('Invalid service name'); } // Transform com.foo.Bar into com\foo\Bar $serviceClass = str_replace('.', '\\', $serviceClass); // Introspect! if (!class_exists($serviceClass)) { if (!$this->_loadClass($serviceClass)) { return $this->_returnError('Invalid service name; class does not exist'); } } $serv = $this->_xml->createElement('service-description'); $serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008'); $this->_types = $this->_xml->createElement('types'); $this->_ops = $this->_xml->createElement('operations'); $r = Reflection::reflectClass($serviceClass); $this->_addService($r, $this->_ops); $serv->appendChild($this->_types); $serv->appendChild($this->_ops); $this->_xml->appendChild($serv); return $this->_xml->saveXML(); }
/** * a program (by it's basename) is available on system for execution * * @param $program * @return bool */ public static function isProgramInstalled($program) { // programs with an invalid name do not exist if (false !== strpbrk($program, self::FORBIDDEN_CHARS)) { return false; } $isExecutable = self::isExecutableName($program); $paths = explode(self::PATH_SEPARATOR, getenv('PATH')); array_unshift($paths, getcwd()); $exts = self::getInstance()->getExecuteableExtesions(); foreach ($paths as $path) { if (!is_dir($path)) { continue; } $file = $path . '/' . $program; if ($isExecutable && is_readable($file)) { return true; } foreach ($exts as $ext => $index) { $fileEx = $file . $ext; if (is_readable($fileEx)) { return true; } } } return false; }
/** * Encoder les entites * @param string $texte * @return string */ function xml_entites_html($texte) { if (!is_string($texte) or !$texte or strpbrk($texte, "&\"'<>") == false) { return $texte; } $texte = htmlspecialchars($texte, ENT_QUOTES); return $texte; }
static function symbol(&$stream) { $buf = ""; while (sizeof($stream) != 0 and !strpbrk(Reader::$ignore, $stream[0])) { $buf .= array_shift($stream); } return ($buf == "null" or $buf == "nil") ? null : symbol($buf); }