Example #1
0
 /**
  * Sends message
  * @param  integer $type
  * @param  string  $msg
  * @return void
  */
 public function send($type, $msg)
 {
     $err = 0;
     if (!msg_send($this->queue, $type, $msg, true, false, $err)) {
         $this->logger->critical("Message of type {$type} not sent: {$err}", (array) $msg);
     } else {
         $this->logger->debug("Message of type {$type} sent", (array) $msg);
     }
 }
Example #2
0
 public function __construct(Config $config, Logger $logger)
 {
     $this->config = $config;
     $this->logger = $logger;
     if (($this->config->usecache || $this->config->storecache) && !is_dir($this->config->cachedir)) {
         $this->logger->critical("[Cache] Configured cache directory [{$this->config->cachedir}] does not exist!");
         throw new Exception("[Cache] Configured cache directory [{$this->config->cachedir}] does not exist!");
     }
     if ($this->config->storecache && !is_writable($this->config->cachedir)) {
         $this->logger->critical("[Cache] Configured cache directory [{$this->config->cachedir}] lacks write permission!");
         throw new Exception("[Cache] Configured cache directory [{$this->config->cachedir}] lacks write permission!");
     }
 }
Example #3
0
 public function testCriticalLevel()
 {
     $this->expectOutputString('critical: Message contents');
     $echo = new Adaptors\EchoAdaptor('debug', '{level}: {message}');
     $logger = new Logger($echo);
     $logger->critical('Message contents');
 }
Example #4
0
 public function __construct()
 {
     $this->prefs = Preferences::getInstance();
     if (!$this->prefs) {
         Logger::critical('main', 'SessionManagement::__construct - get Preferences failed');
         throw_response(INTERNAL_ERROR);
     }
 }
Example #5
0
 public function getUser()
 {
     try {
         $user = Zend_Registry::get("pimcore_user");
         if (!$user instanceof User) {
             Logger::critical("Webservice instantiated, but no user present");
         }
         return $user;
     } catch (Exception $e) {
         Logger::error($e);
         throw $e;
     }
 }
 /**
  * @return mixed
  * @throws \Exception
  */
 public static function getPhpCli()
 {
     if (Config::getSystemConfig()->general->php_cli) {
         if (@is_executable(Config::getSystemConfig()->general->php_cli)) {
             return (string) Config::getSystemConfig()->general->php_cli;
         } else {
             \Logger::critical("PHP-CLI binary: " . Config::getSystemConfig()->general->php_cli . " is not executable");
         }
     }
     $paths = array("/usr/bin/php", "/usr/local/bin/php", "/usr/local/zend/bin/php", "/bin/php", realpath(PIMCORE_DOCUMENT_ROOT . "/../php/php.exe"));
     foreach ($paths as $path) {
         if (@is_executable($path)) {
             return $path;
         }
     }
     throw new \Exception("No php executable found, please configure the correct path in the system settings");
 }
Example #7
0
 /**
  * @static
  * @return string
  */
 public static function getPhpCli()
 {
     if (Pimcore_Config::getSystemConfig()->general->php_cli) {
         if (is_executable(Pimcore_Config::getSystemConfig()->general->php_cli)) {
             return (string) Pimcore_Config::getSystemConfig()->general->php_cli;
         } else {
             Logger::critical("PHP-CLI binary: " . Pimcore_Config::getSystemConfig()->general->php_cli . " is not executable");
         }
     }
     $paths = array("/usr/bin/php", "/usr/local/bin/php", "/usr/local/zend/bin/php", "/bin/php");
     foreach ($paths as $path) {
         if (is_executable($path)) {
             return $path;
         }
     }
     throw new Exception("No php executable found, please configure the correct path in the system settings");
 }
