示例#1
1
 /**
  * Add a complex type by recursivly using all the class properties fetched via Reflection.
  *
  * @param  string $type Name of the class to be specified
  * @return string XSD Type for the given PHP type
  */
 public function addComplexType($type)
 {
     if (!class_exists($type)) {
         throw new \Zend\Soap\WSDL\Exception(sprintf('Cannot add a complex type %s that is not an object or where ' . 'class could not be found in \'DefaultComplexType\' strategy.', $type));
     }
     $dom = $this->getContext()->toDomDocument();
     $class = new \ReflectionClass($type);
     $complexType = $dom->createElement('xsd:complexType');
     $complexType->setAttribute('name', $type);
     $all = $dom->createElement('xsd:all');
     foreach ($class->getProperties() as $property) {
         if ($property->isPublic() && preg_match_all('/@var\\s+([^\\s]+)/m', $property->getDocComment(), $matches)) {
             /**
              * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
              * node for describing other classes used as attribute types for current class
              */
             $element = $dom->createElement('xsd:element');
             $element->setAttribute('name', $property->getName());
             $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
             $all->appendChild($element);
         }
     }
     $complexType->appendChild($all);
     $this->getContext()->getSchema()->appendChild($complexType);
     $this->getContext()->addType($type);
     return "tns:{$type}";
 }
 public static function convertDateMomentToPhp($format)
 {
     $tokens = ["M" => "n", "Mo" => "nS", "MM" => "m", "MMM" => "M", "MMMM" => "F", "D" => "j", "Do" => "jS", "DD" => "d", "DDD" => "z", "DDDo" => "zS", "DDDD" => "zS", "d" => "w", "do" => "wS", "dd" => "D", "ddd" => "D", "dddd" => "l", "e" => "w", "E" => "N", "w" => "W", "wo" => "WS", "ww" => "W", "W" => "W", "Wo" => "WS", "WW" => "W", "YY" => "y", "YYYY" => "Y", "gg" => "o", "gggg" => "o", "GG" => "o", "GGGG" => "o", "A" => "A", "a" => "a", "H" => "G", "HH" => "H", "h" => "g", "hh" => "h", "m" => "i", "mm" => "i", "s" => "s", "ss" => "s", "S" => "", "SS" => "", "SSS" => "", "z or zz" => "T", "Z" => "P", "ZZ" => "O", "X" => "U", "LT" => "g:i A", "L" => "m/d/Y", "l" => "n/j/Y", "LL" => "F jS Y", "ll" => "M j Y", "LLL" => "F js Y g:i A", "lll" => "M j Y g:i A", "LLLL" => "l, F jS Y g:i A", "llll" => "D, M j Y g:i A"];
     // find all tokens from string, using regular expression
     $regExp = "/(\\[[^\\[]*\\])|(\\\\)?(LT|LL?L?L?|l{1,4}|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/";
     $matches = array();
     preg_match_all($regExp, $format, $matches);
     //  if there is no match found then return the string as it is
     //  TODO: might return escaped string
     if (empty($matches) || is_array($matches) === false) {
         return $format;
     }
     //  to match with extracted tokens
     $momentTokens = array_keys($tokens);
     $phpMatches = array();
     //  ----------------------------------
     foreach ($matches[0] as $id => $match) {
         // if there is a matching php token in token list
         if (in_array($match, $momentTokens)) {
             // use the php token instead
             $string = $tokens[$match];
         } else {
             $string = $match;
         }
         $phpMatches[$id] = $string;
     }
     // join and return php specific tokens
     return implode("", $phpMatches);
 }
示例#3
1
 public function imitateLogin($sdutnum, $password)
 {
     //模拟登录
     $cookie_jar = dirname(__FILE__) . "/cookie";
     $urlLogin = "******";
     $post = "number={$sdutnum}&passwd={$password}&select=cert_no&returnUrl=";
     $this->curl->login_post($urlLogin, $cookie_jar, $post);
     //抓取内容
     $urlBook = "http://222.206.65.12/reader/book_lst.php";
     $html = $this->curl->get_content($urlBook, $cookie_jar);
     $loginReg = "/logout/";
     $BookReg = "/<td.*/";
     $buttonReg = "/<div\\sid=\"\\w\"><input.*\\/>/";
     $nameReg = '/height="11" \\/>.*logout/';
     $numReg = '/<p>.*<b/';
     //book number
     preg_match_all($loginReg, $html, $isLogin);
     //to judgment whether login
     preg_match_all($BookReg, $html, $bookArray);
     preg_match_all($buttonReg, $html, $buttonArray);
     preg_match_all($nameReg, $html, $nameArray);
     //username
     preg_match_all($numReg, $html, $numArray);
     empty($nameArray[0]) ? $username = null : ($username = substr($nameArray[0][0], 14, -37));
     empty($numArray[0]) ? $bookNum = null : ($bookNum = substr($numArray[0][0], 45, -25));
     $bookData['sdutnum'] = $sdutnum;
     /* after changed session*/
     $bookData['isLogin'] = $isLogin;
     $bookData['bookArray'] = $bookArray;
     $bookData['buttonArray'] = $buttonArray;
     $bookData['username'] = $username;
     $bookData['numArray'] = $numArray;
     $bookData['bookNum'] = $bookNum;
     return $bookData;
 }
