function onEndShowScripts($action)
 {
     $timeline = $this->_getTimeline($action);
     // If there's not a timeline on this page,
     // just return true
     if (empty($timeline)) {
         return true;
     }
     $base = $action->selfUrl();
     if (mb_strstr($base, '?')) {
         $url = $base . '&realtime=1';
     } else {
         $url = $base . '?realtime=1';
     }
     $scripts = $this->_getScripts();
     foreach ($scripts as $script) {
         $action->script($script);
     }
     $user = common_current_user();
     if (!empty($user->id)) {
         $user_id = $user->id;
     } else {
         $user_id = 0;
     }
     if ($action->boolean('realtime')) {
         $realtimeUI = ' RealtimeUpdate.initPopupWindow();';
     } else {
         $pluginPath = common_path('plugins/Realtime/');
         $realtimeUI = ' RealtimeUpdate.initActions("' . $url . '", "' . $timeline . '", "' . $pluginPath . '");';
     }
     $script = ' $(document).ready(function() { ' . $realtimeUI . $this->_updateInitialize($timeline, $user_id) . '}); ';
     $action->inlineScript($script);
     return true;
 }
Пример #2
0
 public function isValid($value)
 {
     $this->_setValue($value);
     $valueString = (string) $value;
     $people = Ml_Model_People::getInstance();
     if (mb_strstr($value, "@")) {
         $getUserByEmail = $people->getByEmail($value);
         if (empty($getUserByEmail)) {
             $this->_error(self::MSG_EMAIL_NOT_FOUND);
             return false;
         }
         Zend_Registry::getInstance()->set("loginUserInfo", $getUserByEmail);
         return true;
     }
     if (mb_strlen($value) == 0) {
         return false;
     }
     if (mb_strlen($value) > 20) {
         $this->_error(self::MSG_USERNAME_NOT_FOUND);
         return false;
     }
     if (preg_match('#([^a-z0-9_-]+)#is', $value) || $value == '0') {
         $this->_error(self::MSG_USERNAME_NOT_FOUND);
         return false;
     }
     $getUserByUsername = $people->getByUsername($value);
     if (empty($getUserByUsername)) {
         $this->_error(self::MSG_USERNAME_NOT_FOUND);
         return false;
     }
     Zend_Registry::getInstance()->set("loginUserInfo", $getUserByUsername);
     return true;
 }
Пример #3
0
 private static function detectContext()
 {
     if (self::$context !== null) {
         return;
     }
     if (defined('OW_USE_CONTEXT')) {
         switch (true) {
             case OW_USE_CONTEXT == 1:
                 self::$context = self::CONTEXT_DESKTOP;
                 return;
             case OW_USE_CONTEXT == 1 << 1:
                 self::$context = self::CONTEXT_MOBILE;
                 return;
             case OW_USE_CONTEXT == 1 << 2:
                 self::$context = self::CONTEXT_API;
                 return;
         }
     }
     $context = self::CONTEXT_DESKTOP;
     try {
         $isSmart = UTIL_Browser::isSmartphone();
     } catch (Exception $e) {
         return;
     }
     if (defined('OW_CRON')) {
         $context = self::CONTEXT_DESKTOP;
     } else {
         if (self::getSession()->isKeySet(OW_Application::CONTEXT_NAME)) {
             $context = self::getSession()->get(OW_Application::CONTEXT_NAME);
         } else {
             if ($isSmart) {
                 $context = self::CONTEXT_MOBILE;
             }
         }
     }
     if (defined('OW_USE_CONTEXT')) {
         if ((OW_USE_CONTEXT & 1 << 1) == 0 && $context == self::CONTEXT_MOBILE) {
             $context = self::CONTEXT_DESKTOP;
         }
         if ((OW_USE_CONTEXT & 1 << 2) == 0 && $context == self::CONTEXT_API) {
             $context = self::CONTEXT_DESKTOP;
         }
     }
     if ((bool) OW::getConfig()->getValue('base', 'disable_mobile_context') && $context == self::CONTEXT_MOBILE) {
         $context = self::CONTEXT_DESKTOP;
     }
     //temp API context detection
     //TODO remake
     $uri = UTIL_Url::getRealRequestUri(OW::getRouter()->getBaseUrl(), $_SERVER['REQUEST_URI']);
     if (mb_strstr($uri, '/')) {
         if (trim(mb_substr($uri, 0, mb_strpos($uri, '/'))) == 'api') {
             $context = self::CONTEXT_API;
         }
     } else {
         if (trim($uri) == 'api') {
             $context = self::CONTEXT_API;
         }
     }
     self::$context = $context;
 }
