function halt($message = '', $sql = '') { $error = self::error(); $errno = self::errno(); $errmsg = "MySQL: [{$errno}] {$message} | SQL: \"{$sql}\" | Error: {$error}"; print_log($errmsg); }
function PDO_Inst() { require SYSTEM_ROOT . '/config.mysql.php'; try { return new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')); } catch (PDOException $Exception) { print_log($Exception->getMessage()); } }
admin_externalpage_setup('reportlog'); echo $OUTPUT->header(); } else { $PAGE->set_title($course->shortname .': '. $strlogs); $PAGE->set_heading($course->fullname); $PAGE->navbar->add("$userinfo, $dateinfo"); echo $OUTPUT->header(); } echo $OUTPUT->heading(format_string($course->fullname) . ": $userinfo, $dateinfo (".usertimezone().")"); report_log_print_mnet_selector_form($hostid, $course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat); if ($hostid == $CFG->mnet_localhost_id) { print_log($course, $user, $date, 'l.time DESC', $page, $perpage, "index.php?id=$course->id&chooselog=1&user=$user&date=$date&modid=$modid&modaction=$modaction&group=$group", $modname, $modid, $modaction, $group); } else { print_mnet_log($hostid, $id, $user, $date, 'l.time DESC', $page, $perpage, "", $modname, $modid, $modaction, $group); } break; case 'downloadascsv': if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname, $modid, $modaction, $group)) { echo $OUTPUT->notification("No logs found!"); echo $OUTPUT->footer(); } exit; case 'downloadasods': if (!print_log_ods($course, $user, $date, 'l.time DESC', $modname, $modid, $modaction, $group)) {
require_once "../../../config.php"; require_once "../../lib.php"; $id = required_param('id', PARAM_INT); $page = optional_param('page', 0, PARAM_INT); // which page to show if (!($course = $DB->get_record("course", array("id" => $id)))) { print_error('invalidcourseid'); } require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('coursereport/log:viewlive', $context); add_to_log($course->id, "course", "report live", "report/log/live.php?id={$course->id}", $course->id); session_get_instance()->write_close(); // we override the default framename so header/footer // links open in a new window if (empty($CFG->framename) || $CFG->framename === '_top') { $CFG->framename = '_blank'; } $strlivelogs = get_string("livelogs"); $strupdatesevery = get_string("updatesevery", "moodle", COURSE_LIVELOG_REFRESH); $PAGE->set_url('/course/report/log/live.php', array('id' => $course->id)); $PAGE->set_pagelayout('popup'); $PAGE->set_title("{$strlivelogs} ({$strupdatesevery})"); $PAGE->set_periodic_refresh_delay(COURSE_LIVELOG_REFRESH); $PAGE->set_heading($strlivelogs); echo $OUTPUT->header(); $user = 0; $date = time() - 3600; print_log($course, $user, $date, "l.time DESC", $page, 500, "live.php?id={$course->id}&user={$user}&date={$date}"); echo $OUTPUT->footer(); exit;
$date = time() - 3600; $url = new moodle_url('/report/loglive/index.php', array('id' => $course->id, 'user' => 0, 'date' => $date, 'inpopup' => 1)); $strupdatesevery = get_string('updatesevery', 'moodle', REPORT_LOGLIVE_REFRESH); $coursename = format_string($course->fullname, true, array('context' => $context)); $PAGE->set_url($url); $PAGE->set_pagelayout('popup'); $PAGE->set_title("{$coursename}: {$strlivelogs} ({$strupdatesevery})"); $PAGE->set_periodic_refresh_delay(REPORT_LOGLIVE_REFRESH); $PAGE->set_heading($strlivelogs); echo $OUTPUT->header(); // Trigger a content view event. $event = \report_loglive\event\content_viewed::create(array('courseid' => $course->id, 'other' => array('content' => 'loglive'))); $event->set_page_detail(); $event->set_legacy_logdata(array($course->id, 'course', 'report live', "report/loglive/index.php?id={$course->id}", $course->id)); $event->trigger(); print_log($course, 0, $date, "l.time DESC", $page, 500, $url); echo $OUTPUT->footer(); exit; } if ($course->id == SITEID) { admin_externalpage_setup('reportloglive', '', null, '', array('pagelayout' => 'report')); echo $OUTPUT->header(); } else { $PAGE->set_url('/report/log/live.php', array('id' => $course->id)); $PAGE->set_title($course->shortname . ': ' . $strlivelogs); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); } echo $OUTPUT->heading(get_string('pluginname', 'report_loglive')); echo $OUTPUT->container_start('info'); $link = new moodle_url('/report/loglive/index.php', array('id' => $course->id, 'inpopup' => 1));
} break; case "todaylogs" : echo '<div class="graph">'; print_log_graph($course, $user->id, "userday.png"); echo '</div>'; print_log($course, $user->id, usergetmidnight(time()), "l.time DESC", $page, $perpage, "user.php?id=$course->id&user=$user->id&mode=$mode"); break; case "alllogs" : echo '<div class="graph">'; print_log_graph($course, $user->id, "usercourse.png"); echo '</div>'; print_log($course, $user->id, 0, "l.time DESC", $page, $perpage, "user.php?id=$course->id&user=$user->id&mode=$mode"); break; case 'stats': if (empty($CFG->enablestats)) { print_error('statsdisable', 'error'); } require_once($CFG->dirroot.'/lib/statslib.php'); $statsstatus = stats_check_uptodate($course->id); if ($statsstatus !== NULL) { echo $OUTPUT->notification($statsstatus); } $earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_user_daily} ORDER BY timeend');
} $value_step = 10; if (count($argv) > 3) { $value_step = $argv[3]; } $best_brl = find_best_rate($pairs_arbitrage_brl, $value_min, $value_max, $value_step, true); //$best_usd = find_best_rate($pairs_arbitrage_usd, $value_min, $value_max, $value_step, false); date_default_timezone_set('America/Sao_Paulo'); $arb_log = "/tmp/arbitrage.log"; /* open trade log*/ $fh = fopen($arb_log, 'a+') or die("can't open file"); function print_log($tolog) { global $fh; fwrite($fh, date('Y-m-d H:i:s', time()) . " - " . $tolog . "\n"); print date('Y-m-d H:i:s', time()) . " - " . $tolog . "\n"; } if ($best_brl['rate_no_withdrawal'] < 1.0) { print_log("BRL => BTC => BRL (" . $best_brl['origin']['name'] . " => " . $best_brl['destination']['name'] . ")"); print_log($best_brl['origin']['results']['initial'] . " BRL => " . $best_brl['destination']['results']['initial'] . " BTC => " . $best_brl['destination']['results']['bought'] . " BRL"); print_log(1.0 / $best_brl['rate_no_withdrawal'] . " (Sell)"); print_log(1.0 / $best_brl['rate'] . " (Sell and withdraw)"); print_log(""); } //if ($best_usd['rate_no_withdrawal'] < 1.0) { // print_log( "USD => BTC => USD (" . $best_usd['origin']['name'] . " => ". $best_usd['destination']['name'] . ")"); // print_log( $best_usd['origin']['results']['initial'] . " USD => " . $best_usd['destination']['results']['initial'] . " BTC => " . $best_usd['destination']['results']['bought'] . " USD"); // print_log( 1.0/$best_usd['rate_no_withdrawal'] . " (Sell)"); // print_log( 1.0/$best_usd['rate'] . " (Sell and withdraw)"); // print_log( ""); //}
echo "Usage : release.sh <version>"; die; } $versionNumber = $argv[$argc - 1]; $nugetDirectory = $versionNumber . "/"; if (!file_exists($nugetDirectory)) { log_error("Missing directory " . $nugetDirectory . " to create nuget package"); } print_log("# Ok let's go !"); print_log("# Updating nuspec file for " . $projectName . " in version " . $versionNumber); $nuspecFile = $nugetDirectory . $nuspecTemplate; UpdateTemplate($nuspecTemplate, $nuspecFile, array('version' => $versionNumber)); move_chdir($nugetDirectory); print_log("# Generating nuget package for " . $projectName . " in version " . $versionNumber); exec_system("nuget pack -Verbosity quiet -NonInteractive"); print_log("# Uploading nuget package " . $projectName . " version " . $versionNumber . " to nuget server"); exec_system("nuget push -Verbosity quiet -NonInteractive *.nupkg"); move_chdir('..'); print_log("# Add new packages to git"); exec_system("git add -f " . $versionNumber . "/*.nupkg"); $commitMessage = "Release nuget package " . $projectName . " in version " . $versionNumber; $commitMessage = str_replace('"', '\\"', $commitMessage); print_log("# Commit packages to git"); $tag = 'v_' . $versionNumber; exec_system('git tag -a ' . $tag . ' -m "Release ' . $projectName . ' in version ' . $versionNumber . '"'); exec_system('git commit -m "' . $commitMessage . '"'); // Push all tags print_log("# Pushing tags to remote"); exec_system('git push origin ' . $tag); print_log("# Finished Release ! :)");
"title":"' . $page_title . '", "series":"' . $original_url->host . '", "publisher":"' . $original_url . '", "url":"' . $original_url . '", "publicationYear":' . date('Y') . ', "publicationMonth":' . date('n') . ', "tags":["Downloads"] }}'; $zip->addFromString("ZipInfo.txt", $zipinfo); $zip->addFromString("manifest.txt", $manifest); $zip->setArchiveComment($zipinfo); $zip->close(); print_log("Created zip file '{$zipfilename}'"); print_log("numfiles: {$zip->numFiles}, size: " . format_bytes(filesize($zipfilename))); } else { print_log("No valid files retrieved. With no contents to bundle, I'm going to skip creating that zip file for you."); } // Clean up rrmdir($dirname); /////////////////////////////////////////////////////////////////////// /** * A list of domains to ignore. * These are domains that often look like image thumbnails - * An img icon with a link around it is indistinguishable from a thumbnail * linking to a gallery page - until you visit it. */ function get_domain_blacklist() { return array('www.facebook.com', 'feeds.feedburner.com', 'twitter.com', 'www.addthis.com', 'ehgt.org'); } /**
function do_get_links($path, $sess_id, $server, $md5) { $out = array(); $md5_sid = substr(md5(time()), 0, 16); $command = CURL_BIN . ' -A ' . CURL_USERAGENTS . ' -s -F "sid=' . $md5 . '" -F "session_id=' . $sess_id . '" -F "fname=' . basename($path) . '" -F "op=compile" ' . $server . '/api.cgi'; exec($command, $out); if (is_array($out)) { $str = implode('', $out); $str = str_replace('#', '', $str); $xml = xml2array($str); if (array_key_exists('Links', $xml)) { print_log('File uploaded successfully.', '+', 1, false); print_log('---------------------------------------------------------------------------', '+', 1, false); print_log('Link : ' . $xml['Links']['Link'], '+', 1, false); print_log('Delete Link : ' . $xml['Links']['DelLink'], '+', 1, false); print_log('---------------------------------------------------------------------------', '+', 1, true); } else { if (array_key_exists('Error', $xml)) { print_log('Cannot compile uploaded file. (Reason: ' . $xml['Error'] . '). Exit', 'do_get_links', 0, true); } else { print_log('Invalid responds. (Reason: unknown XML). Exit', 'do_get_links', 0, true); } } } else { print_log('Invalid responds. Exit', 'do_get_links', 0, true); } }
*/ function read_logs() { $files = glob(dirname(__FILE__) . '/*' . G_EXT_LOGS); for ($index = 0, $max = count($files); $index < $max; $index++) { echo '<a href="?file=' . $files[$index] . '">' . $files[$index] . '</a><br/>'; } } function print_log($file) { if (isset($file) && file_exists($file)) { $lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($lines as $line_nb => $line) { echo sprintf('<div id="%s"> #<b>%d</b>: %s<br/></div>', $line_nb % 2 == 0 ? 'codeLnA' : 'codeLnB', $line_nb, htmlspecialchars($line)); } unset($lines); } } require '../local_configuration.php'; if (isset($_GET['file']) && file_exists($_GET['file'])) { echo '<div style="font-family: monospace; size: 10px;"><h2>Current file</h2>'; print_log($_GET['file']); echo '</div>'; } echo '<div><h2>File list</h2>'; read_logs(); echo '</div>'; ?> </body> </html>
/** * Given an array of file data, discard non-images */ function proofsheet_filter_images($files) { foreach ($files as $filepath => &$file) { $meta = library_invoke_all('metadata_from_file', $file->filepath); $file->meta = $meta; #print_log($meta); // Among a hundred other things, the meta will have // deduced the mime_type. // From the scanned metadata, promote the 'info' fields to the file object. foreach ($meta as $tag => $values) { list($tag_source, $tag_name) = split(':', $tag); if ($tag_source == 'info') { $file->{$tag_name} = reset($values); } } if ($file->mime_type) { list($media, $format) = split('/', $file->mime_type); if ($media != 'image') { print_log("{$filepath} is not an image, it's a {$media} ({$format})"); unset($files[$filepath]); } } else { print_log("{$filepath} is unknown mime type"); unset($files[$filepath]); } } return $files; }
function onload_func() { global $onlinedir, $Client, $inittime; $olfile = $onlinedir . '/' . $Client['uid']; if (file_exists($olfile)) { print_log("Client file '{$olfile}' duplicated"); } $data = array('uid' => $Client['uid'], 'pid' => $Client['pid'], 'ip' => $Client['ip'], 'host' => $Client['host'], 'useragent' => $Client['useragent'], 'inittime' => $inittime); file_put_contents($olfile, serialize($data)); }
<?php if (isset($_POST['login_c'])) { include_once '../../../settings.php'; include_once APPLICATION_PATH . '/includes/template.php'; include_once APPLICATION_PATH . '/includes/autoloader.php'; $member_ = new Member(); if ($member_->existUser($_POST['login_c'])) { $member_->setUserData($_POST['login_c']); $member_->initSession(); print_log($member_); print_log($_POST); print_log($_COOKIE); if (isset($_POST['remember_me_c']) && $_POST['remember_me_c'] === true) { $member_->initCookies(); } else { $member_->destroyCookies(); } } } $layouts_ = array('main_nav' => true, 'connexion' => true, 'footer' => true);
function halt($str) { self::close(); print_log($str); }
//$config['maintain_ratio'] = FALSE; //TRUE;//default true $config['master_dim'] = 'height'; //'width'; //TRUE; $config['width'] = 275; $config['height'] = 250; $imglib = new CI_Image_lib($config); if ( !$imglib->resize() ) { echo $imglib->display_errors(); }*/ $config['source_image'] = 'cute.jpg'; $config['new_image'] = './thumb/wt_cute.jpg'; $config['wm_text'] = 'Copyright 2010 - Nissi Audio'; $config['wm_type'] = 'text'; $config['wm_font_path'] = './fonts/osaka-re.ttf'; $config['wm_font_size'] = '16'; $config['wm_font_color'] = '#3f0101'; $config['wm_shadow_color'] = '#a7a6aa'; $config['wm_shadow_distance'] = 1; //$config['wm_vrt_alignment'] = 'bottom'; $config['wm_vrt_alignment'] = 'middle'; $config['wm_hor_alignment'] = 'center'; //wm type = image $config['wm_opacity'] = 10; //$config['wm_padding'] = '20'; $imglib = new CI_Image_lib(); $imglib->initialize($config); if (!$imglib->watermark()) { echo $imglib->display_errors(); } print_log($_SESSION['log']);
if ($date) { $dateinfo = userdate($date, get_string('strftimedaydate')); } switch ($logformat) { case 'showashtml': if ($hostid != $CFG->mnet_localhost_id || $hostid == $CFG->mnet_localhost_id && $course->id == SITEID) { $adminroot = admin_get_root(); admin_externalpage_setup('reportlog', $adminroot); admin_externalpage_print_header($adminroot); } else { print_header($course->shortname . ': ' . $strlogs, $course->fullname, "<a href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}\">{$course->shortname}</a> ->\n <a href=\"{$CFG->wwwroot}/course/report.php?id={$course->id}\">{$strreports}</a> ->\n <a href=\"index.php?id={$course->id}\">{$strlogs}</a> -> {$userinfo}, {$dateinfo}", ''); } print_heading(format_string($course->fullname) . ": {$userinfo}, {$dateinfo} (" . usertimezone() . ")"); print_mnet_log_selector_form($hostid, $course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat); if ($hostid == $CFG->mnet_localhost_id) { print_log($course, $user, $date, 'l.time DESC', $page, $perpage, "index.php?id={$course->id}&chooselog=1&user={$user}&date={$date}&modid={$modid}&modaction={$modaction}&group={$group}", $modname, $modid, $modaction, $group); } else { print_mnet_log($hostid, $id, $user, $date, 'l.time DESC', $page, $perpage, "", $modname, $modid, $modaction, $group); } break; case 'downloadascsv': if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname, $modid, $modaction, $group)) { notify("No logs found!"); print_footer($course); } exit; case 'downloadasods': if (!print_log_ods($course, $user, $date, 'l.time DESC', $modname, $modid, $modaction, $group)) { notify("No logs found!"); print_footer($course); }
function load_file($users_file, $assigned_by, $group, $profile, $nivel, $pass_policy, $file_log = false) { if (file_exists($users_file)) { $file_handle = fopen($users_file, "r"); while (!feof($file_handle)) { $line = fgets($file_handle); preg_match_all('/(.*),/', $line, $matches); $values = explode(',', $line); if ($values[0] != "") { $id_usuario = $values[0]; $pass = $values[1]; $pass = md5($pass); $nombre_real = $values[2]; $mail = $values[3]; $tlf = $values[4]; $desc = $values[5]; $avatar = $values[6]; $disabled = $values[7]; $id_company = $values[8]; $num_employee = $values[9]; $enable_login = $values[10]; $force_change_pass = 0; if ($pass_policy) { $force_change_pass = 1; } $value = array('id_usuario' => $id_usuario, 'nombre_real' => $nombre_real, 'password' => $pass, 'comentarios' => $desc, 'direccion' => $mail, 'telefono' => $tlf, 'nivel' => $nivel, 'avatar' => $avatar, 'disabled' => $disabled, 'id_company' => $id_company, 'num_employee' => $num_employee, 'enable_login' => $enable_login, 'force_change_pass' => $force_change_pass); if ($id_usuario != '' && $nombre_real != '') { if ($id_usuario == get_value('id_usuario', 'tusuario', 'id_usuario', $id_usuario)) { $msg = "[" . date('d/m/Y-H:m:s') . "] [ERROR] USER " . $id_usuario . " ALREADY EXISTS\n"; echo $msg; print_log($file_log, $msg); } else { $resul = sql_insert('tusuario', $value); if ($resul == false) { $value2 = array('id_usuario' => $id_usuario, 'id_perfil' => $profile, 'id_grupo' => $group, 'assigned_by' => $assigned_by); if ($id_usuario != '') { sql_insert('tusuario_perfil', $value2); } } } } } } fclose($file_handle); echo "[" . date('d/m/Y-H:m:s') . "] [INFO] FILE LOADED\n"; return; } else { echo "[" . date('d/m/Y-H:m:s') . "] [ERROR] CSV FILE NOT EXISTS\n"; } }
$functionname = 'grade_report_' . $CFG->grade_profilereport . '_profilereport'; if (function_exists($functionname)) { $functionname($course, $user); } break; case "todaylogs": echo '<div class="graph">'; print_log_graph($course, $user->id, "userday.png"); echo '</div>'; print_log($course, $user->id, usergetmidnight(time()), "l.time DESC", $page, $perpage, "user.php?id={$course->id}&user={$user->id}&mode={$mode}"); break; case "alllogs": echo '<div class="graph">'; print_log_graph($course, $user->id, "usercourse.png"); echo '</div>'; print_log($course, $user->id, 0, "l.time DESC", $page, $perpage, "user.php?id={$course->id}&user={$user->id}&mode={$mode}"); break; case 'stats': if (empty($CFG->enablestats)) { error("Stats is not enabled."); } require_once $CFG->dirroot . '/lib/statslib.php'; $statsstatus = stats_check_uptodate($course->id); if ($statsstatus !== NULL) { notify($statsstatus); } $earliestday = get_field_sql('SELECT timeend FROM ' . $CFG->prefix . 'stats_user_daily ORDER BY timeend'); $earliestweek = get_field_sql('SELECT timeend FROM ' . $CFG->prefix . 'stats_user_weekly ORDER BY timeend'); $earliestmonth = get_field_sql('SELECT timeend FROM ' . $CFG->prefix . 'stats_user_monthly ORDER BY timeend'); if (empty($earliestday)) { $earliestday = time();
function record_count() { global $url_scheme, $count_template, $args, $total_count, $debug, $error; $get_array = array(); $url = $url_scheme . $args["endpoint"] . sprintf($count_template, $args["client-key"], $args["client-secret"], $args["capture-schema"]); print_log("Requesting {$url}"); $get = http_get($url); if (!empty($get) && is_array($get)) { $get_array = json_decode($get['content'], true); } $debug[] = $get; $debug[] = $get_array; if (empty($get_array) || !is_array($get_array) || !isset($get_array['stat']) || $get_array['stat'] != 'ok') { $error[] = 'Count not ok.'; return false; } $total_count = $get_array['total_count']; return true; }