Example #8
0
 /**
  * @static
  * @return string
  */
 public static function getFfmpegCli()
 {
     if (Pimcore_Config::getSystemConfig()->assets->ffmpeg) {
         if (is_executable(Pimcore_Config::getSystemConfig()->assets->ffmpeg)) {
             return Pimcore_Config::getSystemConfig()->assets->ffmpeg;
         } else {
             Logger::critical("FFMPEG binary: " . Pimcore_Config::getSystemConfig()->assets->ffmpeg . " is not executable");
         }
     }
     $paths = array("/usr/bin/ffmpeg", "/usr/local/bin/ffmpeg", "/bin/ffmpeg");
     foreach ($paths as $path) {
         if (is_executable($path)) {
             return $path;
         }
     }
     throw new Exception("No ffmpeg executable found, please configure the correct path in the system settings");
 }
Example #9
0
 /**
  * @return bool
  */
 public static function getWkhtmltoimageBinary()
 {
     if (Config::getSystemConfig()->documents->wkhtmltoimage) {
         if (@is_executable(Config::getSystemConfig()->documents->wkhtmltoimage)) {
             return (string) Config::getSystemConfig()->documents->wkhtmltoimage;
         } else {
             \Logger::critical("wkhtmltoimage binary: " . Config::getSystemConfig()->documents->wkhtmltoimage . " is not executable");
         }
     }
     $paths = array("/usr/bin/wkhtmltoimage-amd64", "/usr/local/bin/wkhtmltoimage-amd64", "/bin/wkhtmltoimage-amd64", "/usr/bin/wkhtmltoimage", "/usr/local/bin/wkhtmltoimage", "/bin/wkhtmltoimage", realpath(PIMCORE_DOCUMENT_ROOT . "/../wkhtmltox/wkhtmltoimage.exe"));
     foreach ($paths as $path) {
         if (@is_executable($path)) {
             return $path;
         }
     }
     return false;
 }
Example #10
0
 /**
  * @return mixed
  * @throws \Exception
  */
 public static function getLibreOfficeCli()
 {
     $loPath = Config::getSystemConfig()->assets->libreoffice;
     if ($loPath) {
         if (@is_executable($loPath)) {
             return $loPath;
         } else {
             \Logger::critical("LibreOffice binary: " . $loPath . " is not executable");
         }
     }
     $paths = array("/usr/local/bin/soffice", "/usr/bin/soffice", "/bin/soffice");
     foreach ($paths as $path) {
         if (@is_executable($path)) {
             return $path;
         }
     }
     throw new \Exception("No LibreOffice executable found, please configure the correct path in the system settings");
 }
 public function test_methods_Magento()
 {
     $CONFIG_FILE_NAME = __DIR__ . '/logging_exception.yaml';
     $LOGGER_NAME = 'defaultLoggerName';
     /**
      * Perform testing.
      */
     $log = new Logger($CONFIG_FILE_NAME, $LOGGER_NAME);
     $context = ['test' => true, 'env' => ['param1' => 'value1']];
     $log->debug('debug', $context);
     $log->info('info', $context);
     $log->notice('notice', $context);
     $log->warning('warning', $context);
     $log->error('error', $context);
     $log->alert('alert', $context);
     $log->critical('critical', $context);
     $log->emergency('emergency', $context);
 }
Example #12
0
 /**
  * @return mixed
  * @throws \Exception
  */
 public static function getPdftotextCli()
 {
     // check the system-config for a path
     $configPath = Config::getSystemConfig()->assets->pdftotext;
     if ($configPath) {
         if (@is_executable($configPath)) {
             return $configPath;
         } else {
             \Logger::critical("Binary: " . $configPath . " is not executable");
         }
     }
     $paths = array("/usr/local/bin/pdftotext", "/usr/bin/pdftotext", "/bin/pdftotext");
     foreach ($paths as $path) {
         if (@is_executable($path)) {
             return $path;
         }
     }
     throw new \Exception("No pdftotext executable found, please configure the correct path in the system settings");
 }
