Example #1
0
 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $signedUserInfo = $registry->get('signedUserInfo');
     $uploadStatus = $registry->get("uploadStatus");
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->setMethod('post');
     $file = new Zend_Form_Element_File('file');
     $file->setRequired(false);
     $file->setLabel('What do you want to share today?');
     if ($uploadStatus['bandwidth']['remainingbytes'] > 0) {
         $maxFileSize = $uploadStatus['filesize']['maxbytes'];
     } else {
         $maxFileSize = 0;
     }
     $file->addValidator('Size', false, $maxFileSize);
     $file->setMaxFileSize($maxFileSize);
     $file->setMultiFile(4);
     $file->addValidator('Count', false, array('min' => 0, 'max' => 4));
     $this->addElement($file, 'file');
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('submit', 'submitupload', array('label' => 'Upload!', 'class' => 'btn primary'));
     $this->setAttrib('class', 'form-stacked');
 }
Example #2
0
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #3
0
 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $auth = Zend_Auth::getInstance();
     $config = $registry->get("config");
     $sessionConfig = $config['resources']['session'];
     $cookieLifetime = $sessionConfig['cookie_lifetime'];
     /* @todo fix issue of system with incoherent behavior when the session
        system has a issue, such as when the savehandler doesn't work as
        expected when it's off-line which results in differents
        catched / uncatched exception when the resource (page) loads
        */
     $saveHandler = new Ml_Session_SaveHandler_PlusCache($registry->get("memCache"), $config['session']['prefix'], $config['lastActivity']['prefix']);
     Zend_Session::setSaveHandler($saveHandler);
     Zend_Session::getSaveHandler()->setLifetime($cookieLifetime, true);
     Zend_Session::start();
     $defaultNamespace = new Zend_Session_Namespace();
     if (!isset($defaultNamespace->initialized)) {
         Zend_Session::regenerateId();
         $defaultNamespace->initialized = true;
     }
     if ($auth->hasIdentity()) {
         $people = Ml_Model_People::getInstance();
         $signedUserInfo = $people->getById($auth->getIdentity());
         $registry->set('signedUserInfo', $signedUserInfo);
     }
     $globalHash = Ml_Model_MagicCookies::getInstance()->getLast(true);
     $registry->set("globalHash", $globalHash);
 }
Example #4
0
 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $auth = Zend_Auth::getInstance();
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     if ($auth->hasIdentity()) {
         $this->addElement('password', 'currentpassword', array('filters' => array('StringTrim'), 'validators' => array(array('validator' => 'matchPassword')), 'autocomplete' => 'off', 'required' => true, 'label' => 'Current Password:'******'class' => 'span3'));
     }
     $this->addElement('password', 'password', array('filters' => array('StringTrim'), 'description' => "Six or more characters required; case-sensitive", 'validators' => array(array('validator' => 'StringLength', 'options' => array(6, 20)), array('validator' => 'Hardpassword'), array('validator' => 'newPassword'), array('validator' => 'newPasswordRepeat')), 'autocomplete' => 'off', 'required' => true, 'label' => 'New Password:'******'class' => 'span3'));
     $this->addElement('password', 'password_confirm', array('filters' => array('StringTrim'), 'required' => true, 'label' => 'Confirm Password:'******'autocomplete' => 'off', 'class' => 'span3'));
     if ($registry->isRegistered("changeUserProperPassword")) {
         $this->addElement(Ml_Model_AntiAttack::captchaElement());
     }
     $this->addElement('submit', 'submit', array('label' => 'Change it!', 'class' => 'btn primary'));
     if ($config['ssl']) {
         $this->getElement("submit")->addValidator("Https");
         //By default the submit element doesn't display a error decorator
         $this->getElement("submit")->addDecorator("Errors");
     }
     if ($auth->hasIdentity()) {
         $this->addElement(Ml_Model_MagicCookies::formElement());
     }
     $this->setAttrib('class', 'form-stacked');
 }
Example #5
0
 public function init()
 {
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement('submit', 'remove', array('label' => 'Remove Twitter!', 'required' => true, 'class' => 'btn danger'));
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->setAttrib('class', 'form-stacked');
 }
Example #6
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('submit', 'deleteTag', array('label' => 'Delete tag', 'class' => 'btn danger'));
 }
Example #7
0
 public function init()
 {
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement('submit', 'remote_signout', array('label' => 'Sign out all other sessions', 'class' => 'btn'));
     $this->addElement('submit', 'signout', array('label' => 'Sign out!', 'class' => 'btn danger'));
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->setAttrib('class', 'form-stacked');
 }
Example #8
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('submit', 'favoriteSubmit', array('label' => 'Yes', 'class' => 'btn primary'));
     $this->setAttrib('class', 'form-stacked');
 }
