Пример #1
0
 public function actionSetlang()
 {
     if (!isset($_GET['lang'])) {
         return $this->goBack();
     }
     $lang = $_GET['lang'];
     $langs = isset(Yii::$app->params['langs']) ? Yii::$app->params['langs'] : array();
     if (!isset($langs[$lang])) {
         return $this->goBack();
     }
     $session = new Session();
     $session->open();
     $session['lang'] = $lang;
 }
Пример #2
0
 public function actionLogin()
 {
     $modelLoginFrom = new LoginForm();
     if ($modelLoginFrom->load(\Yii::$app->getRequest()->getBodyParams(), '') && $modelLoginFrom->login()) {
         $post = \Yii::$app->getRequest()->getBodyParams();
         $modelUser = new User();
         $modelRole = new Role();
         $result = $modelRole->find()->where(['=', 'id', \Yii::$app->user->identity->getRole()])->all();
         $resultuserdata = $modelUser->find()->where(['=', 'name', $post['name']])->one();
         $session = new Session();
         $session->open();
         $session->set('role', $result[0]->name);
         $session->close();
         return ['username' => $post['name'], 'role' => $result[0]->name, 'isLogined' => true, 'userDataID' => $resultuserdata->id];
     } else {
         return $modelLoginFrom;
     }
 }
Пример #3
0
 public function logout()
 {
     \Auth::logout();
     \Session::flush();
     //\Session::forget();
     sleep(1);
     \Auth::logout();
     if (\Auth::check()) {
         $user = \Auth::user();
         $user->last_active_time = time() - 3600;
         $user->updateStatus(0);
         $user->save();
     }
     return \Redirect::to('/');
 }
Пример #4
0
 public function checkLogin()
 {
     if (!isset($_POST['username']) || !isset($_POST['password']) || empty($_POST['username'])) {
         Session::set('error', "Login credentials were empty or missing.");
         header("Location: " . BASE_URL . "/login");
         exit;
     }
     # Check credentials and then get the account id
     $accountID = $this->model->checkCredentials();
     if (!$accountID) {
         Session::set('error', $this->model->errorMsg);
         header("Location: " . BASE_URL . "/login");
         exit;
     }
     # Check for account info and assign to session
     if (isset($accountID) && !empty($accountID)) {
         Session::set('accountID', $accountID);
         header("Location: " . BASE_URL . "/home");
         exit;
     }
     Session::set('error', "Login has failed.");
     header("Location: " . BASE_URL . "/login");
     exit;
 }
 public function vkData()
 {
     $vk = $this->socialauthRepository->vk();
     $callback = \URL::route('vk-auth-data');
     if ($code = \Input::get('code')) {
         if (\Session::has('vk_token')) {
             $accessToken = \Session::get('vk_token');
         } else {
             $vkToken = $vk->getAccessToken($code, $callback);
             $accessToken = $vkToken;
             \Session::put('vk_token', $accessToken);
         }
         $result = $vk->api('getProfiles', ['uids' => $accessToken['user_id'], 'fields' => 'uid, first_name, last_name, nickname, screen_name, photo_big, gender']);
         $userProfile = $result['response'][0];
         /**
          * @var $first_name
          * @var $last_name
          * @var $screen_name
          * @var $uid
          * @var $gender
          */
         extract($userProfile);
         $details = ['fullname' => $first_name . ' ' . $last_name, 'genre' => '', 'country' => '', 'email_address' => '', 'password' => time(), 'username' => $screen_name, 'auth' => 'vk', 'authId' => $uid];
         return $this->socialauthRepository->register($details);
     } else {
         return \Redirect::route('vk-auth');
     }
 }
Пример #6
0
 public function filterData()
 {
     $in = Input::get('kode_prodi');
     $a = Input::get('semester');
     if (empty($in)) {
         return Redirect::to('administrator/rekapitulasi/cetakLaporan')->with('msge', 'Maaf.....<br>Inputan tidak beleh kosong!');
     } else {
         $rekap = Rekap::where('kode_prodi', '=', $in)->orWhere('semester', '=', $a)->get();
         dd($rekap);
         if ($rekap == null) {
             Session::flash('msge', 'Data kosong!');
             return Redirect::to('administrator/rekapitulasi');
         } else {
             return View::make('rekapitulasi.index', $rekap);
         }
     }
 }