Example #13
0
 public function usersGroups()
 {
     Logger::debug('main', 'USER::UsersGroups');
     $result = array();
     // add the default user group is enable
     $prefs = Preferences::getInstance();
     if (!$prefs) {
         Logger::critical('main', 'USER::UsersGroups get prefs failed');
         die_error('get Preferences failed', __FILE__, __LINE__);
     }
     $user_default_group = $prefs->get('general', 'user_default_group');
     $userGroupDB = UserGroupDB::getInstance();
     $static = Abstract_Liaison::load('UsersGroup', $this->attributes['login'], NULL);
     if (is_null($static)) {
         Logger::error('main', 'User::usersGroups load(' . $this->attributes['login'] . ') is null');
         return $result;
     }
     if ($userGroupDB->isDynamic()) {
         $dynamic = Abstract_Liaison_dynamic::load('UsersGroup', $this->attributes['login'], NULL);
         if (is_null($dynamic)) {
             $dynamic = array();
         }
     } else {
         $dynamic = array();
     }
     $rows = array_unique(array_merge($static, $dynamic));
     if (!is_null($user_default_group) && $user_default_group !== '-1' && $user_default_group !== '') {
         $g = $userGroupDB->import($user_default_group);
         // safe because even if  group = -1, the import failed safely
         if (is_object($g)) {
             $result[$user_default_group] = $g;
         }
     }
     foreach ($rows as $lug) {
         $g = $userGroupDB->import($lug->group);
         if (is_object($g)) {
             $result[$lug->group] = $g;
         } else {
             Logger::error('main', 'USER::usersGroups user group (\'' . $lug->group . '\') not ok');
         }
     }
     return $result;
 }
Example #14
0
 public function perform($error_ = false, $file_ = NULL, $line_ = NULL, $display_ = false)
 {
     $display_ = true;
     //always display the real error message instead of a generic one
     $file_ = substr(str_replace(SESSIONMANAGER_ROOT, '', $file_), 1);
     Logger::debug('main', 'die_error() called with message \'' . $error_ . '\' in ' . $file_ . ':' . $line_);
     Logger::critical('main', $error_);
     header('Content-Type: text/xml; charset=utf-8');
     $dom = new DomDocument('1.0', 'utf-8');
     $node = $dom->createElement('error');
     $node->setAttribute('id', 0);
     if ($display_ === true) {
         $node->setAttribute('message', $error_);
     } else {
         $node->setAttribute('message', 'The service is not available, please try again later');
     }
     $dom->appendChild($node);
     echo $dom->saveXML();
     die;
 }
 public function __construct($game)
 {
     if (!isset($_SERVER['HTTP_HOST'])) {
         throw new GambinoException(__CLASS__ . ' Unable to instantiate due to absence of HTTP_HOST in $_SERVER');
     }
     parent::__construct($game);
     try {
         $this->facebook = new \Facebook($this->getFacebookConfig());
         $this->session_cached = new \DateTime();
         $this->user_id = $this->facebook->getUser();
         $this->user_profile = $this->facebook->api('/me');
         $this->user_email = trim($this->user_profile['email']);
         $this->user_nicename = trim($this->user_profile['username']);
     } catch (\FacebookApiException $ex) {
         // This is not usually thrown when getting the userId from Facebook
         // but when you try to do something that requires some elevated
         // permissions
         // Facebook token has expired
         Logger::critical('Facebook OAuth (session) token invalid');
     }
 }
Example #16
0
 /**
  * runs the application for a request
  *
  * @param ServerRequestInterface $request
  * @throws \Throwable
  */
 public function run(ServerRequestInterface $request)
 {
     assert($this->config instanceof Configuration && $this->container instanceof DependencyContainer, "You need to call Application::setup() before Application::run()");
     try {
         $response = $this->runRequest($request);
     } catch (RouteNotFoundException $e) {
         $this->logger->info("Error 404 - " . $e->getPath());
         if (!isset($this->error[0])) {
             $response = new Response([], "php://memory", 404);
             $response->getBody()->write("Page not found");
             $this->writeResponse($response);
             return;
         }
         $response = $this->resolveErrorResponse($e);
     } catch (\Throwable $e) {
         $this->logger->critical($e);
         if (!isset($this->error[0])) {
             throw $e;
         }
         $response = $this->resolveErrorResponse($e);
     }
     $this->writeResponse($response);
 }
