Beispiel #1
0
 public function __construct($id)
 {
     $server = Servers::model()->findByPK($id);
     $http = new http();
     $http->setTimeout(10);
     $this->moment = new moment($http, array('server_ip' => $server->ip, 'server_port' => $server->s_port, 'web_port' => $server->w_port));
 }
 public function actionDelete()
 {
     if (Servers::model()->deleteByPk($_GET['id'])) {
         Yii::app()->user->setFlash('success', "Deleted!");
         $this->redirect($this->createUrl("index"));
     } else {
         Yii::app()->user->setFlash('error', "Error!");
         $this->redirect($this->createUrl("index"));
     }
 }
 public function actionCreate()
 {
     $data = $_POST;
     // clean input here
     $data['application_id'] = trim($data['application_id']);
     $data['server_id'] = trim($data['server_id']);
     $data['application_path'] = trim($data['application_path']);
     $data['application_log'] = trim($data['application_log']);
     if (!empty($data)) {
         //FORM VALIDATION HERE
         $errors = array();
         // server is required
         if (strlen($data['server_id']) == 0) {
             array_push($errors, 'SERVER_ERROR: Please choose a server');
             // server chosen does not exist
         } else {
             if (!Servers::model()->exists('server_id=:server_id', array(':server_id' => $data['server_id']))) {
                 array_push($errors, 'SERVER_ERROR: Server does not exist');
                 // server is taken
             } else {
                 if (ApplicationServers::model()->findByPk(array('server_id' => $data['server_id'], 'application_id' => $data['application_id'])) != null) {
                     array_push($errors, 'SERVER_ERROR: The application is already in this server');
                     // check if application is already in a server of the same type
                 } else {
                     if ($data['check_duplicate'] == 'true') {
                         $duplicate_type = Servers::model()->findAll(array('join' => 'JOIN application_servers a ON t.server_id = a.server_id', 'condition' => 'a.application_id=:application_id AND t.server_type=:server_type', 'params' => array('application_id' => $data['application_id'], 'server_type' => $data['server_type'])));
                         if (count($duplicate_type) != 0) {
                             array_push($errors, 'DUPLICATE_ERROR: The application is already in a server of the same type.');
                         }
                     }
                 }
             }
         }
         //data is good
         if (count($errors) == 0) {
             $app_server = new ApplicationServers();
             $app_server->application_id = $data['application_id'];
             $app_server->server_id = $data['server_id'];
             $app_server->application_path = $data['application_path'];
             $app_server->application_log = $data['application_log'];
             $app_server->date_created = date("Y-m-d H:i:s");
             $app_server->date_updated = '0000-00-00 00:00:00';
             $app_server->created_by = Yii::app()->user->name;
             $app_server->save();
             echo CJSON::encode(array('type' => 'success', 'data' => ''));
         } else {
             echo CJSON::encode(array('type' => 'error', 'data' => implode(',', $errors)));
         }
     } else {
         echo CJSON::encode(array('type' => 'error', 'data' => 'CSRF_ERROR: CSRF Token did not match'));
     }
 }
Beispiel #4
0
echo CHtml::submitButton($model->isNewRecord ? Yii::t('cams', 'Add') : Yii::t('cams', 'Save'), array('class' => 'btn btn-primary'));
?>
					</div>
				</div>
				<?php 
$this->endWidget();
?>
			</div>

		</div>

	</div>
</div>
<?php 
if ($model->server_id) {
    $server = Servers::model()->findByPK($model->server_id);
}
if (Yii::app()->user->hasFlash('notify')) {
    $notify = Yii::app()->user->getFlash('notify');
    ?>
	<div class="alert alert-<?php 
    echo $notify['type'];
    ?>
"><?php 
    echo $notify['message'];
    ?>
.
		<?php 
    echo Yii::t('cams', 'Go to {user CP}', array('{user CP}' => CHtml::link(Yii::t('cams', 'personal cabinet'), $this->createUrl('cams/manage'))));
    ?>
			?
Beispiel #5
0
	iconAnchor:   [15, 20],
	shadowAnchor: [15, 20],
	popupAnchor:  [0, -10]
	}
});
var buildind_icon = new LeafIcon({iconUrl: '/images/building_icon.png'});

var markers_cluster = new L.MarkerClusterGroup();

		<?php 