Пример #7
0
 public function installSave()
 {
     try {
         //Getting our input from the Input library
         $input = Input::all();
         //Rules
         $rules = array('password' => 'required', 'email' => 'required');
         // Validate Rules Input Fields
         $validation = Validator::make($input, $rules);
         if ($validation->fails()) {
             return Redirect::to('install')->with_errors($validation);
         }
         if (Schema::hasTable('users') == false) {
             Schema::create('users', function ($table) {
                 $table->increments('id');
                 $table->string('email');
                 $table->string('password');
                 $table->text('permissions')->nullable();
                 $table->boolean('activated')->default(0);
                 $table->string('activation_code')->nullable();
                 $table->timestamp('activated_at')->nullable();
                 $table->timestamp('last_login')->nullable();
                 $table->string('persist_code')->nullable();
                 $table->string('reset_password_code')->nullable();
                 $table->string('first_name')->nullable();
                 $table->string('last_name')->nullable();
                 $table->text('remember_token')->nullable();
                 $table->timestamps();
                 // We'll need to ensure that MySQL uses the InnoDB engine to
                 // support the indexes, other engines aren't affected.
                 // $table->engine = 'InnoDB';
                 $table->unique('email');
                 $table->index('activation_code');
                 $table->index('reset_password_code');
             });
         }
         if (Schema::hasTable('groups') == false) {
             Schema::create('groups', function ($table) {
                 $table->increments('id');
                 $table->string('name');
                 $table->text('permissions')->nullable();
                 $table->timestamps();
                 // We'll need to ensure that MySQL uses the InnoDB engine to
                 // support the indexes, other engines aren't affected.
                 // $table->engine = 'InnoDB';
                 $table->unique('name');
             });
         }
         if (Schema::hasTable('users_groups') == false) {
             Schema::create('users_groups', function ($table) {
                 $table->integer('user_id')->unsigned();
                 $table->integer('group_id')->unsigned();
                 // We'll need to ensure that MySQL uses the InnoDB engine to
                 // support the indexes, other engines aren't affected.
                 // $table->engine = 'InnoDB';
                 $table->primary(array('user_id', 'group_id'));
             });
         }
         /* Userpermissions */
         if (Schema::hasTable('userspermissions') == false) {
             Schema::create('userspermissions', function ($table) {
                 $table->increments('id');
                 $table->text('clients')->nullable();
                 $table->text('jobs')->nullable();
             });
         }
         if (Schema::hasTable('groupspermissions') == false) {
             /* Groupspermissions */
             Schema::create('groupspermissions', function ($table) {
                 $table->increments('id');
                 $table->text('clients')->nullable();
                 $table->text('jobs')->nullable();
             });
         }
         if (Schema::hasTable('throttle') == false) {
             Schema::create('throttle', function ($table) {
                 $table->increments('id');
                 $table->integer('user_id')->unsigned();
                 $table->string('ip_address')->nullable();
                 $table->integer('attempts')->default(0);
                 $table->boolean('suspended')->default(0);
                 $table->boolean('banned')->default(0);
                 $table->timestamp('last_attempt_at')->nullable();
                 $table->timestamp('suspended_at')->nullable();
                 $table->timestamp('banned_at')->nullable();
                 // We'll need to ensure that MySQL uses the InnoDB engine to
                 // support the indexes, other engines aren't affected.
                 //$table->engine = 'InnoDB';
             });
         }
         // Create rules table
         /* Schema::create(Config::get('sentry::sentry.table.rules'), function ($table) {
                $table->on(Config::get('sentry::sentry.db_instance'));
                $table->increments('id')->unsigned();
                $table->string('rule')->unique();
                $table->string('description')->nullable();
                $table->create();
            });*/
         /* Settings Table */
         if (!Schema::hasTable('settings')) {
             Schema::create('settings', function ($table) {
                 $table->integer('id')->nullable();
                 $table->boolean('ldapon');
                 $table->string('ldapserver')->nullable();
                 $table->string('ldapdomain')->nullable();
                 $table->string('ldapuser')->nullable();
                 $table->string('ldappassword')->nullable();
                 $table->string('ldapport')->nullable();
                 $table->string('servername')->nullable();
                 $table->string('adminemail')->nullable();
                 $table->string('logo')->nullable();
                 $table->string('confdir')->nullable();
             });
         }
         if (!Schema::hasTable('filessearch')) {
             Schema::create('filessearch', function ($table) {
                 $table->increments('id');
                 $table->integer('jobid')->nullable();
                 $table->string('path')->nullable();
                 $table->string('filename')->nullable();
             });
         }
         /// Configuration Bacula Tables /////
         if (!Schema::hasTable('cfgconsole')) {
             /* cfgFileSetExclude */
             Schema::create('cfgconsole', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Password')->nullable();
                 $table->string('JobACL')->nullable();
                 $table->string('ClientACL')->nullable();
                 $table->string('StorageACL')->nullable();
                 $table->string('ScheduleACL')->nullable();
                 $table->string('PoolACL')->nullable();
                 $table->string('FileSetACL')->nullable();
                 $table->string('CatalogACL')->nullable();
                 $table->string('CommandACL')->nullable();
                 $table->string('WhereACL')->nullable();
             });
         }
         if (!Schema::hasTable('cfgmessages')) {
             /* cfgFileSetExclude */
             Schema::create('cfgmessages', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('MailCommand')->nullable();
                 $table->string('OperatorCommand')->nullable();
                 $table->string('destination')->nullable();
                 $table->string('append')->nullable();
                 $table->string('operator')->nullable();
                 $table->string('console')->nullable();
                 $table->string('mail')->nullable();
                 $table->string('mailonerror')->nullable();
                 $table->string('catalog')->nullable();
             });
         }
         if (!Schema::hasTable('cfgfilesetexclude')) {
             /* cfgFileSetExclude */
             Schema::create('cfgfilesetexclude', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('file')->nullable();
             });
         }
         /* cfgFileSetInclude  */
         if (!Schema::hasTable('cfgfilesetinclude')) {
             Schema::create('cfgfilesetinclude', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('file')->nullable();
             });
         }
         /* cfgFileSetIncludeOptions   */
         if (!Schema::hasTable('cfgfilesetincludeoptions')) {
             Schema::create('cfgfilesetincludeoptions', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('option')->nullable();
                 $table->string('value')->nullable();
             });
         }
         /* cfgFileSetIncludeOptions   */
         if (!Schema::hasTable('cfgfilesetexcludeoptions')) {
             Schema::create('cfgfilesetexcludeoptions', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('option')->nullable();
                 $table->string('value')->nullable();
             });
         }
         /* cfgcatalog */
         if (!Schema::hasTable('cfgcatalog')) {
             Schema::create('cfgcatalog', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('DBPassword')->nullable();
                 $table->string('DBName')->nullable();
                 $table->string('DBUser')->nullable();
                 $table->string('DBSocket')->nullable();
                 $table->string('DBAddress')->nullable();
                 $table->string('DBPort')->nullable();
             });
         }
         /* cfgclient */
         if (!Schema::hasTable('cfgclient')) {
             Schema::create('cfgclient', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Address')->nullable();
                 $table->string('FDPort')->nullable();
                 $table->string('Catalog')->nullable();
                 $table->string('Password')->nullable();
                 $table->string('FileRetention')->nullable();
                 $table->string('JobRetention')->nullable();
                 $table->string('AutoPrune')->nullable();
                 $table->string('MaximumConcurrentJobs')->nullable();
                 $table->string('Priority')->nullable();
                 $table->string('HeartbeatInterval')->nullable();
             });
         }
         /* cfgdirector */
         if (!Schema::hasTable('cfgdirector')) {
             Schema::create('cfgdirector', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Description')->nullable();
                 $table->string('Password')->nullable();
                 $table->string('Messages')->nullable();
                 $table->string('PidDirectory')->nullable();
                 $table->string('ScriptsDirectory')->nullable();
                 $table->string('QueryFile')->nullable();
                 $table->string('HeartbeatInterval')->nullable();
                 $table->string('MaximumConcurrentJobs')->nullable();
                 $table->string('FDConnectTimeout')->nullable();
                 $table->string('SDConnectTimeout')->nullable();
                 $table->string('DirPort')->nullable();
                 $table->string('DirAddress')->nullable();
                 $table->string('DirSourceAddress')->nullable();
                 $table->string('StatisticsRetention')->nullable();
                 $table->string('MaximumConsoleConnections')->nullable();
                 $table->string('VerId')->nullable();
                 $table->string('WorkingDirectory')->nullable();
             });
         }
         /* cfgfileset */
         if (!Schema::hasTable('cfgfileset')) {
             Schema::create('cfgfileset', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('IgnoreFileSetChanges')->nullable();
                 $table->string('EnableVSS')->nullable();
             });
         }
         /* cfgfilesetexcludeoptions */
         if (!Schema::hasTable('cfgfilesetexcludeoptions')) {
             Schema::create('cfgfilesetexcludeoptions', function ($table) {
                 $table->increments('id');
                 $table->integer('idfileset')->nullable();
                 $table->string('option')->nullable();
                 $table->string('value')->nullable();
             });
         }
         /* cfgjob */
         if (!Schema::hasTable('cfgjob')) {
             Schema::create('cfgjob', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Enabled')->nullable();
                 $table->string('Type')->nullable();
                 $table->string('Level')->nullable();
                 $table->string('Accurate')->nullable();
                 $table->string('VerifyJob')->nullable();
                 $table->string('JobDefs')->nullable();
                 $table->string('Bootstrap')->nullable();
                 $table->string('WriteBootstrap')->nullable();
                 $table->string('Client')->nullable();
                 $table->string('FileSet')->nullable();
                 $table->string('Base')->nullable();
                 $table->string('Messages')->nullable();
                 $table->string('Pool')->nullable();
                 $table->string('FullBackupPool')->nullable();
                 $table->string('MaximumBandwidth')->nullable();
                 $table->string('IncrementalBackupPool')->nullable();
                 $table->string('Storage')->nullable();
                 $table->string('DifferentialBackupPool')->nullable();
                 $table->string('Schedule')->nullable();
                 $table->string('MaxRunTime')->nullable();
                 $table->string('DifferentialMaxWaitTime')->nullable();
                 $table->string('MaxRunSchedTime')->nullable();
                 $table->string('MaxWaitTime')->nullable();
                 $table->string('MaxStartDelay')->nullable();
                 $table->string('PruneJobs')->nullable();
                 $table->string('PreferMountedVolumes')->nullable();
                 $table->string('IncrementalMaxRunTime')->nullable();
                 $table->string('PruneVolumes')->nullable();
                 $table->string('SpoolData')->nullable();
                 $table->string('RunBeforeJob')->nullable();
                 $table->string('RunAfterJob')->nullable();
                 $table->string('RunAfterFailedJob')->nullable();
                 $table->string('ClientRunBeforeJob')->nullable();
                 $table->string('ClientRunAfterJob')->nullable();
                 $table->string('RerunFailedLevels')->nullable();
                 $table->string('MaxFullInterval')->nullable();
                 $table->string('SpoolSize')->nullable();
                 $table->string('Where')->nullable();
                 $table->string('AddPrefix')->nullable();
                 $table->string('RegexWhere')->nullable();
                 $table->string('StripPrefix')->nullable();
                 $table->string('MaximumConcurrentJobs')->nullable();
                 $table->string('RescheduleInterval')->nullable();
                 $table->string('PrefixLinks')->nullable();
                 $table->string('RescheduleOnError')->nullable();
                 $table->string('Replace')->nullable();
                 $table->string('AllowMixedPriority')->nullable();
                 $table->string('Priority')->nullable();
                 $table->string('AllowHigherDuplicates')->nullable();
                 $table->string('CancelLowerLevelDuplicates')->nullable();
                 $table->string('CancelQueuedDuplicates')->nullable();
                 $table->string('RescheduleTimes')->nullable();
                 $table->string('AllowDuplicateJobs')->nullable();
                 $table->string('CancelRunningDuplicates')->nullable();
                 $table->string('SpoolAttributes')->nullable();
                 $table->string('WritePartAfterJob')->nullable();
                 $table->string('Run')->nullable();
                 $table->string('PruneFiles')->nullable();
             });
         }
         /* cfgpool */
         if (!Schema::hasTable('cfgpool')) {
             Schema::create('cfgpool', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('MaximumVolumes')->nullable();
                 $table->string('PoolType')->nullable();
                 $table->string('Storage')->nullable();
                 $table->string('UseVolumeOnce')->nullable();
                 $table->string('MaximumVolumeJobs')->nullable();
                 $table->string('MaximumVolumeFiles')->nullable();
                 $table->string('MaximumVolumeBytes')->nullable();
                 $table->string('VolumeUseDuration')->nullable();
                 $table->string('CatalogFiles')->nullable();
                 $table->string('AutoPrune')->nullable();
                 $table->string('VolumeRetention')->nullable();
                 $table->string('ActionOnPurge')->nullable();
                 $table->string('ScratchPool')->nullable();
                 $table->string('RecyclePool')->nullable();
                 $table->string('RecycleOldestVolume')->nullable();
                 $table->string('RecycleCurrentVolume')->nullable();
                 $table->string('Recycle')->nullable();
                 $table->string('PurgeOldestVolume')->nullable();
                 $table->string('FileRetention')->nullable();
                 $table->string('JobRetention')->nullable();
                 $table->string('CleaningPrefix')->nullable();
                 $table->string('LabelFormat')->nullable();
             });
         }
         /* cfgschedule */
         if (!Schema::hasTable('cfgschedule')) {
             Schema::create('cfgschedule', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Run')->nullable();
             });
         }
         /* cfgscheduleRun */
         if (!Schema::hasTable('cfgschedulerun')) {
             Schema::create('cfgschedulerun', function ($table) {
                 $table->increments('id');
                 $table->string('idschedule')->nullable();
                 $table->string('Run')->nullable();
             });
         }
         /* cfgstorage */
         if (!Schema::hasTable('cfgstorage')) {
             Schema::create('cfgstorage', function ($table) {
                 $table->increments('id');
                 $table->string('Name')->nullable();
                 $table->string('Run')->nullable();
                 $table->string('SDPort')->nullable();
                 $table->string('Password')->nullable();
                 $table->string('Device')->nullable();
                 $table->string('MediaType')->nullable();
                 $table->string('Autochanger')->nullable();
                 $table->string('MaximumConcurrentJobs')->nullable();
                 $table->string('AllowCompression')->nullable();
                 $table->string('HeartbeatInterval')->nullable();
                 $table->string('Address')->nullable();
             });
         }
         /* daystats */
         if (!Schema::hasTable('daystats')) {
             Schema::create('daystats', function ($table) {
                 $table->increments('id');
                 $table->timestamp('data')->nullable();
                 $table->string('server')->nullable();
                 $table->bigInteger('bytes')->nullable();
                 $table->bigInteger('files')->nullable();
                 $table->integer('clients')->nullable();
                 $table->bigInteger('databasesize')->nullable();
             });
         }
         /* hoursstats */
         if (!Schema::hasTable('hoursstats')) {
             Schema::create('hoursstats', function ($table) {
                 $table->increments('id');
                 $table->timestamp('data')->nullable();
                 $table->string('server')->nullable();
                 $table->timestamp('starttime')->nullable();
                 $table->timestamp('endtime')->nullable();
                 $table->bigInteger('bytes')->nullable();
                 $table->bigInteger('hoursdiff')->nullable();
                 $table->double('hourbytes')->nullable();
                 $table->string('timediff')->nullable();
             });
         }
         //Group::where('name', '=', 'Admins')->count();
         //var_dump ($count);
         /* If Not Found Create Admin Group */
         if (!Group::where('name', '=', 'Admins')->count()) {
             $group = Sentry::createGroup(array('name' => 'Admins', 'permissions' => array('admin' => 1, 'users' => 1)));
         } else {
             $group = Sentry::findGroupByName('Admins');
         }
         // Create User
         if (!User::where('email', '=', Input::get('email'))->count()) {
             $user = Sentry::createUser(array('email' => Input::get('email'), 'password' => Input::get('password'), 'activated' => '1'));
             $user->addGroup($group);
         }
         /* Emails Tables */
         if (Schema::hasTable('emails') == false) {
             Schema::create('emails', function ($table) {
                 $table->increments('id');
                 $table->text('emails');
                 $table->text('clients')->nullable();
                 $table->text('jobs')->nullable();
                 $table->text('when')->nullable();
             });
         }
         echo json_encode(array('location' => 'install/installSucess'));
     } catch (Sentry\SentryException $e) {
         // $errors = new Laravel\Messages();
         Session::flash('status_error', $e->getMessage());
         return Redirect::to('install')->with_errors($validation);
     }
 }