PHP Функция substr - примеры использования

На этой странице представлены лучшие примеры PHP кода для метода substr, полученные из open source проектов. Вы можете ставить оценку каждому примеру, чтобы помочь нам улучшить качество примеров.
Пример #1
Показать файл Файл: Link.php Проект: jubinpatel/horde
1
 /**
  * @param mixed $in
  */
 public function __construct($in = null)
 {
     $fields = array('to', 'cc', 'bcc', 'message', 'body', 'subject');
     if (is_string($in)) {
         if (($pos = strpos($in, '?')) !== false) {
             parse_str(substr($in, $pos + 1), $this->args);
             $this->args['to'] = substr($in, 0, $pos);
         } else {
             $this->args['to'] = $in;
         }
     } elseif ($in instanceof Horde_Variables) {
         foreach ($fields as $val) {
             if (isset($in->{$val})) {
                 $this->args[$val] = $in->{$val};
             }
         }
     } elseif (is_array($in)) {
         $this->args = $in;
     }
     if (isset($this->args['to']) && strpos($this->args['to'], 'mailto:') === 0) {
         $mailto = @parse_url($this->args['to']);
         if (is_array($mailto)) {
             $this->args['to'] = isset($mailto['path']) ? $mailto['path'] : '';
             if (!empty($mailto['query'])) {
                 parse_str($mailto['query'], $vals);
                 foreach ($fields as $val) {
                     if (isset($vals[$val])) {
                         $this->args[$val] = $vals[$val];
                     }
                 }
             }
         }
     }
 }
Пример #2
Показать файл Файл: PhpNameGenerator.php Проект: kalaspuffar/php-orm-benchmark
0
 /**
  * <code>inputs</code> should consist of two (three) elements, the
  * original name of the database element and the method for
  * generating the name.
  * The optional third element may contain a prefix that will be
  * stript from name prior to generate the resulting name.
  * There are currently three methods:
  * <code>CONV_METHOD_NOCHANGE</code> - xml names are converted
  * directly to php names without modification.
  * <code>CONV_METHOD_UNDERSCORE</code> will capitalize the first
  * letter, remove underscores, and capitalize each letter before
  * an underscore.  All other letters are lowercased. "phpname"
  * works the same as the <code>CONV_METHOD_PHPNAME</code> method
  * but will not lowercase any characters.
  *
  * @param      inputs list expected to contain two (optional: three) parameters,
  * element 0 contains name to convert, element 1 contains method for conversion,
  * optional element 2 contains prefix to be striped from name
  * @return The generated name.
  * @see        NameGenerator
  */
 public function generateName($inputs)
 {
     $schemaName = $inputs[0];
     $method = $inputs[1];
     if (count($inputs) > 2) {
         $prefix = $inputs[2];
         if ($prefix != '' && substr($schemaName, 0, strlen($prefix)) == $prefix) {
             $schemaName = substr($schemaName, strlen($prefix));
         }
     }
     $phpName = null;
     switch ($method) {
         case self::CONV_METHOD_CLEAN:
             $phpName = $this->cleanMethod($schemaName);
             break;
         case self::CONV_METHOD_PHPNAME:
             $phpName = $this->phpnameMethod($schemaName);
             break;
         case self::CONV_METHOD_NOCHANGE:
             $phpName = $this->nochangeMethod($schemaName);
             break;
         case self::CONV_METHOD_UNDERSCORE:
         default:
             $phpName = $this->underscoreMethod($schemaName);
     }
     return $phpName;
 }
