function exec_command($command) { $output = array(); exec($command, $output); foreach ($output as $line) { log_append('SHELL: ' . $line); } }
/** * Prints the error message on screen and quits * @param string $msg The message to print * @param bool $log If set to false, the error won't be logged. */ function error_print_message($msg, $log = true) { //echo '<b>Error: </b>'.$msg; echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; echo '<script type="text/javascript">window.alert("' . $msg . '");</script>'; //echo '<div style="display: none;" id="#error" onload="show_popup_from_inner_div(\'#error\');">'.$msg.'</div>'; if ($log) { log_append('error', $msg); die; } }
/** * Logs the user out, i.e. destroys all the data stored about them */ function user_logout() { global $ezplayer_url; // 1) Deleting the ACLs from the session var log_append("logout"); $lvl = $_SESSION['album'] != '' && $_SESSION['asset'] != '' ? 3 : ($_SESSION['album'] != '' ? 2 : 1); trace_append(array($lvl, 'logout')); acl_exit(); // 2) Unsetting session vars unset($_SESSION['ezplayer_mode']); unset($_SESSION['user_login']); // User netID unset($_SESSION['ezplayer_logged']); // "boolean" stating that we're logged unset($_SESSION['ezplayer_anonymous']); // "boolean" stating that we're logged session_destroy(); // 3) Displaying the logout message include_once template_getpath('logout.php'); //include_once "tmpl/fr/logout.php"; $url = $ezplayer_url; unset($_SESSION['lang']); }
/** * Displays the flash player * @global type $input */ function view_embed() { global $input; global $repository_path; global $flash_only_browsers; global $template_folder; global $ezmanager_url; // Sanity checks if (!isset($input['album']) || !isset($input['asset']) || !isset($input['quality']) || !isset($input['type']) || !isset($input['token'])) { echo "Usage: distribute.php?action=embed&album=ALBUM&asset=ASSET&type=TYPE&quality=QUALITY&token=TOKEN<br/>"; echo "Optional parameters: width: Video width in pixels. height: video height in pixels. iframe: set to true if you want the return code to be an iframe instead of a full HTML page"; die; } if (!ezmam_album_exists($input['album'])) { error_print_http(404); log_append('warning', 'view_embed: tried to access non-existant album ' . $input['album']); die; } if (!ezmam_asset_exists($input['album'], $input['asset'])) { error_print_http(404); log_append('warning', 'tried to access non-existant asset ' . $input['asset'] . ' of album ' . $input['album']); die; } if (!ezmam_album_token_check($input['album'], $input['token']) && !ezmam_asset_token_check($input['album'], $input['asset'], $input['token'])) { error_print_http(403); log_append('warning', 'view_media: tried to access asset ' . $input['asset'] . ' from album ' . $input['album'] . ' with invalid token ' . $input['token']); die; } // Then we retrieve the useful information, i.e. the media path and the dimensions // Fallback: if the media doesn't exist in the requested quality, // we try to find it in another one available $media_name = $input['quality'] . '_' . $input['type']; if (!ezmam_media_exists($input['album'], $input['asset'], $media_name)) { if ($input['quality'] == 'high') { $media_name = 'low_' . $input['type']; } else { if ($input['quality'] == 'low') { $media_name = 'high_' . $input['type']; } } // If no quality is available, we tell that to the user. if (!ezmam_media_exists($input['album'], $input['asset'], $media_name)) { error_print_http(404); die; } } $metadata = ezmam_media_metadata_get($input['album'], $input['asset'], $media_name); $width = $metadata['width']; if (isset($input['width']) && !empty($input['width'])) { $width = $input['width'] - 5; } $height = $metadata['height']; if (isset($input['height']) && !empty($input['height'])) { $height = $input['height'] - 5; } $origin = $input['origin'] == 'ezmanager' ? 'ezmanager' : 'embed'; $media_url = urlencode(ezmam_media_geturl($input['album'], $input['asset'], $media_name) . '&origin=' . $origin); $player_url = $ezmanager_url . '/swf/bugatti.swf'; // And finally we display the player through a template! // If the user wanted to have the player in an iframe, we must change the code a little bit if (isset($input['iframe']) && $input['iframe'] == 'true') { $origin = $input['origin'] == 'ezmanager' ? 'ezmanager' : 'embed'; echo '<iframe style="padding: 0; z-index: 100;" frameborder="0" scrolling="no" src="distribute.php?action=embed&album=' . $input['album'] . '&asset=' . $input['asset'] . '&type=' . $input['type'] . '&quality=' . $input['quality'] . '&token=' . $input['token'] . '&width=' . $width . '&height=' . $height . '&origin=' . $origin . '" width="' . $width . '" height="' . $height . '"></iframe>'; } else { template_repository_path($template_folder . 'en'); require_once template_getpath('embed_header.php'); // We check if the user's browser is a flash-only browser or if it accepts HTML5 // It's a Flash browser IIF // UA includes 'Firefox' OR UA includes 'MSIE' BUT UA does not include 'MSIE 9.' // TODO: prepare for future revisions of MSIE if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.') !== false) { require_once template_getpath('embed_flash.php'); require_once template_getpath('embed_footer.php'); die; } // Otherwise, if it accepts HTML5, we display the HTML5 browser require_once template_getpath('embed_html5.php'); require_once template_getpath('embed_footer.php'); } }
/** * Effectively logs the user in * @param string $login * @param string $passwd */ function user_login($login, $passwd) { global $input; global $template_folder; global $error; global $ezadmin_url; // 0) Sanity checks if (empty($login) || empty($passwd)) { $error = template_get_message('empty_username_password', get_lang()); view_login_form(); die; } $login_parts = explode("/", $login); // checks if runas if (count($login_parts) >= 2) { $error = "No runas here !"; view_login_form(); die; } if (!file_exists('admin.inc')) { $error = "User not authorized"; view_login_form(); die; } include 'admin.inc'; //file containing an assoc array of admin users if (!isset($users[$login_parts[0]])) { $error = "User not authorized"; view_login_form(); die; } $res = checkauth(strtolower($login), $passwd); if (!$res) { $error = checkauth_last_error(); view_login_form(); die; } // 1) Initializing session vars $_SESSION['podcastcours_logged'] = "LEtimin"; // "boolean" stating that we're logged $_SESSION['user_login'] = $login; $_SESSION['user_real_login'] = $res['real_login']; $_SESSION['user_full_name'] = $res['full_name']; $_SESSION['user_email'] = $res['email']; // 3) Setting correct language set_lang($input['lang']); // 4) Resetting the template path to the one of the language chosen template_repository_path($template_folder . get_lang()); // 5) Logging the login operation log_append("login"); // 6) Displaying the page header("Location: " . $ezadmin_url); view_main(); }
/** * Moves asset from $input['from'] to $input['to'] * @global type $input * @global type $repository_path */ function asset_move() { global $input; global $repository_path; ezmam_repository_path($repository_path); // // Sanity checks // if (!isset($input['asset']) || !isset($input['from']) || !isset($input['to'])) { echo 'Usage: web_index.php?action=move_asset&from=SOURCE&to=DESTINATION&asset=ASSET'; die; } if (!acl_has_album_permissions($input['from']) || !acl_has_album_permissions($input['to'])) { error_print_message(template_get_message('Unauthorized', get_lang())); log_append('warning', 'move_asset: you can\'t manage album ' . $input['from'] . ' or ' . $input['to']); die; } if (!ezmam_asset_exists($input['from'], $input['asset'])) { error_print_message(template_get_message('Non-existant_album', get_lang())); log_append('warning', 'move_asset: asset ' . $input['asset'] . ' of album ' . $input['from'] . ' does not exist'); die; } // saves the bookmarks to copy $bookmarks = toc_asset_bookmark_list_get($input['from'], $input['asset']); // deletes the bookmarks from the source album toc_asset_bookmarks_delete_all($input['from'], $input['asset']); // // Moving the asset // TODO: the moving won't work if there is a different asset with the same name in dest folder. Should be corrected in the future (new asset renamed) // $res = ezmam_asset_move($input['asset'], $input['from'], $input['to']); if (!$res) { error_print_message(ezmam_last_error()); die; } // adds the previously saved bookmarks to the new album $count = count($bookmarks); for ($index = 0; $index < $count; $index++) { $bookmarks[$index]['album'] = $input['to']; } toc_album_bookmarks_add($bookmarks); include_once template_getpath('popup_asset_successfully_moved.php'); }
/** * Deletes a comment using his ID * @global null $db * @param int $id * @return boolean error flag */ function comment_delete_by_id($id) { global $statements; $comment = comment_select_by_id($id); $statements['comment_delete_by_id']->bindParam(':id', $id); $res = $statements['comment_delete_by_id']->execute(); if ($res) { thread_update_nbComments($comment['thread'], FALSE); if ($comment['nbChilds'] > 0) { $children = comment_children_get($id); foreach ($children as $child) { comment_delete_by_id($child['id']); } } if ($comment['parent'] != NULL) { comment_update_nbChild($comment['parent'], FALSE); } } log_append('Delete comment: ', 'Delete comment with id = ' . $id); return $res; }
function printlog_sql($data) { global $ps_file102; log_append($ps_file102, $data . "\n"); }
/** * Resets a token for a specific asset * @param type $asset * @param type $album * @param bool $logging If set to false, the operation won't be logged * @return bool error status */ function ezmam_asset_token_reset($album, $asset, $logging = true) { $repository_path = ezmam_repository_path(); $old_token = ezmam_asset_token_get($album, $asset); $res = ezmam_asset_token_create($album, $asset); if (!$res) { ezmam_last_error("ezmam_asset_token_reset: unable to reset token"); return false; } // Logging if ($logging) { log_append('asset_token_reset', 'Asset: ' . $asset . ', Album: ' . $album . ', Old token: ' . $old_token . ', New token: ' . $res); } }
<?php /* gitlab deploy webhook */ $logfile = '/var/log/apache2/gitlab-webhook.log'; /* Read the raw POST data */ $json = file_get_contents('php://input'); $data = json_decode($json); //log_append($json); if (!is_object($data) || empty($data->ref)) { log_append("Invalid Post Request"); exit; } system('cd /var/www/bootcamp && git pull'); log_append("Gitlab Webhook executed"); function log_append($message, $time = null) { global $logfile; $time = $time === null ? time() : $time; $date = date('Y-m-d H:i:s'); $pre = $date . ' (' . $_SERVER['REMOTE_ADDR'] . '): '; file_put_contents($logfile, $pre . $message . "\n", FILE_APPEND); }
if (file_exists($pidfile)) { //Если найден - то выходим $oldpid = file_get_contents($pidfile); log_append($ps_repalllog, $zver . " Find previous PID: " . $oldpid . " - exit" . "\n"); log_append($ps_repalllog, $zver . " Update FINISH at " . date("d.m.Y H:i:s") . "\n"); log_append($ps_repalllog, "=============================================" . "\n"); // DEBUG die('PID file already exists'); } //рисуем новый PID на будущее file_put_contents($pidfile, '0'); // Выведем заголовок типа данных print "Sync module: " . $zver . "\n"; print "===================================" . "\n"; print "start module at " . date("d.m.Y H:i:s") . "\n"; $ps_file101 = $ps_rep_logupd; log_append($ps_rep_logupd, "===========================================" . "\n"); printlog($zver . " начало обновления"); //Открываем базу биллинга $ub_db['server'] = $znserver; $ub_db['username'] = $znuser; $ub_db['password'] = $znpass; $ub_db['db'] = $znbase; $ub_db['character'] = $zncp; $conn1 = mysql_connect($ub_db['server'], $ub_db['username'], $ub_db['password'], true); mysql_select_db($ub_db['db'], $conn1); mysql_query("set character_set_client='" . $ub_db['character'] . "'", $conn1); mysql_query("set character_set_results='" . $ub_db['character'] . "'", $conn1); mysql_query("set collation_connection='" . $ub_db['character'] . "_general_ci'", $conn1); //Открываем базу userside $us_db['server'] = $zuserver; $us_db['username'] = $zuuser;
function _xTradesBulkAdd() { global $C; $C['flag_register_email_admin'] = false; $v = Validator::Get(); $v->Register($_REQUEST['data'], VT_NOT_EMPTY, 'The trade data field is required'); $v->Register(in_array('return_url', $_REQUEST['fields']), VT_IS_TRUE, 'The Return URL field must be one of the selected fields'); if (!$v->Validate()) { return JSON::Warning(array(JSON_KEY_MESSAGE => 'Trades could not be added; please fix the following items', JSON_KEY_WARNINGS => $v->GetErrors())); } require_once 'dirdb.php'; $db = new TradeDB(); $added = 0; $duplicate = 0; $invalid = 0; $loginfo = array('Importing trades'); $_REQUEST['fields'] = array_values(array_filter($_REQUEST['fields'])); foreach (explode(STRING_LF_UNIX, string_format_lf($_REQUEST['data'])) as $line) { $data = array(); $line_fields = explode($_REQUEST['separator'], $line); foreach ($_REQUEST['fields'] as $i => $field) { $data[$field] = $line_fields[$i]; } $data['domain'] = domain_from_url($data['return_url']); if (!empty($data['domain']) && $db->Exists($data['domain'])) { $loginfo[] = "\t{$line} [Duplicate]"; $duplicate++; continue; } $data = array_merge($_REQUEST, $data); $v->Reset(); $v->Register($data['return_url'], VT_VALID_HTTP_URL, 'The Return URL is not a properly formatted URL'); $v->Register($data['status'], VT_IS_IN, 'The Status value is not valid', array(STATUS_UNCONFIRMED, STATUS_NEW, STATUS_ACTIVE, STATUS_AUTOSTOPPED, STATUS_DISABLED)); if (!$v->Validate()) { $loginfo[] = "\t{$line} [" . join(', ', $v->GetErrors()) . "]"; $invalid++; continue; } trade_add($data); $added++; } log_append('import.log', join(STRING_LF_UNIX, $loginfo)); if ($duplicate == 0 && $invalid == 0) { $message = format_int_to_string($added) . ' trades successfully added'; JSON::Success(array(JSON_KEY_MESSAGE => $message)); } else { $message = format_int_to_string($added) . ' trades successfully added<br />' . format_int_to_string($duplicate) . ' duplicates were skipped<br />' . format_int_to_string($invalid) . ' with invalid formatting were skipped<br /><br />' . 'For details, check the import.log file in the logs directory of your TradeX installation'; JSON::Warning(array(JSON_KEY_MESSAGE => $message)); } }