Example #1
0
 /**
  * Returns the error text if needed to prevent user activation
  * Пароль до активации и регистрации пользователя в phpBB хранится в открытом виде!
  * @param struct_core_users $user
  * @return string
  */
 protected function beforeActivateUser($user)
 {
     if (!($error = $this->phpBBRegister($user))) {
         $user->u_pass = rad_session::encodePassword($user->u_pass);
     }
     return $error;
 }
Example #2
0
 /**
  * Shows the image
  */
 public function show()
 {
     if (is_file($this->_kcaptchaFilename)) {
         include_once $this->_kcaptchaFilename;
         $this->_instanceCaptcha = new KCAPTCHA();
         rad_session::setVar($this->_sessionName, $this->_instanceCaptcha->getKeyString());
     } else {
         throw new rad_exception('KCaptcha library not found!');
     }
 }
Example #3
0
 function __construct()
 {
     if ($this->request('t')) {
         if (rad_themer::themeExists($this->request('t'))) {
             rad_session::setVar('theme', $this->request('t'));
         }
     } else {
         rad_session::setVar('theme', $this->config('theme.default'));
     }
     if (isset($_SERVER['HTTP_REFERER'])) {
         $this->redirect($_SERVER['HTTP_REFERER']);
     } else {
         $this->redirect($this->makeURL('alias=' . $this->config('defaultAlias')));
     }
 }
Example #4
0
 /**
  * Update user row
  * @var integer
  */
 public static function updateUser(struct_core_users $user)
 {
     $result = rad_dbpdo::update_struct($user, RAD . 'users');
     if ($result) {
         rad_session::$user = $user;
         $_SESSION['user_dump'] = $user;
     }
     return $result;
 }
Example #5
0
 /**
  * Register new user
  * @param struct_core_users $item
  */
 public function register($item, $encode_password = true)
 {
     $item->u_active = 1;
     $item->u_subscribe_active = 1;
     $item->u_subscribe_langid = $this->getCurrentLangID();
     $clearpass = empty($item->u_pass) ? rad_session::genereCode(6) : $item->u_pass;
     $item->u_pass = $encode_password ? rad_session::encodePassword($clearpass) : $clearpass;
     $this->insertItem($item);
     $item->u_id = $this->inserted_id();
     rad_instances::get('model_coremail_subscribes')->removeExpired();
     $item_url = new struct_coremail_subscribers_activationurl();
     $item_url->sac_url = md5(rad_session::genereCode(31) . now() . $item->u_id);
     $item_url->sac_scrid = $item->u_id;
     $item_url->sac_type = 2;
     $item_url->email = $item->u_email;
     $item_url->date_created = time();
     $item_url->save();
     rad_mailtemplate::send($item->u_email, $this->config('registration.template'), array('user' => $item, 'link' => rad_input::makeURL('alias=register&c=' . urlencode($item_url->sac_url)), 'clearpass' => $clearpass), $this->config('mail_format', 'html'));
 }
Example #6
0
 /**
  * Check and validate input data about user before saving
  * @return TRUE if OK, FALSE if wrong
  * @author Slavik Tereshchenko
  * @package RADCMS
  * @datecreated 21.12.2011
  */
 private function _verifyInputData($item)
 {
     $messages = array();
     $req = $this->getAllRequest();
     foreach ($req as $key => $value) {
         if (is_string($value)) {
             $req[$key] = strip_tags(stripslashes($value));
         }
     }
     $item->MergeArrayToStruct($req);
     if (empty($item->u_login)) {
         $messages[] = $this->lang('emptylogin.session.error');
     } elseif (rad_instances::get('model_core_users')->loginExists($item->u_login, $item->u_id)) {
         $messages[] = $this->lang('loginexists.session.error');
     }
     if (!filter_var($item->u_email, FILTER_VALIDATE_EMAIL)) {
         $messages[] = $this->lang('entervalidemail.session.error');
     } elseif (rad_instances::get('model_core_users')->emailExists($item->u_email, $item->u_id)) {
         $messages[] = $this->lang('mailexsists.session.message');
     }
     if ($this->request('changepass') !== NULL && $this->request('changepass') === 'on') {
         if ($this->request('u_pass') && $this->request('u_pass1') && $this->request('u_pass2')) {
             if (!strcmp($this->getCurrentUser()->u_pass, rad_session::encodePassword($this->request('u_pass')))) {
                 if (strlen($this->request('u_pass1')) >= 6) {
                     if (!strcmp($this->request('u_pass1'), $this->request('u_pass2'))) {
                         $item->u_pass = rad_session::encodePassword($this->request('u_pass1'));
                     } else {
                         $messages[] = $this->lang('passwordnotpassed.session.error');
                     }
                 } else {
                     $messages[] = $this->lang('passwordishort.session.error');
                 }
             } else {
                 $messages[] = $this->lang('passwordnotmatch.session.error');
             }
         } else {
             $messages[] = $this->lang('passwordishort.session.error');
         }
     } else {
         $item->u_pass = $this->getCurrentUser()->u_pass;
     }
     if (count($messages)) {
         $this->setVar('message', implode('<br />', $messages));
         return false;
     }
     return true;
 }
