public static function validate($user_id) { if (empty($_SERVER['REMOTE_ADDR'])) { return false; } $long_ip = self::_ip2long($_SERVER['REMOTE_ADDR']); if ($long_ip === false) { return false; } $criteria = new CDbCriteria(); $criteria->compare('t.uxip_user_id', $user_id); $user_ip_list = UxipUserXIpTable::model()->findAll($criteria); foreach ($user_ip_list as $user_ip) { $ip = IptbIpTable::model()->findByPk($user_ip->uxip_iptb_id); if ($ip->iptb_status == BaseIptbIpTable::IPTB_STATUS_ACTIVE) { $long_from = self::_ip2long($ip->iptb_from); $long_to = self::_ip2long($ip->iptb_to); if ($long_from === false || $long_to === false) { continue; } if ($long_ip >= $long_from && $long_ip <= $long_to) { return true; } } } return false; }
public function loadModel($id) { $m = IptbIpTable::model(); // apply scope, if available $scopes = $m->scopes(); if (isset($scopes[$this->scope])) { $m->{$this->scope}(); } $model = $m->findByPk($id); if ($model === null) { throw new CHttpException(404, UserModule::t('The requested page does not exist.')); } return $model; }
} } else { //get user sys companies foreach ($companies_list as $mCcmp) { $list[$mCcmp['ccmp_id']] = $mCcmp['ccmp_name']; } } $body = CHtml::checkBoxList('user_sys_ccmp_id', $aChecked, $list, array('labelOptions' => array('style' => 'display: inline'), 'template' => '{input}<span class="lbl"></span> {label}', 'class' => 'ace')); $this->widget('AceBox', array('header_text' => UserModule::t('Sys companies'), 'body' => $body)); /** * IP Tables */ $security_policy = Yii::app()->getModule('user')->SecurityPolicy; if ($security_policy['useIpTables']) { $aChecked = UxipUserXIpTable::model()->getUserIpTables($model->id); $Iptb_list = IptbIpTable::model()->findAll(); $list = array(); foreach ($Iptb_list as $Iptb) { $list[$Iptb['iptb_id']] = Yii::t('roles', $Iptb['iptb_name']); } $body = CHtml::checkBoxList('ip_tables', $aChecked, $list, array('labelOptions' => array('style' => 'display: inline'), 'template' => '{input}<span class="lbl"></span> {label}', 'class' => 'ace')); $this->widget('AceBox', array('header_text' => UserModule::t('IP Tables'), 'body' => $body)); } ?> <div class="btn-toolbar pull-left"> <div class="btn-group"> <?php $this->widget("bootstrap.widgets.TbButton", array("label" => UserModule::t("Save"), "icon" => "icon-thumbs-up icon-white", "size" => "large", "type" => "primary", "htmlOptions" => array("onclick" => "\$('#user-rolls').submit();"), "visible" => Yii::app()->user->checkAccess("UserAdmin")));