コード例 #1
0
 /**
  * @param string $username BulkSMS username
  * @param string $password BulkSMS password
  * @param string $baseUrl  Optional - defaults to "http://bulksms.vsms.net:5567"
  * @param cURL   $curl     Optional - a new instance will be constructed if null is passed.
  */
 public function __construct($username, $password, $baseUrl = "http://bulksms.vsms.net:5567", $curl = null)
 {
     v::url()->setName("Base Bulksms URL")->check($baseUrl);
     $this->baseUrl = $baseUrl;
     $this->username = $username;
     $this->password = $password;
     $this->curl = $curl ?: new cURL();
 }
コード例 #2
0
ファイル: Share.php プロジェクト: christine-ho-dev/movim
 function display()
 {
     $validate_url = Validator::url();
     $url = rawurldecode(urldecode($this->get('url')));
     if ($validate_url->validate($url)) {
         $this->view->assign('url', $url);
     }
 }
コード例 #3
0
ファイル: Config.php プロジェクト: christine-ho-dev/movim
 private function validateForm($data)
 {
     $l = Movim\i18n\Locale::start();
     if (Validator::in(array_keys($l->getList()))->validate($data['language']) && Validator::in(array('show', 'hide'))->validate($data['roster']) && ($data['cssurl'] == '' || Validator::url()->validate($data['cssurl']))) {
         return true;
     }
     return false;
 }
コード例 #4
0
ファイル: Product.php プロジェクト: dafiti/datajet-client
 private function validateConfig(array $config)
 {
     if (empty($config)) {
         throw new \InvalidArgumentException('Empty config is not allowed');
     }
     $validator = v::arrayVal()->notEmpty()->key('search', v::arrayVal()->notEmpty()->key('uri', v::url()->notEmpty())->key('key', v::alnum()->notEmpty()))->key('data', v::arrayVal()->notEmpty()->key('uri', v::url()->notEmpty())->key('key', v::alnum()->notEmpty()));
     $validator->assert($config);
 }
コード例 #5
0
 /**
  * (non-PHPdoc)
  * 
  * @see \Solvire\API\Serializers\DataFields\DataField::setData()
  */
 public function setData($data)
 {
     if (!is_string($data) || !v::url()->validate($data)) {
         throw new \RuntimeException('URLField data must be a string representation of a URL ' . $data);
     }
     $this->data = $data;
     return $this;
 }
コード例 #6
0
 /**
  * @param string $username BulkSMS username
  * @param string $password BulkSMS password
  * @param        $baseUrl
  * @param cURL   $curl
  */
 public function __construct($username, $password, $baseUrl, $routingGroup, cURL $curl = null)
 {
     v::url()->setName("Base Bulksms URL")->check($baseUrl);
     $this->baseUrl = $baseUrl;
     $this->username = $username;
     $this->password = $password;
     $this->curl = $curl ?: new cURL();
     $this->routingGroup = $routingGroup;
 }
コード例 #7
0
ファイル: WordPress.php プロジェクト: aszone/hacking
 public function isWordPress()
 {
     $isUrl = v::url()->notEmpty()->validate($this->target);
     if ($isUrl) {
         $baseUrlWordPress = $this->getBaseUrlWordPressCrawler();
         if ($baseUrlWordPress) {
             return true;
         }
         return false;
     }
 }
コード例 #8
0
ファイル: Conf.php プロジェクト: qinyuguang/libyaf
 public function __construct(array $options)
 {
     $options = ['baseUri' => Arr::get($options, 'baseUri', $this->baseUri), 'timeout' => Arr::get($options, 'timeout', $this->timeout), 'proxy' => Arr::get($options, 'proxy', $this->proxy), 'auth' => Arr::get($options, 'auth', $this->auth), 'logger' => Arr::get($options, 'logger')];
     try {
         V::arrayVal()->key('baseUri', V::url()->notEmpty())->key('timeout', V::floatVal()->min(0))->key('proxy', V::optional(V::url()))->key('auth', V::arrayVal()->key('user', V::stringType())->key('pass', V::stringType()))->key('logger', V::instance('\\Psr\\Log\\LoggerInterface'))->assert($options);
     } catch (\InvalidArgumentException $e) {
         $errors = array_filter($e->findMessages(['baseUri' => 'Required correct baseUri', 'timeout' => 'Required correct timeout', 'proxy' => 'Required correct proxy', 'auth' => 'Required correct authuser', 'logger' => 'Required a logger instance of psr\\log']));
         $errmsg = array_shift($errors);
         throw new Exception($errmsg);
     }
     $this->baseUri = $options['baseUri'];
     $this->timeout = $options['timeout'];
     $this->proxy = $options['proxy'];
     $this->auth = $options['auth'];
     $this->logger = $options['logger'];
 }
