Example #1
0
 public function cmd_list()
 {
     \System\Init::basic();
     $list = cfg('assets', 'dependencies');
     if ($this->json) {
         \Helper\Cli::out(json_encode(array("dependencies" => $list), JSON_PRETTY_PRINT));
     } else {
         \Helper\Cli::out('Bower dependencies');
         \Helper\Cli::out_flist(array("list" => $list, "margin" => 2));
     }
 }
Example #2
0
 /**
  * Build static cache
  *
  * @return void
  */
 public function cmd_static()
 {
     \System\Init::basic();
     $lib_list = \System\Composer::get_libs();
     $libs = array();
     foreach ($lib_list as $lib) {
         $libs[$lib] = $lib;
     }
     array_push($libs, null);
     \Helper\Cli::do_over($libs, function ($key, $name) {
         \System\Cache::build_static_for($name);
     }, 'Collecting static files');
 }
Example #3
0
 public function cmd_pair()
 {
     \System\Init::full();
     $token = \System\Settings::get('bank', 'token');
     $from = \System\Settings::get('bank', 'from');
     $to = date('Y-m-d');
     $url = str_replace('{token}', $token, self::URL_TRANSACTIONS);
     $url = str_replace('{from}', $from, $url);
     $url = str_replace('{to}', $to, $url);
     $res = \Helper\Offcom\Request::get($url);
     if (!$res->ok()) {
         if ($res->status == 409) {
             \Helper\Cli::out('Please wait 30 seconds and try again.');
             exit(4);
         } else {
             \Helper\Cli::out('Unknown error during transaction scrape.');
             exit(5);
         }
     }
     $feed = \System\Json::decode($res->content);
     \Workshop\Payment::pair_with_feed($feed);
 }
Example #4
0
 public static function cmd_database()
 {
     \System\Init::full();
     $db_list = \System\Settings::get('database', 'list');
     foreach ($db_list as $db_ident => $db_cfg) {
         $size = \System\Database::query("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tsum(data_length + index_length) 'size',\n\t\t\t\t\t\t\tsum( data_free ) 'free'\n\t\t\t\t\t\tFROM information_schema.TABLES\n\t\t\t\t\t\tWHERE table_schema = '" . $db_cfg['database'] . "'\n\t\t\t\t\t\tGROUP BY table_schema;\n\t\t\t\t")->fetch();
         $mlast_date = false;
         $mcount = 0;
         try {
             $mig = \System\Database\Migration::get_new();
             $mcount = count($mig);
             $stat = "Ok";
             $mlast = \System\Database\Migration::get_first()->where(array("status" => 'ok'))->sort_by("updated_at DESC")->fetch();
             if ($mlast) {
                 $mlast_date = $mlast->updated_at;
             }
         } catch (System\Error $e) {
             $stat = "Migrating database is necessary.";
         }
         \Helper\Cli::out('Database ' . $db_ident);
         \Helper\Cli::sep();
         \Helper\Cli::out_flist(array("list" => array("Driver" => $db_cfg['driver'], "Host name" => $db_cfg['host'], "Database name" => $db_cfg['database'], "User" => $db_cfg['username'], "Used charset" => $db_cfg['charset'], "Lazy driver" => $db_cfg['lazy'] ? 'yes' : 'no', "Size" => \System\Template::convert_value('information', $size['size']), "Free space" => \System\Template::convert_value('information', $size['free']), "Structure" => $stat, "Last migrated" => $mlast_date ? $mlast_date->format('Y-m-d H:i:s') : 'never', "New migrations" => $mcount)));
     }
 }
Example #5
0
<?php

if (!defined('BASE_DIR')) {
    define('BASE_DIR', ROOT);
}
require_once ROOT . "/etc/init.d/core.php";
preloadFudjanCore();
\Helper\Cli::parse_command($argv);
Example #6
0
 public static function cmd_list()
 {
     \Helper\Cli::out_flist(array("list" => self::get_all(), "show_keys" => false));
 }
Example #7
0
 public function cmd_lostAndFound()
 {
     \System\Init::full();
     $users = \Workshop\SignUp::get_all()->where(array("solved" => true, "newsletter" => true, "sentLostAndFound" => false))->fetch();
     \Helper\Cli::do_over($users, function ($key, $user) {
         $ren = new \System\Template\Renderer\Txt();
         $ren->reset_layout();
         $ren->partial('mail/notif/lost-and-found', array("user" => $user, "symvar" => $user->check->symvar));
         $mail = new \Helper\Offcom\Mail(array('rcpt' => array($user->email), 'subject' => 'Improtřesk 2016 - Ztráty a nálezy, pozvánka', 'reply_to' => \System\Settings::get('offcom', 'default', 'reply_to'), 'message' => $ren->render_content()));
         $mail->send();
         $user->sentLostAndFound = true;
         $user->save();
     });
 }
Example #8
0
 /** Print heading separator to STDOUT
  * @param bool $return Return the value if true
  * @return void
  */
 public static function sep($return = false)
 {
     $str = '';
     for ($i = 0; $i <= \Helper\Cli::get_width() - 1; $i++) {
         $str .= '-';
     }
     $str .= NL;
     if ($return) {
         return $str;
     } else {
         echo $str;
     }
 }
Example #9
0
 public function cmd($cmd, array $params = array())
 {
     if ($this->command_exists($cmd)) {
         $name = 'cmd_' . $cmd;
         if (method_exists($this, $name)) {
             $this->{$name}($params);
         } else {
             \Helper\Cli::give_up("Command is not defined!", 3);
         }
     } else {
         \Helper\Cli::give_up("Please specify a valid command. Use --help option to get more info.", 2);
     }
     return $this;
 }
Example #10
0
 public function cmd_reset()
 {
     $this->cmd_rebuild();
     \Helper\Cli::out();
     $this->cmd_seed();
     return $this;
 }