Пример #1
0
 /**
  * パスワード生成
  *
  * @param integer $length 生成するパスワードの桁数
  *
  * @return string
  */
 public static function generate($length = 10)
 {
     if (!class_exists('Text_Password')) {
         throw new \RuntimeException('Text_Password library does not exists.');
     }
     $obj = new \Text_Password();
     return $obj->create($length, "unpronounceable", self::PASSWORD_CHAR);
 }
 public function __construct($db)
 {
     parent::__construct($db, 'user_account_balance_withdraw_tracking', 'user_account_balance_withdraw_tracking_id');
     $this->add('balance_withdraw_unique_id', Text_Password::create(1, 'unpronounceable', 'alphabetical') . Text_Password::create(8, 'unpronounceable', 'numeric'));
     $this->add('user_id');
     $this->add('balance_withdraw_amount');
     $this->add('status', 'PENDING');
     $this->add('pending_tracking_id');
     $this->add('date_of_request', time(), self::TYPE_TIMESTAMP);
     $this->add('date_processed');
 }
Пример #3
0
 function post()
 {
     //DB_DataObject::debuglevel(1);
     //  gets id : c.id,  rawPasswd: c.rawPasswd
     if (!$this->hasPerm("Core.Person", "A")) {
         $this->jerr("Not Permitted - no permission to add users.");
     }
     $p = DB_DataObject::factory('core_person');
     // let's make a password anyway..
     $rawPasswd = false;
     if (!empty($_REQUEST['_createPasswd'])) {
         require_once 'Text/Password.php';
         $rawPasswd = Text_Password::create(6) . rand(11, 99);
     }
     if (!empty($_REQUEST['rawPasswd'])) {
         $rawPasswd = $_REQUEST['rawPasswd'];
     }
     $id = empty($_REQUEST['id']) ? 0 : $_REQUEST['id'];
     if (!empty($_REQUEST['_create'])) {
         // check account does not exist yet..
         if ($p->get('email', $_REQUEST['email'])) {
             $this->jerr("duplicate email address:" . $_REQUEST['email']);
         }
         $p = DB_DataObject::factory('core_person');
         $p->setFrom($_REQUEST);
         if ($rawPasswd == false) {
             // -- needed for bulk adding... ?*** not sure why it's here, rather than in Roo?
             $p->insert();
             $this->jok("OK");
         }
         // generate a password.
         $p->insert();
         $id = $p->id;
     }
     $p = DB_DataObject::factory('core_person');
     if (!$id || !$p->get($_REQUEST['id'])) {
         $this->jerr("Invalid user id");
     }
     if ($rawPasswd !== false) {
         $p->setPassword($rawPasswd);
         $p->update();
     }
     // next..
     $ret = $p->sendTemplate('password_welcome', array('sender' => $this->authUser, 'rawPasswd' => $rawPasswd, 'baseURL' => $this->baseURL));
     if (is_object($ret)) {
         $this->jerr($ret->toString());
     }
     $this->jok("SENT");
     //
 }
Пример #4
0
 /**
  * Create multiple, different passwords
  *
  * Method to create a list of different passwords which are
  * all different.
  *
  * @access public
  * @param  integer Number of different password
  * @param  integer Length of the password
  * @param  string  Type of password (pronounceable, unpronounceable)
  * @param  string  Character which could be use in the
  *                 unpronounceable password ex : 'A,B,C,D,E,F,G'
  *                 or numeric or alphanumeric.
  * @return array   Array containing the passwords
  */
 function createMultiple($number, $length = 10, $type = 'pronounceable', $chars = '')
 {
     $passwords = array();
     while ($number > 0) {
         while (true) {
             $password = Text_Password::create($length, $type, $chars);
             if (!in_array($password, $passwords)) {
                 $passwords[] = $password;
                 break;
             }
         }
         $number--;
     }
     return $passwords;
 }
Пример #5
0
 public function __construct($db)
 {
     parent::__construct($db, 'user_products', 'products_id');
     $this->add('product_type');
     $this->add('product_tag');
     $this->add('product_price_range');
     $this->add('shipping_rate');
     $this->add('uniqueIdentifierForJS', Text_Password::create(10, 'unpronounceable'));
     $this->add('User_id');
     $this->add('Username');
     $this->add('user_network');
     $this->add('user_city');
     $this->add('url');
     $this->add('name');
     $this->add('price');
     $this->add('brand');
     $this->add('ts_created', time(), self::TYPE_TIMESTAMP);
     $this->add('status', self::PRODUCT_STATUS_DRAFT);
     $this->add('listing_type');
     $this->add('new', '0');
     $this->add('video_youtube');
     $this->add('reward_point', 0);
     $this->add('quantity');
     $this->add('main_color');
     $this->add('arm_length');
     $this->add('bust');
     $this->add('bust_to_bust');
     $this->add('chest');
     $this->add('crotch');
     $this->add('hip');
     $this->add('nape_to_waist');
     $this->add('neck');
     $this->add('shoulder_to_bust');
     $this->add('shoulder');
     $this->add('shoulder_to_waist');
     $this->add('waist');
     $this->add('waist_floor');
     $this->add('wrist');
     $this->add('armpit_circumference');
     $this->add('pants_length');
     $this->add('size');
     $this->add('heel');
     $this->add('body_height');
     $this->add('last_status_change', time(), self::TYPE_TIMESTAMP);
     $this->profile = new Profile_UserProducts($db);
     $this->setImageDatabaseTable();
     //this attribute is purely for the sake of passing it to other objects
 }
 public function __construct($db)
 {
     parent::__construct($db, 'user_account_balance_transfer_tracking', 'user_account_balance_transfer_tracking_id');
     $this->add('balance_transfer_unique_id', Text_Password::create(1, 'unpronounceable', 'alphabetical') . Text_Password::create(8, 'unpronounceable', 'numeric'));
     $this->add('from_user_id');
     $this->add('to_user_id');
     $this->add('to_user_email');
     $this->add('to_username');
     $this->add('balance_transfer_amount');
     $this->add('status', 'PENDING');
     $this->add('sender_pending_tracking_id');
     $this->add('receiver_pending_tracking_id');
     $this->add('message');
     $this->add('date_of_request', time(), self::TYPE_TIMESTAMP);
     $this->add('date_processed');
 }
 public function __construct($db)
 {
     parent::__construct($db, 'user_pending_reward_point_and_balance_tracking', 'user_pending_reward_point_and_balance_tracking_id');
     $this->add('pending_tracking_unique_id', Text_Password::create(1, 'unpronounceable', 'alphabetical') . Text_Password::create(8, 'unpronounceable', 'numeric'));
     $this->add('user_id');
     $this->add('tracking_type');
     $this->add('caused_by_type');
     $this->add('from_order_id');
     $this->add('from_order_profile_id');
     $this->add('caused_by_user_id');
     $this->add('added_reward_points');
     $this->add('deducted_reward_points');
     $this->add('added_dollar_amount');
     $this->add('deducted_dollar_amount');
     $this->add('status');
     $this->add('description');
     $this->add('date', time(), self::TYPE_TIMESTAMP);
     $this->add('ts_updated', date('Y-m-d G:i:s'));
 }
 public function __construct($db)
 {
     parent::__construct($db, 'sellerinformation', 'User_id');
     $this->add('User_id');
     $this->add('unique_identifier', Text_Password::create(10, 'unpronounceable'));
     $this->add('verified', 0);
     $this->add('paypal_email');
     $this->add('phone_number');
     $this->add('type');
     $this->add('address_one');
     $this->add('address_two');
     $this->add('city');
     $this->add('state');
     $this->add('country', 'USA');
     $this->add('zip');
     $this->add('items_description');
     $this->add('store_description', '');
     $this->add('ts_created', time(), self::TYPE_TIMESTAMP);
     $this->add('status', 'pending');
     //different type of status is ('pendingGeneralSeller', 'pendingStoreSeller','confirmedGeneralSeller', 'confirmedStoreSeller')
 }
