Browse the code

 

Differences between 34 and 35 on /.
Number of edited files: 3 (0 added, 0 deleted and 3 modified)
Revision 35

About 9 years and 8 months ago.

Added file(s) Deleted file(s) Modified file(s)

 

Old New Code
17
17
	'jquery_ajax'		=> "/jquery.ajax.js",
18
18
	'jquery_progress'	=> "/jquery.progressbar.js",
19
19
	'progress_bar'		=> "/progressbar.gif",
20
 
	'progressbg'		=> "/progressbg_green.gif",
 
20
	'progressbg'		=> "/progressbg_green.gif"
21
21
);
22
22
	
 
23
/*$PAL_PACKAGE = array(
 
24
	'zip_class'		=> "/class.zip.php",
 
25
	'pal_package' 	=> "/pal-package.zip"	
 
26
);*/
 
27

                                    
23
28
$PAL_PACKAGE = array(
24
 
	'zip_class'		=> "/class.zip.php",
25
 
	'pal_package' 	=> "/pal-package.zip"
 
29
	'pal_package' 	=> "/pal-package.zip"	
26
30
);
27
31

                                        
28
32
function envVariable()
60
64
			$server['protocol'] = "http"; # we supposed it is straight HTTP protocol
61
65
			break;
62
66
	}
63
 
	return $server['protocol']."://".$server['name'].":".$server['port'].$server['dir']."/";
 
67
	return $server['protocol'].";://";.$server['name'].";:";.$server['port'].$server['dir'];
64
68
}
65
69

                                        
66
 
function getRemoteFiles($src, &$dest, $step=0)
 
70
function getRemoteFiles($src, &$dest, $remoteStep=0)
67
71
{
68
 
	// FTP connexion
69
 
	$conn_id = ftp_connect(PAL_ARCHIVE);
70
 

                                    
71
 
	// Login in on to the FTP server and go to the correct directory
72
 
	$login_result = ftp_login($conn_id, "package", "public");
 
72
	if (($s = @fsockopen(PAL_ARCHIVE, 80, $errno, $errstr,5)) === false) { return false; }
73
73
	
74
 
	# Get remote and local file size
75
 
	$remote_size = ftp_size();
76
 
	$local_size = ;
 
74
	fwrite($s,
 
75
		'GET http://'.PAL_ARCHIVE."/package".$src." HTTP/1.0\r\n"
 
76
		.'Host: '.PAL_ARCHIVE."\r\n"
 
77
		."User-Agent: Pizza aux lentilles remote files\r\n"
 
78
		."Accept: text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*\r\n"
 
79
		."\r\n"
 
80
	);
77
81
	
78
 
	# Check download progression
79
 
	$_SESSION['download'] = round($local_size/$remote_size*100);
 
82
	$i = 0;
 
83
	$in_content = false;
80
84
	
81
 
	# Download the needed file from the remote server
82
 
	if (ftp_get($conn_id, $dest, $src, FTP_BINARY)) {
83
 
    	ftp_close($conn_id);
84
 
		return true;
85
 
	} else {
86
 
    	return false;
 
85
	$headers = get_headers("http://".PAL_ARCHIVE."/package".$src, 1);
 
86
    $src_filesize = $headers["Content-Length"];
 
87
	
 
88
	$_SESSION['progress'] = 0;
 
89
	
 
90
	while (!feof($s))
 
91
	{
 
92
		
 
93
		$line = fgets($s, 4096);
 
94
		
 
95
		if (rtrim($line, "\r\n") == '' && !$in_content) {
 
96
			$in_content = true;
 
97
			$i++;
 
98
			continue;
 
99
		}
 
100
		
 
101
		if ($i == 0) {
 
102
			if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', rtrim($line, "\r\n"), $m)) {
 
103
				fclose($s);
 
104
				return false;
 
105
			}
 
106
			$status = (integer) $m[2];
 
107
			if ($status < 200 || $status >= 400) {
 
108
				fclose($s);
 
109
				return false;
 
110
			}
 
111
		}
 
112
		
 
113
		if (!$in_content)
 
114
		{
 
115
			if (preg_match('/Location:\s+?(.+)$/', rtrim($line, "\r\n"), $m)) {
 
116
				fclose($s);
 
117
				return getRemoteFiles(trim($m[1]), $dest, $remoteStep+1);
 
118
			}
 
119
			$i++;
 
120
			continue;
 
121
		}
 
122
		
 
123
		if (is_resource($dest)) {
 
124
			fwrite($dest, $line);
 
125
		} else {
 
126
			$dest .= $line;
 
127
		}
 
128
		
 
129
		$i++;
 
130
		$headers = get_headers("http://".$_SERVER['SERVER_NAME'].$src, 1);
 
131
    	$dest_filesize = $headers["Content-Length"];
 
132
    	
 
133
    	$_SESSION['progress'] = round(($dest_filesize / $src_filesize) * 100);
87
134
	}
 
135
	
 
136
	fclose($s);
 
137
	return true;
88
138
}
89
139

                                        
90
140
function getFiles(&$files)
92
142
	#  create and open with write access the destination file in binary mode
93
143
	foreach($files as $k => $v)
94
144
	{
95
 
		${$k} = dirname(__FILE__).$v;
96
 
		//$f[] = getRemoteFiles($v, ${$k});
97
 
		$f[] = copy(dirname(__FILE__)."/package/".$v, ${$k});
 
145
		${$k} = @fopen(dirname(__FILE__).$v,'wb');
 
146
		
 
147
		# Get file
 
148
		$f[] = getRemoteFiles($v, ${$k});
 
149
		
 
150
		fclose(${$k});
98
151
	}