Example #7
0
 public static function getAliasByName(&$aliasname = '')
 {
     $result = self::getAliasRecord($aliasname);
     if (!$result->id || !$result->active) {
         rad_session::setVar('message', $aliasname);
         $aliasname = rad_config::getParam('alias.404');
         $result = self::getAliasRecord(self::$alias);
         header(rad_config::getParam('header.404'));
     }
     if ($result->ali_admin && !rad_session::adminAccess()) {
         rad_session::setVar('message', $aliasname);
         rad_session::logout();
         $aliasname = rad_config::getParam('alias.loginform');
         $result = self::getAliasRecord(self::$alias);
     }
     if ($result->id) {
         $result->includes = array();
         $themeId = $result->themeid ? $result->themeid : 0;
         $sqlParams = array('alias_1_id' => $result->id, 'theme_1_id' => $themeId);
         if ($result->group_id) {
             $sqlParams['alias_2_id'] = $result->group_id;
             $theme2Id = rad_dbpdo::query('SELECT theme_id FROM ' . RAD . 'themes WHERE theme_aliasid=? AND theme_folder=?', array($result->group_id, rad_themer::getCurrentTheme()));
             $theme2Id = !empty($theme2Id['theme_id']) ? (int) $theme2Id['theme_id'] : $themeId;
             $sqlParams['theme_2_id'] = $theme2Id;
         }
         $sql = 'SELECT inc_id,inc_name,inc_filename,controller,order_sort,rp_name,id_module,m_name,params_hash,ina.id as incinal_id,ina.params_presonal as params_presonal, ip.ip_params as original_params ' . 'FROM ' . RAD . 'includes_in_aliases ina ' . 'INNER JOIN ' . RAD . 'includes on include_id=inc_id ' . 'INNER JOIN ' . RAD . 'modules m on m.m_id=id_module ' . 'INNER JOIN ' . RAD . 'positions p on position_id=p.rp_id ' . 'LEFT JOIN ' . RAD . 'includes_params ip on ip.ip_incid=ina.include_id ' . 'WHERE alias_id=:alias_1_id' . ' AND ina.theme_id=:theme_1_id' . ($result->group_id ? ' UNION (SELECT inc_id,inc_name,inc_filename,controller,order_sort,rp_name,id_module,m_name,params_hash,ina.id as incinal_id,ina.params_presonal as params_presonal, ip.ip_params as original_params ' . 'FROM ' . RAD . 'includes_in_aliases ina ' . 'INNER JOIN ' . RAD . 'includes on include_id=inc_id ' . 'INNER JOIN ' . RAD . 'modules m on m.m_id=id_module ' . 'INNER JOIN ' . RAD . 'positions p on position_id=p.rp_id ' . 'LEFT JOIN ' . RAD . 'includes_params ip on ip.ip_incid=ina.include_id ' . 'WHERE alias_id=:alias_2_id' . ' AND ina.theme_id=:theme_2_id' . ')' : '') . ' ORDER BY order_sort, rp_name';
         foreach (rad_dbpdo::queryAll($sql, $sqlParams) as $id) {
             $result->includes[] = new struct_core_include($id);
         }
     } else {
         $result = NULL;
     }
     return $result;
 }
