/**
  * Format a string data.
  *
  * @param string $str A string.
  *
  * @return string
  */
 protected function formatString($str)
 {
     if (extension_loaded('mbstring')) {
         $originalStr = $str;
         $str = mb_convert_case($str, MB_CASE_TITLE, 'UTF-8');
         // Correct for MB_TITLE_CASE's insistence on uppercasing letters
         // immediately preceded by numerals, eg: 1st -> 1St
         $originalEncoding = mb_regex_encoding();
         mb_regex_encoding('UTF-8');
         // matches an upper case letter character immediately preceded by a numeral
         mb_ereg_search_init($str, '[0-9]\\p{Lu}');
         while ($match = mb_ereg_search_pos()) {
             $charPos = $match[0] + 1;
             // Only swap it back to lowercase if it was lowercase to begin with
             if (mb_ereg_match('\\p{Ll}', $originalStr[$charPos])) {
                 $str[$charPos] = mb_strtolower($str[$charPos]);
             }
         }
         mb_regex_encoding($originalEncoding);
     } else {
         $str = $this->lowerize($str);
         $str = ucwords($str);
     }
     $str = str_replace('-', '- ', $str);
     $str = str_replace('- ', '-', $str);
     return $str;
 }
Ejemplo n.º 2
0
 public function addLink($userId, $href, $title, $description, $thumbnailUrl, $text = null, $addToFeed = true)
 {
     if (!$this->isActive()) {
         return null;
     }
     OW::getCacheManager()->clean(array(LinkDao::CACHE_TAG_LINK_COUNT));
     $service = LinkService::getInstance();
     $url = mb_ereg_match('^http(s)?:\\/\\/', $href) ? $href : 'http://' . $href;
     $link = new Link();
     $eventParams = array('action' => LinkService::PRIVACY_ACTION_VIEW_LINKS, 'ownerId' => OW::getUser()->getId());
     $privacy = OW::getEventManager()->getInstance()->call('plugin.privacy.get_privacy', $eventParams);
     if (!empty($privacy)) {
         $link->setPrivacy($privacy);
     }
     $link->setUserId($userId);
     $link->setTimestamp(time());
     $link->setUrl($url);
     $link->setDescription(strip_tags($description));
     $title = empty($title) ? $text : $title;
     $link->setTitle(strip_tags($title));
     $service->save($link);
     if ($addToFeed) {
         $content = array("format" => null, "vars" => array("status" => $text));
         if (!empty($thumbnailUrl)) {
             $content["format"] = "image_content";
             $content["vars"]["image"] = $thumbnailUrl;
             $content["vars"]["thumbnail"] = $thumbnailUrl;
         }
         //Newsfeed
         $event = new OW_Event('feed.action', array('pluginKey' => 'links', 'entityType' => 'link', 'entityId' => $link->getId(), 'userId' => $link->getUserId()), array("content" => $content));
         OW::getEventManager()->trigger($event);
     }
     return $link->id;
 }
Ejemplo n.º 3
0
 public function isValid($value)
 {
     if (!mb_ereg_match($this->getValidateRegex(), $value)) {
         return false;
     }
     $num_value = $this->getValue($value);
     return $this->min <= $num_value && $num_value <= $this->max;
 }
Ejemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function process(LanguageInterface $language, $item)
 {
     $alphabet = implode('', $language->getAlphabet());
     $wordPattern = "^[{$alphabet}]+\$";
     $options = $this->getOptions();
     $itemPassed = mb_ereg_match($wordPattern, $item, $options);
     return $itemPassed;
 }
 public function searchbooks()
 {
     if ($this->request->is('post')) {
         if (empty($this->request->data)) {
             $this->redirect('/posts/index');
             $this->Session->setFlash('formを入力してください');
         }
         $title = $this->request->data['Book']['title'];
         $author = $this->request->data['Book']['author'];
         if (mb_ereg_match("^(\\s| )+\$", $title)) {
             if (mb_ereg_match("^(\\s| )+\$", $author)) {
                 $this->Session->setFlash("ちゃんと入力してください");
                 $this->redirect('/posts/index');
             }
         }
         $title = preg_replace("/( | )/", "", $title);
         $author = preg_replace("/( | )/", "", $author);
         if (!empty($title) && !empty($author)) {
             $data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'title' => $title, 'author' => $author, 'hits' => 25, 'page' => 1);
         } else {
             if (!empty($title)) {
                 $data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'title' => $title, 'hits' => 25, 'page' => 1);
             } else {
                 if (!empty($author)) {
                     $data = array('applicationId' => '1020646643727437143', 'format' => 'xml', 'author' => $author, 'hits' => 25, 'page' => 1);
                 } else {
                     $this->Session->setFlash('ちゃんと入力してください');
                     $this->redirect('/posts/index');
                 }
             }
         }
         $items = parent::search($data);
         if (empty($items)) {
             $this->Session->setFlash("該当する本が見つかりませんでした");
             $this->redirect('/posts/index');
         }
         if ($items['count'] == 0) {
             $this->Session->setFlash('該当する本が見つかりませんでした');
             $this->redirect($this->referer());
         }
         $count = $items['count'];
         $page = $items['page'];
         $hits = $items['hits'];
         $first = $items['first'];
         $tmppage = ceil($count / 25);
         $items['count'] = null;
         $items['page'] = null;
         $items['hits'] = null;
         $items['first'] = null;
         $this->set('data', $data);
         $this->set('items', $items);
         $this->set('count', $count);
         $this->set('tmppage', $tmppage);
         $this->set('page', $page);
         $this->set('hits', $hits);
         $this->set('first', $first);
     }
 }