99
 
	
100
152
	if (in_array(false, $f)){
101
 
		removesFiles($files);
 
153
		removeFiles($files);
102
154
		return false;
103
155
	}
 
156
	
 
157
	
104
158
	return true;
105
159
}
106
160

                                        
107
161
function unzipFile(&$zip_class, &$pal_package)
108
162
{
109
 
	require_once(dirname(__FILE__).$zip_class);
 
163
	require_once(dirname(__FILE__)."/class.zip.php");
110
164
		
111
165
	$oZip = new zip;
112
166
	$files = $oZip->get_List(dirname(__FILE__).$pal_package);
206
260

                                        
207
261
function msg($type, $head, $info)
208
262
{
209
 
	$msg = "";
210
 
	
211
263
	echo
212
264
	'<div class="msg '.$type.'">'.
213
265
	'<h3>'.$head.'</h3>'.
233
285
	$info.
234
286
	'<p>'.
235
287
	'  <input type="hidden" name="step" value="'.$step.'" />'.
236
 
	'  <input type="button" name="submit" value="'.$btn_value.'" onClick="download();progress();ajaxFunction(\'install-fr.php\', \''.$step.'\');" />'.
 
288
	'  <input type="button" name="submit" value="'.$btn_value.'" onClick="progress(); ajaxFunction(\'install-fr.php\', \''.$step.'\');"/>'.
237
289
	'</p>';
238
290
}
239
291

                                        
467
519
				);
468
520
			}
469
521
		} else {
 
522
			$msg[] = "Les fichiers nécessaires à l'installation ne sont pas disponibles.";
 
523
			$error = true;
 
524
		}
 
