コード例 #1
1
ファイル: entry.php プロジェクト: xp-runners/main
function entry(&$argv)
{
    if (is_file($argv[0])) {
        if (0 === substr_compare($argv[0], '.class.php', -10)) {
            $uri = realpath($argv[0]);
            if (null === ($cl = \lang\ClassLoader::getDefault()->findUri($uri))) {
                throw new \Exception('Cannot load ' . $uri . ' - not in class path');
            }
            return $cl->loadUri($uri)->literal();
        } else {
            if (0 === substr_compare($argv[0], '.xar', -4)) {
                $cl = \lang\ClassLoader::registerPath($argv[0]);
                if (!$cl->providesResource('META-INF/manifest.ini')) {
                    throw new \Exception($cl->toString() . ' does not provide a manifest');
                }
                $manifest = parse_ini_string($cl->getResource('META-INF/manifest.ini'));
                return strtr($manifest['main-class'], '.', '\\');
            } else {
                array_unshift($argv, 'eval');
                return 'xp\\runtime\\Evaluate';
            }
        }
    } else {
        return strtr($argv[0], '.', '\\');
    }
}
コード例 #2
0
/**
 * phplogmon
 *
 * Copyright (c) 2012-2014 Holger de Carne and contributors, All Rights Reserved.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
function __autoload($name)
{
    if (substr_compare($name, "GeoIp2\\", 0, strlen("GeoIp2\\")) == 0) {
        $includeFile = dirname(__FILE__);
        $includeFile .= DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "ext-lib" . DIRECTORY_SEPARATOR;
        if ("\\" != DIRECTORY_SEPARATOR) {
            $includeFile .= str_replace("\\", DIRECTORY_SEPARATOR, $name);
        } else {
            $includeFile .= $name;
        }
        $includeFile .= ".php";
    } elseif (substr_compare($name, "MaxMind\\", 0, strlen("MaxMind\\")) == 0) {
        $includeFile = dirname(__FILE__);
        $includeFile .= DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "ext-lib" . DIRECTORY_SEPARATOR;
        if ("\\" != DIRECTORY_SEPARATOR) {
            $includeFile .= str_replace("\\", DIRECTORY_SEPARATOR, $name);
        } else {
            $includeFile .= $name;
        }
        $includeFile .= ".php";
    } else {
        $includeFile = $name;
        $includeFile .= ".class.php";
    }
    include $includeFile;
}
 /**
  * Compiles code for the execution of block plugin
  * 
  * @param array $args array with attributes from parser
  * @param string $tag name of block function
  * @param string $methode name of methode to call
  * @param object $compiler compiler object
  * @return string compiled code
  */
 public function compile($args, $compiler, $tag, $methode)
 {
     $this->compiler = $compiler;
     if (strlen($tag) < 5 || substr_compare($tag, 'close', -5, 5) != 0) {
         // opening tag of block plugin
         $this->required_attributes = array();
         $this->optional_attributes = array('_any');
         // check and get attributes
         $_attr = $this->_get_attributes($args);
         // convert attributes into parameter array string
         $_paramsArray = array();
         foreach ($_attr as $_key => $_value) {
             if (is_int($_key)) {
                 $_paramsArray[] = "{$_key}=>{$_value}";
             } else {
                 $_paramsArray[] = "'{$_key}'=>{$_value}";
             }
         }
         $_params = 'array(' . implode(",", $_paramsArray) . ')';
         $this->_open_tag($tag . '->' . $methode, $_params);
         // compile code
         $output = '<?php $_block_repeat=true; $_smarty_tpl->smarty->registered_objects[\'' . $tag . '\'][0]->' . $methode . '(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl);while ($_block_repeat) { ob_start();?>';
     } else {
         // closing tag of block plugin
         $_params = $this->_close_tag(substr($tag, 0, -5) . '->' . $methode);
         // This tag does create output
         $this->compiler->has_output = true;
         // compile code
         $output = '<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false; echo $_smarty_tpl->smarty->registered_objects[\'' . substr($tag, 0, -5) . '\'][0]->' . $methode . '(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl); }?>';
     }
     return $output;
 }