示例#4
1
/**
 * Sanitizes $message, taking into account our special codes
 * for formatting.
 *
 * If you want to include result in element attribute, you should escape it.
 *
 * Examples:
 *
 * <p><?php echo PMA_sanitize($foo); ?></p>
 *
 * <a title="<?php echo PMA_sanitize($foo, true); ?>">bar</a>
 *
 * @uses    preg_replace()
 * @uses    strtr()
 * @param   string   the message
 * @param   boolean  whether to escape html in result
 *
 * @return  string   the sanitized message
 *
 * @access  public
 */
function PMA_sanitize($message, $escape = false, $safe = false)
{
    if (!$safe) {
        $message = strtr($message, array('<' => '&lt;', '>' => '&gt;'));
    }
    $replace_pairs = array('[i]' => '<em>', '[/i]' => '</em>', '[em]' => '<em>', '[/em]' => '</em>', '[b]' => '<strong>', '[/b]' => '</strong>', '[strong]' => '<strong>', '[/strong]' => '</strong>', '[tt]' => '<code>', '[/tt]' => '</code>', '[code]' => '<code>', '[/code]' => '</code>', '[kbd]' => '<kbd>', '[/kbd]' => '</kbd>', '[br]' => '<br />', '[/a]' => '</a>', '[sup]' => '<sup>', '[/sup]' => '</sup>');
    $message = strtr($message, $replace_pairs);
    $pattern = '/\\[a@([^"@]*)@([^]"]*)\\]/';
    if (preg_match_all($pattern, $message, $founds, PREG_SET_ORDER)) {
        $valid_links = array('http', './Do', './ur');
        foreach ($founds as $found) {
            // only http... and ./Do... allowed
            if (!in_array(substr($found[1], 0, 4), $valid_links)) {
                return $message;
            }
            // a-z and _ allowed in target
            if (!empty($found[2]) && preg_match('/[^a-z_]+/i', $found[2])) {
                return $message;
            }
        }
        if (substr($found[1], 0, 4) == 'http') {
            $message = preg_replace($pattern, '<a href="' . PMA_linkURL($found[1]) . '" target="\\2">', $message);
        } else {
            $message = preg_replace($pattern, '<a href="\\1" target="\\2">', $message);
        }
    }
    if ($escape) {
        $message = htmlspecialchars($message);
    }
    return $message;
}
示例#5
0
 protected function loadColumnData($table, $schema)
 {
     if (isset($this->data['columns'][$schema][$table])) {
         return;
     }
     $this->prepareDataHierarchy('columns', $schema, $table);
     $p = $this->adapter->getPlatform();
     $isColumns = array(array('C', 'ORDINAL_POSITION'), array('C', 'COLUMN_DEFAULT'), array('C', 'IS_NULLABLE'), array('C', 'DATA_TYPE'), array('C', 'CHARACTER_MAXIMUM_LENGTH'), array('C', 'CHARACTER_OCTET_LENGTH'), array('C', 'NUMERIC_PRECISION'), array('C', 'NUMERIC_SCALE'), array('C', 'COLUMN_NAME'), array('C', 'COLUMN_TYPE'));
     array_walk($isColumns, function (&$c) use($p) {
         $c = $p->quoteIdentifierChain($c);
     });
     $sql = 'SELECT ' . implode(', ', $isColumns) . ' FROM ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'TABLES')) . 'T' . ' INNER JOIN ' . $p->quoteIdentifierChain(array('INFORMATION_SCHEMA', 'COLUMNS')) . 'C' . ' ON ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) . '  = ' . $p->quoteIdentifierChain(array('C', 'TABLE_SCHEMA')) . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) . '  = ' . $p->quoteIdentifierChain(array('C', 'TABLE_NAME')) . ' WHERE ' . $p->quoteIdentifierChain(array('T', 'TABLE_TYPE')) . ' IN (\'BASE TABLE\', \'VIEW\')' . ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_NAME')) . '  = ' . $p->quoteTrustedValue($table);
     if ($schema != self::DEFAULT_SCHEMA) {
         $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) . ' = ' . $p->quoteTrustedValue($schema);
     } else {
         $sql .= ' AND ' . $p->quoteIdentifierChain(array('T', 'TABLE_SCHEMA')) . ' != \'INFORMATION_SCHEMA\'';
     }
     $results = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
     $columns = array();
     foreach ($results->toArray() as $row) {
         $erratas = array();
         $matches = array();
         if (preg_match('/^(?:enum|set)\\((.+)\\)$/i', $row['COLUMN_TYPE'], $matches)) {
             $permittedValues = $matches[1];
             if (preg_match_all("/\\s*'((?:[^']++|'')*+)'\\s*(?:,|\$)/", $permittedValues, $matches, PREG_PATTERN_ORDER)) {
                 $permittedValues = str_replace("''", "'", $matches[1]);
             } else {
                 $permittedValues = array($permittedValues);
             }
             $erratas['permitted_values'] = $permittedValues;
         }
         $columns[$row['COLUMN_NAME']] = array('ordinal_position' => $row['ORDINAL_POSITION'], 'column_default' => $row['COLUMN_DEFAULT'], 'is_nullable' => 'YES' == $row['IS_NULLABLE'], 'data_type' => $row['DATA_TYPE'], 'character_maximum_length' => $row['CHARACTER_MAXIMUM_LENGTH'], 'character_octet_length' => $row['CHARACTER_OCTET_LENGTH'], 'numeric_precision' => $row['NUMERIC_PRECISION'], 'numeric_scale' => $row['NUMERIC_SCALE'], 'numeric_unsigned' => false !== strpos($row['COLUMN_TYPE'], 'unsigned'), 'erratas' => $erratas);
     }
     $this->data['columns'][$schema][$table] = $columns;
 }
