<?php header("Expires: Mon, 25 Jan 1970 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // in MAMP the default folder is located on MAC os here: // /Applications/MAMP/htdocs/temp $TEMP_FOLDER = 'temp/'; print_r($_FILES); // Different file fields if (isset($_FILES['Filedata'])) { $fileName = $_FILES['Filedata']['name']; $filePath = $TEMP_FOLDER . basename($fileName); $message = "upload strarted... filePath: " . $filePath; if (move_uploaded_file($_FILES['Filedata']['tmp_name'], $filePath)) { $message = $message . " -> success"; } print_r(get_last_error()); } else { $message = "false: " . ($fileName = $_POST['Filename']); } echo $message; exit(0);
if (!all_not_empty($class_to_call, $method_to_call)) { $class_to_call = $class_to_call ? $class_to_call : '?'; $method_to_call = $method_to_call ? $method_to_call : '?'; throw new Error(503, "Class and/or method to call missing: {$class_to_call}->{$method_to_call}"); } $class_file = 'classes/' . $class_to_call . '.class.php'; if (!file_exists($class_file)) { throw new Error(503, 'The file ' . $class_file . ' does not exists'); } include_once $class_file; if (!class_exists($class_to_call, false)) { throw new Error(503, 'The file ' . $class_file . ' does not contain the class ' . $class_to_call); } $class_methods = get_class_methods($class_to_call); if ($class_methods === NULL) { throw new Error(503, 'Unable to get methods from class ' . $class_to_call . ': ' . get_last_error()); } if (!in_array($method_to_call, $class_methods)) { throw new Error(503, 'The class ' . $class_to_call . ' does not contain the method ' . $method_to_call); } /* fetch logged-in user email */ $logged_in_user_email = array_keys($_SESSION); $logged_in_user_email = empty($logged_in_user_email) ? '' : $logged_in_user_email[0]; /* check if the user is allowed to call the method */ $class_vars = get_class_vars($class_to_call); if (isset($class_vars['restricted_methods']) && isset($class_vars['restricted_methods'][$method_to_call])) { $current_permissions = unserialize($_SESSION[$logged_in_user_email]); $current_permissions = $current_permissions['permissions']; $possible_permissions = $class_vars['restricted_methods'][$method_to_call]; $has_permission = false; foreach ($current_permissions as $index => $permission) {
$action = strtolower($parts[0]); array_shift($parts); $trailing = trim(implode(" ", $parts)); switch ($action) { case "count": $records = fetch_query("SELECT COUNT(*) FROM " . BOT_SCHEMA . "." . LOG_TABLE); privmsg($records[0]["COUNT(*)"]); break; case "last": $params = array("destination" => $dest); $records = fetch_prepare("SELECT * FROM " . BOT_SCHEMA . "." . LOG_TABLE . " WHERE ((cmd='PRIVMSG') and (destination=:destination)) ORDER BY id DESC LIMIT 1", $params); privmsg($records[0]["data"]); break; case "query": # ~sql query select comment_body from exec_irc_bot.sn_comments where (comment_body like '%fart%') order by rand() limit 1 $records = fetch_query($trailing); $error = get_last_error(); if ($error != "") { privmsg($error); return; } for ($i = 0; $i < min(3, count($records)); $i++) { if (is_array($records[$i]) == True) { privmsg(implode("|", $records[$i])); } else { privmsg($records[$i]); } } break; } #####################################################################################################