Ejemplo n.º 6
0
 public function setText($value)
 {
     if ($value != '') {
         if (!mb_ereg_match(REGEX_STATPIC_TEXT, $value)) {
             return false;
         }
     }
     return $this->reUser->setValue('statpic_text', $value);
 }
Ejemplo n.º 7
0
 public function vxCleanKijijiTitle($title)
 {
     if (mb_ereg_match('最新的客齐集广告', $title)) {
         mb_ereg('最新的客齐集广告 所在地:(.+) 分类:(.+)', $title, $m);
         return '最新的客齐集广告' . ' - ' . $m[1] . ' - ' . $m[2];
     } else {
         return $title;
     }
 }
Ejemplo n.º 8
0
 /**
  * (non-PHPdoc)
  * @see JSONImportStateInterface::processLine()
  */
 public function processLine($line)
 {
     // Change state
     if (mb_ereg_match("\"export\"\\:[ ]*\\{.*", $line)) {
         return new JSONImportStateMetaData($this->importData);
     } else {
         return $this;
     }
 }
Ejemplo n.º 9
0
 function space_only($field = array())
 {
     foreach ($field as $name => $value) {
     }
     if (mb_ereg_match("^(\\s| )+\$", $value)) {
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 10
0
 public function checkOk()
 {
     $value = $this->field->getValue();
     $pattern = ".*[。-゚①-⑳Ⅰ-Ⅹ㍉㌔㌢㍍㌘㌧㌃㌶㍑㍗㌍㌦㌣㌫㍊㌻㎜㎝㎞㎎㎏㏄㎡〝〟№㏍℡㊤-㊨㈱㈲㈹㍻-㍾≒≡∫∮∑√⊥∠∟⊿∵∩∪].*";
     // 半角カタカナ(。-゚)と機種依存文字の判定
     if (mb_ereg_match($pattern, $value) == true) {
         return false;
     }
     return true;
 }
Ejemplo n.º 11
0
function checkCaptcha($id, $string)
{
    global $CAPTCHA_CONFIG;
    $captcha =& new b2evo_captcha($CAPTCHA_CONFIG);
    // additional check ... id and string can only contain [a-f0-9]
    if (mb_ereg_match('^[0-9a-f]{32}$', $id) == false) {
        return false;
    }
    if ($captcha->validate_submit($id . '.jpg', $string) == 1) {
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 12
0
 /**
  * (non-PHPdoc)
  * @see JSONImportStateInterface::processLine()
  */
 public function processLine($line)
 {
     // Change state
     if (mb_ereg_match("\"marks\"\\:[ ]*\\[.*", $line)) {
         return new JSONImportStateMarks($this->importData);
     } else {
         // Strip trailing comma and simulate JSON
         $jsonLine = '{' . mb_ereg_replace("\\,[ ]*\$", '', $line) . '}';
         $decodedObject = json_decode($jsonLine);
         foreach ($decodedObject as $key => $value) {
             if (!isset($this->importData['meta'])) {
                 $this->importData['meta'] = array();
             }
             $this->importData['meta'][$key] = $value;
         }
         return $this;
     }
 }
Ejemplo n.º 13
0
 /**
  * (non-PHPdoc)
  *
  * @see JSONImportStateInterface::processLine()
  */
 public function processLine($line)
 {
     // Finished
     if (mb_ereg_match("^[ ]*\\][ ]*\$", $line)) {
         return $this->importData;
     } else {
         // Strip trailing comma and simulate JSON
         $jsonLine = mb_ereg_replace("\\,[ ]*\$", '', $line);
         $decodedMark = json_decode($jsonLine);
         $importResult = $this->CI->mark_import->importMark($decodedMark);
         $this->importData['result']['total']++;
         $this->importData['result'][$importResult['result']]++;
         if (self::RETURN_DETAILS && (!self::RETURN_DETAILS_ERRORS_ONLY || $importResult['result'] === self::RESULT_FAILED || !empty($importResult['warnings']))) {
             $this->importData['details'][$decodedMark->mark_id] = $importResult;
         }
         return $this;
     }
 }
Ejemplo n.º 14
0
/**
 * @param string $nome O nome a ser normalizado
 * @return string O nome devidamente normalizado
 */
function normalizarNome($nome)
{
    $nome = mb_ereg_replace(self::NN_PONTO, self::NN_PONTO_ESPACO, $nome);
    $nome = mb_ereg_replace(self::NN_REGEX_MULTIPLOS_ESPACOS, self::NN_ESPACO, $nome);
    $nome = ucwords(strtolower($nome));
    // alterando essa linha pela anterior funciona para acentos
    $partesNome = mb_split(self::NN_ESPACO, $nome);
    $excecoes = array('de', 'do', 'di', 'da', 'dos', 'das', 'dello', 'della', 'dalla', 'dal', 'del', 'e', 'em', 'na', 'no', 'nas', 'nos', 'van', 'von', 'y', 'der');
    for ($i = 0; $i < count($partesNome); ++$i) {
        if (mb_ereg_match(self::NN_REGEX_NUMERO_ROMANO, mb_strtoupper($partesNome[$i]))) {
            $partesNome[$i] = mb_strtoupper($partesNome[$i]);
        }
        foreach ($excecoes as $excecao) {
            if (mb_strtolower($partesNome[$i]) == mb_strtolower($excecao)) {
                $partesNome[$i] = $excecao;
            }
        }
    }
    $nomeCompleto = implode(self::NN_ESPACO, $partesNome);
    return addslashes($nomeCompleto);
}
Ejemplo n.º 15
0
 /**
  * Enter description here...
  *
  * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
  * @link http://docs.jquery.com/Traversing/filter
  */
 public function filter($selectors, $_skipHistory = false)
 {
     if ($selectors instanceof Callback or $selectors instanceof Closure) {
         return $this->filterCallback($selectors, $_skipHistory);
     }
     if (!$_skipHistory) {
         $this->elementsBackup = $this->elements;
     }
     $notSimpleSelector = array(' ', '>', '~', '+', '/');
     if (!is_array($selectors)) {
         $selectors = $this->parseSelector($selectors);
     }
     if (!$_skipHistory) {
         $this->debug(array("Filtering:", $selectors));
     }
     $finalStack = array();
     foreach ($selectors as $selector) {
         $stack = array();
         if (!$selector) {
             break;
         }
         // avoid first space or /
         if (in_array($selector[0], $notSimpleSelector)) {
             $selector = array_slice($selector, 1);
         }
         // PER NODE selector chunks
         foreach ($this->stack() as $node) {
             $break = false;
             foreach ($selector as $s) {
                 if (!$node instanceof DOMELEMENT) {
                     // all besides DOMElement
                     if ($s[0] == '[') {
                         $attr = trim($s, '[]');
                         if (mb_strpos($attr, '=')) {
                             list($attr, $val) = explode('=', $attr);
                             if ($attr == 'nodeType' && $node->nodeType != $val) {
                                 $break = true;
                             }
                         }
                     } else {
                         $break = true;
                     }
                 } else {
                     // DOMElement only
                     // ID
                     if ($s[0] == '#') {
                         if ($node->getAttribute('id') != substr($s, 1)) {
                             $break = true;
                         }
                         // CLASSES
                     } else {
                         if ($s[0] == '.') {
                             if (!$this->matchClasses($s, $node)) {
                                 $break = true;
                             }
                             // ATTRS
                         } else {
                             if ($s[0] == '[') {
                                 // strip side brackets
                                 $attr = trim($s, '[]');
                                 if (mb_strpos($attr, '=')) {
                                     list($attr, $val) = explode('=', $attr);
                                     $val = self::unQuote($val);
                                     if ($attr == 'nodeType') {
                                         if ($val != $node->nodeType) {
                                             $break = true;
                                         }
                                     } else {
                                         if ($this->isRegexp($attr)) {
                                             $val = extension_loaded('mbstring') && phpQuery::$mbstringSupport ? quotemeta(trim($val, '"\'')) : preg_quote(trim($val, '"\''), '@');
                                             // switch last character
                                             switch (substr($attr, -1)) {
                                                 // quotemeta used insted of preg_quote
                                                 // http://code.google.com/p/phpquery/issues/detail?id=76
                                                 case '^':
                                                     $pattern = '^' . $val;
                                                     break;
                                                 case '*':
                                                     $pattern = '.*' . $val . '.*';
                                                     break;
                                                 case '$':
                                                     $pattern = '.*' . $val . '$';
                                                     break;
                                             }
                                             // cut last character
                                             $attr = substr($attr, 0, -1);
                                             $isMatch = extension_loaded('mbstring') && phpQuery::$mbstringSupport ? mb_ereg_match($pattern, $node->getAttribute($attr)) : preg_match("@{$pattern}@", $node->getAttribute($attr));
                                             if (!$isMatch) {
                                                 $break = true;
                                             }
                                         } else {
                                             if ($node->getAttribute($attr) != $val) {
                                                 $break = true;
                                             }
                                         }
                                     }
                                 } else {
                                     if (!$node->hasAttribute($attr)) {
                                         $break = true;
                                     }
                                 }
                                 // PSEUDO CLASSES
                             } else {
                                 if ($s[0] == ':') {
                                     // skip
                                     // TAG
                                 } else {
                                     if (trim($s)) {
                                         if ($s != '*') {
                                             // TODO namespaces
                                             if (isset($node->tagName)) {
                                                 if ($node->tagName != $s) {
                                                     $break = true;
                                                 }
                                             } else {
                                                 if ($s == 'html' && !$this->isRoot($node)) {
                                                     $break = true;
                                                 }
                                             }
                                         }
                                         // AVOID NON-SIMPLE SELECTORS
                                     } else {
                                         if (in_array($s, $notSimpleSelector)) {
                                             $break = true;
                                             $this->debug(array('Skipping non simple selector', $selector));
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($break) {
                     break;
                 }
             }
             // if element passed all chunks of selector - add it to new stack
             if (!$break) {
                 $stack[] = $node;
             }
         }
         $tmpStack = $this->elements;
         $this->elements = $stack;
         // PER ALL NODES selector chunks
         foreach ($selector as $s) {
             // PSEUDO CLASSES
             if ($s[0] == ':') {
                 $this->pseudoClasses($s);
             }
         }
         foreach ($this->elements as $node) {
             // XXX it should be merged without duplicates
             // but jQuery doesnt do that
             $finalStack[] = $node;
         }
         $this->elements = $tmpStack;
     }
     $this->elements = $finalStack;
     if ($_skipHistory) {
         return $this;
     } else {
         $this->debug("Stack length after filter(): " . count($finalStack));
         return $this->newInstance();
     }
 }
Ejemplo n.º 16
0
 private function requestHandler($query, $types)
 {
     $result = array('msg' => JText::_('PED_CITY_COUNTRY_NOT_FOUND'));
     // Инициализация структуры массива ответа
     foreach ($types as $t) {
         $result[$t] = array('length' => 0);
     }
     // Подготовка строк для поиска
     $query = mb_strtolower($query, 'utf-8');
     mb_regex_encoding('utf-8');
     $qList = mb_split("[^\\w]", $query);
     // Отбрасывание слов менее 3х букв
     foreach ($qList as $k => $query) {
         if (mb_strlen($query, 'utf-8') < 3) {
             unset($qList[$k]);
         }
     }
     // Проверка налиция шаблонов для поиска
     if (!count($qList)) {
         $result['msg'] = JText::_('PED_SMALL_QUERY');
         return $result;
     }
     // Получение списка городов/стран
     $list = $this->getDestinations();
     // Обрбаотка каждого типа поля
     foreach ($types as &$type) {
         // Поиск совпадений по списку городов/стран
         // и заполнение массива с результатами
         foreach ($list[$type] as $k => &$v) {
             // Поиск совпадений для каждой части запроса
             foreach ($qList as &$q) {
                 if (mb_ereg_match(".*\\b" . $q . ".*", mb_strtolower($v, 'utf-8'))) {
                     $result[$type][$k] = $v;
                 }
             }
         }
         // Сортировка результатов и удаление дубликатов
         $result[$type] = array_unique($result[$type]);
         asort($result[$type]);
         $result[$type]['length'] = count($result[$type]) - 1;
     }
     return $result;
 }
Ejemplo n.º 17
0
function validate_coords($lat_h, $lat_min, $lon_h, $lon_min, $lonEW, $latNS, $error_coords_not_ok)
{
    if ($lat_h == '') {
        tpl_set_var('lat_message', $error_coords_not_ok);
        $error = true;
    }
    if ($lat_min == '') {
        tpl_set_var('lat_message', $error_coords_not_ok);
        $error = true;
    }
    if ($lon_h == '') {
        tpl_set_var('lon_message', $error_coords_not_ok);
        $error = true;
    }
    if ($lon_min == '') {
        tpl_set_var('lon_message', $error_coords_not_ok);
        $error = true;
    }
    if (@$error) {
        return $error;
    }
    //check coordinates
    $error = false;
    if ($lat_h != '' || $lat_min != '') {
        if (!mb_ereg_match('^[0-9]{1,2}$', $lat_h)) {
            tpl_set_var('lat_message', $error_coords_not_ok);
            $error = true;
            $lat_h_not_ok = true;
        } else {
            if ($lat_h >= 0 && $lat_h < 90) {
                $lat_h_not_ok = false;
            } else {
                tpl_set_var('lat_message', $error_coords_not_ok);
                $error = true;
                $lat_h_not_ok = true;
            }
        }
        if (is_numeric($lat_min)) {
            if ($lat_min >= 0 && $lat_min < 60) {
                $lat_min_not_ok = false;
            } else {
                tpl_set_var('lat_message', $error_coords_not_ok);
                $error = true;
                $lat_min_not_ok = true;
            }
        } else {
            tpl_set_var('lat_message', $error_coords_not_ok);
            $error = true;
            $lat_min_not_ok = true;
        }
        $latitude = $lat_h + round($lat_min, 3) / 60;
        if ($latNS == 'S') {
            $latitude = -$latitude;
        }
        if ($latitude == 0) {
            tpl_set_var('lon_message', $error_coords_not_ok);
            $error = true;
            $lat_min_not_ok = true;
        }
    } else {
        $latitude = NULL;
        $lat_h_not_ok = true;
        $lat_min_not_ok = true;
        $error = true;
    }
    if ($lon_h != '' || $lon_min != '') {
        if (!mb_ereg_match('^[0-9]{1,3}$', $lon_h)) {
            tpl_set_var('lon_message', $error_coords_not_ok);
            $error = true;
            $lon_h_not_ok = true;
        } else {
            if ($lon_h >= 0 && $lon_h < 180) {
                $lon_h_not_ok = false;
            } else {
                tpl_set_var('lon_message', $error_coords_not_ok);
                $error = true;
                $lon_h_not_ok = true;
            }
        }
        if (is_numeric($lon_min)) {
            if ($lon_min >= 0 && $lon_min < 60) {
                $lon_min_not_ok = false;
            } else {
                tpl_set_var('lon_message', $error_coords_not_ok);
                $error = true;
                $lon_min_not_ok = true;
            }
        } else {
            tpl_set_var('lon_message', $error_coords_not_ok);
            $error = true;
            $lon_min_not_ok = true;
        }
        $longitude = $lon_h + round($lon_min, 3) / 60;
        if ($lonEW == 'W') {
            $longitude = -$longitude;
        }
        if ($longitude == 0) {
            tpl_set_var('lon_message', $error_coords_not_ok);
            $error = true;
            $lon_min_not_ok = true;
        }
    } else {
        $longitude = NULL;
        $lon_h_not_ok = true;
        $lon_min_not_ok = true;
        $error = true;
    }
    $lon_not_ok = $lon_min_not_ok || $lon_h_not_ok;
    $lat_not_ok = $lat_min_not_ok || $lat_h_not_ok;
    /*
     if ($lon_not_ok == false) print "lon_ok<br>";
     if ($lat_not_ok == false) print "lat_ok<br>";
    
     exit;
    */
    return $error;
}
Ejemplo n.º 18
0
 /** drawRows
  * Draws out a defined set of rows from the sheet.
  * @param $sheet The data container.
  * @param $begin The index of the begining row. (included)
  * @param $end The index of the end row (excluded)
  */
 function drawRows(TikiSheet &$sheet)
 {
     $sheetlib = TikiLib::lib('sheet');
     $beginRow = $sheet->getRangeBeginRow();
     $endRow = $sheet->getRangeEndRow();
     $beginCol = $sheet->getRangeBeginCol();
     $endCol = $sheet->getRangeEndCol();
     for ($i = $beginRow; $i < $endRow; $i++) {
         $td = "";
         $trStyleHeight = "";
         $trHeight = "20px";
         $trHeightIsSet = false;
         for ($j = $beginCol; $j < $endCol; $j++) {
             $width = $height = '';
             if (!empty($sheet->cellInfo[$i][$j])) {
                 extract($sheet->cellInfo[$i][$j]);
             }
             $append = '';
             if ($width > 1) {
                 $append .= " colspan='{$width}'";
             }
             if ($height > 1) {
                 $append .= " rowspan='{$height}'";
             }
             if (!empty($sheet->calcGrid[$i][$j])) {
                 $append .= ' data-formula="=' . str_replace('"', "'", $sheet->calcGrid[$i][$j]['calculation']) . '"';
             }
             if (isset($sheet->dataGrid[$i][$j]['value'])) {
                 $data = $sheet->dataGrid[$i][$j]['value'];
             } else {
                 $data = '';
             }
             $format = $sheet->cellInfo[$i][$j]['format'];
             if (!empty($format)) {
                 $data = TikiSheetDataFormat::$format($data);
             }
             $style = $sheet->cellInfo[$i][$j]['style'];
             if (!empty($style)) {
                 //we have to sanitize the css style here
                 $tdStyle = "";
                 $color = $sheetlib->get_attr_from_css_string($style, "color", "");
                 $bgColor = $sheetlib->get_attr_from_css_string($style, "background-color", "");
                 $tdHeight = '';
                 if ($trHeightIsSet == false) {
                     $trHeight = $sheetlib->get_attr_from_css_string($style, "height", "20px");
                     $trHeightIsSet = true;
                 }
                 if ($color) {
                     $tdStyle .= "color:{$color};";
                 }
                 if ($bgColor) {
                     $tdStyle .= "background-color:{$bgColor};";
                 }
                 $tdHeight = $trHeight;
                 if ($tdHeight) {
                     $tdStyle .= "height:{$tdHeight};";
                     $append .= " height='" . str_replace("px", "", $tdHeight) . "'";
                 }
                 $append .= " style='{$tdStyle}'";
             }
             $class = $sheet->cellInfo[$i][$j]['class'];
             if (!empty($class)) {
                 $append .= ' class="' . $class . '"';
             }
             if ($this->parseOutput && $sheet->parseValues == 'y') {
                 global $tikilib;
                 // only parse if we have non-alphanumeric or space chars
                 if (mb_ereg_match('[^A-Za-z0-9\\s]', $data)) {
                     // needs to be multibyte regex here
                     $data = $tikilib->parse_data($data, array('suppress_icons' => true));
                 }
                 if (strpos($data, '<p>') === 0) {
                     // remove containing <p> tag
                     $data = substr($data, 3);
                     if (strrpos($data, '</p>') === strlen($data) - 4) {
                         $data = substr($data, 0, -4);
                     }
                 }
             }
             $td .= "\t\t\t<td" . $append . ">{$data}</td>\n";
         }
         if (!empty($td)) {
             $this->output .= "\t\t<tr style='height: {$trHeight};' height='" . str_replace("px", "", $trHeight) . "'>\n";
             $this->output .= $td;
             $this->output .= "\t\t</tr>\n";
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * Returns true if $str matches the supplied pattern, false otherwise.
  *
  * @param  string $pattern Regex pattern to match against
  * @return bool   Whether or not $str matches the pattern
  */
 private function matchesPattern($pattern)
 {
     $regexEncoding = mb_regex_encoding();
     mb_regex_encoding($this->encoding);
     $match = mb_ereg_match($pattern, $this->str);
     mb_regex_encoding($regexEncoding);
     return $match;
 }
Ejemplo n.º 20
0
 /**
  * Returns true if the every character in the parameter is an alphabetic
  * character.
  *
  * @param string $string   The string to test.
  * @param string $charset  The charset to use when testing the string.
  *
  * @return boolean  True if the parameter was alphabetic only.
  */
 public static function isAlpha($string, $charset)
 {
     if (!Horde_Util::extensionExists('mbstring')) {
         return ctype_alpha($string);
     }
     $charset = self::_mbstringCharset($charset);
     $old_charset = mb_regex_encoding();
     if ($charset != $old_charset) {
         @mb_regex_encoding($charset);
     }
     $alpha = !@mb_ereg_match('[^[:alpha:]]', $string);
     if ($charset != $old_charset) {
         @mb_regex_encoding($old_charset);
     }
     return $alpha;
 }
Ejemplo n.º 21
0
 static function getSqlDistanceFormula($lonFrom, $latFrom, $maxDistance, $distanceMultiplier = 1, $lonField = 'longitude', $latField = 'latitude', $tableName = 'caches')
 {
     $lonFrom = $lonFrom + 0;
     $latFrom = $latFrom + 0;
     $maxDistance = $maxDistance + 0;
     $distanceMultiplier = $distanceMultiplier + 0;
     if (!mb_ereg_match('^[a-zA-Z][a-zA-Z0-9_]{0,59}$', $lonField)) {
         die('Fatal Error: invalid lonField');
     }
     if (!mb_ereg_match('^[a-zA-Z][a-zA-Z0-9_]{0,59}$', $latField)) {
         die('Fatal Error: invalid latField');
     }
     if (!mb_ereg_match('^[a-zA-Z][a-zA-Z0-9_]{0,59}$', $tableName)) {
         die('Fatal Error: invalid tableName');
     }
     $b1_rad = sprintf('%01.5f', (90 - $latFrom) * 3.14159 / 180);
     $l1_deg = sprintf('%01.5f', $lonFrom);
     $lonField = '`' . sql_escape_backtick($tableName) . '`.`' . sql_escape_backtick($lonField) . '`';
     $latField = '`' . sql_escape_backtick($tableName) . '`.`' . sql_escape_backtick($latField) . '`';
     $r = 6370 * $distanceMultiplier;
     $retval = 'acos(cos(' . $b1_rad . ') * cos((90-' . $latField . ') * 3.14159 / 180) + sin(' . $b1_rad . ') * sin((90-' . $latField . ') * 3.14159 / 180) * cos((' . $l1_deg . '-' . $lonField . ') * 3.14159 / 180)) * ' . $r;
     return $retval;
 }
Ejemplo n.º 22
0
 // 全角ブランク削除
 if ($wk_adr == "") {
     $error .= "住所を入力してください<br>";
 }
 // 電話チェック----------------------------------------------------------
 // ①半角数字
 if (!mb_ereg_match('^[0-9]+$', $tel)) {
     $error .= "電話は半角数字で入力してください(ハイフン不要)<br>";
 } else {
     // ②長さが9~11文字
     if (mb_strlen($tel) < 9 || mb_strlen($tel) > 11) {
         $error .= "電話は半角数字9~11文字で入力してください<br>";
     }
 }
 // 生年月日チェック-------------------------------------------------------
 if (!mb_ereg_match('^[0-9]+$', $birth_year) || !mb_ereg_match('^[0-9]+$', $birth_mon) || !mb_ereg_match('^[0-9]+$', $birth_day)) {
     $error .= "生年月日を入力してください<br><br>";
 }
 // 性別チェック----------------------------------------------------------
 $wk_sex = array("", "");
 $en_sex = "";
 if (!isset($sex)) {
     $error .= "性別を指定してください<br>";
 } else {
     if ($sex == "1") {
         $wk_sex[0] = "checked";
         $en_sex = "男";
     }
     if ($sex == "2") {
         $wk_sex[1] = "checked";
         $en_sex = "女";
Ejemplo n.º 23
0
 // try to change the pw
 $email = $_POST['email'];
 $code = $_POST['code'];
 $password = $_POST['password'];
 $rp_pass = $_POST['rp_pass'];
 tpl_set_var('email', htmlspecialchars($email, ENT_COMPAT, 'UTF-8'));
 $rs = XDb::xSql("SELECT `is_active_flag`, `new_pw_code`, `new_pw_date`, `user_id`\n                FROM `user` WHERE `email`= ? LIMIT 1", $email);
 if ($record = XDb::xFetchArray($rs)) {
     //ok, a user with this email does exist
     if ($record['is_active_flag'] != 1) {
         //no active user with this email exists
         tpl_set_var('email_message', $emailnotexist);
     } else {
         if ($record['new_pw_code'] == $code) {
             if (time() - $record['new_pw_date'] < 259200) {
                 if (!mb_ereg_match(User::REGEX_PASSWORD, $password)) {
                     //no valid password
                     tpl_set_var('code', $code);
                     tpl_set_var('pw_message', $pw_not_ok);
                 } else {
                     if ($password !== $rp_pass) {
                         //both pw's dont match
                         tpl_set_var('code', $code);
                         tpl_set_var('pw_message', $pw_no_match);
                     } else {
                         //set new pw
                         $pm = new PasswordManager($record['user_id']);
                         $pm->change($password);
                         XDb::xSql("UPDATE `user` SET `new_pw_date`=0, `new_pw_code`=NULL, `last_modified`=NOW()\n                                    WHERE `email`= ? LIMIT 1", $email);
                         tpl_set_var('message', $pw_changed);
                     }
Ejemplo n.º 24
0
 /**
  * Update for Irish names.
  *
  * @param string $string
  *
  * @return string
  */
 private static function updateIrish($string)
 {
     if (!self::$options['irish']) {
         return $string;
     }
     if (mb_ereg_match('.*?\\bMac[A-Za-z]{2,}[^aciozj]\\b', $string) || mb_ereg_match('.*?\\bMc', $string)) {
         $string = self::updateMac($string);
     }
     return mb_ereg_replace('Macmurdo', 'MacMurdo', $string);
 }
Ejemplo n.º 25
0
	/**
	 * Convert currency to the proper format
	 * 
	 * @param String $str The currency string
	 * @param Boolean $keepCents Whether or not to keep the cents
	 * @return String $str The modified currency string.
	 */
	public static function parseCurrency($str,$keepCents) {

		$cents = '';
		if($keepCents) {
			$str = mb_ereg_match('[\.,]([0-9]{2})$',$str,$matches);	// get cents
			$cents = $matches[1];
		}
		$str = mb_ereg_replace('[\.,][0-9]{2}$','',$str);	// remove cents
		$str = mb_ereg_replace('[^0-9]','',$str);		//remove all non-numbers
		
		if(!empty($cents))
			$str .= ".$cents";
			
		return $str;
	}
Ejemplo n.º 26
0
 public function isValid($value)
 {
     return mb_ereg_match($this->regex, $value);
 }
Ejemplo n.º 27
0
     $latitude = $lat_h + $lat_min / 60;
     if ($latNS == 'S') {
         $latitude = -$latitude;
     }
     if ($latitude == 0) {
         tpl_set_var('lat_message', $error_lat_not_ok);
         $error = true;
         $lat_min_not_ok = true;
     }
 } else {
     tpl_set_var('lat_message', $error_lat_not_ok);
     $lat_h_not_ok = true;
     $lat_min_not_ok = true;
 }
 if ($lon_h != '' || $lon_min != '') {
     if (!mb_ereg_match('^[0-9]{1,3}$', $lon_h)) {
         tpl_set_var('lon_message', $error_long_not_ok);
         $error = true;
         $lon_h_not_ok = true;
     } else {
         if ($lon_h >= 0 && $lon_h < 180) {
             $lon_h_not_ok = false;
         } else {
             tpl_set_var('lon_message', $error_long_not_ok);
             $error = true;
             $lon_h_not_ok = true;
         }
     }
     if (is_numeric($lon_min)) {
         if ($lon_min >= 0 && $lon_min < 60) {
             $lon_min_not_ok = false;
Ejemplo n.º 28
0
 } elseif (isset($_REQUEST['searchbycacheid'])) {
     $options['searchtype'] = 'bycacheid';
     $options['cacheid'] = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid'] : 0;
     if (!is_numeric($options['cacheid'])) {
         $options['cacheid'] = 0;
     }
 } elseif (isset($_REQUEST['searchbywaypoint'])) {
     $options['searchtype'] = 'bywaypoint';
     $options['waypoint'] = isset($_REQUEST['waypoint']) ? $_REQUEST['waypoint'] : '';
     $options['waypoint'] = mb_trim($options['waypoint']);
     $options['waypointtype'] = mb_strtolower(mb_substr($options['waypoint'], 0, 2));
     if (mb_substr($options['waypointtype'], 0, 1) == 'n') {
         $options['waypointtype'] = 'nc';
     }
     $ocWP = strtolower($GLOBALS['oc_waypoint']);
     if (mb_ereg_match('((oc|' . $ocWP . '|gc)([a-z0-9]){4,4}|n([a-f0-9]){5,5}|([a-z0-9]){4,4})$', mb_strtolower($options['waypoint']))) {
         if ($options['waypointtype'] == $ocWP) {
             $options['waypointtype'] = 'oc';
         } else {
             if ($options['waypointtype'] == 'nc') {
                 $options['waypointtype'] = 'nc';
             } else {
                 $options['waypointtype'] = 'oc';
                 $options['waypoint'] = $ocWP . $options['waypoint'];
             }
         }
     } else {
         $options['waypoint'] = '';
     }
 } elseif (isset($_REQUEST['searchbywatched'])) {
     $options['searchtype'] = 'bywatched';
Ejemplo n.º 29
0
 /**    文字列中にコントロールコードが含まれているかを調べる
  *
  * @param string 調べる文字列
  * @return boolean 含まれていたらTRUEを返す
  */
 private function checkControlCodeNothing($str)
 {
     return mb_ereg_match("/[[:cntrl:]]/", $str);
 }
Ejemplo n.º 30
0
function is_match($str)
{
    $pattern = '^(.{3,5})?(臺北|臺中|臺南|高雄)縣';
    return mb_ereg_match($pattern, $str) == 1 ? "1" : "0";
}