public function __construct()
 {
     Setting::set("allow_video_uploads", getInput("allow_video_uploads"));
     Setting::set("ffmpeg_ffmprobe_executable_path", getInput("ffmpeg_ffmprobe_executable_path"));
     new SystemMessage("Your settings have been updated.");
     forward();
 }
示例#2
0
 /**
  * Update the database structure if needed. This function includes all
  * the incremental steps needed to bring the database up to the latest
  * standard.
  * Basically, this function is a big switch on the data version value
  * with each case falling through to the next one.
  */
 public static function updateTables($dataVersion)
 {
     switch ($dataVersion) {
         case "":
             // No data version yet - create initial table and set version number
             Setting::createSettingTable();
             Setting::set("DataVersion", Setting::getCurrentVersion());
             break;
         case "v0.1":
         case "v0.2":
         case "v0.3":
         case "v0.4":
         case "v0.5":
         case "v0.6":
         case "v0.7":
         case "v0.8":
         case "v0.9":
         case "v0.10":
         case "v0.11":
         case "v0.12":
         case "v0.13":
         case "v0.14":
         case "v0.15":
             // Update data version to the current version
             Setting::set("DataVersion", Setting::getCurrentVersion());
         case "v0.16":
             // current version
             break;
         default:
             // no provision for this version, should not happen
             print "Setting::updateTables({$dataVersion}): don't know this version.\n";
             return false;
     }
     return true;
 }
 public function getInstall()
 {
     if (!Setting::has('support.from_name')) {
         Setting::set('support.from_name', '');
     }
     if (!Setting::has('support.from_email')) {
         Setting::set('support.from_email', '');
     }
     if (!Setting::has('support.reply_to_name')) {
         Setting::set('support.reply_to_name', '');
     }
     if (!Setting::has('support.reply_to_email')) {
         Setting::set('support.reply_to_email', '');
     }
     if (!Setting::has('support.default_department')) {
         Setting::set('support.default_department', '1');
     }
     if (!Setting::has('support.default_status')) {
         Setting::set('support.default_status', '1');
     }
     if (!Setting::has('support.auto_close_delay')) {
         Setting::set('support.auto_close_delay', '1');
     }
     Setting::save();
     echo "Support package installed.";
 }
 public function update()
 {
     $validator = Validator::make(Input::all(), array('schoolname' => 'required|min:3|max:256', 'schoolnameabbr' => 'required|alpha|min:2|max:10', 'schooladdress' => 'required|min:4|max:512', 'logo' => 'required', 'adminsitename' => 'required|min:2|max:256', 'systemurl' => 'required|url', 'url' => 'url|required', 'cache' => "required|integer"));
     if ($validator->fails()) {
         Input::flash();
         return Redirect::to('/settings')->withErrors($validator);
     }
     $schoolname = Input::get('schoolname');
     Setting::set('system.schoolname', $schoolname);
     Setting::set('system.schoolnameabbr', Input::get('schoolnameabbr'));
     Setting::set('system.schooladdress', Input::get('schooladdress'));
     Setting::set('system.logo_src', Input::get('logo'));
     Setting::set('system.adminsitename', Input::get('adminsitename'));
     Setting::set('app.url', Input::get('url'));
     Setting::set('app.captcha', Input::get('captcha'));
     Setting::set('system.dashurl', Input::get('systemurl'));
     Setting::set('system.dashurlshort', Input::get('systemurlshort'));
     Setting::set('system.siteurlshort', Input::get('siteurlshort'));
     Setting::set('system.cache', Input::get('cache'));
     $theme = Theme::uses('dashboard')->layout('default');
     $view = array('name' => 'Dashboard Settings');
     $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Dashboard', 'url' => Setting::get('system.dashurl') . '/settings']]);
     $theme->appendTitle(' - Settings');
     return $theme->scope('settings', $view)->render();
 }
 public function __construct()
 {
     adminGateKeeper();
     $google_analytics = getInput("google_analytics");
     Setting::set("google_analytics", $google_analytics);
     new SystemMessage("Your code has been updated.");
     forward();
 }
 public function __construct()
 {
     adminGateKeeper();
     $add_this = getInput("add_this");
     Setting::set("add_this", $add_this);
     new SystemMessage("Your Addthis Code has been updated");
     forward();
 }
 function __construct()
 {
     adminGateKeeper();
     $home_page = getInput("home_page");
     Setting::set("home_page", $home_page);
     new SystemMessage("Your home page has been updated.");
     forward();
 }
 function __construct()
 {
     $settings = Setting::getAll("groups");
     foreach ($settings as $setting) {
         Setting::set($setting->name, getInput($setting->name));
     }
     forward("admin/groups");
 }