Пример #4
0
 public function apiAction()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $request = $this->getRequest();
     //@todo improve security with whitelist approach or even better: redo the way this works
     $method = $request->getParam("method");
     if (!$method || mb_strlen($method) > 250 || mb_strstr($method, ".") || mb_strstr($method, "@") || mb_substr($method, 0, 1) != "/") {
         exit(1);
     }
     $method = mb_substr($method, 1);
     $responseFormat = $request->getParam("responseformat", "xml");
     if ($responseFormat == 'json') {
         $contentType = 'application/json';
     } else {
         $contentType = 'text/xml';
     }
     header("Content-Type: {$contentType}");
     //&method=bar is being passed, but whatever...
     $url = "http://" . $config['apihost'] . $config['apiroot'] . "/" . $method . "?" . getenv("QUERY_STRING");
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $result = curl_exec($ch);
     curl_close($ch);
     echo $result;
     exit(0);
 }
Пример #5
0
function VerifyLastCurCostDate($CurCostDate, $i, $Errors, $db)
{
    $sql = "SELECT confvalue FROM config WHERE confname='DefaultDateFormat'";
    $result = DB_query($sql, $db);
    $myrow = DB_fetch_array($result);
    $DateFormat = $myrow[0];
    if (mb_strstr('/', $PeriodEnd)) {
        $Date_Array = explode('/', $PeriodEnd);
    } elseif (mb_strstr('.', $PeriodEnd)) {
        $Date_Array = explode('.', $PeriodEnd);
    }
    if ($DateFormat == 'd/m/Y') {
        $Day = $DateArray[0];
        $Month = $DateArray[1];
        $Year = $DateArray[2];
    } elseif ($DateFormat == 'm/d/Y') {
        $Day = $DateArray[1];
        $Month = $DateArray[0];
        $Year = $DateArray[2];
    } elseif ($DateFormat == 'Y/m/d') {
        $Day = $DateArray[2];
        $Month = $DateArray[1];
        $Year = $DateArray[0];
    } elseif ($DateFormat == 'd.m.Y') {
        $Day = $DateArray[0];
        $Month = $DateArray[1];
        $Year = $DateArray[2];
    }
    if (!checkdate(intval($Month), intval($Day), intval($Year))) {
        $Errors[$i] = InvalidCurCostDate;
    }
    return $Errors;
}
Пример #6
0
 /**
  * @param        $haystack
  * @param        $needle
  * @param bool   $caseSensitive
  * @param string $encoding
  *
  * @return bool
  *
  * @author Andreas Glaser
  */
 public static function contains($haystack, $needle, $caseSensitive = true, $encoding = 'UTF-8')
 {
     if ($caseSensitive === false) {
         return mb_stristr($haystack, $needle, null, $encoding) !== false;
     }
     return mb_strstr($haystack, $needle, null, $encoding) !== false;
 }
