function app_controller() { global $session, $route, $mysqli; $result = false; include "Modules/app/AppConfig_model.php"; $appconfig = new AppConfig($mysqli); if ($route->format == 'html') { if ($route->action == "" && $session['write']) { $result = view("Modules/app/client.php", array()); } } if ($route->format == 'json') { if ($route->action == "setconfig" && $session['write']) { $result = $appconfig->set($session['userid'], get('data')); } if ($route->action == "getconfig" && $session['read']) { $result = $appconfig->get($session['userid']); } if ($route->action == "dataremote") { $id = (int) get("id"); $start = (double) get("start"); $end = (double) get("end"); $interval = (int) get("interval"); $result = json_decode(file_get_contents("http://emoncms.org/feed/data.json?id={$id}&start={$start}&end={$end}&interval={$interval}&skipmissing=0&limitinterval=0")); } if ($route->action == "valueremote") { $id = (int) get("id"); $result = (double) json_decode(file_get_contents("http://emoncms.org/feed/value.json?id={$id}")); } } return array('content' => $result, 'fullwidth' => true); }
public static function get_config_data() { if (!($config = AppConfig::get()->first())) { return []; } return $config->forAPI(); }
public static function getDB() { if (is_null(self::$db)) { self::$db = self::getMongo()->{AppConfig::get("db.mongodb.name")}; } return self::$db; }
/** * @return \Doctrine\ORM\EntityManager */ public static function getMySql() { if (is_null(self::$mysql)) { $paths = array('src/Main/Entity'); $config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration($paths, true); self::$mysql = \Doctrine\ORM\EntityManager::create(array('driver' => 'pdo_mysql', 'user' => AppConfig::get("db.mysql.host"), 'password' => AppConfig::get("db.mysql.password"), 'dbname' => AppConfig::get("db.mysql.name"), 'charset' => 'utf8', 'driverOptions' => array(1002 => 'SET NAMES utf8')), $config); } return self::$mysql; }
public static function load($objectType, $asSingelton = FALSE, $params = '') { $factoryClass = AppConfig::get('factory_settings', 'template'); if (!class_exists($factoryClass)) { throw new \Exception("Could not find class {$factoryClass} for Factory Option: {$objectType}"); } $classExtends = class_parents($factoryClass); $classInterfaces = class_implements($factoryClass); if (class_exists($factoryClass) && in_array($objectType, $classExtends) && in_array($objectType . 'Interface', $classInterfaces)) { if ($asSingelton) { return $factoryClass::singleton($params); } else { return new $factoryClass($params); } } else { throw new \Exception('Invalid Factory Option for: ' . $objectType); } }
public function getIndex($slug = '', $link_id = 0) { $debug = ''; $bmStart = microtime(true); $perpage = intval(AppConfig::get('articles_per_page', 50)); $branch_prefixes = explode(',', AppConfig::get('branch_prefixes')); $virtualPerpage = intval(AppConfig::get('virtual_per_page', 20)); $page = Page::where('slug', '=', $slug)->cacheTags('pages')->remember(1440)->first(); //$page = Page::where('slug', '=', Str::slug($slug))->first(); if (count($page) > 0) { if ($filter_return = $this->authFilter($page->level)) { return $filter_return; } if ($page->redirect) { if (substr($page->redirect, 0, 1) == '{') { $redir_arr = json_decode($page->redirect, true); foreach ($redir_arr as $rlvl => $rslug) { if (strpos($this->auth_lvl, $rlvl) !== false) { return Redirect::to($rslug); } } if (isset($redir_arr['def'])) { return Redirect::to($redir_arr['def']); } } else { return Redirect::to($page->redirect); } } // get parameters from URL $page->category = Input::has('category') ? Input::get('category') : ($page->default_category ? $page->default_category : false); $page->section = Input::has('section') ? Input::get('section') : false; $page->keywordInput = $page->ddkeycol ? Input::get('keyword') : ''; $page_vars = new stdClass(); // separate slug into branch and section, if applicable $branch = $slug; if ($page->link_slug) { $branch = $page->link_slug; } $els = explode('/', $branch); if (in_array($els[0], $branch_prefixes) && count($els) > 1) { $branch = $els[0]; if (!$page->section) { $page->section = $els[1]; } } $dta = normal::getTypes(); // get list of categories, if there is a "ddlist" $categories = false; $normalized = false; if ($page->ddlist) { $fld = $page->ddlist; $catq = Link::where('branch', '=', $branch); if ($page->section) { $catq->where('section', '=', $page->section); } if ($dtp = array_search($fld, $dta)) { $catq->join('data', 'data.rec_id', '=', 'links.id')->where('data.table_name', '=', 'links')->where('data.type', '=', $dtp)->whereNull('data.deleted_at'); $fld = 'data_body'; $normalized = true; } $category_model = $catq->groupBy($fld)->whereRaw('trim(`' . $fld . '`) != ""')->cacheTags('links')->remember(1440)->get(array($fld)); $categories = array('' => 'All'); foreach ($category_model as $category_item) { $categories[$category_item->{$fld}] = $category_item->{$fld}; } } $links = false; $columns = false; // get list of links, specified by branch, section, category, state, and/or keyword if ($page->linkdef || $link_id && $page->detaildef) { // get column layout $columns = Listcolumns::where('def', '=', $link_id ? $page->detaildef : $page->linkdef)->cacheTags('links')->remember(1440)->orderBy('listorder')->get(); $perlinkpage = intval(AppConfig::get('links_per_page', 50)); $query = new Link(); if ($link_id) { $query = $query->where('id', '=', $link_id); } else { if ($page->section) { $query = $query->where('section', '=', $page->section); } if ($page->category) { if ($normalized) { $query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', $dtp)->whereNull('d.deleted_at'); } $query = $query->where(isset($fld) ? $fld : ($page->section ? 'category' : 'section'), '=', $page->category); } if ($page->state) { $query = $query->where('state', '=', $page->state); } if ($page->keywordInput) { if ($page->keywordInput == "by_date") { $query = $query->join('data AS d', 'd.rec_id', '=', 'links.id')->where('d.table_name', '=', 'links')->where('d.type', '=', 7)->whereNull('d.deleted_at'); $month = Input::get('themonth'); $year = Input::get('theyear'); $pfx = $year . '-' . $month; $start_date = $pfx . '-01'; $end_date = $pfx . '-' . cal_days_in_month(CAL_GREGORIAN, $month, $year); $query = $query->whereRaw('d.`data_body` BETWEEN ? AND ?', array($start_date, $end_date)); unset($page->keywordInput); $page_vars->month = $month; $page_vars->year = $year; } else { $query = $query->whereRaw('`' . $page->ddkeycol . '` RLIKE ?', array($page->keywordInput)); } } if (!$page->allowBroken) { $query = $query->join('link_check', 'links.id', '=', 'link_check.id'); $query = $query->whereBetween('link_check.last_result', array('200', '399')); } } $order = 'name'; $orderdir = 'asc'; if ($page->linkorder) { $ordera = explode(',', $page->linkorder); $order = $ordera[0]; if (count($ordera) > 1) { $orderdir = $ordera[1]; } if ($dtp = array_search($order, $dta)) { $query = $query->join('data AS d2', 'd2.rec_id', '=', 'links.id')->where('d2.table_name', '=', 'links')->where('d2.type', '=', $dtp)->whereNull('d2.deleted_at'); $order = 'd2.data_body'; } } if ($page->where) { $query = $query->whereRaw($page->where); } if ($page->remove_dupes) { $query = $query->groupBy('name', 'url'); } $links = $query->where('branch', '=', $branch)->select(array('links.*'))->orderBy($order, $orderdir)->cacheTags('links')->remember(1440)->paginate($perlinkpage); $ids = array(); foreach ($links as $link) { $ids[] = $link->id; } $xda = count($ids) ? Cache::tags('links')->remember('linkData|' . implode('-', $ids), 1440, function () use($ids) { $xdata = Data::where('table_name', '=', 'links')->join('data_types', 'data_types.id', '=', 'data.type')->whereIn('rec_id', $ids)->whereNull('data_types.deleted_at')->cacheTags('data')->remember(10080)->get(); $xdda = array(); foreach ($xdata as $xrec) { $xdda[$xrec->rec_id][$xrec->label] = $xrec->data_body; } return $xdda; }) : array(); foreach ($links as $lid => $link) { $id = $link->id; if (isset($xda[$id])) { foreach ($xda[$id] as $xid => $xdt) { $links[$lid]->{$xid} = $xdt; } } } } $thumbs = false; if ($page->virtual_type) { $thumbs = Ad::where('type', '=', $page->virtual_type)->where('category', '=', $page->category)->orderBy('vorder', 'desc')->cacheTags('ads')->remember(1440)->paginate($virtualPerpage); foreach ($thumbs as $thumb) { Ads::track($thumb, 3, $page->id); } // get list of categories $category_model = Ad::groupBy('category')->where('type', '=', $page->virtual_type)->cacheTags('ads')->remember(1440)->get(array('category')); $categories = array(); foreach ($category_model as $category_item) { $categories[$category_item->category] = $category_item->category; } // $page->dname = 'Category'; } // benchmarking the database access $bmEnd = microtime(true); $page->elapsed = $bmEnd - $bmStart; $page_vars->qstring = ''; if ($page->pass_query == 'Y') { $qry = Input::query(); $qry['mc_rnm'] = substr(time(), 2); if (count($qry)) { $page_vars->qstring = '?' . http_build_query($qry); } } if ($page->randomize) { foreach (explode(',', $page->randomize) as $random_tag) { $page_vars->{$random_tag} = mt_rand(10000, 99999); } } foreach (AppConfig::getAll() as $cfi => $cfd) { $page_vars->{$cfi} = $cfd; } $page_vars->nocache = NOCACHE_CODE; if (!$page->layout) { // if ($_SERVER['REMOTE_ADDR'] == '108.47.107.194') { // $page->layout = 'template.layout2'; // } else { $page->layout = 'template.layout'; // } } // get data on child and parent pages $childpages = new Page(); $P = clone $childpages->getConnection()->getPaginator(); $P->setPageName('article'); $childpages->getConnection()->setPaginator($P); $childpages = $childpages->join('article_pages', 'pages.id', '=', 'article_pages.page_id'); $childpages = $childpages->where('article_pages.parent_id', '=', $page->id); $childpages = $childpages->whereNull('article_pages.deleted_at'); $childpages = $childpages->orderBy('pageOrder'); $childpages = $childpages->cacheTags('pages')->remember(1440); $childpages = $childpages->paginate($perpage); // pass ALL the data to the view return View::make('page.page')->with('dyn_layout', $page->layout)->with('page', $page)->with('childpages', $childpages)->with('categories', $categories)->with('links', $links)->with('link_id', $link_id)->with('thumbs', $thumbs)->with('columns', $columns)->with('top_banner', empty($slug))->with('debug', $debug)->with('parse_body', Display::format($page->body, $page_vars, false, false)); } else { if (substr($slug, -5) == '.html') { $new_slug = substr($slug, 0, -5); $new_page = Page::where('slug', '=', $new_slug)->cacheTags('pages')->remember(1440)->first(); if (count($new_page) > 0) { return Redirect::to('/' . $new_slug, 301); } } $missing = new Missing(); $missing->slug = $slug; $missing->referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "[none]"; $missing->save(); AppLog::alert('Page Not Found', 404, json_encode(array('slug' => $slug))); return Response::view('page.notfound', array('slug' => $slug), 404); } }
<?php require_once 'app_config.php'; $_config = new AppConfig(); echo $_config->get('OPERATION_MODE') . "<br>"; echo $_config->get('MYSQL_DEFAULT', 'MYSQL_DEFAULT_DSN');
/** * User password hash function. * * This function use Bcrypt, see http://en.wikipedia.org/wiki/Bcrypt. * * @param $password * The password to hash. * * @return * A printable crypt() scheme. * see http://en.wikipedia.org/wiki/Crypt_(C)#Blowfish-based_scheme */ public static function password_crypt($password) { $cost = AppConfig::get('security.bcrypt_cost', 14); // default is 14, better safe than sorry. return password_hash($password, PASSWORD_BCRYPT, array('cost' => $cost)); }
moment.locale(window.lang); // bootstrap-datetimepicker $('.datepickerize').datetimepicker({ pickTime: false, language: window.lang, weekStart: 1, format: <?php echo json_encode(strftime2momentjs(AppConfig::get('l10n.strftime_date_format'))); ?> }); $('.datetimepickerize').datetimepicker({ pickTime: true, language: window.lang, weekStart: 1, format: <?php echo json_encode(strftime2momentjs(AppConfig::get('l10n.strftime_datetime_format'))); ?> }); }); </script> </head> <body> <?php $view->render('header'); ?> <div class="container"> <section id="content"> <?php $view->render('messages');
public function install(AppConfig $app, $db_params) { logMessage(L_USER, sprintf("Copying application files to %s", $app->get('BASE_DIR'))); logMessage(L_USER, sprintf("current working dir is %s", getcwd())); if (!OsUtils::rsync('package/app/', $app->get('BASE_DIR'), "--exclude web/content")) { return "Failed to copy application files to target directory"; } if ($app->get('DB1_CREATE_NEW_DB')) { if (!OsUtils::rsync("package/app/web/content", $app->get('WEB_DIR'))) { return "Failed to copy default content into /opt/kaltura/web"; } } $os_name = OsUtils::getOsName(); $architecture = OsUtils::getSystemArchitecture(); logMessage(L_USER, "Copying binaries for {$os_name} {$architecture}"); if (!OsUtils::fullCopy("package/bin/{$os_name}/{$architecture}", $app->get('BIN_DIR'))) { return "Failed to copy binaries for {$os_name} {$architecture}"; } logMessage(L_USER, "Creating the uninstaller"); if (!OsUtils::fullCopy('installer/uninstall.php', $app->get('BASE_DIR') . "/uninstaller/")) { return "Failed to create the uninstaller"; } //create uninstaller.ini with minimal definitions $app->saveUninstallerConfig(); //OsUtils::logDir definition OsUtils::$logDir = $app->get('LOG_DIR'); // if vmware installation copy configurator folders if ($app->get('KALTURA_PREINSTALLED')) { mkdir($app->get('BASE_DIR') . '/installer', 0777, true); if (!OsUtils::rsync('installer/', $app->get('BASE_DIR') . '/installer')) { return "Failed to copy installer files to target directory"; } if (!OsUtils::fullCopy('configurator/', $app->get('BASE_DIR') . '/installer')) { return "Failed to copy configurator files to target directory"; } if (!OsUtils::fullCopy('configure.php', $app->get('BASE_DIR') . "/installer/")) { return "Failed to copy configure.php file to targer directory"; } } logMessage(L_USER, "Replacing configuration tokens in files"); foreach ($this->install_config['token_files'] as $file) { $replace_file = $app->replaceTokensInString($file); if (!$app->replaceTokensInFile($replace_file)) { return "Failed to replace tokens in {$replace_file}"; } } $this->changeDirsAndFilesPermissions($app); if (!$app->get('DB1_CREATE_NEW_DB') && DatabaseUtils::dbExists($db_params, $app->get('DB1_NAME')) === true) { logMessage(L_USER, sprintf("Skipping '%s' database creation", $app->get('DB1_NAME'))); } else { $sql_files = parse_ini_file($app->get('BASE_DIR') . APP_SQL_DIR . 'create_kaltura_db.ini', true); logMessage(L_USER, sprintf("Creating and initializing '%s' database", $app->get('DB1_NAME'))); if (!DatabaseUtils::createDb($db_params, $app->get('DB1_NAME'))) { return "Failed to create '" . $app->get('DB1_NAME') . "' database"; } foreach ($sql_files['kaltura']['sql'] as $sql) { $sql_file = $app->get('BASE_DIR') . APP_SQL_DIR . $sql; if (!DatabaseUtils::runScript($sql_file, $db_params, $app->get('DB1_NAME'))) { return "Failed running database script {$sql_file}"; } } } if (!$app->get('DB1_CREATE_NEW_DB') && DatabaseUtils::dbExists($db_params, $app->get('SPHINX_DB_NAME')) === true) { logMessage(L_USER, sprintf("Skipping '%s' database creation", $app->get('SPHINX_DB_NAME'))); } else { logMessage(L_USER, sprintf("Creating and initializing '%s' database", $app->get('SPHINX_DB_NAME'))); if (!DatabaseUtils::createDb($db_params, $app->get('SPHINX_DB_NAME'))) { return "Failed to create '" . $app->get('SPHINX_DB_NAME') . "' database"; } foreach ($sql_files[$app->get('SPHINX_DB_NAME')]['sql'] as $sql) { $sql_file = $app->get('BASE_DIR') . APP_SQL_DIR . $sql; if (!DatabaseUtils::runScript($sql_file, $db_params, $app->get('SPHINX_DB_NAME'))) { return "Failed running database script {$sql_file}"; } } } if (!$app->get('DB1_CREATE_NEW_DB') && DatabaseUtils::dbExists($db_params, $app->get('DWH_DATABASE_NAME')) === true) { logMessage(L_USER, sprintf("Skipping '%s' database creation", $app->get('DWH_DATABASE_NAME'))); } else { logMessage(L_USER, "Creating data warehouse"); if (!OsUtils::execute(sprintf("%s/setup/dwh_setup.sh -h %s -P %s -u %s -p %s -d %s ", $app->get('DWH_DIR'), $app->get('DB1_HOST'), $app->get('DB1_PORT'), $app->get('DWH_USER'), $app->get('DWH_PASS'), $app->get('DWH_DIR')))) { return "Failed running data warehouse initialization script"; } } logMessage(L_USER, "Creating Dynamic Enums"); if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/installPlugins.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "Dynamic Enums created"); } else { return "Failed to create dynamic enums"; } logMessage(L_USER, "Create query cache triggers"); if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/createQueryCacheTriggers.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "sphinx Query Cache Triggers created"); } else { return "Failed to create QueryCacheTriggers"; } logMessage(L_USER, "Populate sphinx tables"); if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/populateSphinxEntries.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "sphinx entries log created"); } else { return "Failed to populate sphinx log from entries"; } if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/populateSphinxEntryDistributions.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "sphinx content distribution log created"); } else { return "Failed to populate sphinx log from content distribution"; } if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/populateSphinxCuePoints.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "sphinx cue points log created"); } else { return "Failed to populate sphinx log from cue points"; } if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/populateSphinxKusers.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "sphinx Kusers log created"); } else { return "Failed to populate sphinx log from Kusers"; } if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/populateSphinxTags.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "sphinx tags log created"); } else { return "Failed to populate sphinx log from tags"; } if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/populateSphinxCategories.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "sphinx Categories log created"); } else { return "Failed to populate sphinx log from categories"; } $this->changeDirsAndFilesPermissions($app); $this->changeDirsAndFilesOwnerships($app); logMessage(L_USER, "Creating system symbolic links"); foreach ($this->install_config['symlinks'] as $slink) { $link_items = explode(SYMLINK_SEPARATOR, $app->replaceTokensInString($slink)); if (symlink($link_items[0], $link_items[1])) { logMessage(L_INFO, "Created symbolic link {$link_items['0']} -> {$link_items['1']}"); } else { logMessage(L_INFO, "Failed to create symbolic link from " . $link_items[0] . " to " . $link_items[1] . ", retyring.."); unlink($link_items[1]); symlink($link_items[0], $link_items[1]); } } //update uninstaller config $app->updateUninstallerConfig($this->install_config['symlinks']); if (strcasecmp($app->get('KALTURA_VERSION_TYPE'), K_CE_TYPE) == 0) { $app->simMafteach(); } logMessage(L_USER, "Deploying uiconfs in order to configure the application"); foreach ($this->install_config['uiconfs_2'] as $uiconfapp) { $to_deploy = $app->replaceTokensInString($uiconfapp); if (OsUtils::execute(sprintf("%s %s/deployment/uiconf/deploy_v2.php --ini=%s", $app->get('PHP_BIN'), $app->get('APP_DIR'), $to_deploy))) { logMessage(L_INFO, "Deployed uiconf {$to_deploy}"); } else { return "Failed to deploy uiconf {$to_deploy}"; } } logMessage(L_USER, "clear cache"); if (!OsUtils::execute(sprintf("%s %s/scripts/clear_cache.php -y", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { return "Failed clear cache"; } logMessage(L_USER, "Running the generate script"); $currentWorkingDir = getcwd(); chdir($app->get('APP_DIR') . '/generator'); if (!OsUtils::execute($app->get('APP_DIR') . '/generator/generate.sh')) { return "Failed running the generate script"; } logMessage(L_USER, "Running the batch manager"); chdir($app->get('APP_DIR') . '/scripts/'); if (!OsUtils::execute($app->get('APP_DIR') . '/scripts/serviceBatchMgr.sh start')) { return "Failed running the batch manager"; } chdir($currentWorkingDir); logMessage(L_USER, "Running the sphinx search daemon"); print "Executing sphinx daemon \n"; OsUtils::executeInBackground('nohup ' . $app->get('APP_DIR') . '/plugins/sphinx_search/scripts/watch.daemon.sh'); OsUtils::executeInBackground('chkconfig sphinx_watch.sh on'); //make sure crond is running. OsUtils::executeInBackground('chkconfig crond on'); $this->changeDirsAndFilesPermissions($app); OsUtils::execute('cp /package/version.ini ' . $app->get('APP_DIR') . '/configurations/'); return null; }
/** * Parse a string to DateTime. * * @param $s * A string in the configured date format. * * @return * A DateTime object or null on failure. */ function s_to_date($s) { $ret = null; $fmt = AppConfig::get('l10n.strftime_date_format'); $parsed = strptime($s, $fmt); if ($parsed) { $t = mktime($parsed['tm_hour'], $parsed['tm_min'], $parsed['tm_sec'], $parsed['tm_mon'] + 1, $parsed['tm_mday'], $parsed['tm_year'] + 1900); $ret = new DateTime(); $ret->setTimestamp($t); } return $ret; }
// load Composer stuff require_once PROJECTDIR . '/vendor/autoload.php'; // initialize no2 framework. require_once PROJECTDIR . '/no2/no2.inc.php'; // get the config stuff require_once APPDIR . '/config.class.php'; AppConfig::parse(PROJECTDIR . '/config/config.yml', array('{{APPDIR}}' => APPDIR, '{{PROJECTDIR}}' => PROJECTDIR, '{{WEBDIR}}' => WEBDIR)); // load the application's models. require_once APPDIR . '/models/user.class.php'; // load the application's helpers. require_once APPDIR . '/help.inc.php'; // set the timezone date_default_timezone_set(AppConfig::get('l10n.default_timezone')); // set the locale setlocale(LC_ALL, AppConfig::get('l10n.default_locale')); // start the logger if (!No2_Logger::setup(AppConfig::get('logger'))) { error_log('unable to setup Logger'); } // connect to the database. No2_SQLQuery::setup(AppConfig::get('database')); // try our best to hide the fact that we still use PHP in the 21th century. if (function_exists('header_remove')) { header_remove('X-Powered-By'); // PHP 5.3+ } else { @ini_set('expose_php', 'off'); } // start the session session_set_cookie_params(0, dirname($_SERVER['SCRIPT_NAME'])); session_start() or die('session_start()');
if (is_file(FILE_INSTALL_SEQ_ID)) { $install_seq = @file_get_contents(FILE_INSTALL_SEQ_ID); $app->set('INSTALLATION_SEQUENCE_UID', $install_seq); } else { $install_seq = uniqid("ISEQID"); // unique id per a set of installations $app->set('INSTALLATION_SEQUENCE_UID', $install_seq); file_put_contents(FILE_INSTALL_SEQ_ID, $install_seq); } // read package version $version = parse_ini_file('package/version.ini'); logMessage(L_INFO, "Installing Kaltura " . $version['type'] . ' ' . $version['number']); $app->set('KALTURA_VERSION', 'Kaltura ' . $version['type'] . ' ' . $version['number']); $app->set('KALTURA_PREINSTALLED', $version['preinstalled']); $app->set('KALTURA_VERSION_TYPE', $version['type']); if (strcasecmp($app->get('KALTURA_VERSION_TYPE'), K_TM_TYPE) !== 0) { $hello_message = "Thank you for installing Media Management based on Kaltura"; $report_message = "If you wish, please provide your email address so that we can offer you future assistance (leave empty to pass)"; $report_error_message = "Email must be in a valid email format"; $report_validator = InputValidator::createEmailValidator(true); $fail_action = "For assistance, please contact us at https://github.com/Akvelon2014/Media-Management-based-on-Kaltura/issues"; } else { $hello_message = "Thank you for installing Media Management based on Kaltura"; $report_message = "Please provide the name of your company or organization"; $report_error_message = "Name cannot be empty"; $report_validator = InputValidator::createNonEmptyValidator(); $fail_action = "For assistance, please contact us at https://github.com/Akvelon2014/Media-Management-based-on-Kaltura/issues"; } // start user interaction @system('clear'); logMessage(L_USER, $hello_message);
/** * Helper function to know if we need to generate / guess sexy URLs. This * method will query the application's config. * * @return * TRUE if sexy URLs option is used, FALSE otherwise. */ protected function use_sexy_urls() { return AppConfig::get('routing.rewrite', false); }
* - $router * - $controller * - $view * * @author * Alexandre Perrin <*****@*****.**> */ include dirname(__FILE__) . '/../bootstrap.inc.php'; /* * CORS setup, needed if we provide API calls that could be requested by other * web applications through scripting. * * see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS */ if (AppConfig::get('security.cors.enabled', false)) { $continue = cross_origin_resource_sharing(AppConfig::get('security.cors.allowed-origins', []), AppConfig::get('security.cors.allow-credentials', false)); if (!$continue) { die; } unset($continue); } /* * get a router to handle and generate URLs. */ require_once APPDIR . '/router.class.php'; $router = new AppRouter(); $router->decode_url($_SERVER['REQUEST_URI']); /* * Find the controller that registered for the requested URI. Note that here * $_REQUEST['controller'] stand for an alias and not a controller class, hence * the need of the router's logic.
/** * can be overrided for controller that does not want the csrf check. * * @return * true if this controller need the csrf protection, false otherwise. */ protected function check_csrf() { return AppConfig::get('security.csrf', true); }
public function updating($model) { if ($model->isDirty('status') && $model->status == 1) { Mail::send(array("body" => Module::template('signup-approved')->compile(array("BASE_URL" => AppConfig::get("retrieve.email.url"))), "subject" => "Approved!", "to" => $model->email, "from" => "*****@*****.**")); } }
<?php Module\Http\Router::get('/send', function () { return $this->json(array("success" => Mail::send(array("body" => Module::template('signup-confirmation')->compile(array("base_url" => AppConfig::get("retrieve.email.url"))), "subject" => "Sign-up confirmation", "to" => $model->email, "from" => "*****@*****.**")))); });