示例#6
0
 private function get_dependencies()
 {
     preg_match_all('/#dependency (.*)/', $this->output, $dependencies);
     foreach ($dependencies[1] as $dependency) {
         $this->dependencies[] = trim($dependency);
     }
 }
示例#7
0
/**
 * On modifie les URLS des images dans le corps de l'article
 */
function filtre_picture($content, $url, $id)
{
    $matches = array();
    $processing_pictures = array();
    // list of processing image to avoid processing the same pictures twice
    preg_match_all('#<\\s*(img)[^>]+src="([^"]*)"[^>]*>#Si', $content, $matches, PREG_SET_ORDER);
    foreach ($matches as $i => $link) {
        $link[1] = trim($link[1]);
        if (!preg_match('#^(([a-z]+://)|(\\#))#', $link[1])) {
            $absolute_path = get_absolute_link($link[2], $url);
            $filename = basename(parse_url($absolute_path, PHP_URL_PATH));
            $directory = create_assets_directory($id);
            $fullpath = $directory . '/' . $filename;
            if (in_array($absolute_path, $processing_pictures) === true) {
                // replace picture's URL only if processing is OK : already processing -> go to next picture
                continue;
            }
            if (download_pictures($absolute_path, $fullpath) === true) {
                $content = str_replace($matches[$i][2], $fullpath, $content);
            }
            $processing_pictures[] = $absolute_path;
        }
    }
    return $content;
}
示例#8
0
 function index()
 {
     $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS;
     $files = \GCore\Libs\Folder::getFiles($path, true);
     $strings = array();
     //function to prepare strings
     $prepare = function ($str) {
         /*$path = \GCore\C::get('GCORE_FRONT_PATH');
         		if(strpos($str, $path) !== false AND strpos($str, $path) == 0){
         			return '//'.str_replace($path, '', $str);
         		}*/
         $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : '';
         return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";';
     };
     foreach ($files as $file) {
         if (substr($file, -4, 4) == '.php') {
             // AND strpos($file, DS.'extensions'.DS) === TRUE){
             //$strings[] = $file;
             $file_code = file_get_contents($file);
             preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs);
             if (!empty($langs[2])) {
                 $strings = array_merge($strings, $langs[2]);
             }
         }
     }
     $strings = array_unique($strings);
     $strings = array_map($prepare, $strings);
     echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>';
 }
 public function Download($link)
 {
     global $premium_acc;
     // check link
     if (preg_match('@http:\\/\\/filejungle\\.com\\/l\\/[^|\\r|\\n]+@i', $link, $dir)) {
         if (!$dir[0]) {
             html_error('Filejungle folder link can\'t be found!');
         }
         $check = $this->GetPage($link);
         preg_match_all('@http:\\/\\/www\\.filejungle\\.com\\/f\\/[^"]+@i', $check, $fj, PREG_SET_ORDER);
         $arr_link = array();
         foreach ($fj as $match) {
             $arr_link[] = $match[0];
         }
         if (!$arr_link) {
             html_error('Can\'t find filejungle single link, probably folder is empty?');
         }
         $this->moveToAutoDownloader($arr_link);
     }
     if ($_REQUEST['premium_acc'] == 'on' && $_REQUEST['premium_user'] && $_REQUEST['premium_pass'] || $_REQUEST['premium_acc'] == 'on' && $premium_acc['filejungle_com']['user'] && $premium_acc['filejungle_com']['pass']) {
         return $this->Premium($link);
     } else {
         return $this->Free($link);
     }
 }
