//上传页面代码
$url = "http://192.168.1.100/upload.php?lang=cn"; #可以get传相应参数 $file = $path.'/'. $Icon; //要上传的文件 $fields['f'] = '@'.$file; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields ); curl_exec( $ch ); if ($error = curl_error($ch) ) { die($error); } curl_close($ch);
//接收图片资源
date_default_timezone_set('Asia/Shanghai'); //设置时区 $ip = ''; if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')){ $ip = getenv('HTTP_CLIENT_IP'); }elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')){ $ip = getenv('HTTP_X_FORWARDED_FOR'); }elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')){ $ip = getenv('REMOTE_ADDR'); }elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')){ $ip = $_SERVER['REMOTE_ADDR']; } preg_match("/[\d\.]{7,15}/", $ip, $ipmatches); $ip = $ipmatches[0] ? $ipmatches[0] : 'unknown'; //驗證請求IP,设置白名单 $date = date("[Y-m-d H:i:s]"); $allowip = array('192.168.1.100'); if(!in_array($ip,$allowip)){ $ipVal = "{$date}{$ip}\n"; file_put_contents('upload_ip.log', $ipVal, FILE_APPEN); die(-1); } //接收get传参 $lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : 'CN'; $uploaddir = "/data/cdncache/res/gifts/{$lang}/"; $uploadfile = $uploaddir . $_FILES['f']['name']; if (move_uploaded_file($_FILES['f']['tmp_name'], $uploadfile)) #保存图片成功 { $type = $_FILES['f']['type']; $tmp_name = $_FILES['f']['tmp_name']; $error = $_FILES['f']['error']; $size = $_FILES['f']['size']; $log_txt = ' name:' . $_FILES['f']['name'] . ' type:' . $type . ' tmp_name:' . $tmp_name . ' error:' . $error . ' size:' . $size . " hello " . ' lang:' . $_REQUEST['lang']; $value = "{$date}{$log_txt}\n"; @file_put_contents('upload_ok.log', $value, FILE_APPEND); exit(); } else { $type = $_FILES['f']['type']; $tmp_name = $_FILES['f']['tmp_name']; $error = $_FILES['f']['error']; $size = $_FILES['f']['size']; $log_txt = ' name:' . $_FILES['f']['name'] . ' type:' . $type . ' tmp_name:' . $tmp_name . ' error:' . $error . ' size:' . $size . " hello " . ' lang:' . $_REQUEST['lang']; $value = "{$date}{$log_txt}\n"; @file_put_contents('upload_ng.log', $value, FILE_APPEND); exit(); }
以上所述就是本文的全部内容了,希望大家能够喜欢。

The article discusses PHP Data Objects (PDO), an extension for database access in PHP. It highlights PDO's role in enhancing security through prepared statements and its benefits over MySQLi, including database abstraction and better error handling.

Memcache and Memcached are PHP caching systems that speed up web apps by reducing database load. A single instance can be shared among projects with careful key management.

Article discusses steps to create and manage MySQL databases using PHP, focusing on connection, creation, common errors, and security measures.

The article discusses how JavaScript and PHP interact indirectly through HTTP requests due to their different environments. It covers methods for sending data from JavaScript to PHP and highlights security considerations like data validation and prot

The article discusses executing PHP scripts from the command line, including steps, common options, troubleshooting errors, and security considerations.

PEAR is a PHP framework for reusable components, enhancing development with package management, coding standards, and community support.

PHP is a versatile scripting language used mainly for web development, creating dynamic pages, and can also be utilized for command-line scripting, desktop apps, and API development.

The article discusses PHP's evolution from "Personal Home Page Tools" in 1995 to "PHP: Hypertext Preprocessor" in 1998, reflecting its expanded use beyond personal websites.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