コード例 #4
0
 public function extract($pathExtracted)
 {
     if (substr_compare($pathExtracted, '/', -1)) {
         $pathExtracted .= '/';
     }
     $fileselector = array();
     $list = array();
     $count = $this->ziparchive->numFiles;
     if ($count === 0) {
         return 0;
     }
     for ($i = 0; $i < $count; $i++) {
         $entry = $this->ziparchive->statIndex($i);
         $filename = str_replace('\\', '/', $entry['name']);
         $parts = explode('/', $filename);
         if (!strncmp($filename, '/', 1) || array_search('..', $parts) !== false || strpos($filename, ':') !== false) {
             return 0;
         }
         $fileselector[] = $entry['name'];
         $list[] = array('filename' => $pathExtracted . $entry['name'], 'stored_filename' => $entry['name'], 'size' => $entry['size'], 'compressed_size' => $entry['comp_size'], 'mtime' => $entry['mtime'], 'index' => $i, 'crc' => $entry['crc']);
     }
     $res = $this->ziparchive->extractTo($pathExtracted, $fileselector);
     if ($res === false) {
         return 0;
     }
     return $list;
 }
コード例 #5
0
 /**
  * This method originates from Dropbox,
  * @link http://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/source-class-Dropbox.Util.html#14-32
  *
  * If the given string begins with the UTF-8 BOM (byte order mark), remove it and
  * return whatever is left. Otherwise, return the original string untouched.
  *
  * Though it's not recommended for UTF-8 to have a BOM, the standard allows it to
  * support software that isn't Unicode-aware.
  *
  * @param string $string
  *    A UTF-8 encoded string.
  *
  * @return string
  */
 public static function stripUtf8Bom($string)
 {
     if (\substr_compare($string, "", 0, 3) === 0) {
         $string = \substr($string, 3);
     }
     return $string;
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function handleError(array $error, FatalErrorException $exception)
 {
     $messageLen = strlen($error['message']);
     $notFoundSuffix = '\' not found';
     $notFoundSuffixLen = strlen($notFoundSuffix);
     if ($notFoundSuffixLen > $messageLen) {
         return;
     }
     if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
         return;
     }
     foreach (array('class', 'interface', 'trait') as $typeName) {
         $prefix = ucfirst($typeName) . ' \'';
         $prefixLen = strlen($prefix);
         if (0 !== strpos($error['message'], $prefix)) {
             continue;
         }
         $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
         if (false !== ($namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\'))) {
             $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
             $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
             $message = sprintf('Attempted to load %s "%s" from namespace "%s" in %s line %d. Do you need to "use" it from another namespace?', $typeName, $className, $namespacePrefix, $error['file'], $error['line']);
         } else {
             $className = $fullyQualifiedClassName;
             $message = sprintf('Attempted to load %s "%s" from the global namespace in %s line %d. Did you forget a use statement for this %s?', $typeName, $className, $error['file'], $error['line'], $typeName);
         }
         if ($classes = $this->getClassCandidates($className)) {
             $message .= sprintf(' Perhaps you need to add a use statement for one of the following: %s.', implode(', ', $classes));
         }
         return new ClassNotFoundException($message, $exception);
     }
 }
コード例 #7
0
 /**
  * @param string $inputFile
  * @param string $outputFile
  *
  * @dataProvider providerForTestConvert
  */
 public function testConvert($inputFile, $outputFile)
 {
     $endsWith = ".lossy.xml";
     if (substr_compare($inputFile, $endsWith, -strlen($endsWith), strlen($endsWith)) === 0) {
         $this->markTestSkipped("Skipped lossy conversion.");
     }
     if (!file_exists($outputFile)) {
         $this->markTestIncomplete("Test is not complete: missing output fixture: " . $outputFile);
     }
     $inputDocument = $this->createDocument($inputFile);
     $outputDocument = $this->createDocument($outputFile);
     $this->removeComments($inputDocument);
     $this->removeComments($outputDocument);
     $converter = $this->getConverter();
     $convertedDocument = $converter->convert($inputDocument);
     // Needed by some disabled output escaping (eg. legacy ezxml paragraph <line/> elements)
     $convertedDocumentNormalized = new DOMDocument();
     $convertedDocumentNormalized->loadXML($convertedDocument->saveXML());
     $this->assertEquals($outputDocument, $convertedDocumentNormalized);
     $validator = $this->getConversionValidator();
     if (isset($validator)) {
         $errors = $validator->validate($convertedDocument);
         $this->assertTrue(empty($errors), "Conversion result did not validate against the configured schemas:" . $this->formatValidationErrors($outputFile, $errors));
     }
 }
コード例 #8
0
 /**
  * Set the Internet media type. Allow only video types + Flash wrapper.
  *
  * @param string $type Internet media type
  */
 public function setType($type)
 {
     if ($type === 'application/x-shockwave-flash' || substr_compare($type, 'video/', 0, 6) === 0) {
         $this->type = $type;
     }
     return $this;
 }
コード例 #9
0
 /**
  * Make sure target path ends in '/'
  *
  * @param string $path
  *
  * @return string
  */
 private function fixPath($path)
 {
     if (substr_compare($path, '/', -1)) {
         $path .= '/';
     }
     return $path;
 }
コード例 #10
0
 public function endsWith($string)
 {
     $rep = Condition::stringOf($string);
     return $this->is(new Match(function ($value) use($string) {
         return '' !== $value && 0 === substr_compare($value, $string, -strlen($string));
     }, ['%s does not end with ' . $rep, '%s ends with ' . $rep]));
 }
コード例 #11
0
 /**
  * @param resource $ch
  * @param string   $header
  *
  * @return int
  * @throws Dropbox_Exception_BadResponse
  */
 public function headerFunction($ch, $header)
 {
     // The first line is the HTTP status line (Ex: "HTTP/1.1 200 OK").
     if (!$this->skippedFirstLine) {
         $this->skippedFirstLine = true;
         return strlen($header);
     }
     // If we've encountered an error on a previous callback, then there's nothing left to do.
     if ($this->error !== null) {
         return strlen($header);
     }
     // case-insensitive starts-with check.
     if (strlen($header) < 19 || substr_compare($header, "x-dropbox-metadata:", 0, 19, true) !== 0) {
         return strlen($header);
     }
     if ($this->metadata !== null) {
         $this->error = "Duplicate X-Dropbox-Metadata header";
         return strlen($header);
     }
     $headerValue = substr($header, 19);
     $parsed = json_decode($headerValue, true);
     if ($parsed === null) {
         $this->error = "Bad JSON in X-Dropbox-Metadata header";
         return strlen($header);
     }
     $this->metadata = $parsed;
     return strlen($header);
 }
コード例 #12
0
ファイル: upgrade-pcre.php プロジェクト: OTiZ/osx
function recurse($path)
{
    global $newpcre, $dirlen;
    foreach (scandir($path) as $file) {
        if ($file[0] === '.' || $file === 'CVS' || @substr_compare($file, '.lo', -3, 3) === 0 || @substr_compare($file, '.loT', -4, 4) === 0 || @substr_compare($file, '.o', -2, 2) === 0) {
            continue;
        }
        $file = "{$path}/{$file}";
        if (is_dir($file)) {
            recurse($file);
            continue;
        }
        echo "processing {$file}... ";
        $newfile = $newpcre . substr($file, $dirlen);
        if (is_file($tmp = $newfile . '.generic') || is_file($tmp = $newfile . '.dist')) {
            $newfile = $tmp;
        }
        if (!is_file($newfile)) {
            die("{$newfile} is not available any more\n");
        }
        // maintain file mtimes so that cvs doesnt get crazy
        if (file_get_contents($newfile) !== file_get_contents($file)) {
            copy($newfile, $file);
        }
        // always include the config.h file
        $content = file_get_contents($newfile);
        $newcontent = preg_replace('/#\\s*ifdef HAVE_CONFIG_H\\s*(.+)\\s*#\\s*endif/', '$1', $content);
        if ($content !== $newcontent) {
            file_put_contents($file, $newcontent);
        }
        echo "OK\n";
    }
}
コード例 #13
0
ファイル: wp-d3.php プロジェクト: qdwwqxwn/www
/**
 * Creates a div around the javascript code to visualize it.
 * Accepts the canvas="xxx" parameter to specify the canvas name. By default it is
 * created with id='canvas' (so original uh ;-))
 */
function print_source($attr, $content)
{
    extract(shortcode_atts(array('canvas' => 'canvas'), $attr));
    $chartId = $canvas;
    $field_code = get_post_meta(get_the_ID(), $chartId, true);
    $code = "";
    $result = "";
    if (!empty($field_code)) {
        $jsonCode = json_decode($field_code, true);
        $code = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n\\']+/", "\n", $jsonCode['code']);
        // remove empty lines
        foreach ($jsonCode['includes'] as $include) {
            if (substr_compare($include, "js", -strlen("js"), strlen("js")) === 0) {
                $result = $result . getJavaScriptInclude($include);
            }
            if (substr_compare($include, "css", -strlen("css"), strlen("css")) === 0) {
                $result = $result . getCssInclude($include);
            }
        }
    } else {
        $code = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n\\']+/", "\n", $content);
        // remove empty lines
    }
    if (containsAutoIdFlag($code)) {
        $genChartId = genRandomId();
        $code = replaceAutoIdFlag($code, $genChartId);
        $chartId = $genChartId;
    }
    $code = wrapAsFunction($code, $chartId);
    $result = $result . '<div class="' . $chartId . '">' . '<script type="text/javascript">' . $code . '</script>' . '</div>';
    return $result;
}
コード例 #14
0
ファイル: TagsSource.class.php プロジェクト: xp-forge/mirrors
 /** @return var */
 protected function next()
 {
     while ($this->tokens->hasMoreTokens()) {
         $token = $this->tokens->nextToken();
         if (strspn($token, ' ')) {
             continue;
         } else {
             if ('@' === $token || '$' === $token) {
                 $token .= $this->tokens->nextToken();
             } else {
                 if (0 === substr_compare($token, '...', -3)) {
                     $token = substr($token, 0, -3);
                     $this->tokens->pushBack('*');
                 }
             }
         }
         if (false !== strpos(self::DELIMITERS, $token)) {
             return $token;
         } else {
             if (isset(self::$keywords[$token])) {
                 return [self::$keywords[$token], $token];
             } else {
                 return [self::T_WORD, $token];
             }
         }
     }
     return null;
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 public function warmUp($cacheDir)
 {
     $finder = new \Symfony\Component\Finder\Finder();
     $finder = $finder->files()->sort(function ($a, $b) {
         $result = strcmp($a->getRealpath(), $b->getRealpath());
         return 1 == $result && 0 == substr_compare($a->getBasename(), $b->getBasename(), 0, 2) ? -1 : $result;
     });
     foreach ($this->patterns as $pattern) {
         $finder->name($pattern);
     }
     $files = $finder->in($flagsPath = $this->getAbsolutePath($this->flagsPath));
     $cache = array('flags' => array(), 'defaults' => array());
     /** @var $file \Symfony\Component\Finder\SplFileInfo */
     foreach ($files as $file) {
         $counter = 0;
         do {
             $match = preg_match($this->patterns[$counter], $file->getBasename(), $out);
         } while (!$match && $counter++ < count($this->patterns));
         $locale = $out['locale'];
         $country = isset($out['country']) ? strtolower($out['country']) : null;
         $localeString = $locale . (is_null($country) ? '' : '-' . $country);
         if ($this->isLocaleEnabled($localeString)) {
             $cache['flags'][$localeString] = new Flag($file->getRealPath(), $locale, $country);
             if (!isset($cache['defaults'][$locale])) {
                 if (isset($this->defaults[$locale])) {
                     $cache['defaults'][$locale] = strtolower($this->defaults[$locale]);
                 } else {
                     $cache['defaults'][$locale] = $localeString;
                 }
             }
         }
     }
     $this->writeCacheFile($cacheDir . DIRECTORY_SEPARATOR . 'flags.php', sprintf('<?php return unserialize(%s);' . PHP_EOL, var_export(serialize($cache), true)));
 }
コード例 #16
0
ファイル: minify.php プロジェクト: GitIPFire/Homeworks
 /**
  * 
  * Check and convert to css real path
  * @var url
  */
 public static function cssPath($url = '')
 {
     $url = preg_replace('#[?\\#]+.*$#', '', $url);
     $base = JURI::base();
     $root = JURI::root(true);
     $path = false;
     $ret = false;
     if (substr($url, 0, 2) === '//') {
         //check and append if url is omit http
         $url = JURI::getInstance()->getScheme() . ':' . $url;
     }
     //check for css file extensions
     foreach (self::$cssexts as $ext) {
         if (substr_compare($url, $ext, -strlen($ext), strlen($ext)) === 0) {
             $ret = true;
             break;
         }
     }
     if ($ret) {
         if (preg_match('/^https?\\:/', $url)) {
             //is full link
             if (strpos($url, $base) === false) {
                 // external css
                 return false;
             }
             $path = JPath::clean(JPATH_ROOT . '/' . substr($url, strlen($base)));
         } else {
             $path = JPath::clean(JPATH_ROOT . '/' . ($root && strpos($url, $root) === 0 ? substr($url, strlen($root)) : $url));
         }
         return is_file($path) ? $path : false;
     }
     return false;
 }
コード例 #17
0
ファイル: system.php プロジェクト: HarriLu/gallery3
 /**
  * Return the path to an executable version of the named binary, or null.
  * The paths are traversed in the following order:
  *   1. $priority_path (if specified)
  *   2. Gallery's own bin directory (DOCROOT . "bin")
  *   3. PATH environment variable
  *   4. extra_binary_paths Gallery variable (if specified)
  * In addition, if the file is found inside Gallery's bin directory but
  * it's not executable, we try to change its permissions to 0755.
  *
  * @param  string $binary
  * @param  string $priority_path (optional)
  * @return string path to binary if found; null if not found
  */
 static function find_binary($binary, $priority_path = null)
 {
     $bin_path = DOCROOT . "bin";
     if ($priority_path) {
         $paths = array($priority_path, $bin_path);
     } else {
         $paths = array($bin_path);
     }
     $paths = array_merge($paths, explode(":", getenv("PATH")), explode(":", module::get_var("gallery", "extra_binary_paths")));
     foreach ($paths as $path) {
         $path = rtrim($path, "/");
         $candidate = "{$path}/{$binary}";
         // @suppress errors below to avoid open_basedir issues
         if (@file_exists($candidate)) {
             if (!@is_executable($candidate) && substr_compare($bin_path, $candidate, 0, strlen($bin_path)) == 0) {
                 // Binary isn't executable but is in Gallery's bin directory - try fixing permissions.
                 @chmod($candidate, 0755);
             }
             if (@is_executable($candidate)) {
                 return $candidate;
             }
         }
     }
     return null;
 }
コード例 #18
0
 /**
  * Метод проверяет начинается ли данная строка ($source) с заданных символов ($needle).
  * 
  * @param string $source проверяемая строка.
  * @param string $needle искомая строка.
  * @return bool true - в случае если строка $source начинается со строки $needle, в противном случае false.
  */
 public static function strStartsWith($source, $needle)
 {
     if (self::isNotString($source) && self::isNotString($needle)) {
         return false;
     }
     return substr_compare($source, $needle, 0, strlen($needle)) === 0;
 }
コード例 #19
0
 /**
  * Check if the clients IP is in a given netmask or array of netmasks
  *
  * @param string  String with the netmask 
  *
  * @return boolean  True if client IP is in netmask
  **/
 public static function applyNetmask($netmask)
 {
     // We do not support IPv6 yet
     if (self::$IsIPv6) {
         return false;
     }
     // Determine mask length
     $netmask_parts = explode('/', $netmask);
     if (count($netmask_parts) > 2) {
         return false;
     }
     if (count($netmask_parts) < 1) {
         return false;
     }
     // Only one part, so we are dealing with a host here
     if (count($netmask_parts) == 1) {
         $netmask_parts[1] = 32;
     }
     // Now we detect the length of the netmask
     if (strpos($netmask_parts[1], '.') === true) {
         // Dot notation
         $netmask_parts[1] = strspn(sprintf("%032b", ip2long($netmask_parts[1])), "1");
     }
     if ($netmask_parts[1] > 0 && $netmask_parts[1] < 33) {
         // Thanks to jwadhams1 @ php.net ip2long documentation
         $client_ip_bin = sprintf("%032b", ip2long(self::$ClientIP));
         $net_ip_bin = sprintf("%032b", ip2long($netmask_parts[0]));
         return substr_compare($client_ip_bin, $net_ip_bin, 0, $netmask_parts[1]) === 0;
     } else {
         return false;
     }
 }
コード例 #20
0
ファイル: FileHandler.class.php プロジェクト: conory/rhymix
 /**
  * Changes path of target file, directory into absolute path
  *
  * @param string $source path to change into absolute path
  * @return string Absolute path
  */
 public static function getRealPath($source)
 {
     if (strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0) {
         return _XE_PATH_ . substr($source, 2);
     }
     return $source;
 }
コード例 #21
0
 /**
  * Initializes UrlManager.
  */
 public function init()
 {
     parent::init();
     if (Yii::$app->request->getIsConsoleRequest()) {
         return true;
     }
     //set $this->langBegin is empty
     $this->setLangBegin();
     $request = Yii::$app->getRequest();
     $sourcePathInfo = $request->getPathInfo();
     $endSlash = '';
     if ($this->normalizer !== false) {
         $pathInfo = $this->normalizer->normalizePathInfo($sourcePathInfo, (string) $this->suffix, $this->normalized);
         if ($sourcePathInfo !== $pathInfo) {
             $endSlash = '/';
         }
     } else {
         $pathInfo = rtrim($sourcePathInfo, '/');
     }
     $suffix = (string) $this->suffix;
     if ($suffix !== '' && $pathInfo !== '') {
         $n = strlen($this->suffix);
         if (substr_compare($pathInfo, $this->suffix, -$n, $n) === 0) {
             $pathInfo = substr($pathInfo, 0, -$n);
             if ($pathInfo === '') {
                 // suffix alone is not allowed
                 throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
             }
         } else {
             // suffix doesn't match
             throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
         }
     }
     if ($this->enableLang) {
         if ($pathInfo != '') {
             if (strpos($pathInfo, '/') !== false) {
                 $segments = explode('/', $pathInfo);
                 $_GET[$this->langParam] = $segments['0'];
                 unset($segments['0']);
                 $pathInfo = join('/', $segments);
             } else {
                 if (in_array($pathInfo, $this->langBegin)) {
                     $_GET[$this->langParam] = $pathInfo;
                     $pathInfo = '';
                 }
             }
         } else {
             $_GET[$this->langParam] = reset($this->langBegin);
         }
     }
     $event = new UrlManagerEvent(['pathInfo' => $pathInfo]);
     $this->trigger(self::EVENT_INIT, $event);
     if (isset($_GET)) {
         foreach ($_GET as $k => $v) {
             $this->gets[$k] = $v;
         }
     }
     $request->setPathInfo($event->pathInfo . $endSlash);
     $this->_pathInfo = $event->pathInfo;
 }
コード例 #22
0
ファイル: CookieJar.php プロジェクト: claudinec/galan-wiki
 /**
  * Parse the content of an Set-Cookie HTTP Response header.
  *
  * @param string $cookie
  * @param string $domain Cookie's domain
  * @return null
  */
 public function parseCookieResponseHeader($cookie, $domain)
 {
     $len = strlen('Set-Cookie:');
     if (substr_compare('Set-Cookie:', $cookie, 0, $len, true) === 0) {
         $cookie = substr($cookie, $len);
     }
     $bit = array_map('trim', explode(';', $cookie));
     if (count($bit) >= 1) {
         list($name, $value) = explode('=', array_shift($bit), 2);
         $attr = [];
         foreach ($bit as $piece) {
             $parts = explode('=', $piece);
             if (count($parts) > 1) {
                 $attr[strtolower($parts[0])] = $parts[1];
             } else {
                 $attr[strtolower($parts[0])] = true;
             }
         }
         if (!isset($attr['domain'])) {
             $attr['domain'] = $domain;
         } elseif (!Cookie::validateCookieDomain($attr['domain'], $domain)) {
             return null;
         }
         $this->setCookie($name, $value, $attr);
     }
 }
コード例 #23
0
ファイル: autoload.include.php プロジェクト: roncemer/pfmgr2
 function __jax__classAutoloadFindClassFile($class_name, $dir)
 {
     $cnlen = strlen($class_name);
     $anyProcessed = false;
     if (($dp = @opendir($dir)) !== false) {
         while (($fn = readdir($dp)) !== false) {
             if ($fn == '.' || $fn == '..') {
                 continue;
             }
             $path = $dir . '/' . $fn;
             if (is_dir($path)) {
                 if (($foundfn = __jax__classAutoloadFindClassFile($class_name, $path)) !== false) {
                     return $foundfn;
                 }
             }
             if (is_file($path)) {
                 $fnlen = strlen($fn);
                 if ($fnlen > $cnlen && strncmp($fn, $class_name, $cnlen) == 0 && ($cnlen + 10 == $fnlen && substr_compare($fn, '.class.php', $cnlen) == 0 || $cnlen + 14 == $fnlen && substr_compare($fn, '.interface.php', $cnlen) == 0)) {
                     return $path;
                 }
             }
         }
         closedir($dp);
     }
     return false;
 }
コード例 #24
0
 public function viewAction()
 {
     $id = $this->getParam('id');
     $item = get_record_by_id('Item', $id);
     if (empty($item)) {
         throw new Omeka_Controller_Exception_404();
     }
     $relations = metadata($item, array('Dublin Core', 'Relation'), array('all' => true, 'no_escape' => true, 'no_filter' => true));
     // Currently, only support gDoc urls.
     $tableUrl = '';
     $baseUrl = 'https://spreadsheets.google.com/feeds/list/';
     $endUrl = '/public/values';
     foreach ($relations as $relation) {
         if (strpos($relation, $baseUrl) === 0 && substr_compare($relation, $endUrl, -strlen($endUrl), strlen($endUrl)) === 0) {
             $tableUrl = $relation;
             break;
         }
     }
     if (empty($tableUrl)) {
         $this->_helper->flashMessenger(__('This item has no table of images.'), 'error');
         return $this->forward('show', 'items', 'default', array('module' => null, 'controller' => 'items', 'action' => 'show', 'id' => $item->id));
     }
     $this->_prepareViewer($item);
     $this->view->tableUrl = $tableUrl . '?alt=json-in-script&callback=spreadsheetLoaded';
 }
コード例 #25
0
 /**
  * Return a class at the given URI
  *
  * @param   string uri
  * @return  string fully qualified class name, or NULL
  */
 protected function classAtUri($uri)
 {
     if (0 !== substr_compare($uri, \xp::CLASS_FILE_EXT, -strlen(\xp::CLASS_FILE_EXT))) {
         return null;
     }
     // Absolute URIs have the form "xar://containing.xar?the/classes/Name.class.php"
     if (DIRECTORY_SEPARATOR === $uri[0] || ':' === $uri[1] && '\\' === $uri[2]) {
         return null;
     } else {
         if (false !== ($p = strpos($uri, '?'))) {
             $archive = substr($uri, 0, $p + 1);
             if ($archive !== $this->archive) {
                 return null;
             }
             $uri = substr($uri, $p + 1);
         } else {
             $archive = $this->archive;
         }
     }
     // Normalize path: Force forward slashes, strip out "." and empty elements,
     // interpret ".." by backing up until last forward slash is found.
     $path = '';
     foreach (explode('/', strtr($uri, DIRECTORY_SEPARATOR, '/')) as $element) {
         if ('' === $element || '.' === $element) {
             // NOOP
         } else {
             if ('..' === $element) {
                 $path = substr($path, 0, strrpos($path, '/'));
             } else {
                 $path .= '/' . $element;
             }
         }
     }
     return is_file($archive . substr($path, 1)) ? strtr(substr($path, 1, -strlen(\xp::CLASS_FILE_EXT)), '/', '.') : null;
 }
コード例 #26
0
 /**
  * Set the Internet media type. Allow only image types.
  *
  * @param string $type Internet media type
  */
 public function setType($type)
 {
     if (substr_compare($type, 'image/', 0, 6) === 0) {
         $this->type = $type;
     }
     return $this;
 }
コード例 #27
0
ファイル: less.php プロジェクト: netbiel/core
 /**
  * Creates a stylesheet link with LESS support
  *
  * @param   string  $style       file name
  * @param   array   $attributes  default attributes
  * @param   bool    $index       include the index page
  * @param   array   $imports     compare file date for these too, CSS and LESS in style @import
  * @return  string
  */
 public static function style($file, array $attributes = null, $index = false, $imports = null)
 {
     $imports = (array) $imports;
     // Compile only .less files
     if (substr_compare($file, '.less', -5, 5, false) === 0) {
         $css = substr_replace($file, 'css', -4);
         $compiled = is_file($css) ? filemtime($css) : 0;
         try {
             // Check if imported files have changed
             $compile = filemtime($file) > $compiled;
             if (!$compile && !empty($imports)) {
                 foreach ($imports as $import) {
                     if (filemtime($import) > $compiled) {
                         $compile = true;
                         break;
                     }
                 }
             }
             // Compile LESS
             if ($compile) {
                 $compiler = new self($file);
                 file_put_contents($css, $compiler->parse());
             }
             $file = $css;
         } catch (Exception $e) {
             Kohana::$log->add(Kohana::ERROR, __METHOD__ . ': Error compiling LESS file ' . $file . ', ' . $e->getMessage());
         }
     }
     return HTML::style($file . '?' . filemtime($file), $attributes, $index);
 }
コード例 #28
0
ファイル: Pap.php プロジェクト: AmineCherrai/rostanvo
 public function SetOrderStatus($order, $status)
 {
     // create an API object for communication
     $request = $this->createGridObject();
     // get a list of transactions for this order
     // we have TWO filters for orderid, because somewhere along the way, someone decided to
     // use t_orderid rather than orderid, but only in the grid. Go figure.
     $request->addFilter("orderid", Gpf_Data_Filter::LIKE, $order->getIncrementId() . "%");
     $request->addFilter("t_orderid", Gpf_Data_Filter::LIKE, $order->getIncrementId() . "%");
     $request->sendNow();
     $grid = $request->getGrid();
     $recordset = $grid->getRecordset();
     foreach ($recordset as $record) {
         $data = $record->getAttributes();
         if ($status == $data['rstatus']) {
             continue;
             // nothing to change
         }
         // load the transaction
         // NOTE: We used to just copy the data to an empty transaction, but the
         // API wasn't reliable about returning all fields in the grid
         $transaction = Mage::getModel("pap/pap")->load($data['transid']);
         if (substr_compare($transaction->getOrderid(), $order->getIncrementId(), 0, strlen($order->getIncrementId())) != 0) {
             // Shouldn't happen, but the API changes enough that it might, (it has before)
             // and we don't want to corrupt everything if it does, so we test.
             // Skip this record.
             continue;
         }
         // set the date approved and the status
         $transaction->setDateapproved($order['dateapproved'] ? $order['dateapproved'] : now());
         $transaction->setRstatus($status);
         // write the transaction
         $transaction->save();
     }
 }
コード例 #29
0
ファイル: ContactsHelper.php プロジェクト: neevan1e/Done
 public static function StripExt($file_name)
 {
     if (strlen($file_name) <= 4 || strlen($file_name) >= 8 && !substr_compare($file_name, "base.php", -8, 8, false) || substr_compare($file_name, ".php", -4, 4, false) !== 0) {
         return false;
     }
     return substr($file_name, 0, strlen($file_name) - 4);
 }
コード例 #30
0
ファイル: Matcher.php プロジェクト: ljarray/dbpedia
 public function match($source, &$pos)
 {
     $sourceLength = strlen($source);
     for (; $pos < $sourceLength; $pos++) {
         $pos += strcspn($source, $this->firstChars, $pos);
         if ($pos == $sourceLength) {
             return false;
         }
         foreach ($this->stdTags as $tagIndex => $tag) {
             $this->tagLength = strlen($tag);
             if ($pos + $this->tagLength <= $sourceLength && substr_compare($source, $tag, $pos, $this->tagLength) === 0) {
                 $pos += $this->tagLength;
                 $this->tagIndex = $tagIndex;
                 $this->isStdTag = true;
                 return true;
             }
         }
         foreach ($this->userTags as $tagIndex => $tag) {
             $this->tagLength = strlen($tag);
             if ($pos + $this->tagLength <= $sourceLength && substr_compare($source, $tag, $pos, $this->tagLength) === 0) {
                 $pos += $this->tagLength;
                 $this->tagIndex = $tagIndex;
                 $this->isStdTag = false;
                 return true;
             }
         }
     }
     return false;
 }