function processFile($error, $type, $size, $tmp_name) { if ($error == 4) { return "<none>"; } if ($size > 300000) { echo makeRetHtml("数据提交失败!图片超过300KB,请修改图片大小。", true); die(2); } if ($type == "image/png" || $type == "image/x-png" || $type == "image/gif" || $type == "image/jpeg" || $type == "image/pjpeg") { $filename = generateFilename($type); move_uploaded_file($tmp_name, "upload/" . $filename); return $filename; } else { echo makeRetHtml("数据提交失败!上传截图仅支持PNG/JPG/GIF格式。", true); die(3); } }
// must be in the format 'user' => 'token' $users = array('myuser' => 'mypass'); // read the input $input = file_get_contents("php://input"); // verify the user if (!isset($_SERVER['HTTP_X_USERNAME']) || !isset($users[$_SERVER['HTTP_X_USERNAME']])) { exit('Error: No authorization'); } $token = $users[$_SERVER['HTTP_X_USERNAME']]; if (!isset($_SERVER['HTTP_X_SIGNATURE']) || $_SERVER['HTTP_X_SIGNATURE'] != sha1($input . $token)) { exit('Error: No authorization'); } // write the file function generateFilename() { return substr(md5(microtime()), 0, 6); } do { $filename = 'caps/' . generateFilename() . '.png'; } while (file_exists($filename)); file_put_contents($filename, base64_decode($input)); if (isset($_SERVER['FCGI_ROLE'])) { $path = $_SERVER['REQUEST_URI']; } else { $path = $_SERVER['PHP_SELF']; } $path = trim(dirname($path), '/'); if (strlen($path) > 0) { $path .= '/'; } echo 'http://' . $_SERVER['HTTP_HOST'] . '/' . $path . $filename;
$restaurant->onlineuser_onlineuserid = $user->onlineuserId; //default link $restaurant->link = "http://"; //super admin access only, so always active $restaurant->restaurant_status = 'active'; } //check if form is being submitted if ((bool) $_POST["submitting"]) { $restaurant->name = $_POST["name"]; $restaurant->description = $_POST["description"]; $restaurant->link = $_POST["link"]; $restaurant->tel = $_POST["tel"]; $restaurant->logo = $_POST["currentFilename"]; $tempFilename = $_FILES["logo"]["tmp_name"]; if ($tempFilename != "") { $restaurant->logo = generateFilename($user->onlineuserId, $_FILES["logo"]["name"]); move_uploaded_file($tempFilename, "logos/{$restaurant->logo}"); } if (($result = validate($restaurant->name, "", 255)) !== true) { $errorText .= "<li>Restaurant name is {$result}"; } if (($result = validate($restaurant->description, "", 5000)) !== true) { $errorText .= "<li>Description is {$result}"; } if (($result = validate($restaurant->link, "", 255)) !== true) { $errorText .= "<li>Website link is {$result}"; } if ($restaurant->tel != "" && ($result = validate($restaurant->tel, "phonenumber", 255)) !== true) { $errorText .= "<li>Telephone number is {$result}"; } if ($errorText == "") {
} } } // Validate the file size (Warning: the largest files supported by this code is 2GB) $file_size = @filesize($_FILES[$upload_name]["tmp_name"]); if (!$file_size || $file_size > $max_file_size_in_bytes) { HandleError("File exceeds the maximum allowed size"); exit(0); } if ($file_size <= 0) { HandleError("File size outside allowed lower bound"); exit(0); } // Validate file name (for our purposes we'll just remove invalid characters) // $file_name = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name'])); $file_name = generateFilename($_FILES[$upload_name]['name']); if (strlen($file_name) == 0 || strlen($file_name) > $MAX_FILENAME_LENGTH) { HandleError("Invalid file name"); exit(0); } // Validate that we won't over-write an existing file if (file_exists($save_path . $file_name)) { HandleError("File with this name already exists"); exit(0); } // Validate file extension $path_info = pathinfo($_FILES[$upload_name]['name']); $file_extension = $path_info["extension"]; $is_valid_extension = false; foreach ($extension_whitelist as $extension) { if (strcasecmp($file_extension, $extension) == 0) {
$member->name = $_POST["name"]; $member->address = $_POST["address"]; $member->tel = $_POST["tel"]; $member->fax = $_POST["fax"]; $member->email = $_POST["email"]; $member->link = $_POST["link"]; if (($tempFilename = $_FILES["logo"]["tmp_name"]) != "") { $member->logo = generateFilename($user->onlineuserId, $_FILES["logo"]["name"]); move_uploaded_file($tempFilename, "logos/{$member->logo}"); } if (($tempFilename1 = $_FILES["image1"]["tmp_name"]) != "") { $member->image1 = generateFilename($user->onlineuserId, $_FILES["image1"]["name"]); move_uploaded_file($tempFilename1, "logos/{$member->image1}"); } if (($tempFilename2 = $_FILES["image2"]["tmp_name"]) != "") { $member->image2 = generateFilename($user->onlineuserId, $_FILES["image2"]["name"]); move_uploaded_file($tempFilename2, "logos/{$member->image2}"); } if (($result = validate($member->heading, "", 255)) !== true) { $errorText .= "<li>The heading is {$result}"; } if (($result = validate($member->text, "", 5000)) !== true) { $errorText .= "<li>The text is {$result}"; } if (($result = validate($member->name, "", 255)) !== true) { $errorText .= "<li>The company name is {$result}"; } if (($result = validate($member->address, "", 255)) !== true) { $errorText .= "<li>The address is {$result}"; } if (($result = validate($member->tel, "phonenumber", 40)) !== true) {
//default link $franchise->link = "http://"; //super admin access only, so always active $franchise->franchise_status = 'active'; } //check if form is being submitted if ((bool) $_POST["submitting"]) { $franchise->logo = $_POST["currentFilename"]; $franchise->county = $_POST["county"]; $franchise->name = $_POST["name"]; $franchise->description = $_POST["description"]; $franchise->link = $_POST["link"]; $franchise->tel = $_POST["tel"]; $tempFilename = $_FILES["logo"]["tmp_name"]; if ($tempFilename != "") { $franchise->logo = generateFilename($user->onlineuserId, $_FILES["logo"]["name"]); move_uploaded_file($tempFilename, "logos/{$franchise->logo}"); } if (($result = validate($franchise->county, "", 255)) !== true) { $errorText .= "<li>The chosen county is {$result}"; } if (($result = validate($franchise->name, "", 50)) !== true) { $errorText .= "<li>The name is {$result}"; } if (($result = validate($franchise->description, "words", 25)) !== true) { $errorText .= "<li>The description is {$result}"; } if (($result = validate($franchise->tel, "phonenumber", 45)) !== true) { $errorText .= "<li>The telephone number is {$result}"; } if (($result = validate($franchise->link, "", 255)) !== true) {
#$AxisX->setLabelInterval(200); # DATA addPoints # -------------- $max_y_value = 5000; # query data if (is_numeric($bucketsz)) { $sec = $bucketsz; } else { $sec = 24 * 60 * 60; // One day } $data = probe_data_query_ts($probeid, $sec, $tstampF, $tstampT); //probe_data_show_table($data); //db_disconnect(); $urldata['bucketsz'] = $bucketsz; $urldata['probeid'] = $probeid; if ($valid == true) { // Call data_addPoints() $records = data_addPoints01($Dataset, $data, $droptype, $max_y_value, $urldata); } else { $err = "Invalid input data cannot proceed"; trigger_error("{$err}", E_USER_ERROR); } $filename = generateFilename("probe_drops_bar01", $_REQUEST, 'png'); // Special output the Graph $output = $Graph->done(array('tohtml' => True, 'showtime' => True, 'border' => 0, 'filename' => $filename, 'filepath' => './graphs/', 'urlpath' => 'graphs/')); if ($records > 0) { print $output; } else { echo "<h3>Graph: No data available in choosen period</h3>"; }
#$FillArray->addColor('green@0.2'); #$FillArray->addColor('blue@0.2'); #$FillArray->addColor('yellow@0.2'); #$FillArray->addColor('red@0.2'); #$FillArray->addColor('orange@0.2'); #$FillArray->addColor('black@0.2', 'rest'); $Plot->explode(10); // create a Y data value marker $Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_TOTAL); // fill it with white $Marker->setFillColor('white'); // and use black border $Marker->setBorderColor('black'); // and format it using a data preprocessor $Marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%')); $Marker->setFontSize(7); // create a pin-point marker type $PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker)); // and use the marker on the plot $Plot->setMarker($PointingMarker); // output the Graph //$Graph->done(); $filename = generateFilename("pie01", $_REQUEST, 'png'); // Special output the Graph $output = $Graph->done(array('tohtml' => True, 'showtime' => $displayTiming, 'border' => 0, 'filename' => $filename, 'filepath' => './graphs/', 'urlpath' => 'graphs/')); print $output; #print '<pre>' . htmlspecialchars($output) . '</pre>'; echo "<p>Channels in period:{$cnt}<br>\n"; echo "Removed channels:{$cnt_removed}\n"; echo "<p>\n"; form_remove_channels($data);
//free for now $supplier->supplier_status = 'active'; $supplier->dt_expire = expiryDate(); } //check if form is being submitted if ((bool) $_POST["submitting"]) { $isNew = $_POST["isNew"]; $supplier->logo = $_POST["currentFilename"]; $supplier->name = $_POST["name"]; $supplier->description = $_POST["description"]; $supplier->link = $_POST["link"]; $supplier->tel = $_POST["tel"]; $supplier->supplier_category_id = (int) $_POST["category"]; $tempFilename = $_FILES["logo"]["tmp_name"]; if ($tempFilename != "") { $supplier->logo = generateFilename($user->onlineuserId, $_FILES["logo"]["name"]); move_uploaded_file($tempFilename, "logos/{$supplier->logo}"); } if (($result = validate($supplier->name, "", 255)) !== true) { $errorText .= "<li>Supplier name is {$result}"; } if (($result = validate($supplier->description, "", 120)) !== true) { $errorText .= "<li>Description is {$result}"; } if (($result = validate($supplier->link, "", 255)) !== true) { $errorText .= "<li>Website link is {$result}"; } if ($supplier->tel != "" && ($result = validate($supplier->tel, "phonenumber", 255)) !== true) { $errorText .= "<li>Telephone number is {$result}"; } if ($errorText == "") {
// Trick we add two datapoints, Start and End of the period we are plotting. $Dataset->addPoint($tstampF, 0); // Call data_addPoints() $records = data_addPoints01($Dataset, $data, $droptype, $maxy, $urldata); // End datapoint $Dataset->addPoint($tstampT, 0); // Fix the Y-axis max $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); if ($_REQUEST['maxy_fixed'] == "fixed") { if (is_numeric($maxy)) { $AxisY->forceMaximum($maxy); } } $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); #$AxisX->setFontAngle(70); # # Needs auto adjustment $AxisX->setLabelOption('dateformat', "Y-m-d\nH:i:s"); #$AxisX->setLabelOption('dateformat', 'Y-m-d'); #$AxisX->setLabelInterval("auto"); #$AxisX->setLabelInterval(200); $filename = generateFilename("channel_drops_bar01", $_REQUEST, 'png'); // Special output the Graph $output = $Graph->done(array('tohtml' => True, 'showtime' => $displayTiming, 'border' => 0, 'filename' => $filename, 'filepath' => './graphs/', 'urlpath' => 'graphs/')); if ($records > 0) { print $output; } else { echo "<h3>Graph: No data available"; echo " in choosen period on probe: <em>{$probename}</em></h3>"; echo "<h4>Have you choosen a probe in the table?</h4>"; }
// Allocate image path WITHOUT domain address $img_array = explode("//", $img_tmp); $img_name_only = $img_array[1]; $img_name_only = explode("/", $img_name_only); unset($img_name_only[0]); $img_name_only = implode("/", $img_name_only); // Change image path to relative path (without domain) $link = str_replace($img_tmp_old, $img_name_only, $link); // Add image to final file $MhtFileMaker->AddFile($img_tmp, $img_name_only, 'utf-8'); } // Create final file $MhtFileMaker->AddContents($link, "text/html"); // Save file $MhtFileMaker->MakeFile($filename); } $link = $_POST['plainHTML']; // Generate random name for file function generateFilename($length = 8) { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $count = mb_strlen($chars); for ($i = 0, $result = ''; $i < $length; $i++) { $index = rand(0, $count - 1); $result .= mb_substr($chars, $index, 1); } return $result; } $filename = "result/" . generateFilename() . ".doc"; CreateDOC($link, $filename); echo $filename;