Пример #9
0
 public function __construct($db)
 {
     parent::__construct($db, 'shopping_cart', 'cart_id');
     $this->add('order_unique_id', Text_Password::create(1, 'unpronounceable', 'alphabetical') . Text_Password::create(8, 'unpronounceable', 'numeric'));
     $this->add('order_shipping_id');
     $this->add('buyer_username');
     $this->add('buyer_id');
     $this->add('buyer_email');
     $this->add('buyer_name');
     $this->add('total_number_items');
     $this->add('cart_costs');
     $this->add('total_costs');
     $this->add('total_shipping_costs');
     $this->add('reward_points_awarded');
     $this->add('reward_points_used');
     $this->add('reward_amount_deducted');
     $this->add('promotion_code_used');
     $this->add('promotion_amount_deducted');
     $this->add('final_total_costs');
     $this->add('ts_created', time(), self::TYPE_TIMESTAMP);
     $this->shippingAddress = new DatabaseObject_OrderShippingAddress($db);
 }
Пример #10
0
 public function __construct($db)
 {
     parent::__construct($db, 'products', 'product_id');
     $this->add('purchase_type');
     $this->add('product_category');
     $this->add('inventory_attribute_table');
     $this->add('product_type');
     $this->add('product_tag');
     $this->add('product_price_range');
     $this->add('domestic_shipping_rate');
     $this->add('international_shipping_rate');
     $this->add('uploader_id');
     $this->add('uploader_username');
     $this->add('uploader_network');
     $this->add('uploader_email');
     $this->add('url');
     $this->add('name');
     $this->add('price');
     $this->add('on_sale');
     $this->add('sales_price');
     $this->add('brand');
     $this->add('inventory_reference', Text_Password::create(10, 'alphabetical'));
     $this->add('uniqueIdentifierForJS', Text_Password::create(10, 'alphabetical'));
     $this->add('return_allowed', '1');
     $this->add('flagged', '0');
     $this->add('ts_created', time(), self::TYPE_TIMESTAMP);
     $this->add('status', self::PRODUCT_STATUS_DRAFT);
     $this->add('listing_type');
     $this->add('new', '0');
     $this->add('video_youtube');
     $this->add('reward_point', 0);
     $this->add('backorder_time', '0');
     $this->add('social_usage', 'off');
     $this->add('competition_usage', 'off');
     $this->add('last_status_change', time(), self::TYPE_TIMESTAMP);
     $this->profile = new Profile_Products($db);
     $this->setImageDatabaseTable();
     //this attribute is purely for the sake of passing it to other objects
 }
Пример #11
0
 /**
  * Create random CAPTCHA phrase, "Word edition" (numbers only)
  *
  * This method creates a random phrase
  *
  * @access  private
  */
 function _createPhrase()
 {
     $this->_phrase = (string) Text_Password::create($this->_length, 'unpronounceable', 'numeric');
 }
Пример #12
0
 /**
  * Create random CAPTCHA phrase, Image edition (with size check)
  *
  * This method creates a random phrase, maximum 8 characters or width / 25, whatever is smaller
  *
  * @param array $options Optionally supply advanced options for the phrase creation
  * 
  * @access private
  * @return void
  */
 protected function _createPhrase($options = array())
 {
     $len = intval(min(8, $this->_width / 25));
     if (!is_array($options) || count($options) === 0) {
         $this->_phrase = Text_Password::create($len);
     } else {
         if (count($options) === 1) {
             $this->_phrase = Text_Password::create($len, $options[0]);
         } else {
             $this->_phrase = Text_Password::create($len, $options[0], $options[1]);
         }
     }
     $this->_created = false;
 }
Пример #13
0
 /**
  * Create random CAPTCHA phrase, Image edition (with size check)
  *
  * This method creates a random phrase, maximum 8 characters or width / 25, whatever is smaller
  *
  * @access  private
  */
 public function _createPhrase($options = array())
 {
     if (isset(self::$_phraseLength)) {
         $len = intval(min(self::$_phraseLength, $this->_width / 25));
     } else {
         $len = intval(min(8, $this->_width / 25));
     }
     if (!is_array($options) || count($options) === 0) {
         $this->_phrase = Text_Password::create($len);
     } else {
         if (count($options) === 1) {
             $this->_phrase = Text_Password::create($len, $options[0]);
         } else {
             $this->_phrase = Text_Password::create($len, $options[0], $options[1]);
         }
     }
     $this->_created = false;
 }