コード例 #9
0
 public static function add(array $data)
 {
     extract($data);
     if (empty($title) or empty($desc) or empty($link)) {
         throw new \InvalidArgumentException("Você precisa enviar todos os campos");
     }
     if (!v::string()->length(3, 100)->validate($title)) {
         throw new \InvalidArgumentException("Título inválido");
     }
     if (!v::string()->length(5, 500)->validate($desc)) {
         throw new \InvalidArgumentException("Descrição inválida");
     }
     if (!v::string()->length(5, 270)->validate($link)) {
         throw new \InvalidArgumentException("Link inválido");
     }
     if (!v::url()->validate($link)) {
         throw new \InvalidArgumentException("Isso não é um link");
     }
     return true;
 }
コード例 #10
0
ファイル: Postn.php プロジェクト: Hywan/movim
 public function getAttachements()
 {
     $attachements = null;
     $this->picture = null;
     if (isset($this->links)) {
         $attachements = array('pictures' => array(), 'files' => array(), 'links' => array());
         $links = unserialize($this->links);
         foreach ($links as $l) {
             if (isset($l['type']) && $this->typeIsPicture($l['type'])) {
                 if ($this->picture == null) {
                     $this->picture = $l['href'];
                 }
                 array_push($attachements['pictures'], $l);
             } elseif ((isset($l['type']) && $this->typeIsLink($l['type']) || in_array($l['rel'], array('related', 'alternate'))) && Validator::url()->validate($l['href'])) {
                 if ($this->youtube == null && preg_match('%(?:youtube(?:-nocookie)?\\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\\.be/)([^"&?/ ]{11})%i', $l['href'], $match)) {
                     $this->youtube = $match[1];
                 }
                 array_push($attachements['links'], array('href' => $l['href'], 'url' => parse_url($l['href'])));
             } elseif (isset($l['rel']) && $l['rel'] == 'enclosure') {
                 array_push($attachements['files'], $l);
             }
         }
     }
     if (empty($attachements['pictures'])) {
         unset($attachements['pictures']);
     }
     if (empty($attachements['files'])) {
         unset($attachements['files']);
     }
     if (empty($attachements['links'])) {
         unset($attachements['links']);
     }
     return $attachements;
 }
コード例 #11
0
ファイル: Valid.php プロジェクト: tourze/base
 /**
  * 是否为正确的URL
  *
  * @param  string $value URL
  * @return bool
  */
 public static function url($value)
 {
     return Validator::url()->validate($value);
 }
コード例 #12
0
ファイル: Postn.php プロジェクト: Anon215/movim
 public function getAttachments()
 {
     $attachments = null;
     $this->openlink = null;
     if (isset($this->links)) {
         $links = unserialize($this->links);
         $attachments = ['pictures' => [], 'files' => [], 'links' => []];
         foreach ($links as $l) {
             // If the href is not a valid URL we skip
             if (!Validator::url()->validate($l['href'])) {
                 continue;
             }
             // Prepare the switch
             $rel = isset($l['rel']) ? $l['rel'] : null;
             switch ($rel) {
                 case 'enclosure':
                     if ($this->typeIsPicture($l['type'])) {
                         array_push($attachments['pictures'], $l);
                     } elseif ($l['type'] != 'picture') {
                         array_push($attachments['files'], $l);
                     }
                     break;
                 case 'related':
                     if (preg_match('%(?:youtube(?:-nocookie)?\\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\\.be/)([^"&?/ ]{11})%i', $l['href'], $match)) {
                         $this->youtube = $match[1];
                     }
                     array_push($attachments['links'], ['href' => $l['href'], 'url' => parse_url($l['href']), 'rel' => 'related']);
                     break;
                 case 'alternate':
                 default:
                     $this->openlink = $l['href'];
                     if (!$this->isMicroblog()) {
                         array_push($attachments['links'], ['href' => $l['href'], 'url' => parse_url($l['href']), 'rel' => 'alternate']);
                     }
                     break;
             }
         }
     }
     if (empty($attachments['pictures'])) {
         unset($attachments['pictures']);
     }
     if (empty($attachments['files'])) {
         unset($attachments['files']);
     }
     if (empty($attachments['links'])) {
         unset($attachments['links']);
     }
     return $attachments;
 }