Пример #7
0
 public function __invoke(Request $request, Response $response, callable $next)
 {
     $xml = file_get_contents('php://input');
     $xml = preg_replace('/[\\n\\r]/', '', $xml);
     $xml = preg_replace('/>\\s+/', '>', $xml);
     $rootBodyClass = 'DTS\\eBaySDK\\Trading\\Types\\AbstractResponseType';
     $parserBody = new XmlParser($rootBodyClass);
     $body = mb_strstr($xml, "<soapenv:Body>", false);
     $body = trim($body, "<soapenv:Body>");
     $body = mb_strstr($body, "</soapenv:Body>", true);
     $body = '<' . $body;
     /** @var AbstractResponseType $notification */
     $notification = $parserBody->parse($body);
     $notification->NotificationSignature = mb_strstr($xml, '<ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">', false);
     $notification->NotificationSignature = trim($notification->NotificationSignature, '<ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">');
     $notification->NotificationSignature = mb_strstr($notification->NotificationSignature, "</ebl:NotificationSignature>", true);
     $timestamp = mb_strstr($body, "<Timestamp>", false);
     $timestamp = trim($timestamp, "<Timestamp>");
     $timestamp = mb_strstr($timestamp, "</Timestamp>", true);
     if ($this->calculationSignature($timestamp) !== $notification->NotificationSignature) {
         throw new \Exception("Not Equalse signature", 403);
     }
     $item = ['add_date' => $notification->Timestamp->format("Y-m-d h:i:s"), 'soapaction' => $notification->NotificationEventName, 'data' => $body];
     $this->store->create($item);
     return $response->withStatus(200);
 }
Пример #8
0
 private static function dealReply($initReply)
 {
     $reply = $initReply;
     $findStr = "意见";
     $desc = "问题分析";
     if (isset($initReply) && !empty($initReply)) {
         //判断参数中,是否存在“意见”
         if (mb_strstr($initReply, $findStr, 'utf-8')) {
             if (mb_strstr($initReply, $desc, 'utf-8')) {
                 if (mb_strpos($initReply, $desc, 0, 'utf-8') != 0) {
                     $reply = "问题分析" . ":" . $initReply;
                 }
             } else {
                 $reply = $desc . ":" . $initReply;
             }
         } else {
             if (mb_strstr($initReply, "指导意见", 'utf-8')) {
                 $reply = "问题分析" . ":" . $initReply;
             } else {
                 $reply = "指导意见" . ":" . $initReply;
             }
         }
     }
     return $reply;
 }
Пример #9
0
 /**
  * URL without a #hash/fragment.
  *
  * @since 150424 Initial release.
  *
  * @param string $url_uri_qsl Input URL, URI, or query string w/ a leading `?`.
  *
  * @return string URL without a #hash fragment.
  */
 public function strip(string $url_uri_qsl) : string
 {
     if (mb_strpos($url_uri_qsl, '#') !== false) {
         $url_uri_qsl = mb_strstr($url_uri_qsl, '#', true);
     }
     return $url_uri_qsl;
 }
 /**
  * StringFirstOccurrence
  */
 public function execute()
 {
     if ($this->isCaseInsensitive()) {
         return mb_stristr($this->getValue(), $this->needle, $this->beforeNeedle);
     } else {
         return mb_strstr($this->getValue(), $this->needle, $this->beforeNeedle);
     }
 }
Пример #11
0
 public function testTagDescription()
 {
     $this->Meta->set('description', $text = self::text(150));
     $tag = $this->Meta->tag('description');
     $this->assertTrue(mb_substr_count($tag, '<meta name="description"') === 1);
     $this->assertTrue(mb_substr_count($tag, '<meta name="twitter:description"') === 1);
     $this->assertTrue(mb_substr_count($tag, '<meta property="og:description"') === 1);
     $this->assertTrue(mb_substr_count($tag, '<description>') === 0);
     $this->assertTrue(mb_strstr($tag, $text) ? true : false);
 }
Пример #12
0
/**
 * Smarty component function.
 *
 * @author Sardar Madumarov <*****@*****.**>
 * @package ow.ow_smarty.plugin
 * @since 1.0
 */
function smarty_function_component($params, $smarty)
{
    if (!isset($params['class']) || !mb_strstr($params['class'], '_')) {
        throw new InvalidArgumentException('Ivalid class name provided `' . $params['class'] . '`');
    }
    $class = trim($params['class']);
    unset($params['class']);
    $cmp = OW::getClassInstance($class, $params);
    return $cmp->render();
}
Пример #13
0
 public function testGetLogFilesInfo()
 {
     $username = '******' . rand();
     try {
         HelperService::getLogFilesInfo($username);
     } catch (\Exception $error) {
         $encoding = $this->getKernel()->getContainer()->getParameter('string_functions_encoding');
         $this->assertTrue(mb_strstr($error->getMessage(), $username, false, $encoding) !== false);
         $this->assertEquals(0, $error->getCode());
     }
 }