Пример #14
0
 /**
  * Create random CAPTCHA phrase
  *
  * This method creates a random phrase, 8 characters long
  *
  * @access  private
  */
 public function _createPhrase($options = array())
 {
     $len = 8;
     if (!is_array($options) || count($options) === 0) {
         $this->_phrase = Text_Password::create($len);
     } else {
         if (count($options) === 1) {
             $this->_phrase = Text_Password::create($len, $options[0]);
         } else {
             $this->_phrase = Text_Password::create($len, $options[0], $options[1]);
         }
     }
 }
Пример #15
0
 /**
  * ランダムな文字列を取得する
  *
  * @param integer $length 文字数
  * @return string ランダムな文字列
  */
 function sfGetRandomString($length = 1)
 {
     return Text_Password::create($length);
 }
Пример #16
0
// ************************************************************************** //
// sample of html pages
$dir = 'samples/Lexer';
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
    if (strpos($filename, '.html') !== strlen($filename) - 5) {
        continue;
    }
    $document = file_get_contents($dir . '/' . $filename);
    do_benchmark("File: {$filename}", $document);
}
// crashers, caused infinite loops before
$snippets = array();
$snippets[] = '<a href="foo>';
$snippets[] = '<a "=>';
foreach ($snippets as $snippet) {
    do_benchmark($snippet, $snippet);
}
// random input
$random = Text_Password::create(80, 'unpronounceable', 'qwerty <>="\'');
do_benchmark('Random input', $random);
?>
</table>

<?php 
echo '<div>Random input was: ' . '<span colspan="4" style="font-family:monospace;">' . htmlspecialchars($random) . '</span></div>';
?>


</body></html>
Пример #17
0
 /**
  * Create random CAPTCHA phrase, Image edition (with size check)
  *
  * This method creates a random phrase, maximum 8 characters or width / 25, whatever is smaller
  *
  * @access  private
  */
 function _createPhrase()
 {
     $len = intval(min(8, $this->_width / 25));
     $this->_phrase = Text_Password::create($len);
     $this->_created = false;
 }
 public function forgotPasswordAction()
 {
     $request = $this->getRequest();
     $validateOnly = $request->isXmlHttpRequest();
     if ($validateOnly) {
         $this->setNoRenderer();
     }
     $status = ValidationContainer::instance();
     $this->view->assign('complete', false);
     $status->setStatusMessage(t('Starting...'));
     if ($this->_getParam('send')) {
         $status->checkRequired($this, 'email', t('Email'));
         if (!$status->hasError()) {
             //$this->view->assign ( 'test', "has error");
             $userTable = new User();
             $select = $userTable->select();
             $select->where("email = ?", $this->_getParam('email'));
             $row = $userTable->fetchRow($select);
             if (!$row) {
                 $status->setStatusMessage('That user could not be found.');
                 $this->view->assign('complete', true);
             }
             if ($row) {
                 require_once 'models/Password.php';
                 $newpass = Text_Password::create(8);
                 $row->password = $newpass;
                 $result = $row->save();
                 if ($result > 0) {
                     $view = new Zend_View();
                     $view->assign('base_url', Settings::$COUNTRY_BASE_URL);
                     $view->setScriptPath(Globals::$BASE_PATH . '/app/views/scripts/email');
                     $view->assign('first_name', $row->first_name);
                     $view->assign('username', $row->username);
                     $view->assign('password', $newpass);
                     $text = $view->render('text/forgot.phtml');
                     $html = $view->render('html/forgot.phtml');
                     $mail = new Zend_Mail();
                     $mail->setBodyText($text);
                     $mail->setBodyHtml($html);
                     $mail->setFrom(Settings::$EMAIL_ADDRESS, Settings::$EMAIL_NAME);
                     $mail->addTo($row->email, $row->username);
                     $mail->setSubject('Password Change Requested');
                     $mail->send();
                     $status->setStatusMessage(t('Your new password has been sent. Please check your email for further instructions.'));
                     //$this->view->assign ( 'complete', true );
                 } else {
                     $status->setStatusMessage(t('Mail send error.'));
                 }
             }
         }
     }
     if ($validateOnly) {
         $this->sendData($status);
     } else {
         $this->view->assign('status', $status);
     }
 }
Пример #19
0
 function generatePassword($length = 5)
 {
     require_once 'Text/Password.php';
     $this->rawPasswd = strtr(ucfirst(Text_Password::create($length)) . ucfirst(Text_Password::create($length)), array("a" => "4", "e" => "3", "i" => "1", "o" => "0", "s" => "5", "t" => "7"));
     $this->setPassword($this->rawPasswd);
     return $this->rawPasswd;
 }
Пример #20
0
 /**
  * ランダムな文字列を取得する
  *
  * @param integer $length 文字数
  * @return string ランダムな文字列
  */
 function sfGetRandomString($length = 1)
 {
     require_once dirname(__FILE__) . '/../../module/Text/Password.php';
     return Text_Password::create($length);
 }
Пример #21
0
 /**
  * Create the passphrase.
  *
  * @return string
  */
 public function createPhrase()
 {
     $options = $this->_textPasswordOptions;
     $textPassword = new Text_Password();
     if (!is_array($options) || count($options) === 0) {
         $this->setPhrase($textPassword->create($this->_length));
     } else {
         if (count($options) === 1) {
             $this->setPhrase($textPassword->create($this->_length, $options[0]));
         } else {
             $this->setPhrase($textPassword->create($this->_length, $options[0], $options[1]));
         }
     }
 }
Пример #22
0
 /**
  * Create random CAPTCHA phrase
  * This method creates a random phrase
  *
  * @access  private
  */
 function _createPhrase()
 {
     $this->_phrase = Text_Password::create($this->_length);
 }
