Esempio n. 1
0
 public static function cmd($str, $root = false)
 {
     $las = \Las\Library\Arr::from_model(Settings::find(array('status = ' . Settings::ACTIVE)), 'category', array('name' => 'value'));
     if ($root) {
         $crypt = \Phalcon\DI::getDefault()->getShared('crypt');
         exec('echo ' . $crypt->decryptBase64($las['general']['rootPassword']) . ' | su -c ' . '"' . $str . '"', $results);
     } else {
         exec($str, $results);
     }
     if ($las['general']['debugCmd']) {
         $results = Dump::one($results, 'output');
         $results .= Dump::one($str, 'commands');
     }
     return $results;
 }
Esempio n. 2
0
 /**
  * Log message into file, notify the admin on stagging/production
  *
  * @package     las
  * @version     1.0
  *
  * @param mixed $messages messages to log
  */
 public static function log($messages)
 {
     $config = \Phalcon\DI::getDefault()->getShared('config');
     if ($config->app->env == "development") {
         foreach ($messages as $key => $message) {
             echo Dump::one($message, $key);
         }
         exit;
     } else {
         $logger = new \Phalcon\Logger\Adapter\File(ROOT_PATH . '/app/common/logs/' . date('Ymd') . '.log', array('mode' => 'a+'));
         $log = '';
         foreach ($messages as $key => $message) {
             if (in_array($key, array('alert', 'debug', 'error', 'info', 'notice', 'warning'))) {
                 $logger->{$key}($message);
             } else {
                 $logger->log($message);
             }
             $log .= Dump::one($message, $key);
         }
         if ($config->app->env != "testing") {
             $email = new Email();
             $email->prepare(__('Something is wrong!'), $config->app->admin, 'error', array('log' => $log));
             if ($email->Send() !== true) {
                 $logger->log($email->ErrorInfo);
             }
         }
         $logger->close();
         return $log;
     }
 }