当前位置: 首页>>代码示例>>PHP>>正文


PHP Common::startsWith方法代码示例

本文整理汇总了PHP中Common::startsWith方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::startsWith方法的具体用法?PHP Common::startsWith怎么用?PHP Common::startsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Common的用法示例。


在下文中一共展示了Common::startsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isValidURL

 public static function isValidURL($url, $maxlen = 255)
 {
     if (Common::startsWith($url, '/')) {
         return true;
     }
     return preg_match("/^[a-zA-Z]+[:\\/\\/]+[A-Za-z0-9\\-_]+\\.+[A-Za-z0-9\\.\\/%&=\\?\\-_]+\$/iD", $url) === 1;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:7,代码来源:GWF_Validator.php

示例2: onTag

 private function onTag(Slay_Song $song)
 {
     $form = $this->formTag($song);
     if (false !== ($error = $form->validateCSRF_WeakS())) {
         return $error;
     }
     $tags = array();
     $errors = array();
     foreach ($_POST as $k => $v) {
         if (Common::startsWith($k, 'tag_')) {
             $k = substr($k, 4);
             if (Slay_Tag::getByName($k) === false) {
                 $errors[] = $this->module->lang('err_tag_uk');
             } else {
                 $tags[] = $k;
             }
         }
     }
     if (count($errors) > 0) {
         return GWF_HTML::error('Slaytags', $errors);
     }
     $user = GWF_Session::getUser();
     if (false === Slay_TagVote::clearVotes($song, $user)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === Slay_TagVote::addVotes($song, $user, $tags)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $song->computeTags()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_tagged');
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:33,代码来源:Tag.php

示例3: main

 /**
  *
  * @todo poll only new revisions and append to changelogfile (extend GDO or modulevar?)
  *  if GDO: repository url dynamically
  * @todo add to WC Cronjob
  * @todo rename
  * @author spaceone
  */
 public static function main()
 {
     $svn = new GWF_SvnInfo();
     $svn->setRepository('https://svn.gwf3.gizmore.org/GWF3');
     $startrev = 422;
     //292;
     $logs = $svn->getLog($startrev, $svn->getCurrentRevision());
     # Known users and their WeChall profiles
     $users = array('spaceone' => 'space', 'gizmore' => 'Gizmore');
     $back = '';
     foreach ($logs as $log) {
         $comment = $log['comment'];
         $thx = '';
         if (Common::startsWith($comment, 'WC') || false !== strpos(strtolower($comment), 'wechall')) {
             # TODO: GWF_Date::toString
             if (0 < preg_match_all('/\\(\\s*?thx +([^\\)]+)\\)/', $comment, $matches)) {
                 foreach ($matches[1] as $match) {
                     foreach (preg_split('/[\\s,;]+/', $match) as $username) {
                         $username = htmlspecialchars(trim($username));
                         $username = isset($users[$username]) ? $users[$username] : $username;
                         $thx .= sprintf('<a title="%s" href="%sprofile/%s">%s</a>' . PHP_EOL, $username, GWF_WEB_ROOT, $username);
                     }
                 }
             }
             # TODO: HTML formatting
             $creator = isset($users[$log['creator-displayname']]) ? $users[$log['creator-displayname']] : $log['creator-displayname'];
             $pattern = 'Revision: %s; by <a href="%s/profile/%s">%s</a>; on %s;' . PHP_EOL . '  %s' . PHP_EOL . '%s' . PHP_EOL;
             $back .= sprintf($pattern, $log['version-name'], GWF_WEB_ROOT, $creator, $creator, $log['date'], str_replace("\n", "\n  ", $comment), $thx);
         }
     }
     if (false === file_put_contents(GWF_WWW_PATH . self::$outfile, $back)) {
         # TODO
     }
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:42,代码来源:WC_AutoChangelog.php

示例4: getReplyTitle

 private function getReplyTitle()
 {
     $title = $this->replyThread === true ? $this->thread->getVar('thread_title') : $this->post->getVar('post_title');
     if (!Common::startsWith($title, 'RE: ')) {
         $title = 'RE: ' . $title;
     }
     return $title;
     #return GWF_HTML::display($title);
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:9,代码来源:Reply.php

示例5: sanitize

 private function sanitize()
 {
     $this->ipp = $this->module->getHistmsgPerPage();
     $channel = Common::getGet('channel', '');
     if (Common::startsWith($channel, 'G-')) {
         $channel = 'G#' . substr($channel, 2);
     }
     $this->channel = $this->module->getWhitelistedChannel($channel);
     $this->nItems = $this->module->countHistoryMessages($this->channel);
     $this->nPages = GWF_PageMenu::getPagecount($this->ipp, $this->nItems);
     $this->page = Common::clamp((int) Common::getGet('page', $this->nPages), 1, $this->nPages);
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:12,代码来源:History.php

示例6: getLanguageFilesR

 private function getLanguageFilesR($iso, $path, array &$files)
 {
     if (false === ($dir = dir($path))) {
         return;
     }
     while (false !== ($entry = $dir->read())) {
         $fullpath = $path . '/' . $entry;
         if (Common::startsWith($entry, '.')) {
         } elseif (is_dir($fullpath)) {
             $this->getLanguageFilesR($iso, $fullpath, $files);
         } elseif (preg_match("/.+_{$iso}.php\$/D", $entry)) {
             $files[] = $fullpath;
         }
     }
     $dir->close();
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:16,代码来源:Bundle.php

示例7: populateRec

 public static function populateRec($basedir, $path)
 {
     if (false === ($dir = dir($path))) {
         return false;
     }
     while (false !== ($entry = $dir->read())) {
         if (Common::startsWith($entry, '.')) {
             continue;
         }
         $fullpath = $path . '/' . $entry;
         if (is_dir($fullpath)) {
             self::populateRec($basedir, $fullpath);
         } else {
             self::populateFile($basedir, $fullpath);
         }
     }
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:17,代码来源:GWF_VersionFilesClient.php

示例8: install

 public static function install(Module_Admin $module, $dropTables)
 {
     //		if ($module->cfgRobotUsers() === false) {
     //			return '';
     //		}
     $users = GDO::table('GWF_User');
     $users->deleteWhere("user_name LIKE '[%]'");
     printf('Deleted %d bots.<br/>', $users->affectedRows());
     GDO::table('GWF_Webspider')->createTable(true);
     $filename = GWF_CORE_PATH . 'module/Admin/' . self::SPIDER_FILE;
     if (false === ($fh = fopen($filename, 'r'))) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', $filename);
     }
     $ips = array();
     $botname = '';
     while (true) {
         if (false === ($line = fgets($fh))) {
             break;
         }
         $line = trim($line);
         if ($line === '' || Common::startsWith($line, '#')) {
             continue;
         }
         if (Common::startsWith($line, '[')) {
             if ($botname !== '') {
                 self::install_spider($botname, $ips);
             }
             $line = trim($line, '[]');
             $botname = $line;
             $ips = array();
             echo "SWITCHING TO NEXT BOT: {$line}<br/>";
         } else {
             $ips[] = $line;
         }
     }
     if ($botname !== '') {
         self::install_spider($botname, $ips);
         $ips = array();
     }
     fclose($fh);
     return '';
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:42,代码来源:GWF_AdminWebSpiders.php

示例9: parseSudoshRow

 private static function parseSudoshRow(Module_Audit $module, $row, $fh2)
 {
     // 		echo $row;
     if (false === ($row2 = Common::substrFrom($row, '-sudosh: ', false))) {
         return self::error('Invalid line: ' . $row);
     } elseif (Common::startsWith($row2, 'created')) {
         return self::parseSudoCreated($module, $row2);
     } elseif (Common::startsWith($row2, 'destroyed')) {
         return self::parseSudoDestroyed($module, $row2);
     } elseif (Common::startsWith($row2, 'st')) {
         return true;
         # skip
     } elseif (false === ($id = Common::substrUntil($row2, ':', false))) {
         return self::error('Invalid line: ' . $row);
     } elseif (false === ($row2 = Common::substrFrom($row2, ':', false))) {
         return self::error('Invalid line: ' . $row);
     } else {
         return self::appendToLog($module, $id, $row2);
     }
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:20,代码来源:GWF_AuditCronjob.php

示例10: gatherFilesRec

 private function gatherFilesRec($path)
 {
     if (false === ($dir = dir($path))) {
         echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array($path));
         return false;
     }
     while (false !== ($entry = $dir->read())) {
         if (Common::startsWith($entry, '.')) {
             continue;
         }
         $fullpath = $path . '/' . $entry;
         if (is_dir($fullpath)) {
             $this->gatherFilesRec($fullpath);
         } elseif (1 === preg_match('/_([a-z]{2})\\.php$/D', $entry, $matches)) {
             $iso = $matches[1];
             $this->files[] = array($fullpath, $this->isBranched($fullpath), GWF_LangFile::getByPath($fullpath), $iso, $entry);
         } else {
             //				echo "SKIP ".$fullpath;
         }
     }
     return true;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:22,代码来源:EditFiles.php

示例11: cleanupCookies

 /**
  * Removes all cookies in a directory
  * @param int $time one week
  * @param string $path
  * @author spaceone
  **/
 public static function cleanupCookies($time = 604800, $path = self::COOKIE_PATH)
 {
     if (false === ($files = scandir($path))) {
         return false;
     }
     $ret = true;
     foreach ($files as $file) {
         if (true === Common::startsWith($dir, self::COOKIE_PREFIX) && false === is_dir($path . $file) && filemtime($path . $file) <= time() - $time) {
             if (false === unlink($path . $file)) {
                 $ret = false;
             }
         }
     }
     return $ret;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:21,代码来源:GWF_HTTP.php

示例12: getFormTitle

 private function getFormTitle()
 {
     if ($this->pm === false) {
         return '';
     } else {
         $re = $this->module->cfgRE();
         $old = $this->pm->getVar('pm_title');
         return Common::startsWith($old, $re) ? $old : $re . $old;
     }
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:10,代码来源:Send.php

示例13: isLockingCommand

 private function isLockingCommand($command)
 {
     $c = strtolower($command);
     if (Common::startsWith($c, '#')) {
         return true;
     }
     if (Common::startsWith($c, 'attack')) {
         return true;
     }
     if (Common::startsWith($c, 'idle')) {
         return true;
     }
     if (Common::startsWith($c, 'fl')) {
         return true;
     }
     // 		if (Common::startsWith($c, 'flee'))
     // 		{
     // 			return true;
     // 		}
     return false;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:21,代码来源:SR_Player.php

示例14: getDescription

 private function getDescription($url)
 {
     # Get page content
     # TODO: Only download .txt and .html content!
     GWF_HTTP::setTimeout(10);
     GWF_HTTP::setConnectTimeout(3);
     $content = GWF_HTTP::getFromURL($url, true);
     GWF_HTTP::setTimeout();
     GWF_HTTP::setConnectTimeout();
     if ($content === false) {
         Dog_Log::error('Mod_Link::getDescription(): getFromURL() failed. URL: ' . $url);
         return false;
     }
     list($head, $content) = preg_split("/[\r\n]{4}/", $content, 2);
     $type = Common::regex('/Content-Type: *(.*)/Di', $head);
     echo $type . PHP_EOL;
     if (Common::startsWith($type, 'image')) {
         return array('image', $content);
     }
     # Get Title from html
     if (0 === preg_match('#< *title *>([^<]+)< */ *title *>#i', $content, $matches)) {
         return false;
     }
     $title = $this->decode($matches[1]);
     $descr = '';
     if (1 === preg_match('#(< *meta.*description[^>]*>)#i', $content, $matchesB)) {
         $tag = $matchesB[1];
         if (1 === preg_match('#content=["\']([^"\']+)["\']#', $tag, $matchesB)) {
             $descr = ' - ' . $this->decode($matchesB[1]);
         }
     }
     return array('html', $title . ' - ' . $descr);
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:33,代码来源:DOGMOD_Link.php

示例15: getProfileURL

 public function getProfileURL($onsitename)
 {
     $profile_part = $this->replaceURL($this->getVar('site_url_profile'), urlencode($onsitename));
     if (Common::startsWith($profile_part, 'http')) {
         return $profile_part;
     }
     return $this->getVar('site_url') . '/' . $profile_part;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:8,代码来源:WC_Site.php


注:本文中的Common::startsWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。