Example #17
0
 public function usersGroups()
 {
     Logger::debug('main', 'Script::usersGroups');
     $userGroupDB = UserGroupDB::getInstance();
     $result = array();
     // add the default user group is enable
     $prefs = Preferences::getInstance();
     if (!$prefs) {
         Logger::critical('main', 'Script::usersGroups get prefs failed');
         die_error('get Preferences failed', __FILE__, __LINE__);
     }
     $liaison = Abstract_Liaison::load('Scripts', $this->getAttribute('name'), NULL);
     if (is_null($liaison)) {
         Logger::error('main', 'Script::usersGroups load(' . $this->getAttribute('name') . ') is null');
         return $result;
     }
     foreach ($liaison as $row) {
         $g = $userGroupDB->import($row->group);
         if (is_object($g)) {
             $result[] = $g;
         }
     }
     return $result;
 }
Example #18
0
 public function __construct(ServerThread $thread, $port, $interface, $description = "", $favicon = null)
 {
     $this->thread = $thread;
     $this->description = $description;
     if ($favicon === null or ($image = file_get_contents($favicon)) == "") {
         $this->favicon = null;
     } else {
         $this->favicon = "data:image/png;base64," . base64_encode($image);
     }
     $this->logger = $this->thread->getLogger();
     $this->fp = $this->thread->getInternalSocket();
     if ($interface === "") {
         $interface = "0.0.0.0";
     }
     $this->socket = stream_socket_server("tcp://{$interface}:{$port}", $errno, $errstr, STREAM_SERVER_LISTEN | STREAM_SERVER_BIND);
     if (!$this->socket) {
         $this->logger->critical("[BigBrother] **** FAILED TO BIND TO " . $interface . ":" . $port . "!", true, true, 0);
         $this->logger->critical("[BigBrother] Perhaps a server is already running on that port?", true, true, 0);
         exit(1);
     }
     $this->sockets[-1] = $this->socket;
     $this->sockets[0] = $this->fp;
     $this->process();
 }
Example #19
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
//if (stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml'))
//	header('Content-Type: application/xhtml+xml; charset=utf-8');
//else
header('Content-Type: text/html; charset=utf-8');
require_once dirname(__FILE__) . '/core-minimal.inc.php';
$folders = array('reporting', 'tmp', 'cache');
foreach ($folders as $folder) {
    $buf = strtoupper($folder) . '_DIR';
    define($buf, SESSIONMANAGER_SPOOL . '/' . $folder);
    if (!check_folder(constant($buf))) {
        Logger::critical('main', constant($buf) . ' does not exist and cannot be created!');
        die_error(constant($buf) . ' does not exist and cannot be created!', __FILE__, __LINE__);
    }
}
$prefs = Preferences::getInstance();
if (is_object($prefs)) {
    define('HAS_PREFERENCES', true);
    $sql_conf = $prefs->get('general', 'sql');
    if (is_array($sql_conf)) {
        define('SERVERS_HISTORY_TABLE', $sql_conf['prefix'] . 'servers_history');
        define('SESSIONS_HISTORY_TABLE', $sql_conf['prefix'] . 'sessions_history');
        SQL::newInstance($sql_conf);
    }
}
Example #20
0
 public function isDefault()
 {
     $prefs = Preferences::getInstance();
     if (!$prefs) {
         Logger::critical('main', 'USERSGROUP::isDefault get prefs failed');
         die_error('get Preferences failed', __FILE__, __LINE__);
     }
     $user_default_group = $prefs->get('general', 'user_default_group');
     return $user_default_group === $this->getUniqueID();
 }
Example #21
0
    }
    public function getLevelName($level)
    {
        return $this->logLevels[$level];
    }
}
// testing
if (isset($_SERVER["argv"][1]) && $_SERVER["argv"][1] == "__main__") {
    $logger = new Logger();
    for ($i = 0; $i < 6; $i++) {
        $logger->setLevel($i);
        error_log("############## Level now: " . $i);
        $logger->debug("");
        $logger->info("");
        $logger->notice("");
        $logger->warn("");
        $logger->error("");
        $logger->critical("");
    }
    error_log("############# With Level Names");
    for ($i = 0; $i < 6; $i++) {
        $logger->setLevel($logger->getLevelName($i));
        error_log("############## Level now: " . $logger->getLevelName($i));
        $logger->debug("");
        $logger->info("", __FILE__, __LINE__);
        $logger->notice("");
        $logger->warn("");
        $logger->error("");
        $logger->critical("");
    }
}
 * @author     Thomas Keil <*****@*****.**>
 * @license    http://www.pimcore.org/license     New BSD License
 */