Пример #23
0
 $form_shop_notreg->addRule('postcountry', $locale->get('account_notreg_error_postalcountry'), 'required');
 if ($form_shop_notreg->validate()) {
     $form_shop_notreg->applyFilter('__ALL__', array(&$mdb2, 'escape'));
     $user_name = $form_shop_notreg->getSubmitValue('user_name');
     $email = $form_shop_notreg->getSubmitValue('email');
     $phone = $form_shop_notreg->getSubmitValue('phone');
     $shipzip = $form_shop_notreg->getSubmitValue('shipzip');
     $shipcity = $form_shop_notreg->getSubmitValue('shipcity');
     $shipaddr = $form_shop_notreg->getSubmitValue('shipaddr');
     $shipcountry = intval($form_shop_notreg->getSubmitValue('shipcountry'));
     $postzip = $form_shop_notreg->getSubmitValue('postzip');
     $postcity = $form_shop_notreg->getSubmitValue('postcity');
     $postaddr = $form_shop_notreg->getSubmitValue('postaddr');
     $postcountry = intval($form_shop_notreg->getSubmitValue('postcountry'));
     require_once "Text/Password.php";
     $activate = Text_Password::create(8, 'unpronounceable', 'alphanumeric');
     $nuser_id = $mdb2->extended->getBeforeID('iShark_Shop_Users_Notreg', 'nuser_id', TRUE, TRUE);
     $query = "\n\t\t\t\tINSERT INTO iShark_Shop_Users_Notreg \n\t\t\t\t(nuser_id, user_name, email, phone_mobile, ship_zipcode, ship_city, ship_country_id, ship_address, \n\t\t\t\tpost_zipcode, post_city, post_country_id, post_address, is_active, activate, add_date) \n\t\t\t\tVALUES \n\t\t\t\t({$nuser_id}, '" . $user_name . "', '" . $email . "', '" . $phone . "', '" . $shipzip . "', '" . $shipcity . "', '{$shipcountry}', '" . $shipaddr . "', \n\t\t\t\t'" . $postzip . "', '" . $postcity . "', '{$postcountry}', '" . $postaddr . "', '0', '" . $activate . "', NOW())\n\t\t\t";
     $mdb2->exec($query);
     $last_nuser_id = $mdb2->extended->getAfterID($nuser_id, 'iShark_Shop_Users_Notreg', 'nuser_id');
     //frissitjuk a kosarat is, mert beallitjuk az nuser_id valtozot
     $query = "\n\t\t\t\tUPDATE iShark_Shop_Basket \n\t\t\t\tSET nuser_id = {$last_nuser_id} \n\t\t\t\tWHERE session_id = '" . session_id() . "'\n\t\t\t";
     $mdb2->exec($query);
     //elkuldjuk a levelet
     ini_set('display_errors', 0);
     include_once 'Mail.php';
     include_once 'Mail/mime.php';
     $hdrs = array('From' => '"' . preg_replace('|"|', '\\"', $_SESSION['site_sitename']) . '" <' . $_SESSION['site_sitemail'] . '>', 'Subject' => $locale->get('account_notreg_mail_subject'));
     $mime =& new Mail_mime("\n");
     $charset = $locale->getCharset() ? 'ISO-8859-2' : $locale->getCharset();
     $msg = $locale->get('account_notreg_mail_header') . " " . $user_name . "<br /><br />";
Пример #24
0
Файл: db.php Проект: demental/m
 /**
  * Generates a new random password
  * @return string clear password
  */
 public function generatePassword($obj)
 {
     $defs = $obj->_getPluginsDef();
     $field = $defs['user']['pwd'];
     $pwd = Text_Password::create(8);
     $obj->{$field} = $this->encrypt($pwd, $obj)->return;
     return self::returnStatus($pwd);
 }
Пример #25
0
 function testAddCategory()
 {
     $name = new Text_Password();
     TestEnv::startTransaction();
     $ret = Admin_DA::addCategory(array('name' => $name->create()));
     $this->assertTrue(is_int($ret));
     $this->assertTrue($ret > 0);
     TestEnv::rollbackTransaction();
 }
Пример #26
0
 public function generateRandomPassword($length = 10, $string = '', $type = 'pronounceable')
 {
     if (!$type and $string) {
         $type = 'pronounceable';
     } elseif (!$type) {
         $type = 'unpronounceable';
     }
     require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'res/Password.php';
     $suite = new Text_Password();
     switch ($type) {
         case 'pronounceable':
             $password = $suite->create($length, 'pronounceable', $string);
             $password .= rand(10, 99);
             break;
         case 'unpronounceable':
             $password = $suite->create($length, 'unpronounceable', $string . '0123456789!@#$%^&*(');
             break;
         case 'shuffle':
         default:
             $password = $suite->createFromLogin($string, 'shuffle');
             $password .= rand(10, 99);
             break;
     }
     return $password;
 }
Пример #27
0
 /**
  * Create random CAPTCHA phrase
  *
  * This method creates a random phrase, 8 characters long
  *
  * @access  private
  */
 function _createPhrase()
 {
     $len = 8;
     $this->_phrase = Text_Password::create($len);
 }
 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param BaseApplication $app An Application instance
  */
 public function register(BaseApplication $app)
 {
     // PEAR
     $app['smarty'] = function () {
         return new \Smarty();
     };
     $app['mobile.detect'] = function () {
         return new \Mobile_Detect();
     };
     $app['pear.archive.tar'] = $app->protect(function ($p_tarname, $p_compress = null) {
         return new \Archive_Tar($p_tarname, $p_compress);
     });
     $app['pear.cache.lite'] = $app->protect(function ($options = array()) {
         return new \Cache_Lite($options);
     });
     $app['pear.calendar.month.weekdays'] = $app->protect(function ($y, $m, $firstDay = null) {
         return new \Calendar_Month_Weekdays($y, $m, $firstDay);
     });
     $app['pear.http.request'] = $app->protect(function ($url = '', $params = array()) {
         return new \HTTP_Request($url, $params);
     });
     $app['pear.mail'] = $app->protect(function ($driver, $params = array()) {
         return \Mail::factory($driver, $params);
     });
     $app['pear.net.user_agent.mobile'] = $app->protect(function ($userAgent = null) {
         return \Net_UserAgent_Mobile::singleton($userAgent);
     });
     $app['pear.net.url'] = $app->protect(function ($url = null, $useBrackets = true) {
         return new \Net_URL($url, $useBrackets);
     });
     $app['pear.services.json'] = $app->protect(function ($use = 0) {
         return new \Services_JSON($use);
     });
     $app['pear.text.password'] = $app->protect(function ($length = 10, $type = 'pronounceable', $chars = '') {
         return \Text_Password::create($length, $type, $chars);
     });
     $app['pear.xml.serializer'] = $app->protect(function ($options = null) {
         return new \XML_Serializer($options);
     });
     // framework
     $app['eccube.cart_session'] = $app->protect(function ($cartKey = 'cart') {
         return new \Eccube\Framework\CartSession($cartKey);
     });
     $app['eccube.customer'] = function () {
         return new \Eccube\Framework\Customer();
     };
     $app['eccube.customer_list'] = $app->protect(function ($array, $mode = '') {
         return new \Eccube\Framework\CustomerList($array, $mode);
     });
     $app['eccube.cookie'] = $app->protect(function ($day = COOKIE_EXPIRE) {
         return new \Eccube\Framework\Cookie($day);
     });
     $app['eccube.check_error'] = $app->protect(function ($array = '') {
         return new \Eccube\Framework\CheckError($array);
     });
     $app['eccube.date'] = $app->protect(function ($start_year = '', $end_year = '') {
         return new \Eccube\Framework\Date($start_year, $end_year);
     });
     $app['eccube.display'] = $app->protect(function ($hasPrevURL = true) {
         return new \Eccube\Framework\Display($hasPrevURL);
     });
     $app['eccube.form_param'] = function () {
         return new \Eccube\Framework\FormParam();
     };
     $app['eccube.page_navi'] = $app->protect(function ($now_page, $all_row, $page_row, $func_name, $navi_max = NAVI_PMAX, $urlParam = '', $display_number = true) {
         return new \Eccube\Framework\PageNavi($now_page, $all_row, $page_row, $func_name, $navi_max, $urlParam, $display_number);
     });
     $app['eccube.product'] = $app->protect(function () {
         return new \Eccube\Framework\Product();
     });
     $app['eccube.response'] = $app->protect(function () {
         return new \Eccube\Framework\Response();
     });
     $app['eccube.query'] = $app->protect(function ($dsn = '', $force_run = false, $new = false) {
         return \Eccube\Framework\Query::getSingletonInstance($dsn, $force_run, $new);
     });
     $app['eccube.site_session'] = $app->share(function () {
         return new \Eccube\Framework\SiteSession();
     });
     $app['eccube.sendmail'] = $app->protect(function () {
         return new \Eccube\Framework\Sendmail();
     });
     // db
     $app['eccube.db.factory'] = $app->protect(function ($db_type = DB_TYPE) {
         return \Eccube\Framework\DB\DBFactory::getInstance($db_type);
     });
     $app['eccube.db.master_data'] = $app->share(function () {
         return new \Eccube\Framework\DB\MasterData();
     });
     // graph
     $app['eccube.graph.bar'] = $app->protect(function ($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) {
         return new \Eccube\Framework\Graph\BarGraph($bgw, $bgh, $left, $top, $area_width, $area_height);
     });
     $app['eccube.graph.line'] = $app->protect(function ($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) {
         return new \Eccube\Framework\Graph\LineGraph($bgw, $bgh, $left, $top, $area_width, $area_height);
     });
     $app['eccube.graph.pie'] = $app->protect(function ($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = PIE_LEFT, $top = PIE_TOP) {
         return new \Eccube\Framework\Graph\PieGraph($bgw, $bgh, $left, $top);
     });
     // helper
     $app['eccube.helper.address'] = $app->share(function () {
         return new \Eccube\Framework\Helper\AddressHelper();
     });
     $app['eccube.helper.best_products'] = $app->share(function () {
         return new \Eccube\Framework\Helper\BestProductsHelper();
     });
     $app['eccube.helper.bloc'] = $app->protect(function ($devide_type_id = DEVICE_TYPE_PC) {
         return new \Eccube\Framework\Helper\BlocHelper($devide_type_id);
     });
     $app['eccube.helper.category'] = $app->protect(function ($count_check = false) {
         return new \Eccube\Framework\Helper\CategoryHelper($count_check);
     });
     $app['eccube.helper.csv'] = function () {
         return new \Eccube\Framework\Helper\CsvHelper();
     };
     $app['eccube.helper.customer'] = $app->share(function () {
         return new \Eccube\Framework\Helper\CustomerHelper();
     });
     $app['eccube.helper.db'] = $app->share(function () {
         return new \Eccube\Framework\Helper\DbHelper();
     });
     $app['eccube.helper.delivery'] = $app->share(function () {
         return new \Eccube\Framework\Helper\DeliveryHelper();
     });
     $app['eccube.helper.file_manager'] = $app->share(function () {
         return new \Eccube\Framework\Helper\FileManagerHelper();
     });
     $app['eccube.helper.fpdi'] = $app->protect(function ($orientation = 'P', $unit = 'mm', $size = 'A4') {
         return new \Eccube\Framework\Helper\FpdiHelper($orientation, $unit, $size);
     });
     $app['eccube.helper.holiday'] = $app->share(function () {
         return new \Eccube\Framework\Helper\HolidayHelper();
     });
     $app['eccube.helper.kiyaku'] = $app->share(function () {
         return new \Eccube\Framework\Helper\KiyakuHelper();
     });
     $app['eccube.helper.mail'] = $app->share(function () {
         return new \Eccube\Framework\Helper\MailHelper();
     });
     $app['eccube.helper.mailtemplate'] = $app->share(function () {
         return new \Eccube\Framework\Helper\MailtemplateHelper();
     });
     $app['eccube.helper.maker'] = $app->share(function () {
         return new \Eccube\Framework\Helper\MakerHelper();
     });
     $app['eccube.helper.mobile'] = $app->share(function () {
         return new \Eccube\Framework\Helper\MobileHelper();
     });
     $app['eccube.helper.news'] = $app->share(function () {
         return new \Eccube\Framework\Helper\NewsHelper();
     });
     $app['eccube.helper.page_layout'] = $app->share(function () {
         return new \Eccube\Framework\Helper\PageLayoutHelper();
     });
     $app['eccube.helper.payment'] = $app->share(function () {
         return new \Eccube\Framework\Helper\PaymentHelper();
     });
     $app['eccube.helper.plugin'] = function () {
         $plugin_activate_flg = PLUGIN_ACTIVATE_FLAG;
         return \Eccube\Framework\Helper\PluginHelper::getSingletonInstance($plugin_activate_flg);
     };
     $app['eccube.helper.purchase'] = $app->share(function () {
         return new \Eccube\Framework\Helper\PurchaseHelper();
     });
     $app['eccube.helper.session'] = $app->share(function () {
         return new \Eccube\Framework\Helper\SessionHelper();
     });
     $app['eccube.helper.tax_rule'] = $app->share(function () {
         return new \Eccube\Framework\Helper\TaxRuleHelper();
     });
     $app['eccube.helper.transform'] = $app->protect(function ($source) {
         return new \Eccube\Framework\Helper\TransformHelper($source);
     });
     // util
     $app['eccube.util.utils'] = $app->share(function () {
         return new \Eccube\Framework\Util\Utils();
     });
     $app['eccube.util.gc_utils'] = $app->share(function () {
         return new \Eccube\Framework\Util\GcUtils();
     });
     // smarty
     $app['smarty'] = $app->extend('smarty', function ($smarty) {
         /* @var $DbHelper \Eccube\Framework\Helper\DbHelper */
         $DbHelper = Application::alias('eccube.helper.db');
         /* @var $Utils \Eccube\Framework\Util\Utils */
         $Utils = Application::alias('eccube.util.utils');
         /* @var $GcUtils \Eccube\Framework\Util\GcUtils */
         $GcUtils = Application::alias('eccube.util.gc_utils');
         $smarty->left_delimiter = '<!--{';
         $smarty->right_delimiter = '}-->';
         $smarty->plugins_dir = array(realpath(__DIR__ . '/../../smarty_extends'), realpath(__DIR__ . '/../../../vendor/smarty/smarty/libs/plugins'));
         $smarty->register_modifier('sfDispDBDate', array($Utils, 'sfDispDBDate'));
         $smarty->register_modifier('sfGetErrorColor', array($Utils, 'sfGetErrorColor'));
         $smarty->register_modifier('sfTrim', array($Utils, 'sfTrim'));
         $smarty->register_modifier('sfCalcIncTax', array($DbHelper, 'calcIncTax'));
         $smarty->register_modifier('sfPrePoint', array($Utils, 'sfPrePoint'));
         $smarty->register_modifier('sfGetChecked', array($Utils, 'sfGetChecked'));
         $smarty->register_modifier('sfTrimURL', array($Utils, 'sfTrimURL'));
         $smarty->register_modifier('sfMultiply', array($Utils, 'sfMultiply'));
         $smarty->register_modifier('sfRmDupSlash', array($Utils, 'sfRmDupSlash'));
         $smarty->register_modifier('sfCutString', array($Utils, 'sfCutString'));
         $smarty->register_modifier('sfMbConvertEncoding', array($Utils, 'sfMbConvertEncoding'));
         $smarty->register_modifier('sfGetEnabled', array($Utils, 'sfGetEnabled'));
         $smarty->register_modifier('sfNoImageMainList', array($Utils, 'sfNoImageMainList'));
         // XXX register_function で登録すると if で使用できないのではないか?
         $smarty->register_function('sfIsHTTPS', array($Utils, 'sfIsHTTPS'));
         $smarty->register_function('sfSetErrorStyle', array($Utils, 'sfSetErrorStyle'));
         $smarty->register_function('printXMLDeclaration', array($GcUtils, 'printXMLDeclaration'));
         $smarty->default_modifiers = array('script_escape');
         $smarty->force_compile = SMARTY_FORCE_COMPILE_MODE === true;
         return $smarty;
     });
 }
Пример #29
0
 /**
  * Create random CAPTCHA phrase, Image edition (with size check).
  *
  * This method creates a random phrase, maximum 8 characters or width / 25,
  * whatever is smaller.
  *
  * @return void
  */
 public function createPhrase()
 {
     $len = intval(min(8, $this->_width / 25));
     $options = $this->_textPasswordOptions;
     $textPassword = new Text_Password();
     if (!is_array($options) || count($options) === 0) {
         $this->setPhrase($textPassword->create($len));
     } else {
         if (count($options) === 1) {
             $this->setPhrase($textPassword->create($len, $options[0]));
         } else {
             $this->setPhrase($textPassword->create($len, $options[0], $options[1]));
         }
     }
 }
Пример #30
0
function login_display($task)
{
    global $db, $cfg;
    if ($task == NULL) {
        if (auth_logged_in()) {
            $task = 'profile';
        } else {
            $task = 'login';
        }
    }
    switch ($task) {
        case "register":
            $form = new HTML_QuickForm('regForm', 'post', 'index.php?view=login&task=register');
            $form->addElement('header', null, 'Register');
            $form->addElement('text', 'handle', 'Handle:');
            $form->addElement('password', 'password', 'Password:'******'password', 'password2', 'Retype Password:'******'text', 'email', 'Email:');
            $form->addElement('header', null, 'Personal Information');
            $form->addElement('text', 'first_name', 'First Name:');
            $form->addElement('text', 'last_name', 'Last Name:');
            $date = getdate();
            $form->addElement('date', 'birth_date', 'Date of Birth:', array('minYear' => $date['year'] - 100, 'maxYear' => $date['year']));
            $form->addElement('text', 'address', 'Street Address:');
            $form->addElement('text', 'city', 'City:');
            $form->addElement('text', 'state', 'State:');
            $form->addElement('text', 'zip', 'Zip:');
            $form->addElement('select', 'division', 'Division:', $cfg["tcl"]["divisions"]);
            $form->addElement('text', 'phone', 'Phone:');
            $form->addElement('textarea', 'quote', 'Quote:', array('rows' => 3));
            $form->addElement('header', null, 'For Password Recovery');
            $form->addElement('text', 'question', 'Secret Question:');
            $form->addElement('text', 'secret', 'Secret Answer:');
            $form->addElement('submit', null, 'Submit');
            $form->applyFilter('handle', 'trim');
            $form->applyFilter('handle', 'strtolower');
            $form->applyFilter('email', 'trim');
            $form->applyFilter('first_name', 'trim');
            $form->applyFilter('last_name', 'trim');
            $form->applyFilter('address', 'trim');
            $form->applyFilter('state', 'trim');
            $form->applyFilter('city', 'trim');
            $form->applyFilter('zip', 'trim');
            $form->applyFilter('phone', 'trim');
            $form->applyFilter('question', 'trim');
            $form->applyFilter('secret', 'trim');
            $form->addRule('handle', 'Handle is required.', 'required', null, 'client');
            $form->addRule('handle', 'Handle can only contain alphabets, numbers. and/or undescores.', 'alphanumericscore', null, 'client');
            $form->addRule('password', 'Password is required.', 'required', null, 'client');
            $form->addRule('password2', 'Retyped password is required.', 'required', null, 'client');
            $form->addRule('email', 'Email is required.', 'required', null, 'client');
            $form->addRule('division', 'Division is required.', 'required', null, 'client');
            $form->addRule('first_name', 'First name is required.', 'required', null, 'client');
            $form->addRule('last_name', 'Last name is required.', 'required', null, 'client');
            $form->addRule('question', 'Secret question is required.', 'required', null, 'client');
            $form->addRule('secret', 'Secret answer is required.', 'required', null, 'client');
            $form->addRule('handle', 'Login handle must be between 4 and 15 characters.', 'rangelength', array(4, 15), 'client');
            $form->addRule('password', 'Password must be between 6 and 15 characters.', 'rangelength', array(4, 15), 'client');
            $form->addRule('email', 'Email is invalid.', 'email', null, 'client');
            $form->addRule(array('password', 'password2'), 'Passwords much match.', 'compare', null, 'client');
            $show_form = true;
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                unset($data['password2']);
                // Verify that email is unique
                $res =& db_query('user_by_email', $data['email']);
                if ($res->numRows() != 0) {
                    $res->fetchInto($user);
                    $res->free();
                    ?>
				<p><b>Email already registered to an existing user!</b><br />
				User <?php 
                    echo '<b>' . $user['handle'] . '</b>';
                    ?>
 owns that email address. Maybe you've already registered and forgotten about it?
				Try <a href="index.php?view=login&amp;task=login">logging in</a> if that is the case.</p>
				<?php 
                } else {
                    // Format the birth date correctly
                    $data['birth_date'] = form2sql_date($data['birth_date']);
                    $user = auth_register($data);
                    if ($user == null) {
                        $show_form = false;
                        ?>
	<p><strong>Thanks for registering!</strong><br /> Please proceed to <a href="index.php?view=login&amp;task=login">login</a> into your new account.</p>
	<?php 
                    } else {
                        ?>
	<p><b>That user-handle has already been taken!</b><br/> It belongs to an user registered with the name <?php 
                        echo $user['first_name'] . ' ' . $user['last_name'];
                        ?>
. Please try again with another handle.</p>
	<?php 
                    }
                }
            }
            if ($show_form) {
                ?>
<p><strong>Please fill in your details below.</strong><br /> 
Please choose your <strong>handle</strong> and <strong>division</strong> carefully. Once chosen, they cannot be changed. Moreover, choosing an inappropriate division will lead to disqualification.
<br> 
<br>Any doubts and problems should find their way to the <? echo '<a href="mailto:'.$cfg["site"]["email"].'">admins</a>'; ?>.
</p>
<?php 
                $form->display();
            }
            break;
        case 'logout':
            auth_logout();
            redirect('index.php');
            break;
        case 'login':
            $form = new HTML_QuickForm('loginForm', 'post', 'index.php?view=login&task=login');
            $form->addElement('header', null, 'Login');
            $form->addElement('text', 'handle', 'Handle:');
            $form->addElement('password', 'password', 'Password:'******'submit', null, 'Submit');
            $form->applyFilter('handle', 'trim');
            $form->applyFilter('handle', 'strtolower');
            if ($form->validate()) {
                if (auth_login($form->getSubmitValue('handle'), $form->getSubmitValue('password'))) {
                    redirect('index.php');
                } else {
                    echo "<p>Invalid handle or password! Please try again.</p>\n";
                }
            } else {
                $signature = '<i>' . $_SERVER['SERVER_SOFTWARE'] . ' Server at ' . $_SERVER['SERVER_NAME'] . ', port ' . $_SERVER['SERVER_PORT'] . '</i>';
                ?>
<p><strong>Welcome!</strong><br />
Please login to proceed, or <a href="index.php?view=login&amp;task=register">register</a>
 with us if you're new here.</p>
<?php 
            }
            $form->display();
            ?>
<p class="system_info">This is <b>OGS 2</b> running on <? echo $signature ?>.<br />
<b>Server System:</b> <?php 
            system("uname -srmp");
            ?>
</p>
<hr />
<div id="javascript_warn"><p><strong>Warning!</strong> Javascript is not enabled on your browser. Many features will not work without it.</p></div>
<script type="text/javascript">
getObj('javascript_warn').style.display = "none";
</script>
<p><strong>Before you login.</strong> This website makes heavy use of modern web technologies such as CSS
and Javascript, to enjoy which, you'll need a modern browser. Below is a list of browsers along with their
earliest versions which are guaranteed to work with this website. For best results, we recommend a resolution higher than 800x600 with True Color (32-bit).</p>
<table class="browsers">
<tr>
    <td><img width="32" height="32" src="images/firefox-icon.png" /></td>
    <td><img width="32" height="32" src="images/opera_icon.gif" /></td>
    <td><img width="32" height="32" src="images/internet-explorer-icon.png" /></td>
    <td><img width="32" height="32" src="images/mozilla-icon.png" /></td>
    <td><img width="32" height="32" src="images/safari-icon.png" /></td>
    <td><img width="32" height="32" src="images/icon-konqueror.jpg" /></td>
    <td><img width="32" height="32" src="images/netscape-icon.png" /></td>
</tr>
<tr>
    <td><a href="http://www.getfirefox.com/">Firefox</a><br />1.0+</td>
    <td><a href="http://www.opera.com/">Opera</a><br />7+</td>
    <td><a href="http://www.microsoft.com/windows/ie/">Internet<br />Explorer</a> 6.0+<a></a></td>
    <td><a href="http://www.mozilla.org/products/mozilla1.x/">Mozilla</a><br />1.3+</td>
    <td><a href="http://www.apple.com/safari/">Safari</a><br />1.2+</td>
    <td><a href="http://www.konqueror.org/">Konqueror</a><br />3+</td>
    <td><a href="http://browser.netscape.com">Netscape</a><br />6+</td>
</tr>
</table>
<p>If you experience any problems while browsing this website using one of the above browsers,
then you're welcome to <a href="mailto:de.arijit@gmail.com">email the webmaster</a>. We hope you'll
enjoy your stay here.</p>
        <?php 
            break;
        case 'forgot':
            ?>
<p><strong>Lost your password?</strong><br />Follow these steps to generate a new password for your account.
You will be mailed the new password once you're done.</p>
<?php 
            $form1 = new HTML_QuickForm('forgotForm1', 'post', 'index.php?view=login&task=forgot');
            $form1->addElement('header', null, 'Password Recovery: Step 1');
            $form1->addElement('text', 'handle', 'Enter your login handle:');
            $form1->addElement('submit', null, 'Next');
            $form1->applyFilter('handle', 'trim');
            $form1->applyFilter('handle', 'strtolower');
            $form1->addRule('handle', 'Your login handle is required.', 'required', null, 'client');
            if ($form1->validate()) {
                redirect('index.php?view=login&task=forgot2&handle=' . $form1->getSubmitValue('handle'));
            } else {
                $form1->display();
                ?>
<p><strong>Please note:</strong> Due to the lack of emailing support on our server (Yes! We require better servers!), you'll have to wait a few
hours before we can mail you your new password manually.</p> 
<?php 
            }
            break;
        case 'forgot2':
            $res =& db_query('user_by_handle', $_GET['handle']);
            if ($res->numRows() == 0) {
                $res->free();
                ?>
<p>The given login handle does not exist!</p>
<?php 
            } else {
                $res->fetchInto($row);
                $res->free();
                if ($row['question'][strlen($row['question']) - 1] != '?') {
                    $row['question'] .= '?';
                }
                $form2 = new HTML_QuickForm('forgotForm2', 'post', 'index.php?view=login&task=forgot2&handle=' . $_GET['handle']);
                $form2->addElement('header', null, 'Password Recovery: Step 2');
                $form2->addElement('static', null, 'Secret Question:', $row['question']);
                $form2->addElement('text', 'secret', 'Secret Answer:');
                $form2->addElement('submit', null, 'Next');
                $form2->applyFilter('secret', 'trim');
                $form2->addRule('secret', 'Answer is required for verification.', 'required', null, 'client');
                if ($form2->validate()) {
                    if ($form2->getSubmitValue('secret') == $row['secret']) {
                        $res =& db_query('clean_forgot', $row['user_id']);
                        $new_pass = Text_Password::create(10);
                        $res =& $db->autoExecute('users', array('password' => crypt($new_pass)), DB_AUTOQUERY_UPDATE, 'user_id=' . $row['user_id']);
                        if (PEAR::isError($res)) {
                            error($res->toString());
                        }
                        $res =& $db->autoExecute('forgot', array('user_id' => $row['user_id'], 'password' => $new_pass), DB_AUTOQUERY_INSERT);
                        if (PEAR::isError($res)) {
                            error($res->toString());
                        }
                        ?>
<p>Due to lack of emailing support on our server (Yes! We require better servers!), your password will
have to be emailed to you manually. You should receive your newly generated password within 12 hours.</p>
<?php 
                    } else {
                        ?>
<p><strong>Incorrect answer!</strong><br /> We need to verify your identity before we can proceed. Please try again.</p> 
<?php 
                        $form2->display();
                    }
                } else {
                    $form2->display();
                }
            }
            break;
        case 'profile':
            ?>
<p>You can view or edit your personal information here. 
Any fields that you leave blank will <i>remain unchanged</i>.</p>
<?php 
            $form = new HTML_QuickForm('profileForm', 'post', 'index.php?view=login&task=profile');
            $res =& db_query('user_by_id', $_SESSION['user_id']);
            $res->fetchInto($row);
            $res->free();
            $form->addElement('header', null, 'Edit Your Profile');
            $form->addElement('static', 'handle', 'Handle:');
            $form->addElement('password', 'password', 'Change Password:'******'password', 'password2', 'Retype Password:'******'text', 'email', 'Email:');
            $form->addElement('header', null, 'Personal Information');
            $form->addElement('text', 'first_name', 'First Name:');
            $form->addElement('text', 'last_name', 'Last Name:');
            $date = getdate();
            $form->addElement('date', 'birth_date', 'Date of Birth:', array('minYear' => $date['year'] - 100, 'maxYear' => $date['year']));
            $form->addElement('text', 'address', 'Street Address:');
            $form->addElement('text', 'city', 'City:');
            $form->addElement('text', 'state', 'State:');
            $form->addElement('text', 'zip', 'Zip:');
            $form->addElement('static', null, 'Division:', $cfg['tcl']['divisions'][$row['division']]);
            $form->addElement('text', 'phone', 'Phone:');
            $form->addElement('textarea', 'quote', 'Quote:');
            $form->addElement('submit', null, 'Save Changes');
            unset($row['password']);
            // Format the birth date
            $row['birth_date'] = sql2form_date($row['birth_date']);
            $form->setDefaults($row);
            $form->applyFilter('email', 'trim');
            $form->applyFilter('first_name', 'trim');
            $form->applyFilter('last_name', 'trim');
            $form->applyFilter('address', 'trim');
            $form->applyFilter('state', 'trim');
            $form->applyFilter('city', 'trim');
            $form->applyFilter('zip', 'trim');
            $form->applyFilter('phone', 'trim');
            $form->addRule('password', 'Password must be between 6 and 15 characters.', 'rangelength', array(4, 15), 'client');
            $form->addRule('email', 'Email is invalid.', 'email', null, 'client');
            $form->addRule(array('password', 'password2'), 'Passwords much match.', 'compare', null, 'client');
            if ($form->validate()) {
                $data = $form->getSubmitValues();
                unset($data['password2']);
                // Format the birth date correctly
                $data['birth_date'] = form2sql_date($data['birth_date']);
                foreach ($data as $key => $value) {
                    if ($value == $row['value'] || strlen($value) == 0) {
                        unset($data[$key]);
                    }
                }
                //print_r($data);
                auth_update($data);
                redirect('index.php?view=login&task=profile&updated=1');
            } else {
                $form->display();
            }
            if ($_GET['updated'] == '1') {
                ?>
                <p><b>Note:</b> Your profile has been updated.</p>
            <?php 
            }
            break;
    }
}