Example #9
0
 public function init()
 {
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->setMethod('post');
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('submit', 'allow', array('label' => 'Yes!'));
     $this->addElement('submit', 'deny', array('label' => 'No!'));
 }
Example #10
0
 public function init()
 {
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $registry = Zend_Registry::getInstance();
     $tweet = $this->addElement('textarea', 'tweet', array('label' => 'Tell them...', 'description' => 'Tweet something…', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 140)))));
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('submit', 'tweetSubmit', array('label' => 'Tweet!', 'class' => 'btn primary'));
     $this->setAttrib('class', 'form-stacked');
 }
Example #11
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('text', 'tags', array('label' => 'Add a tag', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 300))), 'placeholder' => 'Add a tag', 'class' => 'span2'));
     $this->addElement('submit', 'tagsSubmit', array('label' => 'Add', 'required' => false, 'class' => 'btn primary'));
     $this->setAttrib('class', 'form-stacked');
 }
Example #12
0
 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement('text', 'redeem', array('label' => 'Type your redeem code:', 'required' => true, 'autoInsertNotEmptyValidator' => false, 'validators' => array(array('validator' => 'Redeem'))));
     $this->addElement('submit', 'submit_redeem', array('label' => 'Redeem!', 'class' => 'btn success'));
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->setAttrib('class', 'form-stacked');
 }
Example #13
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $contactRelation = $this->addElement('checkbox', 'contact_relation', array('label' => 'Contact'));
     /*
             $this->addElement('checkbox', 'friend_relation', array(
                 'label'    => 'Friend'));*/
     $this->addElement('submit', 'update_relation', array('label' => "Change relation", 'required' => false));
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->setAttrib('class', 'form-stacked');
 }
Example #14
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement('text', 'title', array('label' => 'Title:', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 100)))));
     $this->addElement('text', 'filename', array('label' => 'Filename:', 'required' => true, 'description' => "Don't forget the extension (i.e., .txt, .jpg, .pdf)", 'filters' => array('StringTrim', 'StringToLower', 'Filename'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 60)), array('validator' => 'filename'))));
     $this->addElement('text', 'short', array('label' => 'Short description:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 120)))));
     $this->addElement('textarea', 'description', array('label' => 'Description:', 'required' => false, 'description' => '<small><a href="/help/html" class="new-window">' . 'HTML formatting</a></small>', 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 4096)))));
     $this->addElement('submit', 'submit', array('label' => 'Save!', 'class' => 'btn primary'));
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->setAttrib('class', 'form-stacked');
 }
Example #15
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement('text', 'application_title', array('label' => 'Application Title:', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 80)))));
     $this->addElement('textarea', 'application_descr', array('label' => 'Description:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 1024)))));
     $this->addElement('textarea', 'application_notes', array('label' => 'Notes (anything our admins should want know about your app):', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 1024)))));
     $this->addElement('checkbox', 'application_commercial', array('label' => 'Commercial'));
     $this->addElement('text', 'application_uri', array('label' => 'Application URI:', 'required' => false, 'filters' => array('StringTrim', 'UrlFilter'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 255)), array('validator' => 'Url'))));
     $this->addElement('text', 'callback_uri', array('label' => 'Application Callback:', 'required' => false, 'filters' => array('StringTrim', 'UrlFilter'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 255)), array('validator' => 'Url'))));
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('submit', 'submit', array('label' => 'Submit!'));
 }
Example #16
0
 public function isValid($ignoreValue)
 {
     //Warning:
     //$ignoreValue is not used because it's valid always
     //due to unusual behavior of the Ml_Filter_MagicCookies filter
     //this had to be done this way in this specific case
     $value = filter_input(INPUT_POST, Ml_Model_MagicCookies::hash_name, FILTER_UNSAFE_RAW);
     if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) {
         $referer = Zend_Uri::factory($_SERVER['HTTP_REFERER']);
         if (!in_array($referer->getHost(), $this->_options['allowed_referer_hosts'])) {
             $this->_error(self::MSG_REFERER_HOST_INVALID);
             return false;
         }
     }
     $last = Ml_Model_MagicCookies::getLast();
     $magicCookiesNamespace = new Zend_Session_Namespace('MagicCookies');
     if ($last == $value) {
         return true;
     }
     if (!ctype_xdigit($value)) {
         $this->_error(self::MSG_MAGIC_COOKIE_INVALID_FORMAT);
         return false;
     }
     $hexValue = preg_replace('/[^a-f0-9]/', '', $value);
     //sanitizing
     if ($hexValue != $value) {
         $this->_error(self::MSG_MAGIC_COOKIE_ERROR);
         return false;
     }
     if (mb_strlen($hexValue) != Ml_Model_MagicCookies::lenght) {
         $this->_error(self::MSG_MAGIC_COOKIE_INVALID_SIZE);
         return false;
     }
     $auth = Zend_Auth::getInstance();
     $hashInfo = Ml_Model_MagicCookies::getHashInfo($hexValue);
     if (!$hashInfo) {
         $this->_error(self::MSG_MAGIC_COOKIE_INVALID);
         return false;
     }
     if (!array_key_exists("uid", $hashInfo) || !array_key_exists("session_id", $hashInfo)) {
         $this->_error(self::MSG_MAGIC_COOKIE_ERROR);
         return false;
     }
     if (!is_null($hashInfo['uid']) && $hashInfo['uid'] == $auth->getIdentity() || Zend_Session::getId() == $hashInfo['session_id']) {
         return true;
     }
     $this->_error(self::MSG_MAGIC_COOKIE_INVALID);
     return false;
 }