示例#10
0
 /**
  * Counting terminal char width
  * @return int
  */
 private static function getMaxColumns()
 {
     if (preg_match_all("/columns.([0-9]+);/", strtolower(@exec('stty -a | grep columns')), $output) && 2 == sizeof($output)) {
         return $output[1][0];
     }
     return 80;
 }
 protected function createRow($items, $aData = array(), $level = 1)
 {
     if ($items->count()) {
         foreach ($items as $itm) {
             $getter = 'get' . $this->getValueField();
             $aResultTmp = array('Value' => call_user_func(array($itm, $getter)), 'Name' => $this->getTextFormat());
             $aRs = array();
             if (preg_match_all("/:(.*):/iU", $aResultTmp['Name'], $aRs)) {
                 foreach ($aRs[1] as $k => $val) {
                     $value = $itm;
                     if (strpos($val, "-") !== false) {
                         $xVal = explode("-", $val);
                         foreach ($xVal as $_val) {
                             $sGetter = 'get' . $_val;
                             $value = call_user_func(array($value, $sGetter));
                         }
                     } else {
                         $sGetter = 'get' . $val;
                         $value = call_user_func(array($value, $sGetter));
                     }
                     $aResultTmp['Name'] = str_replace($aRs[0][$k], $value, $aResultTmp['Name']);
                 }
             }
             if ($this->getIsTree() && $level > 1) {
                 $aResultTmp['Name'] = str_repeat(" |-- ", $level - 1) . $aResultTmp['Name'];
             }
             $aData[] = $aResultTmp;
             if ($itm->hasChilds()) {
                 $aData = $this->createRow($itm->getChilds(), $aData, $level + 1);
             }
         }
     }
     return $aData;
 }
