public function actionDeleteIp($ip_address)
 {
     $model = Ipaddress::model()->findByAttributes(array('ip_address' => $ip_address));
     if ($model) {
         $model->delete();
     } else {
         throw new CHttpException(404, "Can't find IP Address in the database");
     }
 }
Example #2
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $provisioning = Provisioning::all();
     $customers = Customer::all();
     $onts = Ont::all();
     $accessSwitches = AccessSwitch::all();
     $dhcpSharedNetworks = DhcpSharedNetwork::all();
     $ipaddresses = Ipaddress::all();
     $ports = AccessSwitchPort::all();
     return view('home')->with('provisioning', $provisioning)->with('customers', $customers)->with('onts', $onts)->with('accessSwitches', $accessSwitches)->with('ports', $ports)->with('ipaddresses', $ipaddresses)->with('DhcpSharedNetworks', $dhcpSharedNetworks);
 }
 /**
  * Generates temporary file that has the new htaccess configuration
  * @return string Returns path of generated file containing the htaccess configuration
  */
 public function generateFile()
 {
     $rowTemplate = " allow from %s";
     $generatedRowsArr = array();
     $generatedRowsStr = '';
     $generatedHtAccessConfStr = '';
     Yii::trace('retrieving all ip address', 'dev_trace');
     $allIpAddressesMdls = Ipaddress::model()->findAll();
     foreach ($allIpAddressesMdls as $currentIpAddressMdl) {
         $generatedRowsArr[] = sprintf($rowTemplate, $currentIpAddressMdl->ip_address);
     }
     $generatedRowsStr = implode(PHP_EOL, $generatedRowsArr);
     Yii::trace('generating htaccess configuration string', 'dev_trace');
     $generatedHtAccessConfStr = sprintf($this->getHtaccessTemplate(), $generatedRowsStr);
     Yii::trace('creating and writing the configuration string to temporary file', 'dev_trace');
     $tempFileLoc = tempnam(sys_get_temp_dir(), 'htaccess');
     file_put_contents($tempFileLoc, $generatedHtAccessConfStr);
     Yii::trace('return generated temporary file', 'dev_trace');
     return $tempFileLoc;
 }
Example #4
0
 function getandwriteipaddress()
 {
     global $gbl, $sgbl, $login, $ghtml;
     dprint($this->nname);
     $rmt = new Remote();
     $driverapp = $gbl->getSyncClass($this->__masterserver, $this->nname, 'ipaddress');
     if (!$driverapp) {
         print "NO driverapp for ipaddress\n";
         exit;
     }
     $rmt->func = array("Ipaddress__{$driverapp}", "listSystemIps");
     $rmt->arglist = array($this->nname);
     $rmt->action = 'get';
     $rmt->slave_password = $this->realpass;
     $gbl->pserver_password = $this->realpass;
     $result = rl_exec(null, $this->nname, $rmt);
     if (!$result) {
         dprint("No Result <br> <br> \n\n\n");
     }
     //dprintr($result);
     // hack hack hack
     // Direclty call 'was' to sync the pserver. This is needed because this is an out of the way Action, to remove the ipaddress from the database before the newly got ones are added in.
     $iplist = $this->getList("ipaddress");
     if ($iplist) {
         foreach ($iplist as $ip) {
             $exclusive_client[$ip->nname] = $ip->clientname;
             $ip->dbaction = 'delete';
             $ip->write();
             $ip->dbaction = 'clean';
         }
         //$this->was();
     }
     foreach ($result as $row) {
         if (!trim($row['ipaddr'])) {
             continue;
         }
         $row['nname'] = $row['devname'] . "___" . $this->syncserver;
         $row['syncserver'] = $this->syncserver;
         $row['parent_clname'] = $this->getClName();
         if (isset($exclusive_client[$row['nname']])) {
             $row['clientname'] = $exclusive_client[$row['nname']];
         }
         $obj = new Ipaddress($this->__masterserver, $this->syncserver, $row['nname']);
         $obj->create($row);
         $obj->write();
         $obj->dbaction = 'clean';
     }
 }
Example #5
0
 /**
  * 
  * @method post
  * @route /validator/ipaddress
  */
 public function ipAddressAction()
 {
     $params = $this->getParams('post');
     $jsonResponse = Ipaddress::validate($params['ipaddress']);
     return $jsonResponse['success'];
 }
 public function actionAllow($ip)
 {
     $model = Ipaddress::model()->findByAttributes(array('ip_address' => $ip));
     if ($model) {
         $model->status = Ipaddress::IP_ADDRESS_STATUS_WHITELIST;
         if ($model->update()) {
             Yii::app()->user->setFlash("success", "IP Address {$ip} is now allowed");
         } else {
             Yii::app()->user->setFlash("error", CHtml::errorSummary($model));
         }
         $this->redirect($this->createAbsoluteUrl("site/index"));
     } else {
         throw new CHttpException(404, "Sorry ip address {$ip} doesn't exists");
     }
 }