Example #8
0
 /**
  * Adds the product from add product form
  * full post request
  */
 function add()
 {
     $parent_id = (int) $this->request('parent_id');
     $this->product = $this->_assignProductFromRequest();
     $this->product->cat_datecreated = now();
     if (!empty($this->product->images_link)) {
         rad_session::setVar('iterator_init', max(array_keys($this->product->images_link)) + 1);
     }
     if ($this->product && $this->checkProduct()) {
         $model = rad_instances::get('model_corecatalog_catalog');
         if ($this->_have_sp or $this->_have_sphit or $this->_have_spnews or $this->_have_spoffer) {
             $model->setState('sp_offers', true);
         }
         $newItem = $model->insertItem($this->product);
         if (rad_config::getParam('cleanurl.on')) {
             rad_cleanurl::setAlias('product', $newItem->cat_id, $this->getContentLangID(), $this->post('url_alias'));
         }
         if ($this->request('returntorefferer') == '0') {
             $url = $this->makeURL('alias=' . SITE_ALIAS);
         } else {
             //if apply clicked
             $url = $this->makeURL('alias=' . SITE_ALIAS . '&action=editform&cat_id=' . $newItem->cat_id);
         }
         if (strlen($parent_id) > 0) {
             $url .= '#nic/' . $parent_id;
         }
         rad_session::setVar('iterator_init', NULL);
         $this->redirect($url);
     }
     return false;
 }
Example #9
0
 /**
  * Start order page - show the basket
  *
  */
 function startPage()
 {
     model_corecatalog_currcalc::init();
     $this->setVar('curr', model_corecatalog_currcalc::$_curcours);
     $model = rad_instances::get('model_corecatalog_bin');
     $ct_showing = $this->getParamsObject() ? $this->getParamsObject()->ct_showing : NULL;
     $items = $model->getCartProducts(NULL, NULL, $ct_showing);
     $bin_pos = $model->getItemsCart();
     $counts = array();
     $bin_ids = array();
     $total_count = 0;
     $total_costs = 0;
     if (count($bin_pos)) {
         foreach ($bin_pos as $id) {
             $counts[$id->bp_catid] = $id->bp_count;
             $bin_ids[$id->bp_catid] = $id->bp_id;
         }
     }
     $countElement = count($items);
     for ($i = 0; $i < $countElement; $i++) {
         $items[$i]->cost = $items[$i]->cat_cost;
         $items[$i]->cat_cost = model_corecatalog_currcalc::calcCours($items[$i]->cat_cost, $items[$i]->cat_currency_id);
         $items[$i]->cat_count = $counts[$items[$i]->cat_id];
         $total_count += $items[$i]->cat_count;
         $total_costs += $items[$i]->cat_cost * $items[$i]->cat_count;
         $items[$i]->bp_id = $bin_ids[$items[$i]->cat_id];
     }
     $this->setVar('items', $items);
     $this->setVar('total_count', $total_count);
     $this->setVar('total_costs', $total_costs);
     $this->setVar('hash', $this->hash());
     $userInfo = rad_session::getVar('user_dump');
     if (!empty($userInfo)) {
         $this->setVar('userInfo', $userInfo);
     }
     if ($this->_showDelivery) {
         $this->assignDelivery();
     }
 }
Example #10
0
 protected function sendNewPassword()
 {
     $messages = array();
     $actcode = $this->request('actcode');
     $model = rad_instances::get('model_coremail_subscribes');
     $item = $model->removeExpired()->setState('sac_url', $actcode)->setState('sac_type', 3)->getActivationUrl();
     if (!empty($item->sac_id)) {
         $user = rad_instances::get('model_core_users')->setState('u_id', (int) $item->sac_scrid)->getItem();
         if (!empty($user->u_id)) {
             $password = rad_session::genereCode(6);
             $user->u_pass = rad_session::encodePassword($password);
             if (!($error = $this->beforeSaveNewPassword($user, $password))) {
                 $user->save();
                 $item->remove();
                 $this->_sendMail($user, 'newpass', array('clearpass' => $password));
                 $this->setVar('pass_sent', true);
             } else {
                 $messages[] = $error;
             }
         } else {
             $messages[] = $this->lang('usernotfound.session.error');
         }
     } else {
         $messages[] = $this->lang('wrongcode.session.error');
     }
     if (count($messages)) {
         $this->setVar('message', implode('<br />', $messages));
     }
 }
Example #11
0
}
$mem = memory_get_usage();
require 'config.php';
foreach ($config['db_delimiters'] as $id => $value) {
    define($id, $value);
}
foreach ($config['folders'] as $id => $value) {
    define($id, $value);
}
define('SITE_URL', $config['url']);
require LIBPATH . 'simplefunctions.php';
$time_start = microtime_float();
foreach ($config as $id => $value) {
    if (!is_array($value)) {
        rad_config::setParam($id, $value);
    }
}
rad_config::loadConfig();
rad_exception::setHandlers();
rad_input::init_all();
rad_session::start();
define('SITE_ALIAS', rad_input::get('alias', rad_config::getParam('defaultAlias', 'index.html')));
rad_lang::init();
call_user_func(array(rad_config::getParam('loader_class'), 'init'));
if (rad_config::getParam('lang.caching')) {
    call_user_func(array(rad_config::getParam('loader_class'), 'saveLangCache'));
}
/*
$time_end = microtime_float();
$time = $time_end - $time_start;
*/
Example #12
0
 /**
  * Destroy the session
  *
  */
 public static function logout()
 {
     self::$is_admin = 0;
     self::$user = null;
     unset($_SESSION['user'], $_SESSION['pass'], $_SESSION['user_dump']);
     if (!session_regenerate_id(true)) {
         session_destroy();
         session_start();
     }
 }