Пример #14
0
function smarty_modifier_cut_details($string)
{
    $charset = \Pina\App::charset();
    if (empty($charset)) {
        $charset = 'utf-8';
    }
    if (($r = mb_strstr($string, '<hr class="pinacut" />', false, $charset)) !== false) {
        return $r;
    }
    return $string;
}
Пример #15
0
 /**
  * Stripe query string.
  *
  * @since 150424 Initial release.
  *
  * @param string $url_uri_qsl Input URL, URI, or query string w/ a leading `?`.
  *
  * @return string Input `$url_uri_qsl` without a query string.
  */
 public function strip(string $url_uri_qsl) : string
 {
     if (!$qs_url_uri) {
         return $qs_url_uri;
         // Possible `0`.
     }
     if (mb_strpos($url_uri_qsl, '?') !== false) {
         $url_uri_qsl = mb_strstr($url_uri_qsl, '?', true);
     }
     return $url_uri_qsl;
 }
Пример #16
0
 public function startString($a = "")
 {
     if ($a == "" && $b == "" || $this->html == "") {
         return "";
     }
     $p1 = mb_strstr($this->html, $a);
     if (!$p1) {
         return "";
     }
     return mb_substr($p1, strlen($a));
 }
Пример #17
0
 protected function render($file, $params = [], $custom = false)
 {
     foreach ($params as $key => $value) {
         ${$key} = $value;
     }
     $class = mb_strstr(get_called_class(), '\\');
     $class = trim($class, '\\');
     $class = mb_strstr($class, 'Controller', true);
     $path = $custom ? $file . '.twig' : $class . '/' . $file . '.twig';
     echo $this->twig->render($path, $params);
 }
Пример #18
0
 private function fetch_uri_string()
 {
     $path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : @getenv('REQUEST_URI');
     $path = ($trimmedPath = mb_strstr($path, '?', TRUE)) !== FALSE ? $trimmedPath : $path;
     $urlSplit = explode('.', $_SERVER['HTTP_HOST'], 3);
     $urlSplit[0] == 'www' ? array_shift($urlSplit) : null;
     if (trim($path, '/') != '' && $path != "/" . SELF) {
         $this->string = ltrim($path, '/');
         return;
     }
 }
Пример #19
0
 public function store($file, $yaml)
 {
     Debug::checkArgs(0, 1, 'string', $file, 1, 'nonempty', $file, 2, 'nonempty', $yaml);
     if (is_array($yaml)) {
         $yaml = syck_dump($yaml);
     }
     try {
         file_put_contents($file, $value, LOCK_EX);
     } catch (\ErrorException $e) {
         throw new FtpException(mb_substr(mb_strstr($e->getMessage()), ']:'), 3);
     }
 }
Пример #20
0
 /**
  * Plugin slug from basename.
  *
  * @since 160524 First documented version.
  *
  * @param string $basename Plugin basename.
  *
  * @return string Plugin slug or an empty string.
  */
 public function slug(string $basename) : string
 {
     if ($slug = mb_strstr($basename, '/', true)) {
         return $slug;
         // Got what we need here.
     } elseif ($slug = mb_strstr($basename, '.php', true)) {
         return $slug;
         // Got what we need here.
     }
     return '';
     // Failed on `[slug]/plugin.php` & `[slug].php`.
 }
 /**
  * Check if string match query.
  * return true if string contains every components in query, space delimited, case insensitive.
  * @param string $string
  * @param string $query
  * @return bool
  */
 public static function searchQuery($string, $query)
 {
     $string = mb_strtolower($string);
     $query = mb_strtolower($query);
     $queryArr = explode(" ", $query);
     foreach ($queryArr as $component) {
         if (mb_strstr($string, $component) === false) {
             return false;
         }
     }
     return true;
 }