示例#9
0
 public function save()
 {
     if ($this->validate()) {
         Setting::set('db', $this->attributes);
         return true;
     } else {
         return false;
     }
 }
 function __construct()
 {
     $settings = Setting::getAll("stripe");
     foreach ($settings as $setting) {
         Setting::set($setting->name, getInput($setting->name));
     }
     new SystemMessage("Your stripe settings have been saved.");
     forward();
 }
示例#11
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Load the default configuration and import it into the database
     $config = json_decode(file_get_contents(app_path() . '/../settings.json'));
     foreach ($config as $key => $value) {
         Setting::set($key, $value);
     }
     $this->info('Generated configuration.');
 }
示例#12
0
 public static function removePid($pid)
 {
     $pids = Setting::get('nodejs.pid');
     if (!is_null($pids) && in_array($pid, $pids)) {
         if (($key = array_search($pid, $pids)) !== false) {
             unset($pids[$key]);
         }
         $pids = array_unique($pids);
         Setting::set('nodejs.pid', $pids);
     }
 }
示例#13
0
 public function post()
 {
     $settings = Input::get('settings');
     if (isset($settings) && is_array($settings)) {
         foreach ($settings as $var => $val) {
             Setting::set($var, $val);
         }
         Setting::save();
     }
     return Api::to(array('success', Lang::get('admin/settings/messages.update.success'))) ?: Redirect::to('admin/settings')->with('success', Lang::get('admin/settings/messages.update.success'));
 }
示例#14
0
 /**
  * Creates a new token for specified $name
  * @return newly created token
  */
 public static function generate($owner, $name)
 {
     $session = SessionHandler::getInstance();
     do {
         $val = sha1('pOwplopw' . $session->id . mt_rand() . $session->name . 'LAZER!!');
         if (!Setting::getOwner(TOKEN, $name, $val)) {
             break;
         }
     } while (1);
     Setting::set(TOKEN, $owner, $name, $val);
     return $val;
 }
示例#15
0
 public function saveAction()
 {
     $settings = isset($_POST['setting']) ? (array) $_POST['setting'] : array();
     Nano_Log::message(var_export($settings, true));
     if (empty($settings)) {
         $this->redirect('/cp/settings');
     }
     foreach ($settings as $category => $options) {
         foreach ($options as $name => $value) {
             Setting::set($category, $name, $value);
         }
     }
     $this->redirect('/cp/settings/' . $category);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param $comment
  * @return Response
  */
 public function postIndex()
 {
     $rules = array();
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $settings = Input::get('settings');
         if (isset($settings) && is_array($settings)) {
             foreach ($settings as $var => $val) {
                 Setting::set($var, $val);
             }
             Setting::save();
         }
         return Api::to(array('success', Lang::get('admin/settings/messages.update.success'))) ?: Redirect::to('admin/settings')->with('success', Lang::get('admin/settings/messages.update.success'));
     } else {
         return Api::to(array('error', Lang::get('admin/settings/messages.update.error'))) ?: Redirect::to('admin/settings')->withInput()->withErrors($validator);
     }
 }