Пример #3
Показать файл Файл: HtmlList.php Проект: ravi2jdesign/solvingmagento_1.7.0
0
 /**
  * Generates a 'List' element.
  *
  * @param array   $items   Array with the elements of the list
  * @param boolean $ordered Specifies ordered/unordered list; default unordered
  * @param array   $attribs Attributes for the ol/ul tag.
  * @return string The list XHTML.
  */
 public function htmlList(array $items, $ordered = false, $attribs = false, $escape = true)
 {
     if (!is_array($items)) {
         #require_once 'Zend/View/Exception.php';
         $e = new Zend_View_Exception('First param must be an array');
         $e->setView($this->view);
         throw $e;
     }
     $list = '';
     foreach ($items as $item) {
         if (!is_array($item)) {
             if ($escape) {
                 $item = $this->view->escape($item);
             }
             $list .= '<li>' . $item . '</li>' . self::EOL;
         } else {
             if (6 < strlen($list)) {
                 $list = substr($list, 0, strlen($list) - 6) . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
             } else {
                 $list .= '<li>' . $this->htmlList($item, $ordered, $attribs, $escape) . '</li>' . self::EOL;
             }
         }
     }
     if ($attribs) {
         $attribs = $this->_htmlAttribs($attribs);
     } else {
         $attribs = '';
     }
     $tag = 'ul';
     if ($ordered) {
         $tag = 'ol';
     }
     return '<' . $tag . $attribs . '>' . self::EOL . $list . '</' . $tag . '>' . self::EOL;
 }
Пример #4
Показать файл Файл: FileAdapterTest.php Проект: genkgo/cache
0
 /**
  *
  */
 public function testChmod()
 {
     $cache = new FileAdapter(self::$dir, new NoneSerializer(), 0777);
     $cache->set('item', 'content');
     $perms = fileperms(self::$dir . '/' . md5('item'));
     $this->assertEquals('0777', substr(sprintf('%o', $perms), -4));
 }
Пример #5
Показать файл Файл: DocBlockReturnSelfSniff.php Проект: Anna-KarinaOertzen/code-sniffer
0
 /**
  * @param \PHP_CodeSniffer_File $phpCsFile
  * @param int $stackPointer
  *
  * @return void
  */
 public function process(\PHP_CodeSniffer_File $phpCsFile, $stackPointer)
 {
     $tokens = $phpCsFile->getTokens();
     $docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
     if (!$docBlockEndIndex) {
         return;
     }
     $docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener'];
     for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
         if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') {
             continue;
         }
         if (!in_array($tokens[$i]['content'], ['@return'])) {
             continue;
         }
         $classNameIndex = $i + 2;
         if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
             continue;
         }
         $content = $tokens[$classNameIndex]['content'];
         $appendix = '';
         $spaceIndex = strpos($content, ' ');
         if ($spaceIndex) {
             $appendix = substr($content, $spaceIndex);
             $content = substr($content, 0, $spaceIndex);
         }
         if (empty($content)) {
             continue;
         }
         $parts = explode('|', $content);
         $this->fixParts($phpCsFile, $classNameIndex, $parts, $appendix);
     }
 }
Пример #6
Показать файл Файл: class из content.php Проект: tomoonshine/postsms
0
 public function __call($s_method_name, $arr_arguments)
 {
     if (!method_exists($this, $s_method_name)) {
         // если еще не имлементировали
         $s_match = "";
         $s_method_prefix = '';
         $s_method_base = '';
         $arr_matches = array();
         $bSucc = preg_match("/[A-Z_]/", $s_method_name, $arr_matches);
         if ($bSucc) {
             $s_match = $arr_matches[0];
             $i_match = strpos($s_method_name, $s_match);
             $s_method_prefix = substr($s_method_name, 0, $i_match) . "/";
             $s_method_base = substr($s_method_name, 0, $i_match + ($s_match === "_" ? 1 : 0));
         }
         $s_class_enter = "__" . $s_method_name;
         // метод, общий для всех режимов
         if (!class_exists($s_class_enter)) {
             $s_entermethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . ".lib.php";
             $this->__loadLib($s_entermethod_lib);
             $this->__implement($s_class_enter);
         }
         $s_class_mode = "__" . $s_method_name . "_";
         // метод, выбираемый в зависимости от режима
         if (!class_exists($s_class_mode)) {
             $s_modemethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . "_" . cmsController::getInstance()->getCurrentMode() . ".lib.php";
             $this->__loadLib($s_modemethod_lib);
             $this->__implement($s_class_mode);
         }
     }
     return parent::__call($s_method_name, $arr_arguments);
 }
