<?php function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip; } function log_download() { $fp = fopen('/home/webadmin/cuke4ninja.com/pdfdownload', 'a'); fwrite($fp, date("F j, Y, g:i a") . "\t" . getRealIpAddr()); fwrite($fp, "\n"); fclose($fp); } log_download(); Header("Location: http://cuke4ninja.s3.amazonaws.com/cuke4ninja-2011-03-16.pdf?AWSAccessKeyId=1X67X2N8SN9A2283RSR2&Expires=1308913112&Signature=5Hayswv9i%2BTTf7AxZ3nxq8pKj68%3D");
$jailnames[] = $jails['jailname']; } for ($i = 0; $i < $countjails; $i++) { $loginfo1[$i] = array("visible" => TRUE, "desc" => $jailnames[$i], "logfile" => $config['thebrig']['rootfolder'] . $jailnames[$i] . "/var/log/messages", "filename" => "messages", "type" => "plain", "pattern" => "/^(\\w+\\s+\\d+\\s+\\S+)(\\s\\w+\\s\\S+)(\\:\\s.+\$)/", "columns" => array(array("title" => gettext("Date & Time"), "class" => "listlr", "param" => "nowrap=\"nowrap\"", "pmid" => 1), array("title" => gettext("Who"), "class" => "listr", "param" => "nowrap=\"nowrap\"", "pmid" => 2), array("title" => gettext("Event"), "class" => "listr", "param" => "", "pmid" => 3))); } $loginfo = array_merge_recursive($loginfo2, $loginfo1); } else { $loginfo = $loginfo2; } if (isset($_POST['clear']) && $_POST['clear']) { log_clear($loginfo[$log]); header("Location: extensions_thebrig_log.php?log={$log}"); exit; } if (isset($_POST['download']) && $_POST['download']) { log_download($loginfo[$log]); exit; } if (isset($_POST['refresh']) && $_POST['refresh']) { header("Location: extensions_thebrig_log.php?log={$log}"); exit; } function log_get_contents($logfile, $type) { $content = array(); $param = isset($config['syslogd']['reverse']) ? "-r " : ""; $param .= "-n 200"; switch ($type) { case "clog": exec("/usr/sbin/clog {$logfile} | /usr/bin/tail {$param}", $content); break;
/** * Farm out the files for downloads. */ function dload_script() { // Closed site $site_closed = get_option('site_closed'); if ($site_closed == '1' && !has_specific_permission(get_member(), 'access_closed_site') && !$GLOBALS['IS_ACTUALLY_ADMIN']) { header('Content-Type: text/plain'); @exit(get_option('closed')); } global $SITE_INFO; if (!is_guest() || !isset($SITE_INFO['any_guest_cached_too']) || $SITE_INFO['any_guest_cached_too'] == '0') { if (get_param('for_session', '-1') != md5(strval(get_session_id())) && get_option('anti_leech') == '1' && ocp_srv('HTTP_REFERER') != '') { warn_exit(do_lang_tempcode('LEECH_BLOCK')); } } require_lang('downloads'); $id = get_param_integer('id', 0); // Lookup $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; // Permission if (!has_category_access(get_member(), 'downloads', strval($myrow['category_id']))) { access_denied('CATEGORY_ACCESS'); } // Cost? $got_before = $GLOBALS['SITE_DB']->query_value_null_ok('download_logging', 'the_user', array('the_user' => get_member(), 'id' => $id)); if (addon_installed('points')) { if ($myrow['download_cost'] > 0) { require_code('points2'); $member = get_member(); if (is_guest($member)) { access_denied('NOT_AS_GUEST'); } // Check they haven't downloaded this before (they only get charged once - maybe they are resuming) if (is_null($got_before)) { $cost = $myrow['download_cost']; $member = get_member(); if (is_guest($member)) { access_denied('NOT_AS_GUEST'); } $dif = $cost - available_points($member); if ($dif > 0 && !has_specific_permission(get_member(), 'have_negative_gift_points')) { warn_exit(do_lang_tempcode('LACKING_POINTS', integer_format($dif))); } require_code('points2'); charge_member($member, $cost, do_lang('DOWNLOADED_THIS', get_translated_text($myrow['name']))); if ($myrow['download_submitter_gets_points'] == 1) { system_gift_transfer(do_lang('THEY_DOWNLOADED_THIS', get_translated_text($myrow['name'])), $cost, $myrow['submitter']); } } } } // Filename $full = $myrow['url']; $breakdown = @pathinfo($full) or warn_exit(do_lang_tempcode('HTTP_DOWNLOAD_NO_SERVER', $full)); // $filename=$breakdown['basename']; if (!array_key_exists('extension', $breakdown)) { $extension = ''; } else { $extension = strtolower($breakdown['extension']); } if (url_is_local($full)) { $_full = get_custom_file_base() . '/' . rawurldecode($full); } else { $_full = rawurldecode($full); } // Is it non-local? If so, redirect if (!url_is_local($full) || !file_exists(get_file_base() . '/' . rawurldecode(filter_naughty($full)))) { if (url_is_local($full)) { $full = get_custom_base_url() . '/' . $full; } if (strpos($full, chr(10)) !== false || strpos($full, chr(13)) !== false) { log_hack_attack_and_exit('HEADER_SPLIT_HACK'); } header('Location: ' . $full); log_download($id, 0, !is_null($got_before)); // Bandwidth used is 0 for an external download return; } // Some basic security: don't fopen php files if ($extension == 'php') { log_hack_attack_and_exit('PHP_DOWNLOAD_INNOCENT', integer_format($id)); } // Size, bandwidth, logging $size = filesize($_full); if (is_null($got_before)) { $bandwidth = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(file_size) AS answer FROM ' . get_table_prefix() . 'download_logging l LEFT JOIN ' . get_table_prefix() . 'download_downloads d ON l.id=d.id WHERE date_and_time>' . strval(time() - 24 * 60 * 60 * 32)); if ($bandwidth + floatval($size) > floatval(get_option('maximum_download')) * 1024 * 1024 * 1024 && !has_specific_permission(get_member(), 'bypass_bandwidth_restriction')) { warn_exit(do_lang_tempcode('TOO_MUCH_DOWNLOAD')); } require_code('files2'); check_shared_bandwidth_usage($size); } log_download($id, $size, !is_null($got_before)); // Send header if (strpos($myrow['original_filename'], chr(10)) !== false || strpos($myrow['original_filename'], chr(13)) !== false) { log_hack_attack_and_exit('HEADER_SPLIT_HACK'); } header('Content-Type: application/octet-stream' . '; authoritative=true;'); if (get_option('immediate_downloads') == '1') { require_code('mime_types'); header('Content-Type: ' . get_mime_type(get_file_extension($myrow['original_filename'])) . '; authoritative=true;'); header('Content-Disposition: filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($myrow['original_filename']))) . '"'); } else { if (strstr(ocp_srv('HTTP_USER_AGENT'), 'MSIE') !== false) { header('Content-Disposition: filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($myrow['original_filename']))) . '"'); } else { header('Content-Disposition: attachment; filename="' . str_replace(chr(13), '', str_replace(chr(10), '', addslashes($myrow['original_filename']))) . '"'); } } header('Accept-Ranges: bytes'); // Caching header("Pragma: private"); header("Cache-Control: private"); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 24 * 365) . ' GMT'); $time = is_null($myrow['edit_date']) ? $myrow['add_date'] : $myrow['edit_date']; $time = max($time, filemtime($_full)); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $time) . ' GMT'); // Default to no resume $from = 0; $new_length = $size; @ini_set('zlib.output_compression', 'Off'); // They're trying to resume (so update our range) $httprange = ocp_srv('HTTP_RANGE'); if (strlen($httprange) > 0) { $_range = explode('=', ocp_srv('HTTP_RANGE')); if (count($_range) == 2) { if (strpos($_range[0], '-') === false) { $_range = array_reverse($_range); } $range = $_range[0]; if (substr($range, 0, 1) == '-') { $range = strval($size - intval(substr($range, 1)) - 1) . $range; } if (substr($range, -1, 1) == '-') { $range .= strval($size - 1); } $bits = explode('-', $range); if (count($bits) == 2) { list($from, $to) = array_map('intval', $bits); if ($to - $from != 0 || $from == 0) { $new_length = $to - $from + 1; header('HTTP/1.1 206 Partial Content'); header('Content-Range: bytes ' . $range . '/' . strval($size)); } else { $from = 0; } } } } header('Content-Length: ' . strval($new_length)); if (function_exists('set_time_limit')) { @set_time_limit(0); } error_reporting(0); // Send actual data $myfile = fopen($_full, 'rb'); fseek($myfile, $from); $i = 0; flush(); // Works around weird PHP bug that sends data before headers, on some PHP versions while ($i < $new_length) { $content = fread($myfile, min($new_length - $i, 1048576)); echo $content; $len = strlen($content); if ($len == 0) { break; } $i += $len; } fclose($myfile); /* Security note... at the download adding/editing stage, we ensured that only files accessible to the web server (in raw form) could end up in our database. Therefore we did not check here that our file was accessible in raw form. */ }
extensions_dnsmasq_log.php */ require "auth.inc"; require "guiconfig.inc"; // require("diag_log.inc"); require_once "globals.inc"; require_once "rc.inc"; $loginfo = array("visible" => TRUE, "desc" => gettext("Dnsmasq Log"), "logfile" => "/var/log/dnsmasq.log", "filename" => "dnsmasq.log", "type" => "plain", "pattern" => "/^(\\S+\\s+\\d+\\s+\\S+)\\s+(\\S+\\]\\:)\\s+(.*)\$/", "columns" => array(array("title" => gettext("Date & Time"), "class" => "listlr", "param" => "nowrap=\"nowrap\"", "pmid" => 1), array("title" => gettext("Who"), "class" => "listr", "param" => "nowrap=\"nowrap\"", "pmid" => 2), array("title" => gettext("Event"), "class" => "listr", "param" => "", "pmid" => 3))); $pgtitle = array(gettext("Dnsmasq "), gettext(" Log")); if (isset($_POST['clear']) && $_POST['clear']) { log_clear($loginfo); header("Location: extensions_dnsmasq_log.php"); exit; } if (isset($_POST['download']) && $_POST['download']) { log_download($loginfo); exit; } if (isset($_POST['refresh']) && $_POST['refresh']) { header("Location: extensions_dnsmasq_log.php"); exit; } function log_get_contents($logfile, $type) { $content = array(); $param = isset($config['syslogd']['reverse']) ? "-r " : ""; $param .= "-n 200"; switch ($type) { case "clog": exec("/usr/sbin/clog {$logfile} | /usr/bin/tail {$param}", $content); break;