function check_user_identity($required = true) { $realm = 'OpenMediakit Transcoder'; if ($required && !isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="' . $realm . '"'); header('HTTP/1.0 401 Unauthorized'); echo 'Please authenticate'; exit; } /* * Autre exemple de hook possible: * Hooks::call('pre_check_user_identity', array($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])); */ require_once __DIR__ . '/../modules/users/libs/users.php'; if ($required && isset($_SERVER['PHP_AUTH_USER'])) { $GLOBALS["me"] = Users::auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); } else { $GLOBALS["me"] = array(); } if ($required && !$GLOBALS["me"]) { header('WWW-Authenticate: Basic realm="' . $realm . '"'); header('HTTP/1.0 401 Unauthorized'); echo 'Login or password incorrect, or account disabled'; exit; } Hooks::call('post_check_user_identity', $GLOBALS["me"]); // mq("UPDATE user SET lastlogin=NOW() WHERE id='".$GLOBALS["me"]["id"]."';"); }
public static function call($event, array &$args = array()) { $objects = Hooks::getObjects(); $hooks = array(); foreach ($objects as $module => $obj) { if (method_exists($obj, $event)) { $hooks[$module] = $obj; } } if ($event != 'ordering_hooks') { $infos = array(&$event, &$hooks); Hooks::call('ordering_hooks', $infos); } foreach ($hooks as $obj) { $obj->{$event}($args); } }
public function transcode($media, $source, $destination, $setting, $adapterObject) { global $api; $api->log(LOG_DEBUG, "[ffmpeg::transcode] media:" . $media["id"] . " source:{$source} destination:{$destination} setting:{$setting}"); $metadata = @unserialize($media["metadata"]); // Standard settings are <10000. // Non-standard are using a plugin system, in that case we launch the hook ... if ($setting >= 10000) { $all = array("result" => false, "media" => $media, "source" => $source, "destination" => $destination, "setting" => $setting); Hooks::call('transcodeCustom', $all); return $all["result"]; } // standard settings are managed here : include __DIR__ . "/../libs/settings.php"; if (!isset($settings[$setting])) { $api->log(LOG_ERR, "[ffmpeg::transcode] Setting not found"); return false; } // is it 16/9, 4/3, or ... $params = $this->computeOutputSize($metadata); if ($params === false) { // no video track ?? $api->log(LOG_ERR, "[ffmpeg::transcode] No video track found"); return false; } $ratio = $params["ratio"]; switch ($params["ratio"]) { case "16:9": $api->log(LOG_DEBUG, "[ffmpeg::transcode] ratio is 16:9, size will be {$size}"); $size = $settings[$setting]["size_169"]; break; case "4:3": $api->log(LOG_DEBUG, "[ffmpeg::transcode] ratio is 4:3, size will be {$size}"); $size = $settings[$setting]["size_43"]; break; case "1:1": $api->log(LOG_DEBUG, "[ffmpeg::transcode] ratio is 1:1, size will be {$size}"); $size = $settings[$setting]["size_169"]; list($w, $h) = explode("x", $size); $size = $h . "x" . $h; break; default: // [ffmpeg::transcode] ratio is DEFAULT, size will be 0x / 426x240 / x , realratio will be 1.6 $sss = $size = $settings[$setting]["size_169"]; list($w, $h) = explode("x", $size); $size = intval(round($w / 4) * 4) . "x" . intval(round($h / 4) * 4); $ratio = $params["realratio"]; $api->log(LOG_DEBUG, "[ffmpeg::transcode] ratio is DEFAULT, size will be {$size} / {$sss} / {$w} {$h}, realratio will be " . $params["realratio"] . ""); break; } if ($params["invert"]) { list($w, $h) = explode($size, "x"); $size = $h . "x" . $w; } $failed = false; // substitution foreach ($settings[$setting] as $k => $v) { $v = str_replace("%%SIZE%%", $size, $v); $v = str_replace("%%SOURCE%%", escapeshellarg($source), $v); $v = str_replace("%%DESTINATION%%", escapeshellarg($destination), $v); $v = str_replace("%%RATIO%%", $ratio, $v); $v = str_replace("%%DURATION%%", floor($metadata["time"]), $v); $settings[$setting][$k] = $v; } // Execution // We cd to a temporary folder where we can write (for statistics files) $TMP = "/tmp/transcode-" . getmypid(); mkdir($TMP); $push = getcwd(); chdir($TMP); $metadata = false; foreach ($settings[$setting] as $k => $v) { if (substr($k, 0, 7) == "command") { $api->log(LOG_DEBUG, "[ffmpeg::transcode] exec: {$v}"); if (substr($v, 0, 8) == "scripts-") { // scripts-functionname.php in transcodes/ if (!function_exists(substr($v, 8))) { require_once dirname(__FILE__) . "/../transcodes/" . $v . ".php"; } $called = substr($v, 8); $result = $called($media, $source, $destination, $settings[$setting], $adapterObject, $metadata); if ($result) { $ret = 0; } else { $out = array($GLOBALS["error"]); $ret = 1; } } else { // or simple executable exec($v . " </dev/null 2>&1", $out, $ret); } if ($ret != 0) { $cancel = $settings[$setting]["cancelcommand"]; $api->log(LOG_ERR, "[ffmpeg::transcode] previous exec failed, output was " . substr(implode("|", $out), -100)); if ($cancel) { // Launch cancel command $api->log(LOG_DEBUG, "[ffmpeg::transcode] CANCEL exec: {$cancel}"); exec($cancel); } // Command FAILED $failed = true; break; } } } exec("rm -rf " . escapeshellarg($TMP)); chdir($push); if ($failed) { return false; } // Get the metadata of the stored file : if (is_file($destination . "." . $settings[$setting]["extension"])) { $metadata = $this->getFfmpegMetadata($destination . "." . $settings[$setting]["extension"]); $metadata["cardinality"] = 1; } else { // multiple files are set as this : if (is_dir($destination) && !isset($metadata["cardinality"])) { // count the number of files in the folder: $cardinality = 0; $d = opendir($destination); while ($c = readdir($d)) { if (is_file($destination . "/" . $c)) { $cardinality++; } } closedir($d); $metadata["cardinality"] = $cardinality; } } // multiple cardinality files may require a finalization function call $adapterObject->filePathTranscodeEnd($media, $metadata, $settings[$setting]); if (!$metadata) { return false; } return $metadata; }
/** Returns an instance of the specified Adapter class object. * @param $adapter string the adapter to search for using Hooks * @param $user array the user data, if set, will check that this user * is allowed to use this adapter. If not, triggers an apiError. * @return AdapterObject */ public function getAdapter($adapter, $user = NULL) { // Use the adapter to validate the URL and save the media : $adapter = strtolower(trim($adapter)); $adapterClass = array(); Hooks::call('adapterList', $adapterClass); // error_log(implode(' ',$user)); if (!in_array($adapter, $adapterClass)) { $this->apiError(API_ERROR_ADAPTERNOTSUPPORTED, _("The requested adapter is not supported on this Transcoder")); } if (!empty($user)) { $this->checkAllowedAdapter($user, $adapter); } require_once MODULES . "/" . $adapter . "/adapter.php"; $adapter = strtoupper(substr($adapter, 0, 1)) . substr($adapter, 1) . "Adapter"; return new $adapter(); }
public function meAction($params) { global $db; check_user_identity(); $uid = $GLOBALS['me']['uid']; $user = $db->qone('SELECT uid, email, enabled, admin, url ' . 'FROM users WHERE uid = :uid', array('uid' => $GLOBALS['me']['uid'])); if ($user == false) { not_found(); } if ($params[0] == 'edit') { $errors = array(); if (!empty($_POST)) { $errors = self::verifyForm($_POST, 'meedit'); if (empty($errors)) { $db->q('UPDATE users SET email=? WHERE uid=?', array($_POST['email'], $user->uid)); $old_user = $user; $user = $db->qone('SELECT uid, email, enabled, admin FROM users WHERE uid = ?', array($user->uid)); $args = array('old_user' => $old_user, 'new_user' => $user); Hooks::call('users_edit', $args); if (!empty($_POST['pass'])) { $db->q('UPDATE users SET pass=? WHERE uid=?', array(crypt($_POST['pass'], Users::getSalt()), $user->uid)); $args = array('uid' => $user->uid, 'email' => $user->email, 'pass' => $_POST['pass']); Hooks::call('users_edit_pass', $args); } // Message + redirection header('Location: ' . BASE_URL . 'users/me?msg=' . _("User account changed...")); exit; } } /* * Valeurs pour pré-remplir le formulaire * * Deux cas possibles... * 1/ On vient d'arriver sur la page ( empty($_POST) ): * on pré-rempli le formulaire avec les données de l'utilisateur * * 2/ On à validé le formulaire, mais il y a une erreur: * on pré-rempli le formulaire avec les données de la saisie. */ if (empty($_POST)) { $form_data = get_object_vars($user); // get_object_vars : stdClass -> array } else { $form_data = $_POST; } $this->render('form', array('op' => 'meedit', 'data' => $form_data, 'errors' => $errors)); } else { $this->render('me', array('user' => $user, 'contacts' => $contacts)); } }
/** * Load the bootstrap processes. * * @api * * @since 0.7.0 */ public function load() { // Hooks and filters $hooks = new Hooks(); $hooks->call(); }
?> </dd> <dt><?php __("API Key"); ?> </dt> <dd><?php echo $user->apikey; ?> </dd> <dt><?php __("Administrator?"); ?> </dt> <dd><?php echo $user->admin; ?> </dd> </dl> <?php $infos = array($user); Hooks::call('users_show', $infos); array_shift($infos); echo implode("\n", $infos); ?> <?php require VIEWS . '/footer.php';
<?php $infos = array($user); ?> <?php require_once VIEWS . '/header.php'; ?> <h2><?php __("Home page"); ?> </h2> <p><?php echo $msg; ?> </p> <?php Hooks::call('index_indexview'); ?> <?php require_once VIEWS . '/footer.php';
require VIEWS . '/css.php'; ?> <?php require VIEWS . '/js_pre.php'; ?> <?php Hooks::call('html_head'); ?> </head> <body> <div id="global"> <div id="header"> <div id="top"> <?php $html = array(); Hooks::call('content_top', $html); echo implode($html, "\n"); ?> <p class="login"><?php if (isset($GLOBALS["me"])) { printf(_("Connected as %s"), "<strong>" . $GLOBALS["me"]["email"] . "</strong>"); } ?> </p> </div> <h1>OpenMediaKit Transcoder<?php if (!empty($title)) { ?> - <?php print $title; }
} //Get arm number from URL var 'arm' $arm = getArm(); // Reload page if id is a blank value if (isset($_GET['id']) && trim($_GET['id']) == "") { redirect(PAGE_FULL . "?pid=" . PROJECT_ID . "&page=" . $_GET['page'] . "&arm=" . $arm); exit; } // Clean id if (isset($_GET['id'])) { $_GET['id'] = strip_tags(label_decode($_GET['id'])); } //include APP_PATH_DOCROOT . 'ProjectGeneral/header.php'; require_once $base_path . '/plugins/Overrides/ProjectGeneral/header_advanced_grid.php'; // Hook: redcap_add_edit_records_page Hooks::call('redcap_add_edit_records_page', array(PROJECT_ID, null, null)); // Header if (isset($_GET['id'])) { renderPageTitle("<img src='" . APP_PATH_IMAGES . "application_view_tile.png'> {$lang['grid_02']}"); } else { renderPageTitle("<img src='" . APP_PATH_IMAGES . "blog_pencil.gif'> " . ($user_rights['record_create'] ? $lang['bottom_62'] : $lang['bottom_72'])); } //Custom page header note if (trim($custom_data_entry_note) != '') { print "<br><div class='green' style='font-size:11px;'>" . str_replace("\n", "<br>", $custom_data_entry_note) . "</div>"; } //Alter how records are saved if project is Double Data Entry (i.e. add --# to end of Study ID) if ($double_data_entry && $user_rights['double_data'] != 0) { $entry_num = "--" . $user_rights['double_data']; } else { $entry_num = "";
$title = $user->login; $breadcrumb = array('users' => 'Utilisateurs', 'users/show/' . $user->uid => $user->login, '' => _("Supprimer")); require VIEWS . '/header.php'; ?> <form action="" method="post"> <p><?php echo sprintf(_("Do you really want to delete user '%s'?"), $user->login); ?> </p> <p><?php __("This will delete all its associated media"); ?> </p> <?php $informations = array($user); Hooks::call('users_delete_infos', $informations); array_shift($informations); echo implode($informations); ?> <p> <input type="submit" name="op" value="<?php __("Yes, delete it"); ?> " /> <input type="submit" name="op" value="<?php __("No, don't do anything"); ?> " onclick="javascript:history.go(-1); return false;" /> </p> </form>
<?php // FIXME: make a minified cache of post-js files from modules/hooks $files = array(); Hooks::call('post_js', $files); foreach ($files as $file) { ?> <script src="<?php echo STATIC_URL . 'js/' . $file; ?> "></script> <?php }
<?php $menu = array(); Hooks::call('menu', $menu); $menu_plus = array(); Hooks::call('menu_plus', $menu_plus); // TODO: gestion du lien actif ?> <ul> <?php foreach ($menu as $el) { $url = $el['url']; $name = $el['name']; ?> <li><a href="<?php echo $url; ?> "><?php echo $name; ?> </a></li> <?php } ?> <?php if (count($menu_plus) > 0) { ?> <li id="menu_plus"> <a href="#plus"><?php __("Plus ↓"); ?>
<?php $files = array(); $files[] = 'common.css'; $files[] = 'jquery-ui-1.8.21.custom.css'; $files[] = 'visualize.jQuery.css'; Hooks::call('css', $files); // FIXME: make a minified cache of css files from modules/hooks foreach ($files as $file) { ?> <link rel="stylesheet" media="all" href="<?php echo STATIC_URL . 'css/' . $file; ?> " /> <?php }
} return TRUE; } static function configre($key, $name) { if (!$name || !$key) { return FALSE; } self::$config[$key] = $name; return TRUE; } protected static function getConstruct($key) { if (!$key) { return FALSE; } if (!self::$config[$key]) { return FALSE; } return self::$config[$key]; } } Loader::configre("class_path", CLASS_PATH); Loader::configre("ext_class_path", EXTERNAL_PATH); Loader::loadClasses(); Hooks::create("Loader"); Settings::define("CachePath", CACHE_PATH); Cache::control(); Loader::loadExtClasses(); Hooks::call("Loader");
<script src="<?php echo STATIC_URL . 'js/jquery.js'; ?> "></script> <script src="<?php echo STATIC_URL . 'js/jquery.textlimit.min.js'; ?> "></script> <script src="<?php echo STATIC_URL . 'js/visualize.jQuery.js'; ?> "></script> <script src="<?php echo STATIC_URL . 'js/common.js'; ?> "></script> <?php // FIXME: make a minified cache of js files from modules/hooks $files = array(); Hooks::call('pre_js', $files); $files = array('jquery.tablesorter.min.js', 'tablesorter.js'); foreach ($files as $file) { ?> <script src="<?php echo STATIC_URL . 'js/' . $file; ?> "></script> <?php }
?> </dt> <dd><?php echo $user->login; ?> </dd> <dt><?php __("Email address"); ?> </dt> <dd><?php echo $user->email; ?> </dd> </dl> <?php $infos = array($user); Hooks::call('users_me', $infos); array_shift($infos); echo implode("\n", $infos); ?> </td><td><!-- colonne 2 --> </td></tr></table> <?php require VIEWS . '/footer.php';