Пример #7
Показать файл Файл: class.bank_khusus.php Проект: rifkyzulfikarf/en-sgj
0
 function autocode_on_history()
 {
     $kode = "";
     $query = "SELECT MAX(`id`) FROM `khusus_kas_bank` WHERE DATE(`tgl_input`) = '" . date("Y-m-d") . "';";
     if ($result = $this->runQuery($query)) {
         $rs = $result->fetch_array();
         if ($rs[0] == null) {
             $kode = "KKB" . date("ymd") . "0001";
         } else {
             $lastCode = substr($rs[0], 9, 4);
             $newCode = $lastCode + 1;
             switch (strlen($newCode)) {
                 case 1:
                     $kode = "KKB" . date("ymd") . "000" . $newCode;
                     break;
                 case 2:
                     $kode = "KKB" . date("ymd") . "00" . $newCode;
                     break;
                 case 3:
                     $kode = "KKB" . date("ymd") . "0" . $newCode;
                     break;
                 case 4:
                     $kode = "KKB" . date("ymd") . $newCode;
                     break;
             }
         }
     }
     return $kode;
 }
Пример #8
Показать файл Файл: Library.php Проект: NadaNafti/Thalassa
0
 public function getDatesBetween($dStart, $dEnd)
 {
     if ($dStart > $dEnd) {
         $var = $dStart;
         $dStart = $dEnd;
         $dEnd = $var;
     }
     $iStart = strtotime($dStart);
     $iEnd = strtotime($dEnd);
     if (false === $iStart || false === $iEnd) {
         return false;
     }
     $aStart = explode('-', $dStart);
     $aEnd = explode('-', $dEnd);
     if (count($aStart) !== 3 || count($aEnd) !== 3) {
         return false;
     }
     if (false === checkdate($aStart[1], $aStart[2], $aStart[0]) || false === checkdate($aEnd[1], $aEnd[2], $aEnd[0]) || $iEnd < $iStart) {
         return false;
     }
     for ($i = $iStart; $i < $iEnd + 86400; $i = strtotime('+1 day', $i)) {
         $sDateToArr = strftime('%Y-%m-%d', $i);
         $sYear = substr($sDateToArr, 0, 4);
         $sMonth = substr($sDateToArr, 5, 2);
         //$aDates[$sYear][$sMonth][]=$sDateToArr;
         $aDates[] = $sDateToArr;
     }
     if (isset($aDates) && !empty($aDates)) {
         return $aDates;
     } else {
         return false;
     }
 }
Пример #9
Показать файл Файл: DecamelizeClassNameExtractor.php Проект: ferodss/tactician-pimple-service-provider
0
 /**
  * {@inheritdoc}
  */
 public function extract($command)
 {
     $className = substr(strrchr(get_class($command), '\\'), 1);
     return preg_replace_callback('/(^|[a-z])([A-Z])/', function ($s) {
         return strtolower(strlen($s[1]) ? "{$s['1']}_{$s['2']}" : "{$s['2']}");
     }, $className);
 }
Пример #10
Показать файл Файл: shocky.php Проект: Cazzar/Shocky
0
function mb_ord($char)
{
    $k = mb_convert_encoding($char, 'UCS-2LE', 'UTF-8');
    $k1 = ord(substr($k, 0, 1));
    $k2 = ord(substr($k, 1, 1));
    return $k2 * 256 + $k1;
}
Пример #11
Показать файл Файл: DetectProprietaryXliff.php Проект: spMohanty/MateCat
0
 public static function isXliff($stringData = null, $fullPathToFile = null)
 {
     self::_reset();
     $info = array();
     if (!empty($stringData) && empty($fullPathToFile)) {
         $stringData = substr($stringData, 0, 1024);
     } elseif (empty($stringData) && !empty($fullPathToFile)) {
         $info = FilesStorage::pathinfo_fix($fullPathToFile);
         $file_pointer = fopen("{$fullPathToFile}", 'r');
         // Checking Requirements (By specs, I know that xliff version is in the first 1KB)
         $stringData = fread($file_pointer, 1024);
         fclose($file_pointer);
     } elseif (!empty($stringData) && !empty($fullPathToFile)) {
         //we want to check extension and content
         $info = FilesStorage::pathinfo_fix($fullPathToFile);
     }
     self::$fileType['info'] = $info;
     //we want to check extension also if file path is specified
     if (!empty($info) && !self::isXliffExtension()) {
         //THIS IS NOT an xliff
         return false;
     }
     //		preg_match( '|<xliff\s.*?version\s?=\s?["\'](.*?)["\'](.*?)>|si', $stringData, $tmp );
     if (!empty($stringData)) {
         return array($stringData);
     }
     return false;
 }
