Beispiel #1
0
 public function create($d = array())
 {
     $withoutConfirm = isset($d['withoutConfirm']) ? $d['withoutConfirm'] : false;
     $mainEngine = $this->getMainEngine();
     if ($mainEngine) {
         // Confirnation will be processed by subscribe engine, here it will be created in active state
         $withoutConfirm = true;
     }
     if (isset($d['email']) && !empty($d['email'])) {
         if (is_email($d['email'])) {
             $d['email'] = trim($d['email']);
             $params = array('email' => $d['email'], 'created' => dbCsp::timeToDate(), 'ip' => utilsCsp::getIP(), 'active' => $withoutConfirm ? 1 : 0, 'token' => md5($d['email'] . AUTH_KEY));
             if (isset($d['name']) && !empty($d['name'])) {
                 $params['name'] = $d['name'];
             }
             /*$defSystem = frameCsp::_()->getModule('options')->get('sub_synchronize_system') ;
             		switch($defSystem) {*/
             /*case 'aweber':
             		$listId = frameCsp::_()->getModule('options')->get('sub_aweber_selected_list');
             		$aweberModule = frameCsp::_()->getModule('aweber'); 
             		$params['listId'] = $listId;
             		if($aweberModule->createNewAweberSubscriber($params)){
             			return true;
             		}else{
             			$this->pushError( langCsp::_($aweberModule->getErrors()) );
             			return false;
             		}
             		break;*/
             //default:
             if (!frameCsp::_()->getTable('subscribers')->exists($d['email'], 'email')) {
                 if (frameCsp::_()->getTable('subscribers')->insert($params)) {
                     if ($mainEngine) {
                         $mainEngine->subscribe($params);
                     }
                     $this->processEnginesSubscribe($params, $mainEngine);
                     if (!$withoutConfirm) {
                         $this->sendConfirmEmail($d['email']);
                     }
                     return true;
                 } else {
                     $this->pushError(langCsp::_('Error insert email to database'));
                 }
             } else {
                 $this->pushError(langCsp::_('You are already subscribed'));
             }
             /*break;
             		}*/
         } else {
             $this->pushError(langCsp::_('Invalid email'));
         }
     } else {
         $this->pushError(langCsp::_('Please enter email'));
     }
     return false;
 }
Beispiel #2
0
 public function checkIp()
 {
     $ip = utilsCsp::getIP();
     if (frameCsp::_()->getTable('access')->get('*', array('access' => $ip, 'type_access' => 1))) {
         return false;
     } else {
         return true;
     }
 }