示例#17
0
 public static function init($configfile, $mode = "running", $entryScript = "")
 {
     require_once "Installer.php";
     date_default_timezone_set("Asia/Jakarta");
     $bp = Setting::setupBasePath($configfile);
     Setting::$path = $bp . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "settings.json";
     if (!is_file(Setting::$path)) {
         $json = Setting::$default;
         $json = json_encode($json, JSON_PRETTY_PRINT);
         $result = @file_put_contents(Setting::$path, $json);
         require_once "Installer.php";
         Installer::createIndexFile("install");
         Setting::$mode = "install";
     }
     $file = @file_get_contents(Setting::$path);
     ## set entry script
     Setting::$entryScript = realpath($entryScript == "" ? $_SERVER["SCRIPT_FILENAME"] : $entryScript);
     ## set default data value
     if (!$file || isset($result) && !$result) {
         Setting::$data = Setting::$default;
         $path = isset($result) && !$result ? $result : $file;
         if (!$path) {
             $path = Setting::$path;
         }
         $_GET['errorBeforeInstall'] = true;
         Setting::redirError("Failed to write in '{path}'", ["{path}" => $path]);
         return false;
     } else {
         $setting = json_decode($file, true);
         Setting::$data = Setting::arrayMergeRecursiveReplace(Setting::$default, $setting);
     }
     ## set host
     if (!Setting::get('app.host')) {
         $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
         $port = $_SERVER['SERVER_PORT'] == 443 || $_SERVER['SERVER_PORT'] == 80 ? "" : ":" . $_SERVER['SERVER_PORT'];
         Setting::set('app.host', $protocol . $_SERVER['HTTP_HOST'] . $port);
     }
     ## set debug
     if (Setting::$mode == null) {
         Setting::$mode = $mode;
     }
     if (Setting::get('app.mode') != 'production') {
         defined('YII_DEBUG') or define('YII_DEBUG', true);
         defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param $comment
  * @return Response
  */
 public function postIndex()
 {
     $rules = array();
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         $settings = Input::get('settings');
         if (isset($settings) && is_array($settings)) {
             foreach ($settings as $var => $val) {
                 Setting::set($var, $val);
             }
             Setting::save();
         }
         // Redirect to the comments post management page
         return Redirect::to('admin/settings')->with('success', Lang::get('admin/settings/messages.update.success'));
     }
     // Form validation failed
     return Redirect::to('admin/settings')->withInput()->withErrors($validator);
 }
示例#19
0
 public function update($setting_id)
 {
     if ($setting_id == 'menu') {
         $features = [];
         $input = Input::only($this->features);
         foreach ($input as $feature => $enabled) {
             if ($enabled) {
                 $features[] = $feature;
             }
         }
         $input = join(';', $features);
     } else {
         $input = Input::get($setting_id . '_value');
     }
     if (Setting::set($setting_id, $input)) {
         return Redirect::to(route('settings.index'))->with('message', ['content' => 'Instellingen met succes geupdated!', 'class' => 'success']);
     } else {
         return View::make('settings.index')->with('message', ['content' => 'Er is iets misgegaan met de instelling. :(', 'class' => 'warning']);
     }
 }
示例#20
0
 public function actionIndex($force = false)
 {
     $isPMRunning = null;
     while (true) {
         if (!$force) {
             $isPMRunning = ProcessHelper::isPMRunning();
         }
         if (!$isPMRunning) {
             break;
         }
         $cmds = Setting::get('process', null, true);
         foreach ($cmds as $id => $cmd) {
             $curTime = time();
             $isStillRunning = false;
             # Getting PID of previous process.
             if (isset($cmd['pid'])) {
                 $isStillRunning = ProcessHelper::findRunningProcess($cmd['pid']);
             }
             # Remove one task kill process from Process Manager List
             if ($cmd['runOnce'] && !$isStillRunning) {
                 Setting::remove('process.' . $id);
             }
             if ($cmd['runOnce']) {
                 echo $cmd['name'] . "\n";
                 continue;
             }
             $isStarted = $cmd['isStarted'];
             # Running periodic process continously
             if ((!isset($cmd['lastRun']) || abs($curTime - $cmd['lastRun']) % $cmd['periodCount'] == 0) && !$isStillRunning && $isStarted && !$cmd['runOnce']) {
                 chdir(Yii::getPathOfAlias('application'));
                 exec("process run yiic " . $cmd['command'], $pid);
                 $cmd['lastRun'] = $curTime;
                 $cmd['pid'] = $pid[0];
                 Setting::set('process.' . $id, $cmd);
                 // Logging
                 // echo "[".date('d-m-Y H:i:s')."] ".$cmd['name']." is running\n";
             }
         }
         sleep(1);
     }
 }
示例#21
0
 public function newMigration($post)
 {
     Setting::set('db.migration_name', $post['name']);
     $sql = $post['newsql'];
     $valid = $this->run($sql);
     if ($valid) {
         $valid = $this->run($sql);
         if ($valid) {
             $dir = Yii::getPathOfAlias('app.migrations');
             $migDir = glob($dir . DIRECTORY_SEPARATOR . "*", GLOB_ONLYDIR);
             $newDir = $dir . DIRECTORY_SEPARATOR . (count($migDir) + 1);
             if (!is_dir($newDir)) {
                 mkdir($newDir);
             }
             $newFile = $newDir . DIRECTORY_SEPARATOR . $post['name'] . '.sql';
             file_put_contents($newFile, $sql);
             $this->addList(count($migDir) + 1 . "_" . $post['name'] . ".sql");
         }
     }
     return $valid;
 }
示例#22
0
 public function update($setting_id)
 {
     $succes = false;
     switch ($setting_id) {
         case 'menu':
             $success = $this->updateMenuSettings();
             break;
         case 'export':
             $success = $this->updateExportSettings();
             break;
         case 'project_name':
             $input = Input::get($setting_id);
             $success = Setting::set($setting_id, $input);
             break;
     }
     if ($success) {
         return Redirect::to(route('settings.index'))->with('message', ['content' => 'Instellingen met succes geupdated!', 'class' => 'success']);
     } else {
         return View::make('settings.index')->with('message', ['content' => 'Er is iets misgegaan met de instelling. :(', 'class' => 'warning']);
     }
 }
示例#23
0
 public function actionDb()
 {
     $model = new InstallDbForm();
     $model->host = Setting::get('db.host');
     $model->username = Setting::get('db.username');
     $model->password = Setting::get('db.password');
     $model->dbname = Setting::get('db.dbname');
     $error = false;
     $mode = "init";
     if (isset($_POST['InstallDbForm'])) {
         $model->attributes = $_POST['InstallDbForm'];
         if ($model->validate()) {
             $error = false;
             try {
                 $dbh = new pdo("mysql:host={$model->host};dbname={$model->dbname}", $model->username, $model->password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
             } catch (PDOException $ex) {
                 $error = $ex->getMessage();
             }
             if (!$error) {
                 Setting::set('db.host', $model->host, false);
                 Setting::set('db.username', $model->username, false);
                 Setting::set('db.password', $model->password, false);
                 Setting::set('db.dbname', $model->dbname, false);
                 Setting::write();
                 if ($model->resetdb == "yes") {
                     Installer::createIndexFile("install");
                     $this->redirect(['/install/default/resetdb']);
                 } else {
                     Installer::createIndexFile("running");
                     $this->redirect(['/install/default/finish']);
                 }
             }
         }
     }
     $this->renderForm('InstallDbForm', $model, ['error' => $error, 'mode' => $mode]);
 }
示例#24
0
if ($user_type !== 'Admin' && $user_type !== 'SuperAdmin') {
    die('no permission');
}
$msg = '';
$ERROR_INFO = $config['error']['info'];
switch ($target) {
    case '':
        $settings = Setting::get();
        $name_map = $config['setting_name_map'];
        if ($by_post) {
            $labor_expense = _post('labor_expense');
            $wear_tear = _post('wear_tear');
            $st_expense = _post('st_expense');
            $st_price = _post('st_price');
            $weight_ratio = _post('weight_ratio');
            Setting::set(compact('labor_expense', 'wear_tear', 'st_expense', 'st_price', 'weight_ratio'));
            redirect('setting');
            // refresh
        }
        break;
    case 'password':
        if ($by_post) {
            $password = _post('password');
            $new_password = _post('new_password');
            $re_password = _post('re_password');
            if (empty($password)) {
                $msg = $ERROR_INFO['PASSWORD_EMPTY'];
            } elseif (!$user->checkPassword($password)) {
                $msg = $ERROR_INFO['PASSWORD_INCORRECT'];
            } elseif (empty($new_password)) {
                $msg = $ERROR_INFO['NEW_PASSWORD_EMPTY'];
示例#25
0
    public function create()
    {
        ## Prepare Command Class Directory
        $path = Yii::getPathOfAlias($this->commandPath);
        if (!is_dir($path)) {
            mkdir($path, 0777, true);
        }
        ## Write New Command Class
        $filePath = $path . DIRECTORY_SEPARATOR . $this->command . "Command.php";
        if (!is_file($filePath)) {
            $content = <<<EOF
<?php

class {$this->command}Command extends Service {
    public function actionIndex() {
        ## Put your code here
        
    }
}
EOF;
            file_put_contents($filePath, $content);
        }
        if (substr($this->command, -8) != "Command") {
            $this->command = $this->command . "Command";
        }
        if (substr($this->action, 8) != "action") {
            $this->action = "action" . $this->action;
        }
        ## Setup Process Entry in Setting
        Setting::set("services.list." . $this->name, $this->attributes);
    }
示例#26
0
 public static function run($name, $command, $runOnce = TRUE)
 {
     if (!ProcessHelper::isPMRunning()) {
         return false;
     }
     $pid = [];
     $process = ProcessHelper::getProcessCommand();
     $id = ProcessHelper::createSettingsId($name);
     chdir(Yii::getPathOfAlias('application'));
     exec($process . ' run ' . $command, $pid);
     if (!empty($pid)) {
         # Default value of Processes
         Setting::set("process." . $id . ".name", $name);
         Setting::set("process." . $id . ".command", $command);
         Setting::set("process." . $id . ".period", null);
         Setting::set("process." . $id . ".periodType", null);
         Setting::set("process." . $id . ".periodCount", null);
         Setting::set("process." . $id . ".lastRun", time());
         Setting::set("process." . $id . ".isStarted", true);
         Setting::set("process." . $id . ".pid", $pid[0]);
         Setting::set("process." . $id . ".file", null);
         Setting::set("process." . $id . ".runOnce", $runOnce);
         return $pid[0];
     } else {
         return false;
     }
 }
 static function set($owner, $name, $val)
 {
     return Setting::set(USERDATA_OPTION, $owner, $name, $val);
 }
 public function install_submit()
 {
     $username = Input::get('username');
     $password = Input::get('password');
     $admin_username = Input::get('admin_username');
     $admin_password = Input::get('admin_password');
     $sitename = Input::get('sitename');
     $database_name = Input::get('database_name');
     $picture = Input::file('picture');
     $mandrill_username = Input::get('mandrill_username');
     $mandrill_secret = Input::get('mandrill_secret');
     $timezone = Input::get('timezone');
     $validator = Validator::make(array('password' => $password, 'username' => $username, 'database_name' => $database_name, 'admin_username' => $admin_username, 'admin_password' => $admin_password, 'sitename' => $sitename, 'picture' => $picture, 'mandrill_username' => $mandrill_username, 'timezone' => $timezone, 'mandrill_secret' => $mandrill_secret), array('password' => '', 'username' => 'required', 'sitename' => 'required', 'database_name' => 'required', 'admin_password' => 'required', 'admin_username' => 'required', 'mandrill_username' => 'required', 'mandrill_secret' => 'required', 'timezone' => 'required', 'picture' => 'mimes:png,jpg'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         return Redirect::back()->with('flash_errors', $error_messages);
     } else {
         $file_name = time();
         $file_name .= rand();
         $ext = Input::file('picture')->getClientOriginalExtension();
         Input::file('picture')->move(public_path() . "/uploads", $file_name . "." . $ext);
         $local_url = $file_name . "." . $ext;
         $s3_url = URL::to('/') . '/uploads/' . $local_url;
         Setting::set('sitename', $sitename);
         Setting::set('footer', "Powered by Appoets");
         Setting::set('username', $username);
         Setting::set('password', $password);
         Setting::set('database_name', $database_name);
         Setting::set('mandrill_secret', $mandrill_secret);
         Setting::set('mandrill_username', $mandrill_username);
         Setting::set('timezone', $timezone);
         Setting::set('logo', $s3_url);
         import_db($username, $password, 'localhost', $database_name);
         $admin = new User();
         $admin->email = $admin_username;
         $admin->is_activated = 1;
         $admin->password = Hash::make($admin_password);
         $admin->role_id = 2;
         $admin->save();
         return Redirect::to('/');
     }
 }
示例#29
0
 public function beforeAction($action)
 {
     ## when mode is init or install then redirect to installation mode
     if (Setting::$mode == "init" || Setting::$mode == "install") {
         if ($this->id != "default") {
             $this->redirect(['/install/default/index']);
             return false;
         }
     }
     ## Setup actual url reference, for console command...
     $appUrl = Setting::get('app.url');
     $actualUrl = Yii::app()->getRequest()->getHostInfo() . Yii::app()->getRequest()->getBaseUrl();
     if ($appUrl != $actualUrl) {
         Setting::set('app.url', $actualUrl);
     }
     parent::beforeAction($action);
     return true;
 }
示例#30
0
 public function save()
 {
     Setting::set('app', $this->attributes);
     return true;
 }