Пример #12
Показать файл Файл: votes.php Проект: pippogsm/UserIdeas
0
 /**
  * Build an SQL query to load the list data.
  *
  * @return  JDatabaseQuery
  * @since   1.6
  */
 protected function getListQuery()
 {
     $db = $this->getDbo();
     /** @var $db JDatabaseMySQLi */
     // Create a new query object.
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select($this->getState('list.select', 'a.id, a.record_date, a.votes, a.item_id, ' . 'b.title, ' . 'c.name'));
     $query->from($db->quoteName('#__uideas_votes') . ' AS a');
     $query->innerJoin($db->quoteName('#__uideas_items') . ' AS b ON a.item_id = b.id');
     $query->leftJoin($db->quoteName('#__users') . ' AS c ON a.user_id = c.id');
     // Filter by search in title
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'id:') === 0) {
             $query->where('a.id = ' . (int) substr($search, 3));
         } else {
             $escaped = $db->escape($search, true);
             $quoted = $db->quote("%" . $escaped . "%", false);
             $query->where('b.title LIKE ' . $quoted, "OR");
             $query->where('c.name LIKE ' . $quoted);
         }
     }
     // Add the list ordering clause.
     $orderString = $this->getOrderString();
     $query->order($db->escape($orderString));
     return $query;
 }
Пример #13
Показать файл Файл: Command.php Проект: VasekPurchart/khanovaskola-v3
0
 private function formatPath($path)
 {
     $root = realpath(__DIR__ . '/../../../');
     $path = realpath($path);
     $relative = substr($path, strlen($root) + 1);
     return preg_replace('~/([a-z0-9-]+)(\\.[a-z0-9]+)?$~ims', '/<fg=blue>$1</fg=blue>$2', $relative);
 }
Пример #14
Показать файл Файл: currency.php Проект: vverhun/hoho
0
 public function updateCurrencies()
 {
     if (extension_loaded('curl')) {
         $data = array();
         $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified > '" . date(strtotime('-1 day')) . "'");
         foreach ($query->rows as $result) {
             $data[] = $this->config->get('config_currency') . $result['code'] . '=X';
         }
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $content = curl_exec($ch);
         curl_close($ch);
         $lines = explode("\n", trim($content));
         foreach ($lines as $line) {
             $currency = substr($line, 4, 3);
             $value = substr($line, 11, 6);
             if ((double) $value) {
                 $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (double) $value . "', date_modified = NOW() WHERE code = '" . $this->db->escape($currency) . "'");
             }
         }
         $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = NOW() WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
         $this->cache->delete('currency');
     }
 }
Пример #15
Показать файл Файл: notes.php Проект: moscarar/cityhow
0
 function wpcom_static_url($file)
 {
     $i = hexdec(substr(md5($file), -1)) % 2;
     $http = is_ssl() ? 'https' : 'http';
     $url = $http . '://s' . $i . '.wp.com' . $file;
     return $url;
 }
Пример #16
Показать файл Файл: opendd.php Проект: redvabel/Vabelgg
0
/**
 * Attempt to construct an ODD object out of a XmlElement or sub-elements.
 *
 * @param XmlElement $element The element(s)
 *
 * @return mixed An ODD object if the element can be handled, or false.
 */