コード例 #13
0
ファイル: Vcard4.php プロジェクト: vijo/movim
 function ajaxVcardSubmit($vcard)
 {
     # Format it ISO 8601:
     if ($vcard->year->value != -1 && $vcard->month->value != -1 && $vcard->day->value != -1) {
         $vcard->date->value = $vcard->year->value . '-' . $vcard->month->value . '-' . $vcard->day->value;
     }
     unset($vcard->year->value);
     unset($vcard->month->value);
     unset($vcard->day->value);
     $cd = new \Modl\ContactDAO();
     $c = $cd->get($this->user->getLogin());
     if ($c == null) {
         $c = new \Modl\Contact();
     }
     $c->jid = $this->user->getLogin();
     if (isset($vcard->date->value)) {
         $c->date = $vcard->date->value;
     }
     if (Validator::string()->length(0, 40)->validate($vcard->name->value)) {
         $c->name = $vcard->name->value;
     }
     if (Validator::string()->length(0, 40)->validate($vcard->fn->value)) {
         $c->fn = $vcard->fn->value;
     }
     if (Validator::url()->validate($vcard->url->value)) {
         $c->url = $vcard->url->value;
     }
     if (Validator::in(array_keys(getGender()))->validate($vcard->gender->value)) {
         $c->gender = $vcard->gender->value;
     }
     if (Validator::in(array_keys(getMarital()))->validate($vcard->marital->value)) {
         $c->marital = $vcard->marital->value;
     }
     $c->adrlocality = $vcard->locality->value;
     $c->adrcountry = $vcard->country->value;
     if (Validator::email()->validate($vcard->email->value)) {
         $c->email = $vcard->email->value;
     }
     $c->twitter = $vcard->twitter->value;
     $c->skype = $vcard->skype->value;
     $c->yahoo = $vcard->yahoo->value;
     if (Validator::string()->validate($vcard->desc->value)) {
         $c->description = trim($vcard->desc->value);
     }
     $cd = new \Modl\ContactDAO();
     $cd->set($c);
     $r = new Set();
     $r->setData($c)->request();
     $r = new Moxl\Xec\Action\Vcard\Set();
     $r->setData($vcard)->request();
 }