ini_set('memory_limit', '2048M');
set_time_limit(-1);
date_default_timezone_set("Europe/Berlin");
include_once dirname(__FILE__) . "/../../../pimcore/config/startup.php";
Pimcore::initAutoloader();
Pimcore::initConfiguration();
Pimcore::initLogger();
Pimcore::initPlugins();
$opts = new Zend_Console_Getopt(array('language|l=s' => "language", 'document|d=s' => "document"));
try {
    $opts->parse();
} catch (Exception $e) {
    Logger::critical($e->getMessage());
    die("Error: " . $e->getMessage());
}
$sphinx_config = SphinxSearch_Config::getInstance();
$documents = $sphinx_config->getDocumentsAsArray();
if (!array_key_exists($opts->document, $documents)) {
    SphinxSearch_Logger::err("Unknown document: " . $opts->document . "\n");
    print "Unknown document: " . $opts->document . "\n";
    print "Possible documents are:\n";
    foreach ($documents as $document_name => $document_config) {
        print $document_name . "\n";
    }
    die;
}
$document_config = $documents[$opts->document];
$controller = $document_config["controller"];
Example #23
0
 /**
  *
  */
 public function getConversionStatus()
 {
     $log = file_get_contents($this->getConversionLogFile());
     // check if the conversion failed
     if (stripos($log, "Invalid data found when processing") !== false || stripos($log, "incorrect parameters") !== false || stripos($log, "error") !== false || stripos($log, "unable") !== false) {
         \Logger::critical("Problem converting video: " . $this->file . " to format " . $this->getFormat());
         \Logger::critical($log);
         // create a copy of the conversion log, so that it will persist
         copy($this->getConversionLogFile(), str_replace(".log", ".error.log", $this->getConversionLogFile()));
         return "error";
     }
     $duration = $this->extractDuration($log);
     // get conversion time
     preg_match_all("/time=([0-9:\\.]+) bitrate/", $log, $matches);
     $conversionTimeRaw = $matches[1][count($matches[1]) - 1];
     $conversionTimeParts = explode(":", $conversionTimeRaw);
     // calculate time in seconds
     $conversionTime = intval($conversionTimeParts[0]) * 3600 + intval($conversionTimeParts[1]) * 60 + floatval($conversionTimeParts[2]);
     if ($duration > 0) {
         $status = $conversionTime / $duration;
     } else {
         $status = 0;
     }
     $percent = round($status * 100);
     // check if the conversion is finished
     clearstatcache();
     // clear stat cache otherwise filemtime always returns the same timestamp
     if (time() - filemtime($this->getConversionLogFile()) > 10) {
         $percent = 100;
         $this->deleteConversionLogFile();
     }
     if (!$percent) {
         $percent = 1;
     }
     \Logger::debug("Video transcoding status of " . $this->getDestinationFile() . ": " . $percent . " - " . $this->getFormat());
     return $percent;
 }
 /**
  * Critical conditions.
  *
  * Example: Application component unavailable, unexpected exception.
  *
  * @param string $message
  * @param array $context
  *
  * @return null
  */
 public function critical($message, array $context = array())
 {
     \Logger::critical($message);
 }