示例#12
0
 public function extractPage($pageID, $pageTitle, $pageSource)
 {
     $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID());
     $category = Util::getMediaWikiNamespace($this->language, MW_CATEGORY_NAMESPACE);
     if (preg_match_all("/" . $category . ":(.*)/", $pageID, $match)) {
         $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_PREFLABEL, false), RDFtriple::Literal($this->decode_title($pageTitle), NULL, $this->language));
         $result->addTriple($this->getPageURI(), RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(SKOS_CONCEPT, false));
         if (preg_match_all("/\\[\\[" . $category . ":(.*)\\]\\]/", $pageSource, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $match) {
                 // split on | sign
                 if (strpos($match[1], '|') === false) {
                     $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($match[1]);
                 } else {
                     $split = explode('|', $match[1]);
                     $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($split[0]);
                 }
                 try {
                     $object = RDFtriple::URI($object);
                 } catch (Exception $e) {
                     echo 'Caught exception: ', $e->getMessage(), "\n";
                     continue;
                 }
                 $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_BROADER, false), $object);
             }
         }
     }
     return $result;
 }
 private static function parseParameters($text)
 {
     $text = preg_replace('/[\\x{00a0}\\x{200b}]+/u', ' ', $text);
     if (!preg_match_all(static::$argumentsRegex, $text, $matches, PREG_SET_ORDER)) {
         return ltrim($text) ? array(ltrim($text) => null) : array();
     }
     $parameters = array();
     foreach ($matches as $match) {
         if (!empty($match[1])) {
             $parameters[strtolower($match[1])] = stripcslashes($match[2]);
         } elseif (!empty($match[3])) {
             $parameters[strtolower($match[3])] = stripcslashes($match[4]);
         } elseif (!empty($match[5])) {
             $parameters[strtolower($match[5])] = stripcslashes($match[6]);
         } elseif (isset($match[7]) && strlen($match[7])) {
             $parameters[stripcslashes($match[7])] = null;
         } elseif (isset($match[8])) {
             $parameters[stripcslashes($match[8])] = null;
         }
     }
     foreach ($parameters as $key => $value) {
         if (false !== strpos($value, '<') && 1 !== preg_match('/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value)) {
             $parameters[$key] = '';
         }
     }
     return $parameters;
 }
示例#14
0
function get_recipe($recipe)
{
    global $doc, $xpath;
    $url = 'http://www.marmiton.org/recettes/recherche.aspx?aqt=' . urlencode($recipe);
    $pageList = file_get_contents($url);
    // get response list and match recipes titles
    if (preg_match_all('#m_titre_resultat[^\\<]*<a .*title="(.+)".* href="(.+)"#isU', $pageList, $matchesList)) {
        // echo"<xmp>";print_r($matchesList[1]);echo"</xmp>";
        // for each recipes titles
        // foreach($matchesList[1] as $recipeTitle) {
        // }
        // take first recipe
        $n = 0;
        $url = 'http://www.marmiton.org' . $matchesList[2][$n];
        $pageRecipe = file_get_contents($url);
        // get recipe (minimize/clean before dom load)
        if (preg_match('#<div class="m_content_recette_main">.*<div id="recipePrevNext2"></div>\\s*</div>#isU', $pageRecipe, $match)) {
            $recipe = $match[0];
            $recipe = preg_replace('#<script .*</script>#isU', '', $recipe);
            $doc = loadDOC($pageRecipe);
            $xpath = new DOMXpath($doc);
            $recipeTitle = fetchOne('//h1[@class="m_title"]');
            $recipeMain = fetchOne('//div[@class="m_content_recette_main"]');
            return '<div class="recipe_root">' . $recipeTitle . $recipeMain . '</div>';
        }
    }
}
/**
 * Smarty trimwhitespace outputfilter plugin
 *
 * File:     outputfilter.trimwhitespace.php<br>
 * Type:     outputfilter<br>
 * Name:     trimwhitespace<br>
 * Date:     Jan 25, 2003<br>
 * Purpose:  trim leading white space and blank lines from
 *           template source after it gets interpreted, cleaning
 *           up code and saving bandwidth. Does not affect
 *           <<PRE>></PRE> and <SCRIPT></SCRIPT> blocks.<br>
 * Install:  Drop into the plugin directory, call
 *           <code>$smarty->load_filter('output','trimwhitespace');</code>
 *           from application.
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @author Contributions from Lars Noschinski <*****@*****.**>
 * @version  1.3
 * @param string $source input string
 * @param object &$smarty Smarty object
 * @return string filtered output
 */
function smarty_outputfilter_trimwhitespace($source, $smarty)
{
    // Pull out the script blocks
    preg_match_all("!<script[^>]*?>.*?</script>!is", $source, $match);
    $_script_blocks = $match[0];
    $source = preg_replace("!<script[^>]*?>.*?</script>!is", '@@@SMARTY:TRIM:SCRIPT@@@', $source);
    // Pull out the pre blocks
    preg_match_all("!<pre[^>]*?>.*?</pre>!is", $source, $match);
    $_pre_blocks = $match[0];
    $source = preg_replace("!<pre[^>]*?>.*?</pre>!is", '@@@SMARTY:TRIM:PRE@@@', $source);
    // Pull out the textarea blocks
    preg_match_all("!<textarea[^>]*?>.*?</textarea>!is", $source, $match);
    $_textarea_blocks = $match[0];
    $source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is", '@@@SMARTY:TRIM:TEXTAREA@@@', $source);
    // remove all leading spaces, tabs and carriage returns NOT
    // preceeded by a php close tag.
    $source = trim(preg_replace('/((?<!\\?>)\\n)[\\s]+/m', '\\1', $source));
    // replace textarea blocks
    smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@", $_textarea_blocks, $source);
    // replace pre blocks
    smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@", $_pre_blocks, $source);
    // replace script blocks
    smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@", $_script_blocks, $source);
    return $source;
}
示例#16
0
function Scaffold_image_replace_matrix($params)
{
    if (preg_match_all('/\\([^)]*?,[^)]*?\\)/', $params, $matches)) {
        foreach ($matches as $key => $original) {
            $new = str_replace(',', '#COMMA#', $original);
            $params = str_replace($original, $new, $params);
        }
    }
    $params = explode(',', $params);
    foreach (array('url', 'width', 'height', 'x', 'y') as $key => $name) {
        ${$name} = trim(str_replace('#COMMA#', ',', array_shift($params)));
    }
    $url = preg_replace('/\\s+/', '', $url);
    $url = preg_replace('/url\\([\'\\"]?|[\'\\"]?\\)$/', '', $url);
    if (!$x) {
        $x = 0;
    }
    if (!$y) {
        $y = 0;
    }
    $path = Scaffold::find_file($url);
    if ($path === false) {
        return false;
    }
    // Make sure theres a value so it doesn't break the css
    if (!$width && !$height) {
        $width = $height = 0;
    }
    // Build the selector
    $properties = "background:url(" . Scaffold::url_path($path) . ") no-repeat {$x}px {$y}px;\n\t\theight:{$height}px;\n\t\twidth:{$width}px;\n\t\tdisplay:block;\n\t\ttext-indent:-9999px;\n\t\toverflow:hidden;";
    return $properties;
}
示例#17
0
 /**
  *
  * @package FPU
  * @since FPU 1.4.3
  */
 function tc_generate_default_options($map, $option_group = null)
 {
     $defaults = array();
     //do we have to look in a specific group of option (plugin?)
     $option_group = is_null($option_group) ? TC_wfc::$instance->plug_option_prefix : $option_group;
     foreach ($map['add_setting_control'] as $key => $options) {
         //check it is a customizr option
         if (false !== strpos($key, $option_group)) {
             //isolate the option name between brackets [ ]
             $option_name = '';
             $option = preg_match_all('/\\[(.*?)\\]/', $key, $match);
             if (isset($match[1][0])) {
                 $option_name = $match[1][0];
             }
             //write default option in array
             if (isset($options['default'])) {
                 $defaults[$option_name] = $options['default'];
             } else {
                 $defaults[$option_name] = null;
             }
         }
         //end if
     }
     //end foreach
     return $defaults;
 }
 public function find_variables($json)
 {
     global $__rgt_replace_set;
     $__rgt_replace_set = array();
     preg_match_all('/__(.*?)\\[([^\\]]+)\\]__/', $json, $mall);
     $sid_set = array();
     for ($i = 0; $i < count($mall[0]); $i++) {
         $sid++;
         if (!isset($__rgt_replace_set[$mall[1][$i]])) {
             $__rgt_replace_set[$mall[1][$i]] = $sid;
         }
         if ($mall[2][$i] == "SID" && !isset($sid_set[$mall[1][$i]])) {
             $sid_set[$mall[1][$i]] = $sid;
         }
         if ($mall[2][$i] == "TEXT" && !isset($text_set[$mall[1][$i]])) {
             $variable_set[$mall[1][$i]] = array('TEXT' => array());
         }
     }
     $json = preg_replace_callback('/__(.*?)\\[[^\\]]+\\]__/', "__r_r", $json);
     $d = json_decode($json, true);
     foreach ($sid_set as $sidname => $sid) {
         foreach ($d['datapoints'] as $dp) {
             if ($dp['sid'] == $sid) {
                 $variable_set[$sidname]['SID'][] = array($dp['metric_name'], $dp['metric_type']);
             }
         }
     }
     return $variable_set;
 }
示例#19
0
 public static function snakeCase($string)
 {
     preg_match_all("/(^[a-z_][a-z0-9_]*|[A-Z]+(?![a-z])|[A-Z][a-z0-9_]+)/", $string, $matches);
     return join("_", array_map(function ($e) {
         return mb_strtolower($e);
     }, $matches[1]));
 }
 public function findTranslations($path = null)
 {
     $path = $path ?: base_path();
     $keys = array();
     $functions = array('trans', 'trans_choice', 'Lang::get', 'Lang::choice', 'Lang::trans', 'Lang::transChoice', '@lang', '@choice');
     $pattern = "(" . implode('|', $functions) . ")" . "\\(" . "[\\'\"]" . "(" . "[a-zA-Z0-9_-]+" . "([.][^)]+)+" . ")" . "[\\'\"]" . "[\\),]";
     // Close parentheses or new parameter
     // Find all PHP + Twig files in the app folder, except for storage
     $finder = new Finder();
     $finder->in($path)->exclude('storage')->name('*.php')->name('*.twig')->files();
     /** @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($finder as $file) {
         // Search the current file for the pattern
         if (preg_match_all("/{$pattern}/siU", $file->getContents(), $matches)) {
             // Get all matches
             foreach ($matches[2] as $key) {
                 $keys[] = $key;
             }
         }
     }
     // Remove duplicates
     $keys = array_unique($keys);
     // Add the translations to the database, if not existing.
     foreach ($keys as $key) {
         // Split the group and item
         list($group, $item) = explode('.', $key, 2);
         $this->missingKey('', $group, $item);
     }
     // Return the number of found translations
     return count($keys);
 }
示例#21
0
 function getPublicKeyFromServer($server, $email)
 {
     /* refactor to 
     		$command = "gpg --keyserver ".escapeshellarg($server)." --search-keys ".escapeshellarg($email)."";
     		echo "$command\n\n";
     		
     		//execute the gnupg command
     		exec($command, $result);
     		*/
     $curl = new curl();
     // get Fingerprint
     $data = $curl->get("http://" . $server . ":11371/pks/lookup?search=" . urlencode($email) . "&op=index&fingerprint=on&exact=on");
     $data = $data['FILE'];
     preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
     //$pub = $matches[1][1];
     preg_match_all("/<a href=\"(.*?)\">(\\w*)<\\/a>/", $matches[1][1], $matches);
     $url = $matches[1][0];
     $keyID = $matches[2][0];
     // get Public Key
     $data = $curl->get("http://" . $server . ":11371" . $url);
     $data = $data['FILE'];
     preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
     $pub_key = trim($matches[1][0]);
     return array("keyID" => $keyID, "public_key" => $pub_key);
 }
示例#22
0
 public function isValid($sValue)
 {
     $this->_setValue($sValue);
     if (null === self::$_filter) {
         require_once 'Zend/Filter/Digits.php';
         self::$_filter = new Zend_Filter_Digits();
     }
     $sValueFiltered = self::$_filter->filter($sValue);
     $nLength = strlen($sValueFiltered);
     if ($nLength != 10) {
         $this->_error(self::LENGTH);
         return false;
     }
     $nMod = 11;
     $nSum = 0;
     $aWeights = array(6, 5, 7, 2, 3, 4, 5, 6, 7);
     preg_match_all("/\\d/", $sValueFiltered, $aDigits);
     $aValueFiltered = $aDigits[0];
     foreach ($aValueFiltered as $nDigit) {
         $nWeight = current($aWeights);
         $nSum += $nDigit * $nWeight;
         next($aWeights);
     }
     if (($nSum % $nMod == 10 ? 0 : $nSum % $nMod) != $aValueFiltered[$nLength - 1]) {
         $this->_error(self::CHECKSUM, $sValueFiltered);
         return false;
     }
     return true;
 }
示例#23
0
 /**
  * Parses a search query string.
  * Supports +/-, AND/OR, parens
  * @param $query
  * @return array of the form ('+' => <required>, '' => <optional>, '-' => excluded)
  */
 function parseQuery($query)
 {
     $count = preg_match_all('/(\\+|\\-|)("[^"]+"|\\(|\\)|[^\\s\\)]+)/', $query, $matches);
     $pos = 0;
     $keywords = ArticleSearch::_parseQuery($matches[1], $matches[2], $pos, $count);
     return $keywords;
 }
示例#24
0
 function polldaddy_embed_to_shortcode($content)
 {
     if (false === strpos($content, 'polldaddy.com/p/')) {
         return $content;
     }
     $regexes = array();
     $regexes[] = '#<script[^>]+?src="https?://(secure|static)\\.polldaddy\\.com/p/([0-9]+)\\.js"[^>]*+>\\s*?</script>\\r?\\n?(<noscript>.*?</noscript>)?#i';
     $regexes[] = '#&lt;script(?:[^&]|&(?!gt;))+?src="https?://(secure|static)\\.polldaddy\\.com/p/([0-9]+)\\.js"(?:[^&]|&(?!gt;))*+&gt;\\s*?&lt;/script&gt;\\r?\\n?(&lt;noscript&gt;.*?&lt;/noscript&gt;)?#i';
     foreach ($regexes as $regex) {
         if (!preg_match_all($regex, $content, $matches, PREG_SET_ORDER)) {
             continue;
         }
         foreach ($matches as $match) {
             if (!isset($match[2])) {
                 continue;
             }
             $id = (int) $match[2];
             if ($id > 0) {
                 $content = str_replace($match[0], " [polldaddy poll={$id}]", $content);
                 /** This action is documented in modules/shortcodes/youtube.php */
                 do_action('jetpack_embed_to_shortcode', 'polldaddy', $id);
             }
         }
     }
     return $content;
 }
示例#25
0
 protected function _parse_params($p)
 {
     $params = array();
     preg_match_all('~\\w+\\s*=|(([\'"]).*?(?<!\\\\)\\2|\\S+)~s', $p, $m, PREG_SET_ORDER);
     $lastkey = '';
     foreach ($m as $v) {
         if (trim($v[0]) === '') {
             continue;
         }
         if (sizeof($v) == 1) {
             $lastkey = ltrim(rtrim($v[0], " =\t"));
             continue;
         }
         if ($lastkey === '') {
             $params[] = $v[0];
         } else {
             $params[$lastkey] = $v[0];
         }
         $lastkey = '';
     }
     if ($this->use_stat) {
         $this->stat['numparams'] += sizeof($params);
     }
     return $params;
 }
示例#26
0
 function getVersion($browser, $search, $string)
 {
     $browser = $this->info['Browser'];
     $version = "";
     $browser = strtolower($browser);
     preg_match_all($search, $string, $match);
     switch ($browser) {
         case "firefox":
             $version = str_replace("/", "", $match[1][0]);
             break;
         case "internet explorer":
             $version = substr($match[1][0], 0, 4);
             break;
         case "opera":
             $version = str_replace("/", "", substr($match[1][0], 0, 5));
             break;
         case "navigator":
             $version = substr($match[1][0], 1, 7);
             break;
         case "maxthon":
             $version = str_replace(")", "", $match[1][0]);
             break;
         case "google chrome":
             $version = substr($match[1][0], 1, 10);
     }
     return $version;
 }
示例#27
0
/**
 * This is the model class for table "dcmd_task_template".
 *
 * @property integer $task_tmpt_id
 * @property string $task_tmpt_name
 * @property integer $task_cmd_id
 * @property string $task_cmd
 * @property integer $svr_id
 * @property string $svr_name
 * @property integer $app_id
 * @property integer $update_env
 * @property integer $concurrent_rate
 * @property integer $timeout
 * @property integer $process
 * @property integer $auto
 * @property string $task_arg
 * @property string $comment
 * @property string $utime
 * @property string $ctime
 * @property integer $opr_uid
 */
function xml_to_array($xml)
{
    //array(1) { ["env"]=> array(2) { ["name"]=> string(2) "gu" ["aa"]=> string(4) "miao" } }
    $reg = "/<(\\w+)[^>]*?>([\\x00-\\xFF]*?)<\\/\\1>/";
    if (preg_match_all($reg, $xml, $matches)) {
        $count = count($matches[0]);
        $arr = array();
        for ($i = 0; $i < $count; $i++) {
            $key = $matches[1][$i];
            $val = xml_to_array($matches[2][$i]);
            // 递归
            if (array_key_exists($key, $arr)) {
                if (is_array($arr[$key])) {
                    if (!array_key_exists(0, $arr[$key])) {
                        $arr[$key] = array($arr[$key]);
                    }
                } else {
                    $arr[$key] = array($arr[$key]);
                }
                $arr[$key][] = $val;
            } else {
                $arr[$key] = $val;
            }
        }
        return $arr;
    } else {
        return $xml;
    }
}
 /**
  * Get an array of URNs
  *
  * @param OutputInterface $output
  * @return array
  */
 private function getUrnDictionary(OutputInterface $output)
 {
     $files = $this->filesUtility->getXmlCatalogFiles('*.xml');
     $files = array_merge($files, $this->filesUtility->getXmlCatalogFiles('*.xsd'));
     $urns = [];
     foreach ($files as $file) {
         $content = $this->rootDirRead->readFile($this->rootDirRead->getRelativePath($file[0]));
         $matches = [];
         preg_match_all('/schemaLocation="(urn\\:magento\\:[^"]*)"/i', $content, $matches);
         if (isset($matches[1])) {
             $urns = array_merge($urns, $matches[1]);
         }
     }
     $urns = array_unique($urns);
     $paths = [];
     foreach ($urns as $urn) {
         try {
             $paths[$urn] = $this->urnResolver->getRealPath($urn);
         } catch (\Exception $e) {
             // don't add unsupported element to array
             if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                 $output->writeln($e->getMessage());
             }
         }
     }
     return $paths;
 }