Пример #22
0
function files()
{
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    $do = cmsCore::getInstance()->do;
    $model = new cms_model_files();
    //============================================================================//
    // Скачивание
    if ($do == 'view') {
        $fileurl = cmsCore::request('fileurl', 'html', '');
        if (mb_strpos($fileurl, '-') === 0) {
            $fileurl = htmlspecialchars_decode(base64_decode(ltrim($fileurl, '-')));
        }
        $fileurl = cmsCore::strClear($fileurl);
        if (!$fileurl || mb_strstr($fileurl, '..') || strpos($fileurl, '.') === 0) {
            cmsCore::error404();
        }
        if (strpos($fileurl, 'http') === 0) {
            $model->increaseDownloadCount($fileurl);
            cmsCore::redirect($fileurl);
        } elseif (file_exists(PATH . $fileurl)) {
            $model->increaseDownloadCount($fileurl);
            header('Content-Disposition: attachment; filename=' . basename($fileurl) . "\n");
            header('Content-Type: application/x-force-download; name="' . $fileurl . '"' . "\n");
            header('Location:' . $fileurl);
            cmsCore::halt();
        } else {
            cmsCore::halt($_LANG['FILE_NOT_FOUND']);
        }
    }
    //============================================================================//
    if ($do == 'redirect') {
        $url = str_replace(array('--q--', ' '), array('?', '+'), cmsCore::request('url', 'str', ''));
        if (mb_strpos($url, '-') === 0) {
            $url = htmlspecialchars_decode(base64_decode(ltrim($url, '-')));
        }
        $url = cmsCore::strClear($url);
        if (!$url || mb_strstr($url, '..') || strpos($url, '.') === 0) {
            cmsCore::error404();
        }
        // кириллические домены
        $url_host = parse_url($url, PHP_URL_HOST);
        if (preg_match('/^[а-яё]+/iu', $url_host)) {
            cmsCore::loadClass('idna_convert');
            $IDN = new idna_convert();
            $host = $IDN->encode($url_host);
            $url = str_ireplace($url_host, $host, $url);
        }
        cmsCore::redirect($url);
    }
    //============================================================================//
}
Пример #23
0
 public function componentGeneral()
 {
     $files = scandir(THEBUGGENIE_CORE_PATH . 'lib' . DS . 'easybook' . DS . 'geshi' . DS);
     $geshi_languages = array();
     foreach ($files as $file) {
         if (mb_strstr($file, '.php') === false) {
             continue;
         }
         $lang = str_replace('.php', '', $file);
         $geshi_languages[$lang] = $lang;
     }
     $this->geshi_languages = $geshi_languages;
 }
 public function testSetRealPath()
 {
     $logReaderService = new LogReaderService();
     try {
         $username = '******' . rand();
         $realPath = '/home/' . $username . '/logs/access.log';
         $logReaderService->setRealPath($realPath);
     } catch (\Exception $error) {
         $encoding = $this->getKernel()->getContainer()->getParameter('string_functions_encoding');
         $this->assertTrue(mb_strstr($error->getMessage(), $username, false, $encoding) !== false);
         $this->assertEquals(0, $error->getCode());
     }
 }
Пример #25
0
 public function validate($input)
 {
     if (mb_strstr($input, '--')) {
         return false;
     }
     if (!preg_match('@^[0-9a-z\\-]+$@', $input)) {
         return false;
     }
     if (preg_match('@^-|-$@', $input)) {
         return false;
     }
     return true;
 }
 protected function escape($item)
 {
     $quote = mb_strstr($item, $this->_separator) !== false || mb_strstr($item, "\n") !== false;
     if (mb_strstr($item, '"') !== false) {
         $item = mb_ereg_replace('"', "\"\"", $item, 'm');
         $quote = true;
     }
     if (mb_strstr($item, "\\") !== false) {
         $item = mb_ereg_replace("\\\\", "\\\\", $item, 'm');
         $quote = true;
     }
     if ($quote) {
         $item = "\"{$item}\"";
     }
     return $item;
 }
Пример #27
0
 public function store($file, $yaml)
 {
     Debug::checkArgs(0, 1, 'string', $file, 1, 'nonempty', $file, 2, 'string or array', $yaml);
     if (is_array($yaml)) {
         try {
             $yaml = ScYaml::dump($yaml);
         } catch (\Symfony\Components\Yaml\Exception $e) {
             throw new ParserException($e->getMessage());
         }
     }
     try {
         file_put_contents($file, $yaml, LOCK_EX);
     } catch (\ErrorException $e) {
         throw new FtpException(mb_substr(mb_strstr($e->getMessage(), ']:'), 3));
     }
 }
