function play($idResource, $idParams, $back_url) { //if(!checkPerm('view', true, 'organization') && !checkPerm('view', true, 'storage')) die("You can't access"); //echo ("idResource = ".$idResource."; idParams = ".$idParams."; back_url = ".$back_url); list($file) = sql_fetch_row(sql_query("SELECT path" . " FROM " . $GLOBALS['prefix_lms'] . "_materials_lesson" . " WHERE idLesson = '" . $idResource . "'")); //recognize mime type $expFileName = explode('.', $file); $totPart = count($expFileName) - 1; require_once $GLOBALS['where_lms'] . '/lib/lib.param.php'; $idReference = getLOParam($idParams, 'idReference'); // NOTE: Track only if $idReference is present if ($idReference !== FALSE) { require_once $GLOBALS['where_lms'] . '/class.module/track.item.php'; list($exist, $idTrack) = Track_Item::getIdTrack($idReference, getLogUserId(), $idResource, TRUE); if ($exist) { $ti = new Track_Item($idTrack); $ti->setDate(date('Y-m-d H:i:s')); $ti->status = 'completed'; $ti->update(); } else { $ti = new Track_Item(false); $ti->createTrack($idReference, $idTrack, getLogUserId(), date('Y-m-d H:i:s'), 'completed', 'item'); } } if ($_SESSION['direct_play'] == 1) { if (isset($_SESSION['idCourse'])) { TrackUser::closeSessionCourseTrack(); unset($_SESSION['idCourse']); unset($_SESSION['idEdition']); } if (isset($_SESSION['test_assessment'])) { unset($_SESSION['test_assessment']); } if (isset($_SESSION['cp_assessment_effect'])) { unset($_SESSION['cp_assessment_effect']); } $_SESSION['current_main_menu'] = '1'; $_SESSION['sel_module_id'] = '1'; $_SESSION['is_ghost'] = false; } //send file sendFile('/appLms/' . Get::sett('pathlesson'), $file, $expFileName[$totPart]); }
function downloadcourse() { checkPerm('view_info'); require_once _base_ . '/lib/lib.download.php'; //find selected file list($filename) = sql_fetch_row(sql_query("\r\n\tSELECT path \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_course_file \r\n\tWHERE id_course='" . $_SESSION['idCourse'] . "' AND id_file = '" . (int) $_GET['id'] . "'")); if (!$filename) { $GLOBALS['page']->add(getErrorUi('Sorry, such file does not exist!'), 'content'); return; } //recognize mime type $extens = array_pop(explode('.', $filename)); sendFile(_PATH_COURSE, $filename, $extens); }
$format = $query_arr["format"]; $cmd = $query_arr["cmd"]; $ctype = "application/zip"; if ($format == 'CSV') { $ctype = "text/csv"; } //check if user is guest session_start(); $user = null; if (isset($_SESSION["user_name"])) { $user = $_SESSION["user_name"]; } if ($user != null && $user == 'guest') { throw new Exception("Guest users are not allowed to export data!"); } //check user session and permissions if (!Helpers::isValidUserProj($map)) { throw new Exception("Session time out or unathorized access!"); } //check command if ($cmd == 'prepare') { echo json_encode(["success" => true, "message" => prepareFile($layername, $map, $query_arr, $format)]); } elseif ($cmd == 'get') { $key = $query_arr["key"]; sendFile($ctype, $key); } } catch (Exception $e) { //header('Server Error', true, 500); echo json_encode(["success" => false, "message" => $e->getMessage()]); exit; }
switch ($do) { case "download": uses("attachment"); $attachment = new Attachments(); if (empty($_GET['aid'])) { flash(); } $attach_id = authcode(rawurldecode($_GET['aid']), "DECODE"); if (empty($attach_id)) { flash(); } require LIB_PATH . "func.download.php"; require LIB_PATH . "js.class.php"; $filename = rawurlencode($attachment->getAttachFileName($attach_id)); $filename = $attachment->file_url; if (!sendFile($filename)) { exit('Error occured when get files.'); } else { JS::Close(); } break; default: break; } } if (empty($_GET['id'])) { $picture_src = URL . "images/watermark.png"; } if (isset($_GET['source'])) { $file_source = trim(rawurldecode($_GET['source'])); $picture_src = URL . $attachment_url . $file_source;
<?php require_once './config.php'; require_once '../../php/xmlrpc.php'; define('USE_NGINX', false); define('SCHEME', 'https'); if (!isset($_GET['f']) || empty($_GET['f']) || !file_exists($_GET['f']) || !preg_match('/.(avi|mkv|ts|mp4|flv|wmv|mpe?g|ogg|wma|mp3|flac)$/i', $_GET['f'])) { header('HTTP/1.0 404 Not Found'); exit; } if (USE_NGINX) { header("Content-Type: application/octet-stream"); header("X-Accel-Redirect: /stream{$_GET['f']}"); } else { sendFile($_GET['f']); }
include '../../../include/db.php'; include '../../../include/authenticate.php'; include '../../../include/general.php'; include '../../../include/resource_functions.php'; include_once dirname(__FILE__) . "/../include/utility.php"; $ref = getvalescaped('ref', 0, true); $size = getvalescaped('size', ''); $page = getvalescaped('page', 1, true); $alternative = getvalescaped('alt', -1, true); $resource = get_resource_data($ref); if (!resource_download_allowed($ref, $size, $resource["resource_type"])) { # This download is not allowed. exit("Permission denied"); } $width = getvalescaped('width', 0, true); $height = getvalescaped('height', 0, true); if ($width == 0 && $height == 0) { $format = getImageFormat($size); $width = (int) $format['width']; $height = (int) $format['height']; } $ext = getvalescaped('ext', getDefaultOutputFormat()); $profile = getProfileFileName(getvalescaped('profile', null)); $baseDirectory = get_temp_dir() . '/format_chooser'; @mkdir($baseDirectory); $target = $baseDirectory . '/' . getTargetFilename($ref, $ext, $size); set_time_limit(0); convertImage($resource, $page, $alternative, $target, $width, $height, $profile); sendFile($target); unlink($target);
<?php require 'local/config.inc.php'; require 'common.inc.php'; require 'mysql.inc.php'; connectMysql(); $file = ''; if ($_GET['sound'] == 'newplayer') { $res = $DB->query("SELECT * FROM ressnd WHERE grp = 'Credits' AND name = 'NewPlayers'"); $rs = $res->fetch(); $vals = explode(',', $rs['val']); $num = intval($_GET['num']); $file = '../res-full/' . $rs['resfolder'] . '/' . $vals[$num % sizeof($vals)] . '.' . strtr(substr($_GET['type'], 0, 3), './', '--'); } if ($file && file_exists($file)) { sendFile($file); } header('HTTP/1.0 404 Not Found');
$ext['a'] = "a"; $ext['b'] = "b"; var_dump(sendVedio($filePath, $from = "admin", $target_type, $target, $filename, $length, $thumb, $thumb_secret, $ext)); break; case 40: //发文件消息 $filePath = "./resource/up/a.rar"; $from = 'admin'; $target_type = "users"; $target = array("zhangsan", "lisi"); $filename = "a.rar"; $length = 10; //时长 $ext['a'] = "a"; $ext['b'] = "b"; var_dump(sendFile($filePath, $from = "admin", $target_type, $target, $filename, $length, $ext)); break; case 41: //获取app中的所有群组-----不分页(默认返回10个) var_dump(getGroups()); break; case 42: ////获取app中的所有群组--------分页 $cursor = readCursor("groupfile.txt"); var_dump($cursor); var_dump(getGroupsForPage(2, $cursor)); break; case 43: //获取一个或多个群组的详情 $group_ids = array("1445830526109", "1445833238210"); var_dump(getGroupDetail($group_ids));
function do_mysql_dump($encode = "utf8") { global $DBCFG; $tables = $DBCFG[DBprefix] . 'config,' . $DBCFG[DBprefix] . 'tema,' . $DBCFG[DBprefix] . 'tabla_rel,' . $DBCFG[DBprefix] . 'indice,' . $DBCFG[DBprefix] . 'usuario,' . $DBCFG[DBprefix] . 'notas,' . $DBCFG[DBprefix] . 'values,' . $DBCFG[DBprefix] . 'tvocab,' . $DBCFG[DBprefix] . 'term2tterm,' . $DBCFG[DBprefix] . 'uri'; /* * To UTF-8 databases */ if ($encode == 'utf8') { $setUTF = SQL("SET NAMES", "utf8"); $setUTF1 = SQL("SET CHARACTER SET", "utf8"); } //get the tables $tables = explode(',', $tables); //cycle through foreach ($tables as $table) { $result = SQL('SELECT', ' * FROM ' . $table); $num_fields = $result->_numOfFields; $return .= 'DROP TABLE IF EXISTS ' . $table . '; '; $row2query = SQL('SHOW CREATE TABLE', $table); $row2data = $row2query->FetchRow(); $return .= "\n\n" . $row2data["Create Table"] . ";\n\n"; for ($i = 0; $i < $num_fields; $i++) { while ($row = $result->FetchRow()) { $return .= 'INSERT INTO ' . $table . ' VALUES('; for ($j = 0; $j < $num_fields; $j++) { $row[$j] = addslashes($row[$j]); $row[$j] = $data = arrayReplace(array("\n"), array("\\n"), $row[$j]); if (isset($row[$j])) { $return .= '"' . $row[$j] . '"'; } else { $return .= '""'; } if ($j < $num_fields - 1) { $return .= ','; } } $return .= ");\n"; } } $return .= "\n\n\n"; } sendFile($return, string2url('TemaTres-' . $_SESSION[CFGTitulo]) . '.sql'); }
function forumDispatch($op) { require_once _base_ . '/lib/lib.urlmanager.php'; $url_man =& UrlManager::getInstance('forum'); $url_man->setStdQuery('index.php?modname=forum&op=forum'); switch ($op) { case "forum": forum(); break; //-----------------------------------------------// //-----------------------------------------------// case "addforum": addforum(); break; case "insforum": insforum(); break; //-----------------------------------------------// //-----------------------------------------------// case "modforum": modforum(); break; case "upforum": upforum(); break; case "downforum": moveforum($_GET['idForum'], 'down'); break; case "moveupforum": moveforum($_GET['idForum'], 'up'); break; case "modstatus": changestatus(); break; case "export": export(); break; //-----------------------------------------------// //-----------------------------------------------// case "delforum": delforum(); break; //-----------------------------------------------// //-----------------------------------------------// case "modforumaccess": modforumaccess(); break; //-----------------------------------------------// //-----------------------------------------------// case "thread": thread(); break; //-----------------------------------------------// //-----------------------------------------------// case "addthread": addthread(); break; case "insthread": insthread(); break; //-----------------------------------------------// //-----------------------------------------------// case "modthread": modthread(); break; case "movethread": $id_thread = importVar('id_thread', true, 0); $id_forum = importVar('id_forum', true, 0); moveThread($id_thread, $id_forum); break; case "upthread": upthread(); break; //-----------------------------------------------// //-----------------------------------------------// case "delthread": delthread(); break; //-----------------------------------------------// //-----------------------------------------------// case "message": message(); break; case "moderatemessage": moderatemessage(); break; case "modstatusthread": modstatusthread(); break; case "changeerased": changeerase(); break; //-----------------------------------------------// //-----------------------------------------------// case "addmessage": addmessage(); break; case "insmessage": insmessage(); break; //-----------------------------------------------// //-----------------------------------------------// case "modmessage": modmessage(); break; case "upmessage": upmessage(); break; //-----------------------------------------------// //-----------------------------------------------// case "delmessage": delmessage(); break; //-----------------------------------------------// //-----------------------------------------------// case "viewprofile": viewprofile(); break; //-----------------------------------------------// //-----------------------------------------------// case "editsema": editsema(); break; case "savesema": savesema(); break; //-----------------------------------------------// //-----------------------------------------------// case "download": checkPerm('view'); require_once _base_ . '/lib/lib.download.php'; //find file list($title, $attach) = sql_fetch_row(sql_query("\r\n\t\t\tSELECT title, attach\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_forummessage\r\n\t\t\tWHERE idMessage='" . (int) $_GET['id'] . "'")); if (!$attach) { $GLOBALS['page']->add(getErrorUi('Sorry, such file does not exist!'), 'content'); return; } //recognize mime type $expFileName = explode('.', $attach); $totPart = count($expFileName) - 1; $path = '/appLms/' . Get::sett('pathforum'); //send file sendFile($path, $attach, $expFileName[$totPart]); break; //-----------------------------------------------// //-----------------------------------------------// case "search": forumsearch(); break; case "searchmessage": forumsearchmessage(); break; //-----------------------------------------------// } }
} $FILE = mediaFN($MEDIA); } //check file existance if (!@file_exists($FILE)) { header("HTTP/1.0 404 Not Found"); //FIXME add some default broken image print 'Not Found'; exit; } //handle image resizing if (substr($MIME, 0, 5) == 'image' && $WIDTH) { $FILE = get_resized($FILE, $EXT, $WIDTH, $HEIGHT); } // finally send the file to the client sendFile($FILE, $MIME, $CACHE); /* ------------------------------------------------------------------------ */ /** * Set headers and send the file to the client * * @author Andreas Gohr <*****@*****.**> * @author Ben Coburn <*****@*****.**> */ function sendFile($file, $mime, $cache) { global $conf; $fmtime = filemtime($file); // send headers header("Content-Type: {$mime}"); // smart http caching headers if ($cache == -1) {
moveFolder(); break; case 'deletefolder': deleteFolder(); break; case 'sharefolder': shareFolder(); break; case 'unsharefolder': unshareFolder(); break; case 'getshareinfo': getShareInfo(); break; case 'sendfile': sendFile(); break; case 'filerevisions': getFileRevisions(); break; case 'storagerevisions': getStorageRevisions(); break; case 'downloadafile': $t = true; $err = ''; if (strlen($_POST['token']) == 0) { $t = false; $err = 1; } if (strlen($_POST['durl']) == 0) {
/** * use only for special operation * * @access public */ function specialop() { require_once _base_ . '/lib/lib.download.php'; $re_entry = sql_query("\r\n\t\tSELECT user_entry\r\n\t\tFROM " . $this->_getUserEntryTable() . "\r\n\t\tWHERE id_user = '******'id_user', true) . "' AND\r\n\t\t\tid_common = '" . (int) $this->id_common . "' AND\r\n\t\t\tid_common_son = '0'"); list($file) = sql_fetch_row($re_entry); $path = $GLOBALS['where_files_relative'] . '/appCore/field/'; sendFile($path, $file); }
@comment @copyright Copyright (c) 2011-2012 Plugin Monitoring for GLPI team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/monitoring/ @since 2011 ------------------------------------------------------------------------ */ if (!defined('GLPI_ROOT')) { define('GLPI_ROOT', '../../..'); } include GLPI_ROOT . "/inc/includes.php"; checkLoginUser(); $docDir = GLPI_PLUGIN_DOC_DIR . '/monitoring'; if (isset($_GET['file'])) { $filename = $_GET['file']; $file = $docDir . '/' . $filename; if (preg_match("/PluginMonitoringService-([0-9]+)-2h([0-9]+).png/", $filename)) { include GLPI_ROOT . "/inc/includes.php"; $match = array(); preg_match("/PluginMonitoringService-([0-9]+)-2h([0-9]+).png/", $filename, $match); $pmServicegraph = new PluginMonitoringServicegraph(); $pmService = new PluginMonitoringService(); $pmComponent = new PluginMonitoringComponent(); $pmService->getFromDB($match[1]); $pmComponent->getFromDB($pmService->fields['plugin_monitoring_components_id']); $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], "PluginMonitoringService", $match[1], $match[2], '2h'); } sendFile($file, $filename); }
try { $res = $search->search("emultimedia", $columns, $terms); } catch (Exception $e) { //echo $e; sendError(406); } if (isset($res->rows[0]["resource"])) { $media = $res->rows[0]["resource"]; } else { sendError(404); } $temp_file = tempnam(sys_get_temp_dir(), 'IMU'); saveFile($temp_file, $media); $fn = $media["identifier"]; $mime = $media["mimeType"] . "/" . $media["mimeFormat"]; sendFile($temp_file, $mime, $fn); function saveFile($newloc, $file) { // Save a copy of the resource $temp = $file['file']; $copy = fopen($newloc, 'wb'); for (;;) { $data = fread($temp, 4096); // read 4K at a time if ($data === false || strlen($data) == 0) { break; } fwrite($copy, $data); } fclose($copy); }
} $task = new rTask(array('arg' => call_user_func('getFileName', $filename), 'requester' => 'screenshots', 'name' => 'ffmpeg', 'hash' => $_REQUEST['hash'], 'no' => $_REQUEST['no'])); $ret = $task->start($commands, rTask::FLG_NO_ERR); } } break; case "ffmpeggetall": $dir = rTask::formatPath($_REQUEST['no']); if (@chdir($dir)) { $randName = uniqid(getTempDirectory() . "rutorrent-scrn-"); exec(escapeshellarg(getExternal('tar')) . " -cf " . $randName . " ./*." . ($st->data['exformat'] ? 'png' : 'jpg'), $results, $return); if (is_file($randName)) { sendFile($randName, "application/x-tar", $_REQUEST['file'] . '.tar', false); unlink($randName); exit; } } header('HTTP/1.0 404 Not Found'); exit; case "ffmpeggetimage": $dir = rTask::formatPath($_REQUEST['no']); $ext = $st->data['exformat'] ? '.png' : '.jpg'; $filename = $dir . '/frame' . $_REQUEST['fno'] . $ext; sendFile($filename, $st->data['exformat'] ? 'image/png' : 'image/jpeg', $_REQUEST['file'] . "-" . str_pad($_REQUEST['fno'] + 1, 3, "0", STR_PAD_LEFT) . $ext); exit; case "ffmpegset": $ret = $st->set(); break; } } cachedEcho(json_encode($ret), "application/json");
curl_setopt($ch, CURLOPT_URL, $defaultEndpoint); //curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $response = curl_exec($ch); curl_close($ch); return $response; } $fields['status_code'] = 0; $fields['time_stamp'] = date("Y-m-d H:i:s"); if ($_POST['form']['UPLOAD_OPTION'] == '1') { // G::pr($doc_uid); $fields['message'] = sendFile($filename, $usr_uid, $app_uid, 1, $doc_uid); } else { $fields['message'] = sendFile($filename, $usr_uid, $app_uid); } $G_PUBLISH = new Publisher(); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/wsShowResult', null, $fields); G::RenderPage('publish', 'blank'); die; break; default: print_r($_POST); } } global $_DBArray; } catch (Exception $e) { $G_PUBLISH = new Publisher(); $aMessage['MESSAGE'] = $e->getMessage(); $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage);
function send_certificate() { require_once _lms_ . '/lib/lib.certificate.php'; require_once _base_ . '/lib/lib.download.php'; $id_certificate = importVar('certificate_id', true, 0); $id_course = importVar('course_id', true, 0); $id_user = importVar('user_id', true, 0); $certificate = new Certificate(); $report_info = array(); $report_info = $certificate->getInfoForCourseCertificate($id_course, $id_certificate, $id_user); $info_report = current($report_info); $file = $info_report[ASSIGN_CERT_FILE]; //recognize mime type $expFileName = explode('.', $file); $totPart = count($expFileName) - 1; //send file sendFile('/appLms/certificate/', $file, $expFileName[$totPart]); }
function downloadDemoMaterialTask() { require_once _base_ . '/lib/lib.download.php'; $id = Get::gReq('course_id', DOTY_INT); $db = DbConn::getInstance(); $qtxt = "SELECT course_demo FROM %lms_course WHERE idCourse=" . $id; $q = $db->query($qtxt); list($fname) = $db->fetch_row($q); if (!empty($fname)) { sendFile('/appLms/course/', $fname); } else { echo "nothing found"; } die; }
function do_mysql_dump($encode = "utf8") { global $DBCFG; $tables = $DBCFG[DBprefix] . 'config,' . $DBCFG[DBprefix] . 'tema,' . $DBCFG[DBprefix] . 'tabla_rel,' . $DBCFG[DBprefix] . 'indice,' . $DBCFG[DBprefix] . 'usuario,' . $DBCFG[DBprefix] . 'notas,' . $DBCFG[DBprefix] . 'values,' . $DBCFG[DBprefix] . 'tvocab,' . $DBCFG[DBprefix] . 'term2tterm'; $link = mysql_connect($DBCFG["Server"], $DBCFG["DBLogin"], $DBCFG["DBPass"]); mysql_select_db($DBCFG["DBName"], $link); /* * To UTF-8 databases */ if ($encode == 'utf8') { mysql_query('SET NAMES utf8'); mysql_query('SET CHARACTER SET utf8'); } //get all of the tables if ($tables == '*') { $tables = array(); $result = mysql_query('SHOW TABLES'); while ($row = mysql_fetch_row($result)) { $tables[] = $row[0]; } } else { $tables = is_array($tables) ? $tables : explode(',', $tables); } //cycle through foreach ($tables as $table) { $result = mysql_query('SELECT * FROM ' . $table); $num_fields = mysql_num_fields($result); $return .= 'DROP TABLE IF EXISTS ' . $table . '; '; $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE ' . $table)); $return .= "\n\n" . $row2[1] . ";\n\n"; for ($i = 0; $i < $num_fields; $i++) { while ($row = mysql_fetch_row($result)) { $return .= 'INSERT INTO ' . $table . ' VALUES('; for ($j = 0; $j < $num_fields; $j++) { $row[$j] = addslashes($row[$j]); $row[$j] = $data = arrayReplace(array("\n"), array("\\n"), $row[$j]); if (isset($row[$j])) { $return .= '"' . $row[$j] . '"'; } else { $return .= '""'; } if ($j < $num_fields - 1) { $return .= ','; } } $return .= ");\n"; } } $return .= "\n\n\n"; } sendFile($return, string2url('TemaTres-' . $_SESSION[CFGTitulo]) . '.sql'); }
function donwloadmaterials() { require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once _base_ . '/lib/lib.multimedia.php'; $lang = DoceboLanguage::createInstance('course', 'lms'); $id_course = importVar('id_course', true, 0); $edition_id = importVar('edition_id', true, 0); if ($id_course != 0) { $man_course = new DoceboCourse($id_course); $file = $man_course->getValue('img_material'); } if ($edition_id != 0) { $select_edition = " SELECT img_material "; $from_edition = " FROM " . $GLOBALS["prefix_lms"] . "_course_edition"; $where_edition = " WHERE idCourseEdition = '" . $edition_id . "' "; list($file) = sql_fetch_row(sql_query($select_edition . $from_edition . $where_edition)); } require_once _base_ . '/lib/lib.download.php'; $ext = end(explode('.', $file)); sendFile('/appLms/' . Get::sett('pathcourse'), $file, $ext); }
require_once $rtp; include 'xmlfix.php'; include 'conf.php'; include 'flm.class.php'; $e = new FLM(); switch ($e->postlist['action']) { case 'archive': $e->archive(); break; case 'cp': $e->copy($e->userdir . $e->postlist['to']); break; case 'dl': $e->shout = FALSE; $sf = $e->workdir . $e->postlist['target']; if (!sendFile($sf, null, null, false)) { cachedEcho('log(theUILang.fErrMsg[6]+" - ' . $sf . ' / "+theUILang.fErrMsg[3]);', "text/html"); } exit; break; case 'extract': $e->extract($e->postlist['target'], $e->postlist['to']); break; case 'getlog': $e->readlog($e->postlist['target'], $e->postlist['to']); break; case 'list': $e->dirlist(); break; case 'kill': $e->kill($e->postlist['target']);
public function doTextExportById($param) { $db = $this->getContainer('db'); $db->select_db(DB_CONFIGURATION); $db->dbconnect(); $uuid = getVar('transaction_id', "", $param, 'string'); $query = "SELECT data FROM link_share WHERE uuid='?' limit 1"; $query = $db->makeQuery($query, $uuid); $json = $db->loadObjectArray($query); $djson = json_decode($json[0]['data'], true); $timestamp = $djson['timestamp']; $param = $djson['param']; $data = $this->getMessagesForTransaction($timestamp, $param); list($pcapfile, $fsize, $buf) = $this->generateHomerTextPCAP($data, 1); sendFile(200, "OK", $pcapfile, $fsize, $buf); return; }
function send_certificate($id_certificate, $id_user, $id_course, $array_substituton = false, $download = true, $from_multi = false) { $id_meta = Get::req('idmeta', DOTY_INT, 0); if (!isset($_GET['idmeta'])) { $query_certificate = "\r\n\t\t\tSELECT cert_file\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate_assign\r\n\t\t\tWHERE id_certificate = '" . $id_certificate . "'\r\n\t\t\t\t AND id_course = '" . $id_course . "'\r\n\t\t\t\t AND id_user = '******' "; } else { $query_certificate = "\r\n\t\t\tSELECT cert_file\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign\r\n\t\t\tWHERE idUser = '******'\r\n\t\t\tAND idMetaCertificate = '" . $id_meta . "'"; } $re = sql_query($query_certificate); echo mysql_error(); if (mysql_num_rows($re) > 0) { if (!$download) { return; } require_once _base_ . '/lib/lib.download.php'; list($cert_file) = sql_fetch_row($re); sendFile(CERTIFICATE_PATH, $cert_file); return; } $query_certificate = "\r\n\t\tSELECT name, cert_structure, base_language, orientation, bgimage\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_certificate\r\n\t\tWHERE id_certificate = '" . $id_certificate . "'"; list($name, $cert_structure, $base_language, $orientation, $bgimage) = sql_fetch_row(sql_query($query_certificate)); require_once _base_ . '/lib/lib.upload.php'; if ($array_substituton !== false) { $cert_structure = str_replace(array_keys($array_substituton), $array_substituton, $cert_structure); } $cert_structure = fillSiteBaseUrlTag($cert_structure); $cert_file = $id_course . '_' . $id_certificate . '_' . $id_user . '_' . time() . '_' . $name . '.pdf'; sl_open_fileoperations(); if (!($fp = sl_fopen(CERTIFICATE_PATH . $cert_file, 'w'))) { sl_close_fileoperations(); return false; } if (!fwrite($fp, $this->getPdf($cert_structure, $name, $bgimage, $orientation, false, false, true))) { sl_close_fileoperations(); return false; } fclose($fp); sl_close_fileoperations(); //save the generated file in database if (!isset($_GET['idmeta'])) { $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_certificate_assign " . " ( id_certificate, id_course, id_user, on_date, cert_file ) " . " VALUES " . " ( '" . $id_certificate . "', '" . $id_course . "', '" . $id_user . "', '" . date("Y-m-d H:i:s") . "', '" . addslashes($cert_file) . "' ) "; } else { $query = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_certificate_meta_assign " . " ( idUser, idMetaCertificate, idCertificate, on_date, cert_file ) " . " VALUES " . " ('" . $id_user . "', '" . $id_meta . "', '" . $id_certificate . "', '" . date("Y-m-d H:i:s") . "', '" . addslashes($cert_file) . "' ) "; } if (!sql_query($query)) { return false; } if ($from_multi) { return; } $this->getPdf($cert_structure, $name, $bgimage, $orientation, $download, false); }
$tracker = rawurldecode($_REQUEST["tracker"]); $name = dirname(__FILE__) . "/trackers/" . $tracker . ".png"; if (is_readable($name)) { sendFile($name, "image/png"); exit; } $name = getSettingsPath() . '/trackers'; if (!is_dir($name)) { makeDirectory($name); } $name .= '/'; if (strlen($tracker)) { $name .= $tracker; $name .= '.ico'; if (!is_readable($name)) { $url = Snoopy::linkencode("http://" . $tracker . "/favicon.ico"); $client = new Snoopy(); @$client->fetchComplex($url); if ($client->status == 200) { file_put_contents($name, $client->results); } } if (is_readable($name)) { sendFile($name, "image/x-icon"); exit; } } } header("HTTP/1.0 302 Moved Temporarily"); header("Location: " . dirname($_SERVER['PHP_SELF']) . '/trackers/unknown.png'); exit;
function basicFeautures($type, $data) { global $obj, $auth, $search, $db; $answer = array(); switch ($type) { case 'session': if (!isset($data->username) || !isset($data->password)) { if ($auth->checkSession()) { $answer['auth'] = 'true'; $answer['status'] = 'ok'; $answer['sid'] = session_id(); } else { $answer['sid'] = session_id(); $answer['auth'] = 'false'; $answer['status'] = 'wrong-session'; } } else { $answer['user'] = $auth->logIn($data); if (empty($answer['user'])) { $answer['message'] = 'bad password or username'; $answer['status'] = 'wrong-credentials'; } else { $answer['status'] = 'ok'; } } break; case 'user': $answer['user'] = $auth->getUser(); if (count($answer['user'])) { $answer['status'] = 'ok'; } else { $answer['status'] = 'no-auth'; } break; /* SEARCH CALLS */ /* SEARCH CALLS */ case 'search/messages/all': include 'DataTable/Autoloader.php'; spl_autoload_register(array('DataTable_Autoloader', 'autoload')); include_once 'DataTable/sip/SipDataTable.php'; include_once 'DataTable/sip/SipSearchService.php'; $sipService = new SipSearchService($db->hostname_homer); $table = new SipDataTable(); $table->setBrowserService($sipService); $tmpdata = array(); foreach ($data as $k => $v) { $tmpdata[$v->name] = $v->value; } $dt_request = new DataTable_Request(); $dt_request->fromPhpRequest($tmpdata); echo $table->renderJson($dt_request); exit; break; /* messages */ /* messages */ case 'message/all/last': if ($resp = $search->showMessageAll($data, 0)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'rtcp/report/all': if ($resp = $search->showRtcpAll($data, 0)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { //$answer['status'] = 'not good'; $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'cdr/report/all': if ($resp = $search->showCdrAll($data, 0)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; /* statistic */ /* statistic */ case 'statistic/method/all': case 'statistic/method/total': $reqkey = preg_replace('/statistic\\/method\\//', '', $obj->getRURI()); if ($reqkey == "all") { $total = 0; } else { $total = 1; } if ($resp = $search->statisticMethod($data, $total)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'statistic/data/all': case 'statistic/data/total': $reqkey = preg_replace('/statistic\\/data\\//', '', $obj->getRURI()); if ($reqkey == "all") { $total = 0; } else { $total = 1; } if ($resp = $search->statisticData($data, $total)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'statistic/ip/all': case 'statistic/ip/total': $reqkey = preg_replace('/statistic\\/ip\\//', '', $obj->getRURI()); if ($reqkey == "all") { $total = 0; } else { $total = 1; } if ($resp = $search->statisticIP($data, $total)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'statistic/useragent/all': case 'statistic/useragent/total': $reqkey = preg_replace('/statistic\\/useragent\\//', '', $obj->getRURI()); if ($reqkey == "all") { $total = 0; } else { $total = 1; } if ($resp = $search->statisticUserAgent($data, $total)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'alarm/data/all': case 'alarm/data/total': case 'alarm/data/short': $reqkey = preg_replace('/alarm\\/data\\//', '', $obj->getRURI()); if ($reqkey == "all") { $total = 0; } else { if ($reqkey == "short") { $total = 2; } else { $total = 1; } } if ($resp = $search->alarmData($data, $total)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'alarm/update': if ($resp = $search->replaceAlarm($data)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'alarm/delete': if ($resp = $search->deleteAlarm($data)) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'alarm/delete/all': if ($resp = $search->deleteAllAlarms()) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'alarm/ack/all': console . log("Want to ACK all alarms"); if ($resp = $search->ackAllAlarms()) { $answer['status'] = 'ok'; $answer['data'] = $resp; } else { $answer['status'] = 'not good'; $answer['data'] = array(); } break; case 'export/pcap/callid': case 'export/text/callid': include_once "class/pcap.php"; /* Call Search */ $export = new Export(); $export->setDB($db); $text = 0; if ($obj->getRURI() == "export/text/callid") { $text = 1; } $resp = $export->generatePcap($data, $text); if (!empty($resp)) { sendFile(200, $resp[0], $resp[1], $resp[2]); exit; } else { $answer['status'] = 'ok'; $answer['data'] = array(); exit; } break; /* ALARMS */ /* ALARMS */ default: $answer['status'] = 'not good'; $answer['message'] = 'Unknown get call: [' . $request . ']'; $answer['data'] = array(); break; } return $answer; }
} } $evt->advise_after(); unset($evt); //handle image resizing/cropping if (substr($MIME, 0, 5) == 'image' && $WIDTH) { if ($HEIGHT) { $data['file'] = $FILE = media_crop_image($data['file'], $EXT, $WIDTH, $HEIGHT); } else { $data['file'] = $FILE = media_resize_image($data['file'], $EXT, $WIDTH, $HEIGHT); } } // finally send the file to the client $evt = new Doku_Event('MEDIA_SENDFILE', $data); if ($evt->advise_before()) { sendFile($data['file'], $data['mime'], $data['download'], $data['cache']); } // Do something after the download finished. $evt->advise_after(); /* ------------------------------------------------------------------------ */ /** * Set headers and send the file to the client * * @author Andreas Gohr <*****@*****.**> * @author Ben Coburn <*****@*****.**> */ function sendFile($file, $mime, $dl, $cache) { global $conf; $fmtime = @filemtime($file); // send headers
http_status($data['status'], $data['statusmessage']); } // die on errors if ($data['status'] > 203) { print $data['statusmessage']; if (defined('SIMPLE_TEST')) { return; } exit; } } $evt->advise_after(); unset($evt); //handle image resizing/cropping if (substr($MIME, 0, 5) == 'image' && ($WIDTH || $HEIGHT)) { if ($HEIGHT && $WIDTH) { $data['file'] = $FILE = media_crop_image($data['file'], $EXT, $WIDTH, $HEIGHT); } else { $data['file'] = $FILE = media_resize_image($data['file'], $EXT, $WIDTH, $HEIGHT); } } // finally send the file to the client $evt = new Doku_Event('MEDIA_SENDFILE', $data); if ($evt->advise_before()) { sendFile($data['file'], $data['mime'], $data['download'], $data['cache'], $data['ispublic'], $data['orig']); } // Do something after the download finished. $evt->advise_after(); // will not be emitted on 304 or x-sendfile // END DO main //Setup VIM: ex: et ts=2 :
} catch (Exception $e) { } if ($databaseFileSotrage->getId()) { $directory = dirname($filePath); if (!is_dir($directory)) { mkdir($directory, 0777, true); } $fp = fopen($filePath, 'w'); if (flock($fp, LOCK_EX | LOCK_NB)) { ftruncate($fp, 0); fwrite($fp, $databaseFileSotrage->getContent()); } flock($fp, LOCK_UN); fclose($fp); } sendFile($filePath); sendNotFoundPage(); /** * Send 404 */ function sendNotFoundPage() { header('HTTP/1.0 404 Not Found'); exit; } /** * Check resource by whitelist * * @param string $resource * @param array $allowedResources */
<?php require_once '../../php/xmlrpc.php'; if (isset($_REQUEST['result'])) { cachedEcho('noty(theUILang.cantAccessData,"error");', "text/html"); } if (isset($_REQUEST['hash']) && isset($_REQUEST['no'])) { $req = new rXMLRPCRequest(new rXMLRPCCommand("f.get_frozen_path", array($_REQUEST['hash'], intval($_REQUEST['no'])))); if ($req->success()) { $filename = $req->val[0]; if ($filename == '') { $req = new rXMLRPCRequest(array(new rXMLRPCCommand("d.open", $_REQUEST['hash']), new rXMLRPCCommand("f.get_frozen_path", array($_REQUEST['hash'], intval($_REQUEST['no']))), new rXMLRPCCommand("d.close", $_REQUEST['hash']))); if ($req->success()) { $filename = $req->val[1]; } } if (sendFile($filename)) { exit; } } } if (isset($_REQUEST['readable'])) { cachedEcho("Cant retrieve such large file, sorry", "text/html"); } else { header("HTTP/1.0 302 Moved Temporarily"); header("Location: " . $_SERVER['PHP_SELF'] . '?result=0'); }