function ODD_factory(XmlElement $element)
{
    $name = $element->name;
    $odd = false;
    switch ($name) {
        case 'entity':
            $odd = new ODDEntity("", "", "");
            break;
        case 'metadata':
            $odd = new ODDMetaData("", "", "", "");
            break;
        case 'relationship':
            $odd = new ODDRelationship("", "", "");
            break;
    }
    // Now populate values
    if ($odd) {
        // Attributes
        foreach ($element->attributes as $k => $v) {
            $odd->setAttribute($k, $v);
        }
        // Body
        $body = $element->content;
        $a = stripos($body, "<![CDATA");
        $b = strripos($body, "]]>");
        if ($body && $a !== false && $b !== false) {
            $body = substr($body, $a + 8, $b - ($a + 8));
        }
        $odd->setBody($body);
    }
    return $odd;
}
Пример #17
Показать файл Файл: sanitizing.lib.php Проект: dingdong2310/g5_theme
0
/**
 * 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;
}
Пример #18
Показать файл Файл: FileModel.class.php Проект: walkingmanc/weshop
0
 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     $info = $Upload->upload($files);
     /* 设置文件保存位置 */
     $this->_auto[] = array('location', 'ftp' === strtolower($driver) ? 1 : 0, self::MODEL_INSERT);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                 //在模板里的url路径
                 continue;
             }
             $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
             //在模板里的url路径
             /* 记录文件信息 */
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             } else {
                 //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
                 unset($info[$key]);
             }
         }
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
Пример #19
Показать файл Файл: ReflectionCaster.php Проект: ngitimfoyo/Nyari-AppPHP
0
 public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested)
 {
     $prefix = Caster::PREFIX_VIRTUAL;
     $c = new \ReflectionFunction($c);
     $stub->class = 'Closure';
     // HHVM generates unique class names for closures
     $a = static::castFunctionAbstract($c, $a, $stub, $isNested);
     if (isset($a[$prefix . 'parameters'])) {
         foreach ($a[$prefix . 'parameters'] as &$v) {
             $param = $v;
             $v = array();
             foreach (static::castParameter($param, array(), $stub, true) as $k => $param) {
                 if ("" === $k[0]) {
                     $v[substr($k, 3)] = $param;
                 }
             }
             unset($v['position'], $v['isVariadic'], $v['byReference'], $v);
         }
     }
     if ($f = $c->getFileName()) {
         $a[$prefix . 'file'] = $f;
         $a[$prefix . 'line'] = $c->getStartLine() . ' to ' . $c->getEndLine();
     }
     $prefix = Caster::PREFIX_DYNAMIC;
     unset($a['name'], $a[$prefix . '0'], $a[$prefix . 'this'], $a[$prefix . 'parameter'], $a[Caster::PREFIX_VIRTUAL . 'extra']);
     return $a;
 }
Пример #20
Показать файл Файл: NamingStrategy.php Проект: Johardmeier/bolt
0
 /**
  * Returns a class name with namespaces removed.
  *
  * @param string $className
  *
  * @return string
  */
 public function getRelativeClass($className)
 {
     if (strpos($className, '\\') !== false) {
         $className = substr($className, strrpos($className, '\\') + 1);
     }
     return $className;
 }
Пример #21
Показать файл Файл: FileExtensionSniff.php Проект: CobaltBlueDW/oddsandends
0
 /**
  * Processes this test, when one of its tokens is encountered.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
  * @param int                  $stackPtr  The position of the current token in the
  *                                        stack passed in $tokens.
  *
  * @return void
  */
 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
 {
     $tokens = $phpcsFile->getTokens();
     // Make sure this is the first PHP open tag so we don't process
     // the same file twice.
     $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1);
     if ($prevOpenTag !== false) {
         return;
     }
     $fileName = $phpcsFile->getFileName();
     $extension = substr($fileName, strrpos($fileName, '.'));
     $nextClass = $phpcsFile->findNext(array(T_CLASS, T_INTERFACE), $stackPtr);
     if ($extension === '.php') {
         if ($nextClass !== false) {
             $error = '%s found in ".php" file; use ".inc" extension instead';
             $data = array(ucfirst($tokens[$nextClass]['content']));
             $phpcsFile->addError($error, $stackPtr, 'ClassFound', $data);
         }
     } else {
         if ($extension === '.inc') {
             if ($nextClass === false) {
                 $error = 'No interface or class found in ".inc" file; use ".php" extension instead';
                 $phpcsFile->addError($error, $stackPtr, 'NoClass');
             }
         }
     }
 }