コード例 #14
0
ファイル: Blog.php プロジェクト: christine-ho-dev/movim
 function load()
 {
     if ($this->_view == 'node') {
         $this->_from = $this->get('s');
         $this->_node = $this->get('n');
         if (!$this->validateServerNode($this->_from, $this->_node)) {
             return;
         }
         $pd = new \Modl\ItemDAO();
         $this->_item = $pd->getItem($this->_from, $this->_node);
         $this->_mode = 'group';
         $this->url = Route::urlize('node', array($this->_from, $this->_node));
     } elseif ($this->_view == 'tag' && $this->validateTag($this->get('t'))) {
         $this->_mode = 'tag';
         $this->_tag = $this->get('t');
         $this->title = '#' . $this->_tag;
     } else {
         $this->_from = $this->get('f');
         $cd = new \modl\ContactDAO();
         $this->_contact = $cd->get($this->_from, true);
         if (filter_var($this->_from, FILTER_VALIDATE_EMAIL)) {
             $this->_node = 'urn:xmpp:microblog:0';
         } else {
             return;
         }
         $this->_mode = 'blog';
         $this->url = Route::urlize('blog', $this->_from);
     }
     $pd = new \modl\PostnDAO();
     if ($this->_id = $this->get('i')) {
         if (Validator::intType()->between(0, 100)->validate($this->_id)) {
             if (isset($this->_tag)) {
                 $this->_messages = $pd->getPublicTag($this->get('t'), $this->_id * $this->_paging, $this->_paging + 1);
             } else {
                 $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, $this->_id * $this->_paging, $this->_paging + 1);
             }
             $this->_page = $this->_id + 1;
         } elseif (Validator::stringType()->length(5, 100)->validate($this->_id)) {
             $this->_messages = $pd->getPublicItem($this->_from, $this->_node, $this->_id);
             if (is_object($this->_messages[0])) {
                 $this->title = $this->_messages[0]->title;
                 $description = stripTags($this->_messages[0]->contentcleaned);
                 if (!empty($description)) {
                     $this->description = $description;
                 }
                 $attachements = $this->_messages[0]->getAttachements();
                 if ($attachements && array_key_exists('pictures', $attachements)) {
                     $this->image = urldecode($attachements['pictures'][0]['href']);
                 }
             }
             if ($this->_view == 'node') {
                 $this->url = Route::urlize('node', array($this->_from, $this->_node, $this->_id));
             } else {
                 $this->url = Route::urlize('blog', array($this->_from, $this->_id));
             }
         }
     } else {
         $this->_page = 1;
         if (isset($this->_tag)) {
             $this->_messages = $pd->getPublicTag($this->get('t'), 0, $this->_paging + 1);
         } else {
             $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, 0, $this->_paging + 1);
         }
     }
     if (count($this->_messages) == $this->_paging + 1) {
         array_pop($this->_messages);
     }
     $this->user = new User($this->_from);
     $cssurl = $this->user->getDumpedConfig('cssurl');
     if (isset($cssurl) && $cssurl != '' && Validator::url()->validate($cssurl)) {
         $this->addrawcss($cssurl);
     }
 }
コード例 #15
0
ファイル: Message.php プロジェクト: Anon215/movim
 public function checkPicture()
 {
     $body = trim($this->body);
     if (Validator::url()->notEmpty()->validate($body) && isSmallPicture($body)) {
         $this->picture = $body;
     }
 }
コード例 #16
0
 /**
  * @param string $apiUrl
  */
 public function setApiUrl($apiUrl)
 {
     if (Validator::url()->validate($apiUrl)) {
         $this->_apiUrl = $apiUrl;
     }
 }
コード例 #17
0
ファイル: formclass.php プロジェクト: tohir/formgenerator
 public static function url($details, $value)
 {
     if (empty($value) || !$details) {
         return TRUE;
     }
     return RespectValidator::url()->validate($value);
 }
コード例 #18
0
ファイル: Postn.php プロジェクト: vijo/movim
 public function getAttachement()
 {
     $attachements = $this->getAttachements();
     if (isset($attachements['pictures']) && !isset($attachements['links'])) {
         return $attachements['pictures'][0];
     }
     if (isset($attachements['files'])) {
         return $attachements['files'][0];
     }
     if (isset($attachements['links'])) {
         foreach ($attachements['links'] as $link) {
             if (Validator::url()->validate($link['href'])) {
                 return $link;
             }
         }
         return false;
     }
     return false;
 }
コード例 #19
0
ファイル: DefaultSite.php プロジェクト: aszone/hacking
 private function sanitazeActionForm($action)
 {
     $targetIsUrl = v::url()->notEmpty()->validate($action);
     if ($targetIsUrl) {
         return $action;
     }
     $existeBar = substr($action, 0, 1);
     $explodeUrl = explode('/', $this->target);
     if ($existeBar != '/') {
         array_pop($explodeUrl);
         $implodeUrl = implode('/', $explodeUrl);
         $resultAction = $implodeUrl . '/' . $action;
     } else {
         $resultAction = $explodeUrl[0] . '/' . $explodeUrl[1] . '/' . $explodeUrl[2] . $action;
     }
     return $resultAction;
 }