示例#29
0
/**
 * Print the default configuration to ease creation of a config file.
 */
function exportConfig()
{
    $config = "";
    preg_match_all("/# Script Configuration start.+?# Script Configuration end/ms", file_get_contents(INVNAME), $config);
    $_configuration = preg_replace("/\\\$(?P<name>[^=]+)\\s*=\\s*\"(?P<value>[^\"]*)\";/", "\\1=\\2", $config[0][1]);
    echo $_configuration;
}
 /**
  * Convert simple expressions in curly brackets in text into xsl:value-of elements
  *
  * Will replace
  *     <span>{$FOO}{@bar}</span>
  * with
  *     <span><xsl:value-of value="$FOO"/><xsl:value-of value="@bar"/></span>
  *
  * @param  DOMElement $template <xsl:template/> node
  * @return void
  */
 public function normalize(DOMElement $template)
 {
     $dom = $template->ownerDocument;
     $xpath = new DOMXPath($dom);
     $query = '//text()[contains(., "{@") or contains(., "{$")]';
     foreach ($xpath->query($query) as $node) {
         $parentNode = $node->parentNode;
         // Skip XSL elements
         if ($parentNode->namespaceURI === self::XMLNS_XSL) {
             continue;
         }
         preg_match_all('#\\{([$@][-\\w]+)\\}#', $node->textContent, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
         $lastPos = 0;
         foreach ($matches as $m) {
             $pos = $m[0][1];
             // Catch up to current position
             if ($pos > $lastPos) {
                 $parentNode->insertBefore($dom->createTextNode(substr($node->textContent, $lastPos, $pos - $lastPos)), $node);
             }
             $lastPos = $pos + strlen($m[0][0]);
             // Add the xsl:value-of element
             $parentNode->insertBefore($dom->createElementNS(self::XMLNS_XSL, 'xsl:value-of'), $node)->setAttribute('select', $m[1][0]);
         }
         // Append the rest of the text
         $text = substr($node->textContent, $lastPos);
         if ($text > '') {
             $parentNode->insertBefore($dom->createTextNode($text), $node);
         }
         // Now remove the old text node
         $parentNode->removeChild($node);
     }
 }