Пример #22
Показать файл Файл: xmu.php Проект: surevision/node_mpg123_pi
0
function getLocation($str)
{
    $array_size = intval(substr($str, 0, 1));
    // 拆成的行数
    $code = substr($str, 1);
    // 加密后的串
    $len = strlen($code);
    $subline_size = $len % $array_size;
    // 满字符的行数
    $result = array();
    $deurl = "";
    for ($i = 0; $i < $array_size; $i += 1) {
        if ($i < $subline_size) {
            array_push($result, substr($code, 0, ceil($len / $array_size)));
            $code = substr($code, ceil($len / $array_size));
        } else {
            array_push($result, substr($code, 0, ceil($len / $array_size) - 1));
            $code = substr($code, ceil($len / $array_size) - 1);
        }
    }
    for ($i = 0; $i < ceil($len / $array_size); $i += 1) {
        for ($j = 0; $j < count($result); $j += 1) {
            $deurl = $deurl . "" . substr($result[$j], $i, 1);
        }
    }
    return str_replace("^", "0", urldecode($deurl));
}
Пример #23
Показать файл Файл: toba_solicitud_servicio_web.php Проект: emma5021/toba
0
 function procesar()
 {
     toba::logger_ws()->debug('Servicio Llamado: ' . $this->info['basica']['item']);
     toba::logger_ws()->set_checkpoint();
     set_error_handler('toba_logger_ws::manejador_errores_recuperables', E_ALL);
     $this->validar_componente();
     //-- Pide los datos para construir el componente, WSF no soporta entregar objetos creados
     $clave = array();
     $clave['proyecto'] = $this->info['objetos'][0]['objeto_proyecto'];
     $clave['componente'] = $this->info['objetos'][0]['objeto'];
     list($tipo, $clase, $datos) = toba_constructor::get_runtime_clase_y_datos($clave, $this->info['objetos'][0]['clase'], false);
     agregar_dir_include_path(toba_dir() . '/php/3ros/wsf');
     $opciones_extension = toba_servicio_web::_get_opciones($this->info['basica']['item'], $clase);
     $wsdl = strpos($_SERVER['REQUEST_URI'], "?wsdl") !== false;
     $sufijo = 'op__';
     $metodos = array();
     $reflexion = new ReflectionClass($clase);
     foreach ($reflexion->getMethods() as $metodo) {
         if (strpos($metodo->name, $sufijo) === 0) {
             $servicio = substr($metodo->name, strlen($sufijo));
             $prefijo = $wsdl ? '' : '_';
             $metodos[$servicio] = $prefijo . $metodo->name;
         }
     }
     $opciones = array();
     $opciones['serviceName'] = $this->info['basica']['item'];
     $opciones['classes'][$clase]['operations'] = $metodos;
     $opciones = array_merge($opciones, $opciones_extension);
     $this->log->debug("Opciones del servidor: " . var_export($opciones, true), 'toba');
     $opciones['classes'][$clase]['args'] = array($datos);
     toba::logger_ws()->set_checkpoint();
     $service = new WSService($opciones);
     $service->reply();
     $this->log->debug("Fin de servicio web", 'toba');
 }
Пример #24
Показать файл Файл: BatchingTest.php Проект: toneloc/php-client
0
 public function setUp()
 {
     parent::SetUp();
     $className = $this->getClassName();
     $sampleName = substr($className, 0, -4);
     $this->url = self::baseUrl() . basename(__DIR__) . '/' . $sampleName . '.php';
 }
Пример #25
Показать файл Файл: ProcessUtils.php Проект: drickferreira/rastreador
0
 /**
  * Escapes a string to be used as a shell argument.
  *
  * @param string $argument The argument that will be escaped
  *
  * @return string The escaped argument
  */
 public static function escapeArgument($argument)
 {
     //Fix for PHP bug #43784 escapeshellarg removes % from given string
     //Fix for PHP bug #49446 escapeshellarg doesn't work on Windows
     //@see https://bugs.php.net/bug.php?id=43784
     //@see https://bugs.php.net/bug.php?id=49446
     if ('\\' === DIRECTORY_SEPARATOR) {
         if ('' === $argument) {
             return escapeshellarg($argument);
         }
         $escapedArgument = '';
         $quote = false;
         foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
             if ('"' === $part) {
                 $escapedArgument .= '\\"';
             } elseif (self::isSurroundedBy($part, '%')) {
                 // Avoid environment variable expansion
                 $escapedArgument .= '^%"' . substr($part, 1, -1) . '"^%';
             } else {
                 // escape trailing backslash
                 if ('\\' === substr($part, -1)) {
                     $part .= '\\';
                 }
                 $quote = true;
                 $escapedArgument .= $part;
             }
         }
         if ($quote) {
             $escapedArgument = '"' . $escapedArgument . '"';
         }
         return $escapedArgument;
     }
     return escapeshellarg($argument);
 }