525
		
 
526
		if ($error === true) {
470
527
			msg(
471
528
				'error',
472
529
				'La récupération des fichiers a rencontré des erreurs ...',
548
605
			'<p><label for="bdd_server">Serveur :</label> '.
549
606
			'<input type="text" id="bdd_server" name="bdd_server" value="localhost" size="15" /></p>'.
550
607
			'<p><label for="bdd_name">Base de données :</label> '.
551
 
			'<input type="text" id="bdd_name" name="bdd_name" value="" size="15" /></p>'.
 
608
			'<input type="text" id="bdd_name" name="bdd_name" value="" size="15" onKeyUp="checkDBConnect();" />'.
 
609
			'&nbsp;<img src="" id="db_status"></p>'.
552
610
			'<p><label for="bdd_user">Utilisateur :</label> '.
553
 
			'<input type="text" id="bdd_user" name="bdd_user" value="" size="15" /></p>'.
 
611
			'<input type="text" id="bdd_user" name="bdd_user" value="" size="15" onKeyUp="checkDBConnect();" />'.
554
612
			'<p><label for="bdd_pwd">Mot de passe :</label> '.
555
 
			'<input type="password" id="bdd_pwd" name="bdd_pwd" value="" size="15" /></p>'.
 
613
			'<input type="password" id="bdd_pwd" name="bdd_pwd" value="" size="15" onKeyUp="checkDBConnect();" /></p>'.
556
614
			'<p><label for="bdd_prefix">Préfixe des tables :</label> '.
557
615
			'<input type="text" id="bdd_prefix" name="bdd_prefix" value="pal_" size="15" /></p>'.
558
616
			'<input type="hidden" name="folder" value="'.$_POST['folder'].'" /></p>'
570
628
		
571
629
		# create database tables using db_structure file
572
630
		if(!createDB()) {
573
 
			$msg[] = "Une erreur s'est produite lors de la création de la base de données.";
 
631
			$msg[] = "Une erreur s'est produite lors de la création de la création des tables de la base de données.";
574
632
			$error = true;
575
633
		}
576
634
		
645
703
		break;
646
704
	}
647
705
	
648
 
	case "download" : {
649
 
		echo $_SESSION['download'];
650
 
		break;
 
706
	case "checkDB" : {
 
707
		# Check if DB connexion is OK
 
708
		$connexion = @mysql_connect($_POST['db_server'], $_POST['db_user'], $_POST['db_pwd']);
 
709
		$db = @mysql_select_db($_POST['db_name']);
 
710
		
 
711
		if($connexion and $db) { echo 'ok'; }
651
712
	}
652
713
}
653
714
?>
654
715

                                        

 

Old New Code
1
1
<?php
2
2

                                        
3
 
// Created by bouchon
4
 
// http://dev.maxg.info
 
3
// Unzip/Zip class
5
4

                                        
6
 
// Need help ? http://forum.maxg.info
 
5
class zip {
7
6

                                        
8
 
class zip
9
 
{
 
7
	var $datasec = array();
 
8
	var $ctrl_dir = array();
 
9
	var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
 
10
	var $old_offset = 0;
 
11
	var $dirs = Array(".");
10
12

                                        
11
 
 var $datasec, $ctrl_dir = array();
12
 
 var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
13
 
 var $old_offset = 0; var $dirs = Array(".");
 
13
	function get_List($zip_name) {
 
14
   		$zip = @fopen($zip_name, 'rb');
 
15
   		if(!$zip) return(0);
 
16
   		$centd = $this->ReadCentralDir($zip,$zip_name);
14
17

                                        
15
 
 function get_List($zip_name)
16
 
 {
17
 
   $zip = @fopen($zip_name, 'rb');
18
 
   if(!$zip) return(0);
19
 
   $centd = $this->ReadCentralDir($zip,$zip_name);
 
18
    	@rewind($zip);
 
19
    	@fseek($zip, $centd['offset']);
20
20

                                        
21
 
    @rewind($zip);
22
 
    @fseek($zip, $centd['offset']);
 
21
   		for ($i=0; $i<$centd['entries']; $i++) {
 
22
    		$header = $this->ReadCentralFileHeaders($zip);
 
23
   			$header['index'] = $i;
 
24
    
 
25
    		$info['filename'] 			= $header['filename'];
 
26
    		$info['stored_filename'] 	= $header['stored_filename'];
 
27
    		$info['size'] 				= $header['size'];
 
28
    		$info['compressed_size']	=$header['compressed_size'];
 
29
    		$info['crc'] 				= strtoupper(dechex( $header['crc'] ));
 
30
    		$info['mtime'] 				= $header['mtime'];
 
31
    		$info['comment']			= $header['comment'];
 
32
    		$info['folder'] 			= ($header['external'] == 0x41FF0010 || $header['external'] == 16) ? 1 : 0;
 
33
   		 	$info['index'] 				= $header['index'];
 
34
    		$info['status'] 			= $header['status'];
 
35
    		
 
36
    		$ret[] = $info;
 
37
    
 
38
    		unset($header);
 
39
   		}
 
40
  		return $ret;
 
41
 	}
 
42
 	
 
43
 	function Add($files,$compact) {
 
44
  		if(!is_array($files[0])) { $files = array($files); }
23
45

                                        
24
 
   for ($i=0; $i<$centd['entries']; $i++)
25
 
   {
26
 
    $header = $this->ReadCentralFileHeaders($zip);
27
 
    $header['index'] = $i;$info['filename'] = $header['filename'];
28
 
    $info['stored_filename'] = $header['stored_filename'];
29
 
    $info['size'] = $header['size'];$info['compressed_size']=$header['compressed_size'];
30
 
    $info['crc'] = strtoupper(dechex( $header['crc'] ));
31
 
    $info['mtime'] = $header['mtime']; $info['comment'] = $header['comment'];
32
 
    $info['folder'] = ($header['external']==0x41FF0010||$header['external']==16)?1:0;
33
 
    $info['index'] = $header['index'];$info['status'] = $header['status'];
34
 
    $ret[]=$info; unset($header);
35
 
   }
36
 
  return $ret;
37
 
 }
 
46
  		for($i=0; $files[$i]; $i++){
 
47
    		$fn = $files[$i];
 
48
    		if(!in_Array(dirname($fn[0]), $this->dirs)) { $this->add_Dir(dirname($fn[0])); }
 
49
    		if(basename($fn[0])) { $ret[basename($fn[0])] = $this->add_File($fn[1],$fn[0],$compact); }
 
50
  		}
 
51
  		return $ret;
 
52
 	}
 
53
 	
 
54
 	function get_file() {
 
55
    	$data = implode('', $this->datasec);
 
56
   		$ctrldir = implode('', $this->ctrl_dir);
38
57

                                        
39
 
 function Add($files,$compact)
40
 
 {
41
 
  if(!is_array($files[0])) $files=Array($files);
 
58
   		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";
 
59
 	}
 
60
 	
 
61
 	function add_dir($name) {
 
62
   		$name = str_replace("\\", "/", $name);
 
63
   		$fr = "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00";
42
64

                                        
43
 
  for($i=0;$files[$i];$i++){
44
 
    $fn = $files[$i];
45
 
    if(!in_Array(dirname($fn[0]),$this->dirs))
46
 
     $this->add_Dir(dirname($fn[0]));
47
 
    if(basename($fn[0]))
48
 
     $ret[basename($fn[0])]=$this->add_File($fn[1],$fn[0],$compact);
49
 
  }
50
 
  return $ret;
51
 
 }
 
65
   		$fr .= pack("V", 0).pack("V", 0).pack("V", 0).pack("v", strlen($name));
 
66
   		$fr .= pack("v", 0 ).$name.pack("V", 0).pack("V", 0).pack("V", 0);
 
67
   		$this->datasec[] = $fr;
52
68

                                        
53
 
 function get_file()
54
 
 {
55
 
   $data = implode('', $this -> datasec);
56
 
   $ctrldir = implode('', $this -> ctrl_dir);
 
69
   		$new_offset = strlen(implode("", $this->datasec));
57
70

                                        
58
 
   return $data . $ctrldir . $this -> eof_ctrl_dir .
59
 
    pack('v', sizeof($this -> ctrl_dir)).pack('v', sizeof($this -> ctrl_dir)).
60
 
    pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00";
61
 
 }
 
71
   		$cdrec = "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00";
 
72
   		$cdrec .= pack("V", 0).pack("V", 0).pack("V", 0).pack("v", strlen($name) );
 
73
   		$cdrec .= pack("v", 0 ).pack("v", 0 ).pack("v", 0 ).pack("v", 0);
 
74
   		$ext = "\xff\xff\xff\xff";
 
75
   		$cdrec .= pack("V", 16).pack("V", $this->old_offset).$name;
62
76

                                        
63
 
 function add_dir($name)
64
 
 {
65
 
   $name = str_replace("\\", "/", $name);
66
 
   $fr = "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00";
 
77
   		$this->ctrl_dir[] = $cdrec;
 
78
   		$this->old_offset = $new_offset;
 
79
   		$this->dirs[] = $name;
 
80
	}
 
81
	
 
82
	function add_File($data, $name, $compact = 1) {
 
83
   		$name     = str_replace('\\', '/', $name);
 
84
   		$dtime    = dechex($this->DosTime());
67
85

                                        
68
 
   $fr .= pack("V",0).pack("V",0).pack("V",0).pack("v", strlen($name) );
69
 
   $fr .= pack("v", 0 ).$name.pack("V", 0).pack("V", 0).pack("V", 0);
70
 
   $this -> datasec[] = $fr;
 
86
   		$hexdtime = '\x'.$dtime[6].$dtime[7].'\x'.$dtime[4].$dtime[5].'\x'.$dtime[2].$dtime[3].'\x'.$dtime[0].$dtime[1];
 
87
   		eval('$hexdtime = "'.$hexdtime.'";');
71
88

                                        
72
 
   $new_offset = strlen(implode("", $this->datasec));
 
89
   		if($compact) { $fr = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00".$hexdtime; }
 
90
   		else { $fr = "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00".$hexdtime; }
 
91
   
 
92
   		$unc_len = strlen($data); $crc = crc32($data);
73
93

                                        
74
 
   $cdrec = "\x50\x4b\x01\x02\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00";
75
 
   $cdrec .= pack("V",0).pack("V",0).pack("V",0).pack("v", strlen($name) );
76
 
   $cdrec .= pack("v", 0 ).pack("v", 0 ).pack("v", 0 ).pack("v", 0 );
77
 
   $ext = "\xff\xff\xff\xff";
78
 
   $cdrec .= pack("V", 16 ).pack("V", $this -> old_offset ).$name;
 
94
   		if($compact) {
 
95
     		$zdata = gzcompress($data); $c_len = strlen($zdata);
 
96
     		$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
 
97
   		}
 
98
   		else { $zdata = $data; }
 
99
   
 
100
   		$c_len = strlen($zdata);
 
101
   		$fr .= pack('V', $crc).pack('V', $c_len).pack('V', $unc_len);
 
102
   		$fr .= pack('v', strlen($name)).pack('v', 0).$name.$zdata;
 
103
		$fr .= pack('V', $crc).pack('V', $c_len).pack('V', $unc_len);
79
104

                                        
80
 
   $this -> ctrl_dir[] = $cdrec;
81
 
   $this -> old_offset = $new_offset;
82
 
   $this -> dirs[] = $name;
83
 
 }
 
105
   		$this->datasec[] = $fr;
 
106
   
 
107
   		$new_offset = strlen(implode('', $this->datasec));
 
108
   
 
109
   		if($compact) { $cdrec = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00"; }
 
110
   		else { $cdrec = "\x50\x4b\x01\x02\x14\x00\x0a\x00\x00\x00\x00\x00"; }
 
111
   
 
112
   		$cdrec .= $hexdtime.pack('V', $crc).pack('V', $c_len).pack('V', $unc_len);
 
113
   		$cdrec .= pack('v', strlen($name)).pack('v', 0).pack('v', 0);
 
114
   		$cdrec .= pack('v', 0).pack('v', 0).pack('V', 32);
 
115
   		$cdrec .= pack('V', $this->old_offset);
84
116

                                        
85
 
 function add_File($data, $name, $compact = 1)
86
 
 {
87
 
   $name     = str_replace('\\', '/', $name);
88
 
   $dtime    = dechex($this->DosTime());
 
117
   		$this->old_offset = $new_offset;
 
118
   		$cdrec .= $name;
 
119
   		$this->ctrl_dir[] = $cdrec;
 
120
   
 
121
   		return true;
 
122
 	}
 
123
 	
 
124
 	function DosTime() {
 
125
   		$timearray = getdate();
 
126
   		if ($timearray['year'] < 1980) {
 
127
     		$timearray['year'] = 1980;
 
128
     		$timearray['mon'] = 1;
 
129
     		$timearray['mday'] = 1;
 
130
     		$timearray['hours'] = 0;
 
131
     		$timearray['minutes'] = 0;
 
132
     		$timearray['seconds'] = 0;
 
133
   		}
 
134
   		return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
 
135
 	}
 
136
 	
 
137
 	function Extract ( $zn, $to, $index = Array(-1) ) {
 
138
   		
 
139
   		if(!is_dir($to)) { mkdir($to, 0777, true); }
 
140
   		
 
141
   		$_SESSION['progress'] = 0;
 
142
   		
 
143
   		$ok = 0;
 
144
  		$zip = @fopen($zn, 'rb');
 
145
   		if(!$zip) { return(-1); }
 
146
   		$cdir = $this->ReadCentralDir($zip, $zn);
 
147
   		$pos_entry = $cdir['offset'];
89
148

                                        
90
 
   $hexdtime = '\x' . $dtime[6] . $dtime[7].'\x'.$dtime[4] . $dtime[5]
91
 
     . '\x' . $dtime[2] . $dtime[3].'\x'.$dtime[0].$dtime[1];
92
 
   eval('$hexdtime = "' . $hexdtime . '";');
 
149
   		if(!is_array($index)) { $index = array($index); }
 
150
   
 
151
   		for($i=0; $index[$i]; $i++) {
 
152
     		if (intval($index[$i]) != $index[$i] || $index[$i] > $cdir['entries']) { return(-1); }
 
153
   		}
 
154
		
 
155
   		for ($i=0; $i < $cdir['entries']; $i++) {
 
156
     		
 
157
     		$_SESSION['progress'] = round(($i / $cdir['entries'])*100);
 
158
	  
 
159
	 		@fseek($zip, $pos_entry);
 
160
     		$header = $this->ReadCentralFileHeaders($zip);
 
161
     		$header['index'] = $i;
 
162
	 		$pos_entry = ftell($zip);
 
163
     		@rewind($zip);
 
164
	 		fseek($zip, $header['offset']);
 
165
     		if(in_array("-1", $index) || in_array($i, $index)) { $stat[$header['filename']] = $this->ExtractFile($header, $to, $zip); }
 
166
   		}
 
167
   		
 
168
   		fclose($zip);
 
169
   		sleep(1);
 
170
   		
 
171
   		return $stat;
 
172
 	}
 
173
 	
 
174
 	function ReadFileHeader($zip) {
 
175
    	$binary_data = fread($zip, 30);
 
176
    	$data = unpack('vchk/vid/vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $binary_data);
93
177

                                        
94
 
   if($compact)
95
 
   $fr = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00".$hexdtime;
96
 
   else $fr = "\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00".$hexdtime;
97
 
   $unc_len = strlen($data); $crc = crc32($data);
 
178
    	$header['filename'] = fread($zip, $data['filename_len']);
 
179
    
 
180
    	if ($data['extra_len'] != 0) { $header['extra'] = fread($zip, $data['extra_len']); }
 
181
    	else { $header['extra'] = ''; }
98
182

                                        
99
 
   if($compact){
100
 
     $zdata = gzcompress($data); $c_len = strlen($zdata);
101
 
     $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
102
 
   }else{
103
 
     $zdata = $data;
104
 
   }
105
 
   $c_len=strlen($zdata);
106
 
   $fr .= pack('V', $crc).pack('V', $c_len).pack('V', $unc_len);
107
 
   $fr .= pack('v', strlen($name)).pack('v', 0).$name.$zdata;
 
183
    	$header['compression'] 		= $data['compression'];
 
184
    	$header['size'] 			= $data['size'];
 
185
    	$header['compressed_size'] 	= $data['compressed_size'];
 
186
    	$header['crc'] 				= $data['crc'];
 
187
    	$header['flag'] 			= $data['flag'];
 
188
    	$header['mdate'] 			= $data['mdate'];$header['mtime'] = $data['mtime'];
108
189

                                        
109
 
   $fr .= pack('V', $crc).pack('V', $c_len).pack('V', $unc_len);
 
190
    	if ($header['mdate'] && $header['mtime']){
 
191
     		$hour = ($header['mtime']&0xF800)>>11;
 
192
     		$minute = ($header['mtime']&0x07E0)>>5;
 
193
     		$seconde = ($header['mtime']&0x001F)*2;
 
194
     		$year = (($header['mdate']&0xFE00)>>9)+1980;
 
195
    		$month = ($header['mdate']&0x01E0)>>5;
 
196
     		$day = $header['mdate']&0x001F;
 
197
     		$header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year);
 
198
    	}
 
199
    	else { $header['mtime'] = time(); }
110
200

                                        
111
 
   $this -> datasec[] = $fr;
112
 
   $new_offset        = strlen(implode('', $this->datasec));
113
 
   if($compact)
114
 
        $cdrec = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00";
115
 
   else $cdrec = "\x50\x4b\x01\x02\x14\x00\x0a\x00\x00\x00\x00\x00";
116
 
   $cdrec .= $hexdtime.pack('V', $crc).pack('V', $c_len).pack('V', $unc_len);
117
 
   $cdrec .= pack('v', strlen($name) ).pack('v', 0 ).pack('v', 0 );
118
 
   $cdrec .= pack('v', 0 ).pack('v', 0 ).pack('V', 32 );
119
 
   $cdrec .= pack('V', $this -> old_offset );
 
201
    	$header['stored_filename'] = $header['filename'];
 
202
    	$header['status'] = "ok";
 
203
    
 
204
    	return $header;
 
205
  	}
 
206
  	
 
207
  	function ReadCentralFileHeaders($zip) {
 
208
    	$binary_data = fread($zip, 46);
 
209
    	$header = unpack('vchkid/vid/vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $binary_data);
120
210

                                        
121
 
   $this -> old_offset = $new_offset;
122
 
   $cdrec .= $name;
123
 
   $this -> ctrl_dir[] = $cdrec;
124
 
   return true;
125
 
 }
 
211
    	if ($header['filename_len'] != 0) { $header['filename'] = fread($zip,$header['filename_len']); }
 
212
    	else { $header['filename'] = ''; }
126
213

                                        
127
 
 function DosTime() {
128
 
   $timearray = getdate();
129
 
   if ($timearray['year'] < 1980) {
130
 
     $timearray['year'] = 1980; $timearray['mon'] = 1;
131
 
     $timearray['mday'] = 1; $timearray['hours'] = 0;
132
 
     $timearray['minutes'] = 0; $timearray['seconds'] = 0;
133
 
   }
134
 
   return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) |     ($timearray['mday'] << 16) | ($timearray['hours'] << 11) |
135
 
    ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
136
 
 }
 
214
    	if ($header['extra_len'] != 0) { $header['extra'] = fread($zip, $header['extra_len']); }
 
215
    	else { $header['extra'] = ''; }
137
216

                                        
138
 
 function Extract ( $zn, $to, $index = Array(-1) )
139
 
 {
140
 
   if(!is_dir($to)) { mkdir($to, 0777, true); }
141
 
   $ok = 0;
142
 
   $zip = @fopen($zn, 'rb');
143
 
   if(!$zip) return(-1);
144
 
   $cdir = $this->ReadCentralDir($zip, $zn);
145
 
   $pos_entry = $cdir['offset'];
 
217
    	if ($header['comment_len'] != 0) { $header['comment'] = fread($zip, $header['comment_len']); }
 
218
    	else { $header['comment'] = ''; }
146
219

                                        
147
 
   if(!is_array($index)){ $index = array($index); }
148
 
   for($i=0; $index[$i];$i++){
149
 
     if(intval($index[$i]) != $index[$i] || $index[$i] > $cdir['entries']) return(-1);
150
 
   }
 
220
    	if ($header['mdate'] && $header['mtime']) {
 
221
      		$hour = ($header['mtime'] & 0xF800) >> 11;
 
222
      		$minute = ($header['mtime'] & 0x07E0) >> 5;
 
223
      		$seconde = ($header['mtime'] & 0x001F)*2;
 
224
      		$year = (($header['mdate'] & 0xFE00) >> 9) + 1980;
 
225
      		$month = ($header['mdate'] & 0x01E0) >> 5;
 
226
      		$day = $header['mdate'] & 0x001F;
 
227
      		$header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year);
 
228
    	}
 
229
    	else { $header['mtime'] = time(); }
 
230
    
 
231
    	$header['stored_filename'] = $header['filename'];
 
232
    	$header['status'] = 'ok';
 
233
    
 
234
    	if (substr($header['filename'], -1) == '/') { $header['external'] = 0x41FF0010; }
 
235
    
 
236
    	return $header;
 
237
 	}
 
238
 	
 
239
 	function ReadCentralDir($zip, $zip_name) {
 
240
  		$size = filesize($zip_name);
 
241
  		if ($size < 277) { $maximum_size = $size; }
 
242
  		else { $maximum_size=277; }
151
243

                                        
152
 
   for ($i=0; $i < $cdir['entries']; $i++)
153
 
   {
154
 
     ///////////////////////////////////////
155
 
	 //		progression change		  //
156
 
	 //		2008-01-09			  //
157
 

                                    
158
 
	 ///////////////////////////////////////
159
 
	 // This change calls an ajax function
160
 
	 // that will give the progress completion
161
 
	 ///////////////////////////////////////
162
 
	 $_SESSION['progress'] = round($i/$cdir['entries']*100);
163
 
	 ///////////////////////////////////////
164
 
	 
165
 
	 @fseek($zip, $pos_entry);
166
 
     $header = $this->ReadCentralFileHeaders($zip);
167
 
     $header['index'] = $i;
168
 
	 $pos_entry = ftell($zip);
169
 
     @rewind($zip);
170
 
	 fseek($zip, $header['offset']);
171
 
     if(in_array("-1", $index) || in_array($i, $index)) { $stat[$header['filename']] = $this->ExtractFile($header, $to, $zip); }
172
 
   }
173
 
   fclose($zip);
174
 
   sleep(1);
175
 
   return $stat;
176
 
 }
 
244
  		@fseek($zip, $size-$maximum_size);
 
245
  		$pos = ftell($zip);
 
246
  		$bytes = 0x00000000;
177
247

                                        
178
 
  function ReadFileHeader($zip)
179
 
  {
180
 
    $binary_data = fread($zip, 30);
181
 
    $data = unpack('vchk/vid/vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $binary_data);
 
248
  		while ($pos < $size) {
 
249
    		$byte = @fread($zip, 1);
 
250
    		$bytes = ($bytes << 8) | Ord($byte);
 
251
    		if ($bytes == 0x504b0506) { $pos++; break; }
 
252
    		$pos++;
 
253
  		}
182
254

                                        
183
 
    $header['filename'] = fread($zip, $data['filename_len']);
184
 
    if ($data['extra_len'] != 0) {
185
 
      $header['extra'] = fread($zip, $data['extra_len']);
186
 
    } else { $header['extra'] = ''; }
 
255
  		$data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', fread($zip, 18));
187
256

                                        
188
 
    $header['compression'] = $data['compression'];$header['size'] = $data['size'];
189
 
    $header['compressed_size'] = $data['compressed_size'];
190
 
    $header['crc'] = $data['crc']; $header['flag'] = $data['flag'];
191
 
    $header['mdate'] = $data['mdate'];$header['mtime'] = $data['mtime'];
192
 

                                    
193
 
    if ($header['mdate'] && $header['mtime']){
194
 
     $hour=($header['mtime']&0xF800)>>11;$minute=($header['mtime']&0x07E0)>>5;
195
 
     $seconde=($header['mtime']&0x001F)*2;$year=(($header['mdate']&0xFE00)>>9)+1980;
196
 
     $month=($header['mdate']&0x01E0)>>5;$day=$header['mdate']&0x001F;
197
 
     $header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year);
198
 
    }else{$header['mtime'] = time();}
199
 

                                    
200
 
    $header['stored_filename'] = $header['filename'];
201
 
    $header['status'] = "ok";
202
 
    return $header;
203
 
  }
204
 

                                    
205
 
 function ReadCentralFileHeaders($zip){
206
 
    $binary_data = fread($zip, 46);
207
 
    $header = unpack('vchkid/vid/vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $binary_data);
208
 

                                    
209
 
    if ($header['filename_len'] != 0)
210
 
      $header['filename'] = fread($zip,$header['filename_len']);
211
 
    else $header['filename'] = '';
212
 

                                    
213
 
    if ($header['extra_len'] != 0)
214
 
      $header['extra'] = fread($zip, $header['extra_len']);
215
 
    else $header['extra'] = '';
216
 

                                    
217
 
    if ($header['comment_len'] != 0)
218
 
      $header['comment'] = fread($zip, $header['comment_len']);
219
 
    else $header['comment'] = '';
220
 

                                    
221
 
    if ($header['mdate'] && $header['mtime'])
222
 
    {
223
 
      $hour = ($header['mtime'] & 0xF800) >> 11;
224
 
      $minute = ($header['mtime'] & 0x07E0) >> 5;
225
 
      $seconde = ($header['mtime'] & 0x001F)*2;
226
 
      $year = (($header['mdate'] & 0xFE00) >> 9) + 1980;
227
 
      $month = ($header['mdate'] & 0x01E0) >> 5;
228
 
      $day = $header['mdate'] & 0x001F;
229
 
      $header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year);
230
 
    } else {
231
 
      $header['mtime'] = time();
232
 
    }
233
 
    $header['stored_filename'] = $header['filename'];
234
 
    $header['status'] = 'ok';
235
 
    if (substr($header['filename'], -1) == '/')
236
 
      $header['external'] = 0x41FF0010;
237
 
    return $header;
238
 
 }
239
 

                                    
240
 
 function ReadCentralDir($zip,$zip_name)
241
 
 {
242
 
  $size = filesize($zip_name);
243
 
  if ($size < 277) $maximum_size = $size;
244
 
  else $maximum_size=277;
245
 

                                    
246
 
  @fseek($zip, $size-$maximum_size);
247
 
  $pos = ftell($zip); $bytes = 0x00000000;
248
 

                                    
249
 
  while ($pos < $size)
250
 
  {
251
 
    $byte = @fread($zip, 1); $bytes=($bytes << 8) | Ord($byte);
252
 
    if ($bytes == 0x504b0506){ $pos++; break; } $pos++;
253
 
  }
254
 

                                    
255
 
  $data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', fread($zip, 18));
256
 

                                    
257
 
  if ($data['comment_size'] != 0) { $centd['comment'] = fread($zip, $data['comment_size']); }
258
 
  else { $centd['comment'] = ''; }
 
257
  		if ($data['comment_size'] != 0) { $centd['comment'] = fread($zip, $data['comment_size']); }
 
258
  		else { $centd['comment'] = ''; }
259
259
  
260
 
  $centd['entries'] = $data['entries'];
261
 
  $centd['disk_entries'] = $data['disk_entries'];
262
 
  $centd['offset'] = $data['offset'];$centd['disk_start'] = $data['disk_start'];
263
 
  $centd['size'] = $data['size'];  $centd['disk'] = $data['disk'];
 
260
  		$centd['entries']		= $data['entries'];
 
261
  		$centd['disk_entries'] 	= $data['disk_entries'];
 
262
  		$centd['offset'] 		= $data['offset'];
 
263
  		$centd['disk_start'] 	= $data['disk_start'];
 
264
  		$centd['size'] 			= $data['size'];
 
265
 		$centd['disk'] 			= $data['disk'];
264
266
  
265
 
  return $centd;
266
 
 }
 
267
  		return $centd;
 
268
 	}
 
269
 	
 
270
 	function ExtractFile($header, $to, $zip) {
 
271
   		$header = $this->readfileheader($zip);
267
272

                                        
268
 
 function ExtractFile($header, $to, $zip)
269
 
 {
270
 
   $header = $this->readfileheader($zip);
 
273
   		if(substr($to, -1) != "/") { $to .= "/"; }
 
274
   
 
275
   		if(substr($header['filename'], -1) == "/") {
 
276
    		@mkdir($to.$header['filename'], '0777', true);
 
277
    		return +2;
 
278
   		}
271
279

                                        
272
 
   if(substr($to, -1) != "/") $to .= "/";
273
 
   if(substr($header['filename'], -1) == "/")
274
 
   {
275
 
    @mkdir($to.$header['filename'], '0777', true);
276
 
    return +2;
277
 
   }
 
280
   		$pth = explode("/",dirname($header['filename']));
 
281
   
 
282
   		for($i=0,$tmp=""; isset($pth[$i]); $i++){
 
283
     		if(!$pth[$i]) { continue; }
 
284
     
 
285
     		if(!is_dir($to.$tmp.$pth[$i])) { @mkdir($to.$pth[$i], 0777, true); }
 
286
     
 
287
     		$tmp.=$pth[$i]."/";
 
288
   		}
 
289
   
 
290
  		if (!($header['external'] == 0x41FF0010) && !($header['external'] == 16)) {
 
291
   			if ($header['compression'] == 0) {
 
292
    			$fp = @fopen($to.$header['filename'], 'wb');
 
293
    			if(!$fp) { return(-1); }
 
294
    
 
295
    			$size = $header['compressed_size'];
278
296

                                        
279
 
   $pth = explode("/",dirname($header['filename']));
280
 
   for($i=0,$tmp="";isset($pth[$i]);$i++){
281
 
     if(!$pth[$i]) continue;
282
 
     if(!is_dir($to.$tmp.$pth[$i])) @mkdir($to.$pth[$i], 0777, true);
283
 
     $tmp.=$pth[$i]."/";
284
 
   }
285
 
  if (!($header['external']==0x41FF0010)&&!($header['external']==16))
286
 
  {
287
 
   if ($header['compression']==0)
288
 
   {
289
 
    $fp = @fopen($to.$header['filename'], 'wb');
290
 
    if(!$fp) return(-1);
291
 
    $size = $header['compressed_size'];
 
297
    			while ($size != 0) {
 
298
      				$read_size = ($size < 2048 ? $size : 2048);
 
299
      				$buffer = fread($zip, $read_size);
 
300
      				$binary_data = pack('a'.$read_size, $buffer);
 
301
      				@fwrite($fp, $binary_data, $read_size);
 
302
      				$size -= $read_size;
 
303
    			}
 
304
    
 
305
    			fclose($fp);
 
306
   				touch($to.$header['filename'], $header['mtime']);
292
307

                                        
293
 
    while ($size != 0)
294
 
    {
295
 
      $read_size = ($size < 2048 ? $size : 2048);
296
 
      $buffer = fread($zip, $read_size);
297
 
      $binary_data = pack('a'.$read_size, $buffer);
298
 
      @fwrite($fp, $binary_data, $read_size);
299
 
      $size -= $read_size;
300
 
    }
301
 
    fclose($fp);
302
 
    touch($to.$header['filename'], $header['mtime']);
 
308
  			} else {
 
309
   				$fp = @fopen($to.$header['filename'].'.gz','wb');
 
310
   				if(!$fp) { return(-1); }
 
311
  				$binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($header['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
303
312

                                        
304
 
  }else{
305
 
   $fp = @fopen($to.$header['filename'].'.gz','wb');
306
 
   if(!$fp) return(-1);
307
 
   $binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($header['compression']),
308
 
     Chr(0x00), time(), Chr(0x00), Chr(3));
 
313
   				fwrite($fp, $binary_data, 10);
 
314
   				$size = $header['compressed_size'];
309
315

                                        
310
 
   fwrite($fp, $binary_data, 10);
311
 
   $size = $header['compressed_size'];
 
316
   				while ($size != 0) {
 
317
     				$read_size = ($size < 1024 ? $size : 1024);
 
318
     				$buffer = fread($zip, $read_size);
 
319
     				$binary_data = pack('a'.$read_size, $buffer);
 
320
     				@fwrite($fp, $binary_data, $read_size);
 
321
    				$size -= $read_size;
 
322
   				}
312
323

                                        
313
 
   while ($size != 0)
314
 
   {
315
 
     $read_size = ($size < 1024 ? $size : 1024);
316
 
     $buffer = fread($zip, $read_size);
317
 
     $binary_data = pack('a'.$read_size, $buffer);
318
 
     @fwrite($fp, $binary_data, $read_size);
319
 
     $size -= $read_size;
320
 
   }
 
324
   				$binary_data = pack('VV', $header['crc'], $header['size']);
 
325
   				fwrite($fp, $binary_data,8);
 
326
   				fclose($fp);
321
327

                                        
322
 
   $binary_data = pack('VV', $header['crc'], $header['size']);
323
 
   fwrite($fp, $binary_data,8); fclose($fp);
 
328
   				$gzp = @gzopen($to.$header['filename'].'.gz','rb') or die("Cette archive est compressee");
 
329
   
 
330
   				if(!$gzp) { return(-2); }
 
331
    			$fp = @fopen($to.$header['filename'],'wb');
 
332
   				if(!$fp) { return(-1); }
 
333
   
 
334
   				$size = $header['size'];
324
335

                                        
325
 

                                    
326
 
    if(!$gzp) return(-2);
327
 
   $fp = @fopen($to.$header['filename'],'wb');
328
 
   if(!$fp) return(-1);
329
 
   $size = $header['size'];
330
 

                                    
331
 
   while ($size != 0)
332
 
   {
333
 
     $read_size = ($size < 2048 ? $size : 2048);
334
 
     $buffer = gzread($gzp, $read_size);
335
 
     $binary_data = pack('a'.$read_size, $buffer);
336
 
     @fwrite($fp, $binary_data, $read_size);
337
 
     $size -= $read_size;
338
 
   }
339
 
   fclose($fp); gzclose($gzp);
340
 

                                    
341
 
   touch($to.$header['filename'], $header['mtime']);
342
 
   @unlink($to.$header['filename'].'.gz');
343
 

                                    
344
 
  }}
345
 
  return true;
346
 
 }
 
336
   				while ($size != 0) {
 
337
     				$read_size = ($size < 2048 ? $size : 2048);
 
338
     				$buffer = gzread($gzp, $read_size);
 
339
     				$binary_data = pack('a'.$read_size, $buffer);
 
340
     				@fwrite($fp, $binary_data, $read_size);
 
341
     				$size -= $read_size;
 
342
   				}
 
343
   				fclose($fp);
 
344
   				gzclose($gzp);
 
345
   				touch($to.$header['filename'], $header['mtime']);
 
346
   				@unlink($to.$header['filename'].'.gz');
 
347
   			}
 
348
   		}
 
349
   		return true;
 
350
   	}
347
351
}
348
352

                                        
349
353
?>
350
354

                                        

 

Old New Code
7
7
		
8
8
		success: function(data){
9
9
			$("#progress").progressBar(data);
10
 
			if(data >= 5) { $("#dl_info").html("Décompression en cours..."); }
 
10
			$("#dl_info").html("Téléchargement en cours... ");
 
11
			//if (data >= 99) { clearTimeout(oDownload); }
11
12
		}
12
13
	});
13
 
	setTimeout('progress()', 10);
 
14
	var oProgress = setTimeout('progress()', 500);
14
15
}
15
16

                                        
16
 
function download()
17
 
{
18
 
	$.ajax({
19
 
		type: "POST",
20
 
		url: "install-fr.php",
21
 
		data: "step=download",
22
 
		
23
 
		success: function(data){
24
 
			$("#progress").progressBar(data);
25
 
			if(data >= 5) { $("#dl_info").html("Téléchargement en cours..."); }
26
 
		}
27
 
	});
28
 
	setTimeout('download()', 10);
29
 
}
30
 

                                    
31
17
function ajaxFunction(url, step) {
32
18
	
33
19
	$("#dl_info").html("Téléchargement en cours...");
67
53
    
68
54
}
69
55

                                        
 
56
function checkDBConnect() {
 
57
	
 
58
	var db_server	= $("#bdd_server").val();
 
59
	var db_name		= $("#bdd_name").val();
 
60
	var db_user 	= $("#bdd_user").val();
 
61
	var db_pwd	 	= $("#bdd_pwd").val();
 
62
	
 
63
	$.ajax({
 
64
		type: "POST",
 
65
		url: "install-fr.php",
 
66
		data: "step=checkDB&db_server=" + db_server + "&db_name=" + db_name + "&db_user=" + db_user + "&db_pwd=" + db_pwd,
 
67
		
 
68
		success: function(data){
 
69
			if (data == "ok") {
 
70
				$("#db_status").attr({ 
 
71
					src: './pal/admin/themes/pal/img/check-on.png'
 
72
				});
 
73
			} else {
 
74
				$("#db_status").attr({ 
 
75
					src: './pal/admin/themes/pal/img/check-off.png'
 
76
				});
 
77
			}
 
78
		}
 
79
	});
 
80
}
 
81

                                    
70
82
function checkPassword(field) {
71
83
	
72
84
	var pwd_strength	= 0;
73
85