Example #25
0
define('ABSTRACT_CLASSES_DIR', SESSIONMANAGER_ROOT . '/classes/abstract');
define('PREMIUM_CLASSES_DIR', SESSIONMANAGER_ROOT . '/premium');
define('ADMIN_CLASSES_DIR', SESSIONMANAGER_ROOT_ADMIN . '/classes');
define('MODULES_DIR', SESSIONMANAGER_ROOT . '/modules');
define('EVENTS_DIR', SESSIONMANAGER_ROOT . '/events');
define('CALLBACKS_DIR', SESSIONMANAGER_ROOT . '/events/callbacks');
require_once dirname(__FILE__) . '/functions.inc.php';
require_once dirname(__FILE__) . '/load_balancing.inc.php';
require_once dirname(__FILE__) . '/defaults.inc.php';
if (!file_exists(SESSIONMANAGER_CONF_FILE)) {
    die_error('Configuration file missing', __FILE__, __LINE__);
}
@(include_once SESSIONMANAGER_CONF_FILE);
$buf = conf_is_valid();
if ($buf !== true) {
    Logger::critical('main', 'Configuration not valid : ' . $buf);
    die_error('Configuration not valid : ' . $buf, __FILE__, __LINE__);
}
function __autoload($class_name)
{
    //what about NameSpaces ?
    $class_files = array();
    if (!class_exists($class_name)) {
        $class_files[] = PREMIUM_CLASSES_DIR . '/' . $class_name . '.class.php';
        $class_files[] = CLASSES_DIR . '/' . $class_name . '.class.php';
        $class_files[] = CLASSES_DIR . '/configelements/' . $class_name . '.class.php';
        $class_files[] = CLASSES_DIR . '/events/' . $class_name . '.class.php';
        $class_files[] = EVENTS_DIR . '/' . $class_name . '.class.php';
        $class_files[] = CLASSES_DIR . '/tasks/' . $class_name . '.class.php';
        $class_files[] = MODULES_DIR . '/' . $class_name . '.php';
        $class_files[] = ABSTRACT_CLASSES_DIR . '/' . $class_name . '.class.php';
 /**
  * @param null $key
  * @throws \Exception
  */
 public function initResource($key = null)
 {
     $myClass = get_class($this);
     $resource = null;
     if (!$key) {
         // check for a resource in the cache
         if (array_key_exists($myClass, self::$resourceClassCache)) {
             $resource = self::$resourceClassCache[$myClass];
         } else {
             $classes = $this->getParentClasses($myClass);
             foreach ($classes as $class) {
                 $delimiter = "_";
                 // old prefixed class style
                 if (strpos($class, "\\")) {
                     $delimiter = "\\";
                     // that's the new with namespaces
                 }
                 $classParts = explode($delimiter, $class);
                 $length = count($classParts);
                 $className = null;
                 for ($i = 0; $i < $length; $i++) {
                     // check for a general DBMS resource adapter
                     $tmpClassName = implode($delimiter, $classParts) . $delimiter . "Resource";
                     if ($className = $this->determineResourceClass($tmpClassName)) {
                         break;
                     }
                     // this is just for compatibility anymore, this was before the standard way
                     // but as there will not be a specialized implementation anymore eg. Oracle, PostgreSQL, ...
                     // we can move that below the general resource adapter as a fallback
                     $tmpClassName = implode($delimiter, $classParts) . $delimiter . "Resource" . $delimiter . ucfirst(Resource::getType());
                     if ($className = $this->determineResourceClass($tmpClassName)) {
                         break;
                     }
                     array_pop($classParts);
                 }
                 if ($className && $className != "Pimcore\\Resource") {
                     //\Logger::debug("Found resource implementation " . $className . " for " . $myClass);
                     $resource = $className;
                     self::$resourceClassCache[$myClass] = $resource;
                     break;
                 }
             }
         }
     } else {
         // check in cache
         $cacheKey = $myClass . "-" . $key;
         if (array_key_exists($cacheKey, self::$resourceClassCache)) {
             $resource = self::$resourceClassCache[$cacheKey];
         } else {
             $delimiter = "_";
             // old prefixed class style
             if (strpos($key, "\\") !== false) {
                 $delimiter = "\\";
                 // that's the new with namespaces
             }
             // check for a specialized resource adapter for the current DBMS
             $resourceClass = $key . $delimiter . "Resource" . $delimiter . ucfirst(Resource::getType());
             if (!($resource = $this->determineResourceClass($resourceClass))) {
                 $resource = $key . $delimiter . "Resource";
             }
             self::$resourceClassCache[$cacheKey] = $resource;
         }
     }
     if (!$resource) {
         \Logger::critical("No resource implementation found for: " . $myClass);
         throw new \Exception("No resource implementation found for: " . $myClass);
     }
     $resource = "\\" . ltrim($resource, "\\");
     $this->resource = new $resource();
     $this->resource->setModel($this);
     $db = Resource::get();
     $this->resource->configure($db);
     if (method_exists($this->resource, "init")) {
         $this->resource->init();
     }
 }
Example #27
0
                continue;
            }
            $application_node = $dom->createElement('application');
            $application_node->setAttribute('id', $application->getAttribute('id'));
            $application_node->setAttribute('type', 'webapp');
            $application_node->setAttribute('name', $application->getAttribute('name'));
            $applications_node->appendChild($application_node);
        }
        $session_node->appendChild($applications_node);
        $dom->appendChild($session_node);
        $sessionManagement->appendToSessionCreateXML($dom);
        $xml = $dom->saveXML();
        $ret_xml = query_url_post_xml($server->getBaseURL() . '/webapps/session/create', $xml);
        $ret = $sessionManagement->parseSessionCreate($ret_xml);
        if (!$ret) {
            Logger::critical('main', '(client/start) Unable to create Session \'' . $session->id . '\' for User \'' . $session->user_login . '\' on Server \'' . $server->fqdn . '\', aborting');
            $session->orderDeletion(true, Session::SESSION_END_STATUS_ERROR);
            throw_response(INTERNAL_ERROR);
        }
        $ret_dom = new DomDocument('1.0', 'utf-8');
        $ret_buf = @$ret_dom->loadXML($ret_xml);
        $node = $ret_dom->getElementsByTagname('session')->item(0);
        $webapps_url = $node->getAttribute('webapps-scheme') . '://' . $server->getExternalName() . ':' . $node->getAttribute('webapps-port');
        $session->settings['webapps-url'] = $webapps_url;
    }
    //
    $session->setStatus(Session::SESSION_STATUS_READY);
    Logger::info('main', '(client/start) Resuming session for ' . $user->getAttribute('login') . ' (' . $old_session_id . ' => ' . $session->server . ')');
} else {
    if (!$sessionManagement->generateCredentials()) {
        Logger::error('main', '(client/start) Unable to generate access credentials for User "' . $user->getAttribute('login') . '", aborting');
Example #28
0
 /**
  * @return bool
  */
 public static function getJpegOptimizerCli()
 {
     // check if we have a cached path for this process
     if (array_key_exists("jpegOptimizer", self::$optimizerBinaries)) {
         return self::$optimizerBinaries["jpegOptimizer"];
     }
     // check the system-config for a path
     foreach (["imgmin", "jpegoptim"] as $type) {
         $configPath = Config::getSystemConfig()->assets->{$type};
         if ($configPath) {
             if (@is_executable($configPath)) {
                 self::$optimizerBinaries["pngOptimizer"] = array("path" => $configPath, "type" => $type);
                 return $configPath;
             } else {
                 \Logger::critical("Binary: " . $configPath . " is not executable");
             }
         }
     }
     $paths = array("/usr/local/bin/jpegoptim", "/usr/bin/jpegoptim", "/bin/jpegoptim", "/usr/local/bin/imgmin", "/usr/bin/imgmin", "/bin/imgmin");
     foreach ($paths as $path) {
         if (@is_executable($path)) {
             self::$optimizerBinaries["jpegOptimizer"] = array("path" => $path, "type" => basename($path));
             return self::$optimizerBinaries["jpegOptimizer"];
         }
     }
     self::$optimizerBinaries["jpegOptimizer"] = false;
     return false;
 }
Example #29
0
 /**
  * @param null $key
  * @throws \Exception
  */
 public function initDao($key = null)
 {
     $myClass = get_class($this);
     $dao = null;
     if (!$key) {
         // check for a resource in the cache
         if (array_key_exists($myClass, self::$daoClassCache)) {
             $dao = self::$daoClassCache[$myClass];
         } else {
             $classes = $this->getParentClasses($myClass);
             foreach ($classes as $class) {
                 $delimiter = "_";
                 // old prefixed class style
                 if (strpos($class, "\\")) {
                     $delimiter = "\\";
                     // that's the new with namespaces
                 }
                 $classParts = explode($delimiter, $class);
                 $length = count($classParts);
                 $className = null;
                 for ($i = 0; $i < $length; $i++) {
                     // check for a general dao adapter
                     $tmpClassName = implode($delimiter, $classParts) . $delimiter . "Dao";
                     if ($className = $this->determineResourceClass($tmpClassName)) {
                         break;
                     }
                     // check for the old style resource adapter
                     $tmpClassName = implode($delimiter, $classParts) . $delimiter . "Resource";
                     if ($className = $this->determineResourceClass($tmpClassName)) {
                         break;
                     }
                     array_pop($classParts);
                 }
                 if ($className) {
                     $dao = $className;
                     self::$daoClassCache[$myClass] = $dao;
                     break;
                 }
             }
         }
     } else {
         // check in cache
         $cacheKey = $myClass . "-" . $key;
         if (array_key_exists($cacheKey, self::$daoClassCache)) {
             $dao = self::$daoClassCache[$cacheKey];
         } else {
             $delimiter = "_";
             // old prefixed class style
             if (strpos($key, "\\") !== false) {
                 $delimiter = "\\";
                 // that's the new with namespaces
             }
             $dao = $key . $delimiter . "Dao";
             self::$daoClassCache[$cacheKey] = $dao;
         }
     }
     if (!$dao) {
         \Logger::critical("No dao implementation found for: " . $myClass);
         throw new \Exception("No dao implementation found for: " . $myClass);
     }
     $dao = "\\" . ltrim($dao, "\\");
     $this->dao = new $dao();
     $this->dao->setModel($this);
     $db = Db::get();
     $this->dao->configure($db);
     if (method_exists($this->dao, "init")) {
         $this->dao->init();
     }
 }
Example #30
0
 /**
  *
  */
 public function getConversionStatus()
 {
     $log = file_get_contents($this->getConversionLogFile());
     // check if the conversion failed
     if (stripos($log, "Invalid data found when processing") !== false || stripos($log, "incorrect parameters") !== false || stripos($log, "error") !== false) {
         Logger::critical("Problem converting video: " . $this->file . " to format " . $this->getFormat());
         Logger::critical($log);
         return "error";
     }
     // get total video duration
     preg_match("/Duration: ([0-9:\\.]+),/", $log, $matches);
     $durationRaw = $matches[1];
     $durationParts = explode(":", $durationRaw);
     // calculate duration in seconds
     $duration = intval($durationParts[0]) * 3600 + intval($durationParts[1]) * 60 + floatval($durationParts[2]);
     // get conversion time
     preg_match_all("/time=([0-9:\\.]+) bitrate/", $log, $matches);
     $conversionTimeRaw = $matches[1][count($matches[1]) - 1];
     $conversionTimeParts = explode(":", $conversionTimeRaw);
     // calculate time in seconds
     $conversionTime = intval($conversionTimeParts[0]) * 3600 + intval($conversionTimeParts[1]) * 60 + floatval($conversionTimeParts[2]);
     if ($duration > 0) {
         $status = $conversionTime / $duration;
     } else {
         $status = 0;
     }
     $percent = round($status * 100);
     // check if the conversion is finished
     clearstatcache();
     // clear stat cache otherwise filemtime always returns the same timestamp
     if (time() - filemtime($this->getConversionLogFile()) > 10) {
         $percent = 100;
         @unlink($this->getConversionLogFile());
     }
     if (!$percent) {
         $percent = 1;
     }
     // add flash video metadata when conversion is finished
     if ($percent > 99 && $this->getFormat() == "mp4") {
         $this->addMp4MetaData();
     }
     Logger::debug("Video transcoding status of " . $this->getDestinationFile() . ": " . $percent . " - " . $this->getFormat());
     return $percent;
 }