Пример #26
Показать файл Файл: Generic.php Проект: marqui678/finalchance.Panopta
0
 /**
  * Sets data
  *
  * @param string $key
  * @param string $var
  * @param int $expire
  * @return boolean
  */
 function set($key, $var, $expire = 0)
 {
     $key = $this->get_item_key($key);
     $sub_path = $this->_get_path($key);
     $path = $this->_cache_dir . '/' . $sub_path;
     $sub_dir = dirname($sub_path);
     $dir = dirname($path);
     if (!@is_dir($dir)) {
         if (!w3_mkdir_from($dir, W3TC_CACHE_DIR)) {
             return false;
         }
     }
     $fp = @fopen($path, 'w');
     if (!$fp) {
         return false;
     }
     if ($this->_locking) {
         @flock($fp, LOCK_EX);
     }
     @fputs($fp, $var['content']);
     @fclose($fp);
     if ($this->_locking) {
         @flock($fp, LOCK_UN);
     }
     // some hostings create files with restrictive permissions
     // not allowing apache to read it later
     @chmod($path, 0644);
     $old_entry_path = $path . '.old';
     @unlink($old_entry_path);
     if (w3_is_apache() && isset($var['headers']) && isset($var['headers']['Content-Type']) && substr($var['headers']['Content-Type'], 0, 8) == 'text/xml') {
         file_put_contents(dirname($path) . '/.htaccess', "<IfModule mod_mime.c>\n" . "    RemoveType .html_gzip\n" . "    AddType text/xml .html_gzip\n" . "    RemoveType .html\n" . "    AddType text/xml .html\n" . "</IfModule>");
     }
     return true;
 }
Пример #27
Показать файл Файл: PantheonAliases.php Проект: pantheon-systems/terminus
0
 /**
  * Requests API data and returns aliases
  *
  * @return string
  */
 private function getAliases()
 {
     $request = new Request();
     $user = new User();
     $path = 'drush_aliases';
     $method = 'GET';
     $response = $request->request('users', Session::getValue('user_id'), $path, $method);
     eval(str_replace('<?php', '', $response['data']->drush_aliases));
     $formatted_aliases = substr($response['data']->drush_aliases, 0, -1);
     $sites_object = new Sites();
     $sites = $sites_object->all();
     foreach ($sites as $site) {
         $environments = $site->environments->all();
         foreach ($environments as $environment) {
             $key = $site->get('name') . '.' . $environment->get('id');
             if (isset($aliases[$key])) {
                 break;
             }
             try {
                 $formatted_aliases .= PHP_EOL . "  \$aliases['{$key}'] = ";
                 $formatted_aliases .= $this->constructAlias($environment);
             } catch (TerminusException $e) {
                 continue;
             }
         }
     }
     $formatted_aliases .= PHP_EOL;
     return $formatted_aliases;
 }
Пример #28
Показать файл Файл: langs.php Проект: ejailesb/repo_empr
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>';
 }
Пример #29
Показать файл Файл: test.php Проект: spoymenov/arisgames
0
 protected function stripComments($JSONreturnString)
 {
     if (strpos($JSONreturnString, "/*") !== false) {
         $JSONreturnString = substr($JSONreturnString, strpos($JSONreturnString, "*/") + 2);
     }
     return substr($JSONreturnString, strpos($JSONreturnString, "{"));
 }
Пример #30
Показать файл Файл: ModelFieldString.php Проект: new-frontiers/nostromo-framework
0
 public function save()
 {
     if ($this->maxLength <= 0) {
         $this->maxLength = 255;
     }
     return substr($this->value, 0, $this->maxLength);
 }