Example #13
0
 function socialsLogin()
 {
     $allowed_providers = array('facebook');
     $provider = strtolower($this->request('provider'));
     if ($provider and in_array($provider, $allowed_providers)) {
         $hybridauth = new Hybrid_Auth($this->_config);
         $service = $hybridauth->authenticate($provider);
         if ($service->isUserConnected()) {
             $user_profile = $service->getUserProfile();
             if ($user_profile->identifier) {
                 $modelUsers = rad_instances::get('model_core_users');
                 $modelUsers->setState('u_' . $provider . '_id', $user_profile->identifier);
                 $user = $modelUsers->getItem();
                 if (!$user) {
                     if ($user_profile->email) {
                         $modelUsers->clearState();
                         $modelUsers->setState('u_email', $user_profile->email);
                         $user = $modelUsers->getItem();
                         if ($user) {
                             //add social identifier to user
                             switch ($provider) {
                                 case 'facebook':
                                     $user->u_facebook_id = $user_profile->identifier;
                                     break;
                                 case 'twitter':
                                     $user->u_twitter_id = $user_profile->identifier;
                                     break;
                             }
                             $modelUsers->updateItem($user);
                         }
                     }
                     if (!$user) {
                         // create new user
                         $user = new struct_core_users();
                         $user->u_login = $user_profile->displayName ? $user_profile->displayName : '';
                         $user->u_email = $user_profile->email ? $user_profile->email : '';
                         $user->u_group = $this->_treestart;
                         $user->u_email_confirmed = 1;
                         $user->u_fio = $user_profile->firstName ? $user_profile->firstName : '';
                         $user->u_fio = $user_profile->lastName ? $user->u_fio . ' ' . $user_profile->lastName : $user->u_fio;
                         $user->u_address = $user_profile->country ? $user_profile->country : '';
                         $user->u_address = $user_profile->region ? $user->u_address . ', ' . $user_profile->region : $user->u_address;
                         $user->u_address = $user_profile->city ? $user->u_address . ', ' . $user_profile->city : $user->u_address;
                         $user->u_address = $user_profile->address ? $user->u_address . ', ' . $user_profile->address : $user->u_address;
                         $user->u_phone = $user_profile->phone ? $user_profile->phone : '';
                         $user->u_subscribe_active = 0;
                         switch ($provider) {
                             case 'facebook':
                                 $user->u_facebook_id = $user_profile->identifier;
                                 break;
                             case 'twitter':
                                 $user->u_twitter_id = $user_profile->identifier;
                                 break;
                         }
                         $modelUsers->insertItem($user);
                         $user->u_id = $modelUsers->inserted_id();
                     }
                 }
                 if (rad_session::social_login($user_profile->identifier, $provider)) {
                     $this->setVar('user', $this->getCurrentUser());
                     $this->redirect($this->makeURL('action=soc_refresh'));
                 } else {
                     //login incorrect
                     $this->setVar('message_error', $this->lang('error.session.message'));
                     $this->setVar('req', $this->getAllRequest());
                 }
             }
         } else {
             throw new Exception("Can not connect to the service!");
         }
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }
Example #14
0
 /**
  * Change the content language
  * @param integer $newlangId
  * @return boolean
  */
 public static function changeContentLanguage($newlangId)
 {
     foreach (self::$allLanguages as $id) {
         if ($id->lng_id == $newlangId) {
             $user = rad_session::$user;
             if (isset($user->u_id) and $user->u_id) {
                 $paramsobject = rad_session::$user_params;
                 $paramsobject->_set('contentLng', $newlangId, 'string');
                 $user->u_params = $paramsobject->_hash();
                 if (!rad_instances::get('model_core_users')->updateItem($user)) {
                     echo 'alert("can\'t change language! some error!");';
                 }
                 rad_session::setVar('contentLng', $newlangId);
             }
             return rad_session::setVar('contentLng', $newlangId);
         }
     }
     $false = false;
     return $false;
 }