Example #17
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->addElement('submit', 'submit', array('label' => 'Yes, delete it!', 'class' => 'btn danger'));
     /*
     $this->addElement('submit', 'forget', array(
         'label'    => 'No!',
     ));
     */
     /*$this->addElement('hash', 'no_csrf_foo',
       array('salt' => '%(N*UN(*U00CI7c45v9', 'timeout' => 1200));*/
 }
Example #18
0
 public function init()
 {
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $this->addElement('text', 'name', array('label' => 'Name:', 'required' => true, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 50)))));
     $email = $this->addElement('text', 'email', array('label' => 'E-mail address:', 'required' => true, 'filters' => array('StringTrim', 'StringToLower'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 60)), array('validator' => 'emailCheckUser'), array('validator' => 'EmailAddress'))));
     $emailprivacy = $this->addElement('checkbox', 'private_email', array('label' => 'Hide e-mail from public search'));
     $website = $this->addElement('text', 'website', array('label' => 'Your homepage:', 'required' => false, 'filters' => array('StringTrim', 'UrlFilter'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 100)), array('validator' => 'Url'))));
     $location = $this->addElement('text', 'location', array('label' => 'Location:', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 40)))));
     $about = $this->addElement('textarea', 'about', array('label' => 'About:', 'description' => '<small><a href="' . $this->getView()->staticUrl("/help/html") . '" class="new-window">HTML formatting</a></small>', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(0, 4096)))));
     $this->addElement('submit', 'submit', array('label' => 'Save!', 'class' => 'btn primary'));
     $this->addElement(Ml_Model_MagicCookies::formElement());
     $this->setAttrib('class', 'form-stacked');
 }
Example #19
0
 public function init()
 {
     $this->setAttrib('enctype', 'multipart/form-data');
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     $file = new Zend_Form_Element_File('Image');
     $file->setLabel('Choose a picture:');
     $file->addValidator('Count', false, 1);
     $file->addValidator('Size', false, array('max' => '1MB'));
     $file->setMaxFileSize(2048 * 1024);
     $file->addValidator('Extension', false, 'jpg,png,gif');
     $file->setRequired(false);
     $file->setOptions(array('ignoreNoFile' => true));
     $this->addElement($file, 'Image');
     $this->addElement('submit', 'submit', array('label' => 'Submit!', 'class' => 'btn primary'));
     $this->addElement('submit', 'delete', array('label' => 'Delete current', 'class' => 'btn danger'));
     $this->setAttrib('class', 'form-stacked');
     $this->addElement(Ml_Model_MagicCookies::formElement());
 }
Example #20
0
 public function init()
 {
     if (Zend_Registry::getInstance()->isRegistered("commentInfo")) {
         $altLabel = true;
     }
     $this->setMethod('post');
     $this->addElementPrefixPath('Ml_Validate', 'Ml/Validate/', Zend_Form_Element::VALIDATE);
     $this->addElementPrefixPath('Ml_Filter', 'Ml/Filter/', Zend_Form_Element::FILTER);
     if (isset($altLabel)) {
         $commentLabel = "Edit your comment:";
         $postCommentLabel = "Save Changes";
     } else {
         $commentLabel = "Add your comment:";
         $postCommentLabel = "Post comment";
     }
     $this->addElement('textarea', 'commentMsg', array('label' => $commentLabel, 'required' => true, 'placeholder' => "Write your comment here", 'description' => '<small><a href="/help/html" class="new-window">' . 'HTML formatting</a></small>', 'filters' => array('StringTrim'), 'validators' => array(array('validator' => 'StringLength', 'options' => array(1, 4096)))));
     $this->addElement('submit', 'getCommentPreview', array('label' => 'Preview', 'required' => false, 'class' => 'btn'));
     $this->addElement('submit', 'commentPost', array('label' => $postCommentLabel, 'required' => false, 'class' => 'btn primary'));
     $this->addElement(Ml_Model_MagicCookies::formElement());
 }
Example #21
0
 public function filter($value)
 {
     return Ml_Model_MagicCookies::getLast();
 }