Пример #28
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $params = $request->getParams();
     //avoid rendering /index.php/... 10 = letters in index.php/
     if (mb_substr($_SERVER['REQUEST_URI'], 0, 10 + mb_strlen($config['webroot'])) == $config['webroot'] . '/index.php') {
         $request->setControllerName('doesnotexists')->setActionName('withindexdotphp');
     }
     //@todo this is a workaround, the better approach was to get the string 'as it is'
     if (isset($params['username']) && mb_strstr($_SERVER['REQUEST_URI'], "?", true) != 'proxy') {
         $reservedUsernames = (require APPLICATION_PATH . "/configs/ReservedUsernames.php");
         if (in_array($params['username'], $reservedUsernames)) {
             $request->setControllerName('static')->setActionName('docs');
         }
     }
 }
Пример #29
0
 function find($needle, $ignoreCase = false, $reverse = false)
 {
     if ($ignoreCase) {
         if ($reverse) {
             $this->__invar = mb_strrichr($this->__invar, $needle);
         } else {
             $this->__invar = mb_stristr($this->__invar, $needle);
         }
     } else {
         if ($reverse) {
             $this->__invar = mb_strrchr($this->__invar, $needle);
         } else {
             $this->__invar = mb_strstr($this->__invar, $needle);
         }
     }
     return $this;
 }
Пример #30
-18
 /**
  * @param array $dispatchAttributes
  */
 public function dispatch()
 {
     // check if controller class contains package pointer with plugin key
     if (empty($this->handlerAttributes[self::ATTRS_KEY_CTRL]) || !mb_strstr($this->handlerAttributes[self::ATTRS_KEY_CTRL], '_')) {
         throw new InvalidArgumentException("Can't dispatch request! Empty or invalid controller class provided!");
     }
     // set uri params in request object
     if (!empty($this->handlerAttributes[self::ATTRS_KEY_VARLIST])) {
         OW::getRequest()->setUriParams($this->handlerAttributes[self::ATTRS_KEY_VARLIST]);
     }
     $plugin = OW::getPluginManager()->getPlugin(OW::getAutoloader()->getPluginKey($this->handlerAttributes[self::ATTRS_KEY_CTRL]));
     $catchAllRequests = $this->processCatchAllRequestsAttrs();
     if ($catchAllRequests !== null) {
         $this->handlerAttributes = $catchAllRequests;
     }
     try {
         $reflectionClass = new ReflectionClass($this->handlerAttributes[self::ATTRS_KEY_CTRL]);
     } catch (ReflectionException $e) {
         throw new Redirect404Exception();
     }
     /* @var $controller OW_ActionController */
     $controller = $reflectionClass->newInstance();
     // check if controller exists and is instance of base action controller class
     if ($controller === null || !$controller instanceof OW_ApiActionController) {
         throw new LogicException("Can't dispatch request! Please provide valid controller class!");
     }
     // redirect to page 404 if plugin is inactive and isn't instance of admin controller class
     if (!$plugin->isActive() && !$controller instanceof ADMIN_CTRL_Abstract) {
         throw new Redirect404Exception();
     }
     // call optional init method
     $controller->init();
     if (empty($this->handlerAttributes[self::ATTRS_KEY_ACTION])) {
         $this->handlerAttributes[self::ATTRS_KEY_ACTION] = $controller->getDefaultAction();
     }
     try {
         $action = $reflectionClass->getMethod($this->handlerAttributes[self::ATTRS_KEY_ACTION]);
     } catch (Exception $e) {
         throw new Redirect404Exception();
     }
     $args = array();
     $args[] = $_POST;
     $args[] = empty($this->handlerAttributes[self::ATTRS_KEY_VARLIST]) ? array() : $this->handlerAttributes[self::ATTRS_KEY_VARLIST];
     $action->invokeArgs($controller, $args);
     OW::getDocument()->setBody($controller->render());
 }