$servers = array();
foreach ($myCams as $cam) {
    if (isset($servers[$cam->server_id])) {
        $server = $servers[$cam->server_id];
    } else {
        $servers[$cam->server_id] = Servers::model()->findByPK($cam->server_id);
        $server = $servers[$cam->server_id];
    }
    if (!$cam->show) {
        continue;
    }
    ?>
				cams_hashes["<?php 
    echo $cam->id;
    ?>
"] = {low:"<?php 
    echo $cam->getSessionId(true);
    ?>
",
						server_ip:"<?php 
    echo $server->ip;
<?php

$server_types = ZHtml::enumItem(Servers::model(), 'server_type');
$select_types = array('' => '--Select Server Type--') + $server_types;
?>

<div id="app-main-list" class="table-main" style="display:none";>
    <fieldset>
        <input type="hidden" id="app-main-list-csrf" value="<?php 
echo Yii::app()->request->csrfToken;
?>
" />
        <div class="table-header-block">
            <div class="header-block-button">
                <a id="app-main-list-create-button" class="button round blue image-right ic-add text-upper" href="#">Create Application</a>
            </div><!-- End Header Block Button -->

            <div class="header-block-side">
                <div class="page-nav">
                    <div class="page-count">
                        <span class="current-page" id="app-main-list-part"></span>
                        <span class="all-page" id="app-main-list-total"></span>
                    </div>
                    <div class="page-nav-arrow">
                        <a id="app-main-list-prev" class="prev" href="#" title="Previous"><span class="icon"></span></a>
                        <a id="app-main-list-next" class="next" href="#" title="Next"><span class="icon"></span></a>
                    </div>
                </div>
            </div><!-- End Header Block Side -->
        </div><!-- End Table Header Block -->
        
Beispiel #7
0
 public function actionDelete()
 {
     $data = $_POST;
     if (!empty($data)) {
         Servers::model()->deleteByPk($data['server_id']);
         ApplicationServers::model()->deleteAll('server_id=:server_id', array(':server_id' => $data['server_id']));
         echo CJSON::encode(array('type' => 'success', 'data' => ''));
     } else {
         echo CJSON::encode(array('type' => 'error', 'data' => 'CSRF_ERROR: CSRF Token did not match'));
     }
 }
Beispiel #8
0
 public function actionEdit($id)
 {
     // TODO add check owner
     $model = Cams::model()->findByPK(Cams::model()->getRealId($id));
     if (!$model) {
         $this->redirect(array('manage'));
     }
     if (isset($_POST['Cams'])) {
         $model->attributes = $_POST['Cams'];
         $model->id = Cams::model()->getRealId($id);
         $model->user_id = Yii::app()->user->getId();
         if ($model->validate()) {
             $momentManager = new momentManager($model->server_id);
             if ($momentManager->edit($model) && $model->save()) {
                 Yii::app()->user->setFlash('notify', array('type' => 'success', 'message' => Yii::t('cams', 'Cam successfully changed')));
             } else {
                 Yii::app()->user->setFlash('notify', array('type' => 'danger', 'message' => Yii::t('cams', 'Cam not changed. Problem with nvr')));
             }
             $this->redirect(array('edit', 'id' => $model->id));
         }
     }
     $servers = array();
     $server = Servers::model()->findAll(array('select' => 'id, ip, comment'));
     foreach ($server as $s) {
         $servers[$s->id] = $s->ip . ($s->comment ? ' [ ' . $s->comment . ' ]' : '');
     }
     $this->render('edit', array('model' => $model, 'servers' => $servers));
 }
Beispiel #9
0
            <div id="edit-primary-content" class="content">
                <div class="field field-input-name">
                <div class="field-secondary"><span class="label">Name*</span></div>
                    <div class="field-primary">
                        <div class="pseudo-field">
                        <input id="servers-edit-name" type="text" class="text"/>
                        <span id="servers-edit-name-error" class="field-input-name-error error-message" style="display: none;"></span>
                        </div>
                    </div><!-- End Field Primary -->
                </div><!-- End Field -->
                <div class="field field-input-name">
                    <div class="field-secondary"><span class="label">Type*</span></div>
                    <div class="field-primary">
                        <div class="pseudo-field">
                        <?php 
echo ZHtml::enumDropDownList(Servers::model(), 'server_type', array('id' => 'servers-edit-type', 'class' => 'select'));
?>
                        <span id="servers-edit-type-error" class="field-input-name-error error-message" style="display: none;"></span>
                        </div>
                    </div><!-- End Field Primary -->
                </div><!-- End Field -->
                <div class="field field-input-name">
                    <div class="field-secondary"><span class="label">Host</span></div>
                    <div class="field-primary">
                        <div class="pseudo-field">
                        <input id="servers-edit-host" type="text" class="text"/>
                        </div>
                    </div><!-- End Field Primary -->
                </div><!-- End Field -->
                <div class="field field-input-name">
                    <div class="field-secondary"><span class="label">Public IP</span></div>
Beispiel #10
0
 public function actionServerDelete($id)
 {
     $model = Servers::model()->findByPK($id);
     if (!$model) {
         $this->redirect(array('servers'));
     }
     if ($model->delete()) {
         Yii::app()->user->setFlash('notify', array('type' => 'success', 'message' => Yii::t('admin', 'Server deleted')));
     } else {
         Yii::app()->user->setFlash('notify', array('type' => 'danger', 'message' => Yii::t('admin', 'Server not deleted')));
     }
     $this->redirect(array('servers'));
 }