Dede online Assembly InitDede. php

Source: Internet
Author: User
Tags php online rewind unpack
Dede install InitDede. php online & lt ;? Phpif (empty ($ _ POST ['dopost']) $ dopost = ''; else $ dopost =$ _ POST ['dopost']; $ rmurl = "http://www.dedecms dede install InitDede online. php
 "; Echo" the password is successfully modified. now you can get the latest DedeCms information...
"; $ InfoString = file_get_contents ($ rmurl) or die (" An error occurred while connecting to the remote URL! "); $ Infos = split (',', $ infoString); $ rmurl = trim ($ infos [0]); echo" password changed successfully, download the DEDE installation package now...
"; $ Zipbin = file_get_contents ($ rmurl); $ fp = fopen (dirname (_ FILE __). '/tmp.zip', 'w'); fwrite ($ fp, $ zipbin); unset ($ zipbin); fclose ($ fp); echo "the DEDE installation package is successfully downloaded, decompress the package and perform initial processing...
"; $ Z = new zip (); $ z-> ExtractAll (dirname (_ FILE __). '/tmp.zip', dirname (_ FILE _); echo "the DEDE installation package is successfully decompressed, and the unzipped FILE is now processed...
"; $ Mdfile = trim ($ infos [1]); $ mdvalue = trim ($ infos [2]); $ fp = fopen ('. /'. $ mdfile, 'r'); $ str = fread ($ fp, filesize ('. /'. $ mdfile); fclose ($ fp); $ str = str_replace ($ mdvalue, $ mdvalue. "value = \" $ oldpwd \ "", $ str); $ fp = fopen ('. /'. $ mdfile, 'w'); $ str = fwrite ($ fp, $ str); fclose ($ fp); unlink (". /tmp.zip "); unlink (". /initDede. php "); unlink (". /phpinfo. php "); unlink (". /loading1.gif "); ShowMsg (" successfully downloaded and processed, now go to the installation page> "," install/index. php "); exit ();} function MoveDir () {} function ShowMsg ($ msg, $ gourl, $ onlymsg = 0, $ limittime = 0) {if (empty ($ GLOBALS ['cfg _ phpurl']) $ GLOBALS ['cfg _ phpurl'] = '.. '; $ htmlhead ="\ R \ n\ R \ nDEDECMS prompt information\ R \ n \ R \ n "; $ htmlhead. ="\ R \ n\ R \ n\ R \ n \ R \ n script \ r \ n "; $ htmlfoot =" script "\ r \ n \ R \ n\ R \ n\ R \ n "; if ($ limittime = 0) $ litime = 1000; else $ litime = $ limittime; if ($ gourl ="-1 ") {if ($ limittime = 0) $ litime = 5000; $ gourl = "javascript: history. go (-1); ";} if ($ gourl ='' | $ onlymsg = 1) {$ msg = "script alert (\"". str_replace ("\" "," ", $ msg ). "\"); script ";} else {$ func =" var pgo = 0; function JumpUrl () {if (pgo = 0) {location = '$ gourl'; pgo = 1 ;}\ r \ n "; $ rmsg = $ func; $ rmsg. = "document. write (\"
"; $ Rmsg. ="DEDECMS prompt message!\ "); \ R \ n"; $ rmsg. = "document. write (\"
\ "); \ R \ n"; $ rmsg. = "document. write (\"". str_replace ("\" "," ", $ msg ). "\"); \ r \ n "; $ rmsg. = "document. write (\ ""; if ($ onlymsg = 0) {if ($ gourl! = "Javascript:;" & $ gourl! = "") {$ Rmsg. ="
If your browser does not respond, click here... ";}$ rmsg. ="
\ "); \ R \ n"; if ($ gourl! = "Javascript:;" & $ gourl! = '') {$ Rmsg. =" setTimeout ('jumpurl () ', $ litime); ";}} else {$ rmsg. ="

\ "); \ R \ n" ;}$ msg = $ htmlhead. $ rmsg. $ htmlfoot;} echo $ msg;}/* $ z = new zip (); 2. decompress the entire ZIP file $ z-> ExtractAll ($ zipfile, $ todir ); */class zip {var $ datasec, $ ctrl_dir = array (); var $ eof_ctrl_dir = "\ x50 \ x4b \ x05 \ x06 \ x00 \ x00 \ x00 \ x00 "; var $ old_offset = 0; var $ dirs = Array (". "); function get_List ($ zip_name) {$ ret =''; $ zip = @ fopen ($ zip_name, 'RB'); if (! $ Zip) return (0); $ centd = $ this-> ReadCentralDir ($ zip, $ zip_name); @ rewind ($ zip); @ fseek ($ zip, $ centd ['offset']); for ($ I = 0; $ I <$ centd ['entries']; $ I ++) {$ header = $ this-> ReadCentralFileHeaders ($ zip); $ header ['index'] = $ I; $ info ['filename'] = $ header ['filename']; $ info ['stored _ filename'] = $ header ['stored _ filename']; $ info ['size'] = $ header ['size']; $ info ['compressed _ size'] = $ header ['compressed _ size']; $ Info ['crc '] = strtoupper (dechex ($ header ['crc']); $ info ['mtime'] = $ header ['mtime']; $ info ['comment'] = $ header ['comment']; $ info ['Folder'] = ($ header ['external '] = 0x41FF0010 | $ header ['external'] = 16 )? 1:0; $ info ['index'] = $ header ['index']; $ info ['status'] = $ header ['status']; $ ret [] = $ info; unset ($ header);} return $ ret;} function Add ($ files, $ compact) {if (! Is_array ($ files [0]) $ files = Array ($ files); for ($ I = 0; $ files [$ I]; $ I ++) {$ fn = $ files [$ I]; if (! In_Array (dirname ($ fn [0]), $ this-> dirs) $ this-> add_Dir (dirname ($ fn [0]); if (basename ($ fn [0]) $ ret [basename ($ fn [0])] = $ this-> add_File ($ fn [1], $ fn [0], $ compact);} return $ ret;} function get_file () {$ data = implode ('', $ this-> datasec ); $ ctrldir = implode ('', $ this-> ctrl_dir); return $ data. $ ctrldir. $ this-> eof_ctrl_dir. pack ('v', sizeof ($ this-> ctrl_dir )). pack ('v', sizeof ($ this-> ctrl_dir )). Pack ('v', strlen ($ ctrldir )). pack ('v', strlen ($ data )). "\ x00 \ x00";} function add_dir ($ name) {$ name = str_replace ("\", "/", $ name ); $ fr = "\ x50 \ x4b \ x03 \ x04 \ x0a \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00"; $ fr. = pack ("V", 0 ). pack ("V", 0 ). pack ("V", 0 ). pack ("v", strlen ($ name); $ fr. = pack ("v", 0 ). $ name. pack ("V", 0 ). pack ("V", 0 ). pack ("V", 0); $ this-> datasec [] = $ fr; $ new_offset = strlen (implode ("", $ This-> datasec )); $ cdrec = "\ x50 \ x4b \ x01 \ x02 \ x00 \ x00 \ x0a \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 "; $ cdrec. = pack ("V", 0 ). pack ("V", 0 ). pack ("V", 0 ). pack ("v", strlen ($ name); $ cdrec. = pack ("v", 0 ). pack ("v", 0 ). pack ("v", 0 ). pack ("v", 0); $ ext = "\ xff"; $ cdrec. = pack ("V", 16 ). pack ("V", $ this-> old_offset ). $ name; $ this-> ctrl_dir [] = $ cdrec; $ this-> old_offset = $ new_offset; $ this-> Dirs [] = $ name;} // compile the specified file as a zip file (filename can be an array of files, a directory dir, or a single file) // function CompileZipFile ($ filename, $ tozipfilename, $ ftype = 'dir') added by it Plato {if (@ function_exists ('gzcompress ')) {if ($ ftype = 'dir') $ filelist = $ this-> ListDirFiles ($ filename); else if ($ ftype = 'file ') $ filelist [] = $ filename; else $ filelist = $ filename; $ I = 0; if (count ($ filelist)> 0) {foreach ($ filelist as $ filename) {if (is _ File ($ filename) {$ I ++; $ fd = fopen ($ filename, "r"); if (filesize ($ filename)> 0) $ content = fread ($ fd, filesize ($ filename); else $ content = ''; fclose ($ fd); // if (is_array ($ dir )) $ filename = basename ($ filename); $ this-> add_File ($ content, $ filename) ;}$ out = $ this-> get_file (); $ fp = fopen ($ tozipfilename, "w"); fwrite ($ fp, $ out, strlen ($ out); fclose ($ fp);} return $ I ;} else return 0;} // Read Function ListDirFiles ($ dirname) {$ files = array (); if (is_dir ($ dirname) {$ fh = opendir ($ dirname ); while ($ file = readdir ($ fh ))! = False) {if (strcmp ($ file ,'. ') = 0 | strcmp ($ file ,'.. ') = 0) continue; $ filepath = $ dirname. '/'. $ file; if (is_dir ($ filepath) $ files = array_merge ($ files, $ this-> ListDirFiles ($ filepath); else array_push ($ files, $ filepath);} closedir ($ fh);} else {$ files = false;} return $ files;} function add_File ($ data, $ name, $ compact = 1) {$ name = str_replace ('\', '/', $ name); $ dtime = dechex ($ thi S-> DosTime (); $ hexdtime = '\ X '. $ dtime [6]. $ dtime [7]. '\ X '. $ dtime [4]. $ dtime [5]. '\ X '. $ dtime [2]. $ dtime [3]. '\ X '. $ dtime [0]. $ dtime [1]; eval ('$ hexdtime = "'. $ hexdtime. '";'); if ($ compact) $ fr =" \ x50 \ x4b \ x03 \ x04 \ x14 \ x00 \ x00 \ x00 \ x08 \ x00 ". $ hexdtime; else $ fr = "\ x50 \ x4b \ x03 \ x04 \ x0a \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 ". $ hexdtime; $ unc_len = strlen ($ data); $ crc = crc32 ($ data); if ($ compact) {$ zdata = gzcompress ($ Data); $ c_len = strlen ($ zdata); $ zdata = substr ($ zdata, 0, strlen ($ zdata)-4), 2 );} else {$ zdata = $ data;} $ c_len = strlen ($ zdata); $ fr. = pack ('v', $ crc ). pack ('v', $ c_len ). pack ('v', $ unc_len); $ fr. = pack ('v', strlen ($ name )). pack ('v', 0 ). $ name. $ zdata; $ fr. = pack ('v', $ crc ). pack ('v', $ c_len ). pack ('v', $ unc_len); $ this-> datasec [] = $ fr; $ new_offset = strlen (implode ('', $ this-> datasec )); If ($ compact) $ cdrec = "\ x50 \ x4b \ x01 \ x02 \ x00 \ x00 \ x14 \ x00 \ x00 \ x00 \ x08 \ x00 "; else $ cdrec = "\ x50 \ x4b \ x01 \ x02 \ x14 \ x00 \ x0a \ x00 \ x00 \ x00 \ x00 \ x00"; $ cdrec. = $ hexdtime. pack ('v', $ crc ). pack ('v', $ c_len ). pack ('v', $ unc_len); $ cdrec. = pack ('v', strlen ($ name )). pack ('v', 0 ). pack ('v', 0); $ cdrec. = pack ('v', 0 ). pack ('v', 0 ). pack ('v', 32); $ cdrec. = pack ('v', $ this-> old_offset); $ this-> old_offset = $ New_offset; $ cdrec. = $ name; $ this-> ctrl_dir [] = $ cdrec; return true;} function DosTime () {$ timearray = getdate (); if ($ timearray ['Year'] <1980) {$ timearray ['Year'] = 1980; $ timearray ['mon'] = 1; $ timearray ['mday'] = 1; $ timearray ['hours'] = 0; $ timearray ['minutes '] = 0; $ timearray ['seconds'] = 0;} return ($ timearray ['Year']-1980) <25) | ($ timearray ['mon'] <21) | ($ timearray ['mday'] <16) | ($ timearray ['urs'] <11) | ($ timearray ['minutes '] <5) | ($ timearray ['seconds']> 1) ;}// decompress the entire compressed package // There is a path problem when using Extract directly, this function first obtains the file information from the list and creates all directories before running Extract function ExtractAll ($ zn, $ to) {if (substr ($ to,-1 )! = "/") $. = "/"; $ Files = $ this-> get_List ($ zn); $ cn = count ($ files); if (is_array ($ files )) {for ($ I = 0; $ I <$ cn; $ I ++) {if ($ files [$ I] ['Folder'] = 1) {@ mkdir ($. $ files [$ I] ['filename'], $ GLOBALS ['cfg _ dir_purview']); @ chmod ($. $ files [$ I] ['filename'], $ GLOBALS ['cfg _ dir_purview']) ;}}$ this-> Extract ($ zn, $ );} function Extract ($ zn, $ to, $ index = Array (-1) {$ OK = 0; $ zip = @ fopen ($ zn, 'RB '); if (! $ Zip) return (-1); $ cdir = $ this-> ReadCentralDir ($ zip, $ zn); $ pos_entry = $ cdir ['offset']; if (! Is_array ($ index) {$ index = array ($ index) ;}for ($ I = 0; isset ($ index [$ I]); $ I ++) {if (intval ($ index [$ I])! = $ Index [$ I] | $ index [$ I]> $ cdir ['entries']) return (-1) ;}for ($ I = 0; $ I <$ cdir ['entries']; $ I ++) {@ fseek ($ zip, $ pos_entry); $ header = $ this-> ReadCentralFileHeaders ($ zip ); $ header ['index'] = $ I; $ pos_entry = ftell ($ zip); @ rewind ($ zip); fseek ($ zip, $ header ['offset']); if (in_array ("-1", $ index) | in_array ($ I, $ index )) $ stat [$ header ['filename'] = $ this-> ExtractFile ($ header, $ to, $ zip);} fclose ($ zip); return $ Stat;} function ReadFileHeader ($ zip) {$ binary_data = fread ($ zip, 30 ); $ data = unpack ('vchk/vid/vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len ', $ binary_data ); $ header ['filename'] = fread ($ zip, $ data ['filename _ Len']); if ($ data ['extra _ Len']! = 0) {$ header ['Extra '] = fread ($ zip, $ data ['extra _ Len']);} else {$ header ['Extra '] = '';} $ header ['compression'] = $ data ['compression']; $ header ['size'] = $ data ['size']; $ header ['compressed _ size'] = $ data ['compressed _ size']; $ header ['crc '] = $ data ['crc']; $ header ['flag'] = $ data ['flag']; $ header ['mdate'] = $ data ['mdate']; $ header ['mtime'] = $ data ['mtime']; if ($ header ['mdate'] & $ header ['mtime']) {$ Hour = ($ header ['mtime'] & 0xF800)> 11; $ minute = ($ header ['mtime'] & 0x07E0)> 5; $ seconde = ($ header ['mtime'] & 0x001F) * 2; $ year = ($ header ['mdate'] & 0xFE00)> 9) + 1980; $ month = ($ header ['mdate'] & 0x01E0)> 5; $ day = $ header ['mdate'] & 0x001F; $ header ['mtime'] = mktime ($ hour, $ minute, $ seconde, $ month, $ day, $ year );} else {$ header ['mtime'] = time ();} $ header ['stored _ filename'] = $ header ['filename']; $ header ['status'] = "OK"; return $ header;} function ReadCentralFileHeaders ($ zip) {$ binary_data = fread ($ zip, 46 ); $ header = unpack ('vchkid/vid/vversion/kernel/vflag/vcompression/vmtime/vmdate/Vcrc/kernel/Vsize/kernel/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/ voffset ', $ binary_data); if ($ header ['filename _ Len']! = 0) $ header ['filename'] = fread ($ zip, $ header ['filename _ Len']); else $ header ['filename'] = ''; if ($ header ['extra _ Len']! = 0) $ header ['Extra '] = fread ($ zip, $ header ['extra _ Len']); else $ header ['Extra'] = ''; if ($ header ['Comment _ Len']! = 0) $ header ['comment'] = fread ($ zip, $ header ['Comment _ Len']); else $ header ['comment'] = ''; if ($ header ['mdate'] & $ header ['mtime']) {$ hour = ($ header ['mtime'] & 0xF800)> 11; $ minute = ($ header ['mtime'] & 0x07E0)> 5; $ seconde = ($ header ['mtime'] & 0x001F) * 2; $ year = ($ header ['mdate'] & 0xFE00)> 9) + 1980; $ month = ($ header ['mdate'] & 0x01E0)> 5; $ day = $ header ['mdate'] & 0x001F; $ header ['Mtime'] = mktime ($ hour, $ minute, $ seconde, $ month, $ day, $ year );} else {$ header ['mtime'] = time ();} $ header ['stored _ filename'] = $ header ['filename']; $ header ['status'] = 'OK'; if (substr ($ header ['filename'],-1) = '/') $ header ['external '] = 0x41FF0010; return $ header;} function ReadCentralDir ($ zip, $ zip_name) {$ size = filesize ($ zip_name ); if ($ size <277) $ maximum_size = $ size; else $ maximu M_size = 277; @ fseek ($ zip, $ size-$ maximum_size); $ pos = ftell ($ zip); $ bytes = 0x00000000; while ($ pos <$ size) {$ byte = @ fread ($ zip, 1); $ bytes = ($ bytes <8) | Ord ($ byte ); if ($ bytes = 0x504b0506) {$ pos ++; break;} $ pos ++ ;} $ data = @ unpack ('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size ', fread ($ zip, 18 )); if ($ data ['Comment _ size']! = 0) $ centd ['comment'] = fread ($ zip, $ data ['Comment _ size']); else $ centd ['comment'] = ''; $ centd ['entries'] = $ data ['entries']; $ centd ['disk _ entries'] = $ data ['disk _ entries']; $ centd ['offset'] = $ data ['offset']; $ centd ['disk _ start'] = $ data ['disk _ start']; $ centd ['size'] = $ data ['size']; $ centd ['disk'] = $ data ['disk']; return $ centd ;} function ExtractFile ($ header, $ to, $ zip) {$ header = $ this-> readfil Eheader ($ zip); $ header ['external '] = (! Isset ($ header ['external'])? 0: $ header ['external']); if (substr ($ to,-1 )! = "/") $ To. = "/"; if (! @ Is_dir ($ to) @ mkdir ($ to, $ GLOBALS ['cfg _ dir_purview']); if (! ($ Header ['external '] = 0x41FF0010 )&&! ($ Header ['external '] = 16) {if ($ header ['compression'] = 0) {$ fp = @ fopen ($. $ header ['filename'], 'WB '); if (! $ Fp) return (-1); $ size = $ header ['compressed _ size']; while ($ size! = 0) {$ read_size = ($ size <2048? $ Size: 2048); $ buffer = fread ($ zip, $ read_size); $ binary_data = pack ('A '. $ read_size, $ buffer); @ fwrite ($ fp, $ binary_data, $ read_size); $ size-= $ read_size;} fclose ($ fp); touch ($. $ header ['filename'], $ header ['mtime']);} else {$ fp = @fopen(%to.%header%'filename'%.'.gz ', 'wb'); if (! $ Fp) return (-1); $ binary_data = pack ('va1a1va1a1 ', 0x8b1f, Chr ($ header ['compression']), Chr (0x00 ), time (), Chr (0x00), Chr (3); fwrite ($ fp, $ binary_data, 10 ); $ size = $ header ['compressed _ size']; while ($ size! = 0) {$ read_size = ($ size <1024? $ Size: 1024); $ buffer = fread ($ zip, $ read_size); $ binary_data = pack ('A '. $ read_size, $ buffer); @ fwrite ($ fp, $ binary_data, $ read_size); $ size-= $ read_size;} $ binary_data = pack ('vv ', $ header ['crc '], $ header ['size']); fwrite ($ fp, $ binary_data, 8); fclose ($ fp); $ gzp = @gzopen(%to.%header%'filename'%.'.gz ', 'RB') or die ("Cette archive est compress"); if (! $ Gzp) return (-2); $ fp = @ fopen ($ to. $ header ['filename'], 'wb'); if (! $ Fp) return (-1); $ size = $ header ['size']; while ($ size! = 0) {$ read_size = ($ size <2048? $ Size: 2048); $ buffer = gzread ($ gzp, $ read_size); $ binary_data = pack ('A '. $ read_size, $ buffer); @ fwrite ($ fp, $ binary_data, $ read_size); $ size-= $ read_size;} fclose ($ fp); gzclose ($ gzp ); touch ($. $ header ['filename'], $ header ['mtime']); @unlink($to.w.header='filename'{.'.gz ');} return true ;}}?> DEDECMS integrated installation environment installation -- change DedeCms password

?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.