Ec (2); the phpdiscuzchhome Image Upload swfupload function is far different from the discuz function. lack of functions. & nbsp; in addition to some built-in url leads, we cannot modify other data. & lt ;? Php * & nbsp; [UCenterHome] (C) 2007-2008ComsenzInc. & nbsp; $ Id: do_swfupload. script ec (2); script
Php discuz chhome Image Upload swfupload Function
This upload is far different from discuz, and lacks functions.
In addition to some built-in url leads, we cannot modify other data.
/*
[UCenter Home] (C) 2007-2008 Comsenz Inc.
$ Id: do_swfupload.php 12830 2009-07-22 06: 42: 32Z zhengqingpeng $
*/
If (! Defined ('in _ UCHOME ') {// entry card.
Exit ('Access Denied ');
}
Include_once (S_ROOT. './source/function_cp.php ');
$ Op = empty ($ _ GET ['op'])? '': $ _ GET ['op']; // method variables that uchome prefers.
$ Isupload = empty ($ _ GET ['cam ']) & empty ($ _ GET ['doobao'])? True: false; // whether to upload the image. Another possibility is upload the Avatar.
$ Iscamera = isset ($ _ GET ['cam '])? True: false; // determines whether an avatar is uploaded.
$ Isdoset = isset ($ _ GET ['doobao'])? True: false; // determines whether the background is random.
$ Fileurl = ''; // default value.
If (! Empty ($ _ POST ['uid']) {// If a uid is uploaded, the uid value is obtained when the Avatar is uploaded.
$ _ SGLOBAL ['supe _ uid'] = intval ($ _ POST ['uid']); // force conversion.
If (empty ($ _ SGLOBAL ['supe _ uid']) | $ _ POST ['hash']! = Md5 ($ _ SGLOBAL ['supe _ uid']. UC_KEY) {// Since the uid value is passed, if the user does not log on and does not correspond to the hash code, it is interrupted.
Exit ();
}
} Elseif (empty ($ _ SGLOBAL ['supe _ uid']) {// otherwise, you can determine whether to use the upload function unless you log on.
Showmessage ('to _ login', 'do. php? Ac = '. $ _ SCONFIG ['login _ action']);
}
If ($ op = "finish") {// when the upload is complete.
/* It will pass the following GET
Array (
'Ac' => 'swfupload ',
'Op' => 'finish ',
'Albumid' => '2 ',
)*/
$ Albumid = intval ($ _ GET ['alumid']); // obtain the category id.
$ Space = getspace ($ _ SGLOBAL ['supe _ uid']); // updates some user records, compares the total number of images, and calculates the capacity.
If (ckprivacy ('upload', 1) {// determine whether push has been written.
Include_once (S_ROOT. './source/function_feed.php ');
Feed_publish ($ albumid, 'albumid'); // otherwise, write it again.
}
// Force interrupt.
Exit ();
} Elseif ($ op = 'config') {// swf upload configuration.
/* Based on the captured GET:
Array (
'Ac' => 'swfupload ',
'Op' => 'config ',
)
*/
$ Hash = md5 ($ _ SGLOBAL ['supe _ uid']. UC_KEY); // generate a hash code.
If ($ isupload &&! Checkperm ('allowupload') {// upload an image with sufficient permissions. For configuration, $ isupload is always false.
$ Hash = '';
} Else {
$ Filearr = $ dirstr = array (); // initialize the array. File array/and directory data.
If ($ iscamera) {// upload the Avatar.
/*
According to the capture, the GET data is as follows:
Array (
'Ac' => 'swfupload ',
'Op' => 'config ',
'Cam '=> '1 ',
)
*/
$ Directory = sreaddir (S_ROOT. './image/foreground'); // The background directory. sreaddir reads the directory data.
Foreach ($ directory as $ key => $ value) {// each background is an independent directory, So repeat it.
$ Dirstr = S_ROOT. './image/foreground/'. $ value; // synthesize a new path.
If (is_dir ($ dirstr) {// check whether it is a directory.
$ Filearr = sreaddir ($ dirstr, array ('jpg ', 'jpeg', 'gif', 'png '); // read the image files in the directory.
If (! Empty ($ filearr) {// If the Image array is not empty.
If (is_file ($ dirstr. '/categories.txt') {// if the categories.txt file exists.
$ Catfile = @ file ($ dirstr. '/categories.txt'); // open this file.
$ Dirarr [$ key] [0] = trim ($ catfile [0]); // read the file. of course, there is no need to do this. The contents are the same as the directory name.
} Else {// If the txt file does not exist, obtain the directory name.
$ Dirarr [$ key] [0] = trim ($ value); // accurately obtains the value. trim is used for multiple purposes.
}
$ Dirarr [$ key] [1] = trim ('image/foreground/'. $ value.'/'); // set pointer 1 to the background directory of the current dashboard.
$ Dirarr [$ key] [2] = $ filearr; // set pointer 2 to the image in the background directory of the current dashboard.
}
}
}
} Elseif ($ isdoif) {// If the profile picture is a random background, read the image files in./image/dow./ big.
$ Filearr = sreaddir (S_ROOT. './image/dow./ big', array ('jpg ', 'jpeg', 'gif', 'png '));
}
}
// Configure the Image Upload.
$ Max = @ ini_get (upload_max_filesize); // obtain the maximum php. ini upload value.
$ Unit = strtolower (substr ($ max,-1, 1); // the word "kb" at the end of "max" must be truncated and converted to lowercase.
// The following is a conversion for different computing units.
If ($ unit = 'k '){
$ Max = intval ($ max) * 1024; // it seems that all data is converted to byt bytes. kb x 1024 = How many bytes.
} Elseif ($ unit = 'M '){
$ Max = intval ($ max) * 1024*1024; // mb x 1024X1024 = How many bytes.
} Elseif ($ unit = 'G '){
$ Max = intval ($ max) * 1024*1024*1024; // gb x 1024X1024X1024 = How many bytes.
}
// Obtain the array of user-created categories.
$ Albums = getalbums ($ _ SGLOBAL ['supe _ uid']);
} Elseif ($ op = "screen" | $ op = "DoCoMo") {// screen does not understand when to come out. | the background is pasted randomly because there is no camera, this is skipped.
If (empty ($ GLOBALS ['HTTP _ RAW_POST_DATA ']) {
$ GLOBALS ['HTTP _ RAW_POST_DATA '] = file_get_contents ("php: // input ");
}
$ Status = "failure ";
$ Dosave = true;
If ($ op = "doodle "){
$ Query = $ _ SGLOBAL ['db']-> query ('select * from '. tname ('usermagic '). "WHERE uid = '$ _ SGLOBAL [supe_uid]' AND mid = 'doobao '");
$ Value = $ _ SGLOBAL ['db']-> fetch_array ($ query );
If (empty ($ value) | $ value ['Count'] <1) {// ####
$ Uploadfiles =-8;
$ Dosave = false;
}
}
If ($ dosave &&! Empty ($ GLOBALS ['HTTP _ RAW_POST_DATA ']) {
$ _ SERVER ['HTTP _ albumid'] = addslashes (siconv (urldecode ($ _ SERVER ['HTTP _ albumid']), $ _ SC ['charset'], "UTF-8 "));
$ From = false;
If ($ op = 'screen '){
$ From = 'camera ';
} Elseif ($ _ GET ['from'] = 'alipay '){
$ From = 'uploadimage ';
}
$ _ SCONFIG ['allowwatermark'] = 0;
$ Uploadfiles = stream_save ($ GLOBALS ['HTTP _ RAW_POST_DATA '], $ _ SERVER ['HTTP _ albumid'], 'jpg', '','', 0, $ from );
}
$ UploadResponse = true;
$ Picid = $ proid = $ albumid = 0;
If ($ uploadfiles & is_array ($ uploadfiles )){
$ Status = "success ";
$ Albumid = $ uploadfiles ['alipayid'];
$ Picid = $ uploadfiles ['picid'];
If ($ op = "doodle "){
$ Fileurl = pic_get ($ uploadfiles ['filepath'], $ uploadfiles ['thumb'], $ uploadfiles ['remote'], 0 );
Include_once (S_ROOT. './source/function_magic.php ');
Magic_use ('doobao', array (), 1 );
}
} Else {
Switch ($ uploadfiles ){
Case-1:
$ Uploadfiles = cplang ('inadequate _ capacity_space ');
Break;
Case-2:
$ Uploadfiles = cplang ('only _ allows_upload_file_types ');
Break;
Case-4:
$ Uploadfiles = cplang ('ftp _ upload_file_size ');
Break;
Case-8:
$ Uploadfiles = cplang ('has _ not_more_doang ');
Break;
Default:
$ Uploadfiles = cplang ('mobile _ picture_temporary_failure ');
Break;
}
}
} Elseif ($ _ FILES & $ _ POST) {// when uploading an image,
/* According to the capture, the value of post get is:
POST = array (
'Filename' => 'mjp4520.r3001.jpg ',
'Proid' => '1 ',
'Albumid' => '2 ',
'Uid' => '1 ',
'Title' => 'mjp45 + R3001 ',
'Hash' => '11ed07fe235ca5b9e509043e85419785 ',
'Upload' => 'submit query ',
)
GET = array (
'Ac' => 'swfupload ',
)
*/
If ($ _ FILES ["Filedata"] ['error']) {// if an upload error occurs
$ Uploadfiles = cplang ('file _ is_too_big '); // The system prompts that the file is too large.
} Else {
// For encoding and Case sensitivity, escape is also used to obtain the upload file name.
$ _ FILES ["Filedata"] ['name'] = addslashes (siconv (urldecode ($ _ FILES ["Filedata"] ['name']), $ _ SC ['charset'], "UTF-8 "));
// For encoding and Case sensitivity, escape is also used to obtain the upload category id.
$ _ POST ['alumid'] = addslashes (siconv (urldecode ($ _ POST ['alumid']), $ _ SC ['charset'], "UTF-8 "));
// Take into account the encoding and Case sensitivity issues, and escape. Get a detailed path after the uploaded file.
$ Uploadfiles = pic_save ($ _ FILES ["Filedata"], $ _ POST ['albumid'], addslashes (siconv (urldecode ($ _ POST ['title']), $ _ SC ['charset'], "UTF-8 ")));
}
// According to my analysis, the following content is useless during image uploading. I wonder if the avatar will be used for uploading.
$ Proid = $ _ POST ['proid'];
$ UploadResponse = true;
$ Albumid = 0;
// Determine the file to be uploaded and the array of uploaded files.
If ($ uploadfiles & is_array ($ uploadfiles )){
$ Status = "success"; // Upload complete
$ Albumid = $ uploadfiles ['alumid']; // upload category id
} Else {
$ Status = "failure"; // This indicates that the upload fails.
}
// This is added by myself. It is estimated that uchome will be grateful to me.
Exit ();
}
// Time
$ Newalbumname = sgmdate ('ymmd ');
// Introduce the Template
Include template ("do_swfupload ");
// Output xml, swf configuration required.
$ Outxml =" N ";
$ Outxml. = siconv (ob_get_contents (), 'utf-8 ');
Obclean ();
@ Header ("Expires:-1 ");
@ Header ("Cache-Control: no-store, private, post-check = 0, pre-check = 0, max-age = 0", FALSE );
@ Header ("Pragma: no-cache ");
@ Header ("Content-type: application/xml; charset = UTF-8 ");
Echo $ outxml;
// What does the configuration file export? Please visit this URL.
// Http://u.discuz.net/home/do.php? Ac = swfupload & op = config
?>