[Rcts-checkins] SF.net SVN: rcts: [1960] trunk/install_version2.0
Brought to you by:
bastimmer,
paulsohier
|
From: <pau...@us...> - 2006-09-09 18:44:39
|
Revision: 1960
http://svn.sourceforge.net/rcts/?rev=1960&view=rev
Author: paulsohier
Date: 2006-09-09 11:44:29 -0700 (Sat, 09 Sep 2006)
Log Message:
-----------
Install update
Modified Paths:
--------------
trunk/install_version2.0/install.php
Added Paths:
-----------
trunk/install_version2.0/tmp/class.main.php
Modified: trunk/install_version2.0/install.php
===================================================================
--- trunk/install_version2.0/install.php 2006-09-09 18:42:06 UTC (rev 1959)
+++ trunk/install_version2.0/install.php 2006-09-09 18:44:29 UTC (rev 1960)
@@ -136,6 +136,7 @@
//include('tmp/'.$language.'.php');
include('tmp/en.php');
include('tmp/class.cache.php');
+include('tmp/class.main.php');
$cache = new cache();
$cache->load();
$disabled = '';
@@ -495,352 +496,8 @@
}
}
pagefooter();
-/**
- * Classes needed for install:
- **/
-/**
-* PHPBrowser class
-*
-* @author Really Coding Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
-*/
-class browser{
- var $fields,$cookies,$data,$http_headers,$cookie_array,$path_info,$size;
- /**
- * Constructor
- *
- * Sets cookies to empty.
- */
- function browser(){
- $this->cookies = '';
- }
- /**
- * Reset all vars.
- *
- */
- function reset(){
- $this->cookies = '';
- $this->data = '';
- $this->fields = '';
- $this->http_headers = '';
- $this->cookie_array = '';
- $this->path_info = '';
- $this->size = '';
- }
- /*
- *
- * Next functions are copied from MRlucky's Php browser,
- * Download: http://wmcity.nl/scripts.php?actie=bekijk&id=1238 (Dutch!)
- *
- */
- /**
- * showContents()
- *
- * Return the source.
- * @param bool $md5 check md5?
- * @return string source of the posting page
- */
- function showContents($md5 = true) {
- if(strlen($this -> data) > 0) {
- list($header) = explode("\r\n\r\n", $this -> data);
- list( , $content) = explode($header, $this -> data);
- $content = substr($content, 4);
- if($md5){
- global $MD;
- if($MD){
- if(md5($content) != $MD[$this->path_info]){
- trigger_error('MD5 check error for '.$this->path_info.'.',E_USER_ERROR);
- }
- }
- }
- return $content;
- } else {
- return "No data";
- }
- }
- /**
- * getUrlInfo()
- *
- * gets some info about the url and returns them
- * @param string $url the url
- * @return array Information about the URL
- */
- function getUrlInfo($url) {
- $info = parse_url($url);
- // set vars
- $urlinfo['host'] = $info['host'];
- $urlinfo['port'] = (isset($info['port'])) ? $info['port'] : '80';
- $urlinfo['page'] = $info['path'];
- $this->path_info = $info['path'];
- return $urlinfo;
- }
- /**
- * postPage()
- *
- * Post the page
- * @param string $url the url
- */
- function postPage($url,$mode = 'POST',$display_voortgang = false) {
- //
- // Get URL info
- //
- $urlinfo = $this -> getUrlInfo($url);
- //
- // Remove the last & from POST fields
- //
- $this -> fields = substr($this -> fields, 0, -1);
- $this -> addHeader($mode . " ".$urlinfo['page']." HTTP/1.0");
- $this -> addHeader("Host: ".$urlinfo['host']);
- $this -> addHeader("Connection: Close");
- $this -> addHeader("User-Agent: RCTS php class/0.0.1 (incompatible; No IE;)");
- $this -> addHeader("Content-type: application/x-www-form-urlencoded");
- $this -> addHeader("Content-length: ".strlen($this -> fields));
- $this -> addHeader("Referer: http://reallycoding.nl");
- // Post/Get fields
- $this -> addHeader("");
- $this -> addHeader($this->fields);
- $this -> addHeader("");
- $this -> data = $this -> downloadContents($urlinfo['host'], $urlinfo['port'],$display_voortgang);
-
- $this -> http_headers = array();
- }
- /**
- * downloadContents()
- *
- * Send the request, and return the response.
- * @param string $host The host to connect to.
- * @param integer $port The port to connect to.
- * @return string The response.
- */
- function downloadContents($host, $port,$dis) {
- if (preg_match('/fsockopen/', @ini_get('disable_functions')) || !function_exists('fsockopen')) {
- return false;
- }
- $connection = fsockopen($host, $port, $errornr, $errorstr, 10);
- if(!$connection) {
- trigger_error("Could not connect to ".$host." on port ".$port.":<br />".$errornr.". ".$errorstr);
- }
-
- $http_headers = '';
- foreach($this -> http_headers as $header) {
- $http_headers .= $header."\r\n";
- }
- $contents = "";
-
- fwrite($connection, $http_headers);
- $is = $begin = false;
- $bytes = $length = 0;
- while(!feof($connection)) {
- $tmp = fread($connection, 1024);
- $contents .= $tmp;
- if($dis){
- $match = array();
- if(!$is && preg_match("#Content-Length: (.*?)\n#si",$contents,$match)){
- $length = intval($match[1]);
- $this->size = $length;
- $is = true;
- }
- if($begin && $is){
- $bytes += 1024;
- }
- if(!$begin && eregi("\r\n\r\n",$contents) && $is){
- $begin = true;
- $explode = explode("\r\n\r\n",$contents);
- $explode = $explode[1];
- $bytes += strlen($explode) - 8;
- unset($explode);
- }
- if($begin && $is && $length > 0){
- $tmp = ($bytes / $length) * 100;
- print "<script language='javascript'>document.getElementById('progress').style.width = '$tmp%';</script>\n";
- ob_flush();
- }
-
- }
-
- }
- fclose($connection);
- return $contents;
- }
- /**
- * Encode html
- *
- * @param string $str string to encode
- * @return string encoded string
- */
- function htmlEncode($str) {
- $str = urlencode($str);
- return $str;
- }
- /**
- * addField()
- *
- * Add a POST field to the headers.
- * @param string $fieldname field name
- * @param string $value value
- */
-
- function addField($fieldname, $value) {
- $this -> fields .= $fieldname."=".$this -> htmlEncode($value)."&";
- }
- /**
- * addHeader()
- *
- * Add a HTTP header.
- * @param string $header The header, as it would appear in a HTTP request.
- */
-
- function addHeader($header) {
- $this -> http_headers[] = $header;
- }
-}
/**
- * Zip class, from phpbb.com
- * @package zip
- * @author phpbb group
- *
- */
-class zip
-{
- var $datasec = array();
- var $ctrl_dir = array();
- var $eof_cdh = "\x50\x4b\x05\x06\x00\x00\x00\x00";
-
- var $old_offset = 0;
- var $datasec_len = 0;
- var $length = 0;
- var $done = 0;
-
- function zip($mode, $file)
- {
- return $this->fp = fopen($file, $mode . 'b');
- }
-
- function a($l){
- $this->done += $l;
- $tmp = ($this->done / $this->length) * 100;
- print "<script language='javascript'>document.getElementById('progress').style.width = '$tmp%';</script>\n";
- }
- function extract($dst)
- {
- global $cache;
- // Loop the file, looking for files and folders
- $dd_try = false;
- rewind($this->fp);
-
- while (!feof($this->fp))
- {
- // Check if the signature is valid...
- $signature = fread($this->fp, 4);
- $this->a(4);
-
- switch ($signature)
- {
- // 'Local File Header'
- case "\x50\x4b\x03\x04":
- // Lets get everything we need.
- // We don't store the version needed to extract, the general purpose bit flag or the date and time fields
- $data = unpack("@4/vc_method/@10/Vcrc/Vc_size/Vuc_size/vname_len/vextra_field", fread($this->fp, 26));
- $this->a(26);
- $file_name = fread($this->fp, $data['name_len']); // filename
- $this->a($data['name_len']);
-
- if ($data['extra_field'])
- {
- fread($this->fp, $data['extra_field']); // extra field
- $this->a($data['extra_field']);
- }
-
- $target_filename = "$dst$file_name";
-
- if (!$data['uc_size'] && !$data['crc'] && substr($file_name, -1, 1) == '/')
- {
- if (!is_dir($target_filename))
- {
- $str = '';
- $folders = explode('/', $target_filename);
-
- // Create and folders and subfolders if they do not exist
- foreach ($folders as $folder)
- {
- $str = (!empty($str)) ? $str . '/' . $folder : $folder;
- if (!is_dir($str))
- {
- $cache->_mkdir($str);
- }
- }
- }
- // This is a directory, we are not writting files
- continue;
- }
-
- if (!$data['uc_size'])
- {
- $content = '';
- }
- else
- {
- $content = fread($this->fp, $data['c_size']);
- $this->a($data['c_size']);
- }
-
-
- //$fp = fopen($target_filename, "w");
-
- switch ($data['c_method'])
- {
- case 0:
- break;
- case 8:
- // Deflate
- $content = gzinflate($content, $data['uc_size']);
- break;
-
- case 12:
- // Bzip2
- $content = bzdecompress($content);
- break;
- }
-
- $p = array(
- "mkdir" => true,
- "dir" => $dst
- );
- $cache->write($file_name, "w", $content, $p);
- break;
-
- // We hit the 'Central Directory Header', we can stop because nothing else in here requires our attention
- // or we hit the end of the central directory record, we can safely end the loop as we are totally finished with looking for files and folders
- case "\x50\x4b\x01\x02":
- // This case should simply never happen.. but it does exist..
- case "\x50\x4b\x05\x06":
- break 2;
-
- // 'Packed to Removable Disk', ignore it and look for the next signature...
- case 'PK00':
- continue 2;
-
- // We have encountered a header that is weird. Lets look for better data...
- default:
- if (!$dd_try)
- {
- // Unexpected header. Trying to detect wrong placed 'Data Descriptor';
- $dd_try = true;
- fseek($this->fp, 8, SEEK_CUR); // Jump over 'crc-32'(4) 'compressed-size'(4), 'uncompressed-size'(4)
- $this->a(8);
- continue 2;
- }
- //trigger_error("Unexpected header, ending loop");
- break 2;
- }
- $dd_try = false;
- }
- }
-}
-
-
-/**
* Functions needed for install:
**/
/**
Added: trunk/install_version2.0/tmp/class.main.php
===================================================================
--- trunk/install_version2.0/tmp/class.main.php (rev 0)
+++ trunk/install_version2.0/tmp/class.main.php 2006-09-09 18:44:29 UTC (rev 1960)
@@ -0,0 +1,358 @@
+<?php
+/**
+ * Main classes for installation
+ * @package RCTS2
+ * @version $Id$
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @copyright Really Coding Group, 2005-2006
+ * @author Really Coding Group
+ */
+/**
+ * @ignore
+ */
+if(!defined('IN_INSTALL'))
+{
+ exit();
+}
+/**
+* PHPBrowser class
+*
+* @author Really Coding Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @package install
+*/
+class browser{
+ var $fields,$cookies,$data,$http_headers,$cookie_array,$path_info,$size;
+ /**
+ * Constructor
+ *
+ * Sets cookies to empty.
+ */
+ function browser(){
+ $this->cookies = '';
+ }
+ /**
+ * Reset all vars.
+ *
+ */
+ function reset(){
+ $this->cookies = '';
+ $this->data = '';
+ $this->fields = '';
+ $this->http_headers = '';
+ $this->cookie_array = '';
+ $this->path_info = '';
+ $this->size = '';
+ }
+ /*
+ *
+ * Next functions are copied from MRlucky's Php browser,
+ * Download: http://wmcity.nl/scripts.php?actie=bekijk&id=1238 (Dutch!)
+ *
+ */
+ /**
+ * showContents()
+ *
+ * Return the source.
+ * @param bool $md5 check md5?
+ * @return string source of the posting page
+ */
+ function showContents($md5 = true) {
+ if(strlen($this -> data) > 0) {
+ list($header) = explode("\r\n\r\n", $this -> data);
+
+ list( , $content) = explode($header, $this -> data);
+ $content = substr($content, 4);
+ if($md5){
+ global $MD;
+ if($MD){
+ if(md5($content) != $MD[$this->path_info]){
+ trigger_error('MD5 check error for '.$this->path_info.'.',E_USER_ERROR);
+ }
+ }
+ }
+ return $content;
+ } else {
+ return "No data";
+ }
+ }
+ /**
+ * getUrlInfo()
+ *
+ * gets some info about the url and returns them
+ * @param string $url the url
+ * @return array Information about the URL
+ */
+ function getUrlInfo($url) {
+ $info = parse_url($url);
+ // set vars
+ $urlinfo['host'] = $info['host'];
+ $urlinfo['port'] = (isset($info['port'])) ? $info['port'] : '80';
+ $urlinfo['page'] = $info['path'];
+ $this->path_info = $info['path'];
+ return $urlinfo;
+ }
+ /**
+ * postPage()
+ *
+ * Post the page
+ * @param string $url the url
+ */
+ function postPage($url,$mode = 'POST',$display_voortgang = false) {
+ //
+ // Get URL info
+ //
+ $urlinfo = $this -> getUrlInfo($url);
+ //
+ // Remove the last & from POST fields
+ //
+ $this -> fields = substr($this -> fields, 0, -1);
+ $this -> addHeader($mode . " ".$urlinfo['page']." HTTP/1.0");
+ $this -> addHeader("Host: ".$urlinfo['host']);
+ $this -> addHeader("Connection: Close");
+ $this -> addHeader("User-Agent: RCTS php class/0.0.1 (incompatible; No IE;)");
+ $this -> addHeader("Content-type: application/x-www-form-urlencoded");
+ $this -> addHeader("Content-length: ".strlen($this -> fields));
+ $this -> addHeader("Referer: http://reallycoding.nl");
+ // Post/Get fields
+ $this -> addHeader("");
+ $this -> addHeader($this->fields);
+ $this -> addHeader("");
+ $this -> data = $this -> downloadContents($urlinfo['host'], $urlinfo['port'],$display_voortgang);
+
+ $this -> http_headers = array();
+ }
+ /**
+ * downloadContents()
+ *
+ * Send the request, and return the response.
+ * @param string $host The host to connect to.
+ * @param integer $port The port to connect to.
+ * @return string The response.
+ */
+ function downloadContents($host, $port,$dis) {
+ if (preg_match('/fsockopen/', @ini_get('disable_functions')) || !function_exists('fsockopen')) {
+ return false;
+ }
+ $connection = fsockopen($host, $port, $errornr, $errorstr, 10);
+ if(!$connection) {
+ trigger_error("Could not connect to ".$host." on port ".$port.":<br />".$errornr.". ".$errorstr);
+ }
+
+ $http_headers = '';
+ foreach($this -> http_headers as $header) {
+ $http_headers .= $header."\r\n";
+ }
+ $contents = "";
+
+ fwrite($connection, $http_headers);
+ $is = $begin = false;
+ $bytes = $length = 0;
+ while(!feof($connection)) {
+ $tmp = fread($connection, 1024);
+ $contents .= $tmp;
+ if($dis){
+ $match = array();
+ if(!$is && preg_match("#Content-Length: (.*?)\n#si",$contents,$match)){
+ $length = intval($match[1]);
+ $this->size = $length;
+ $is = true;
+ }
+ if($begin && $is){
+ $bytes += 1024;
+ }
+ if(!$begin && eregi("\r\n\r\n",$contents) && $is){
+ $begin = true;
+ $explode = explode("\r\n\r\n",$contents);
+ $explode = $explode[1];
+ $bytes += strlen($explode) - 8;
+ unset($explode);
+ }
+ if($begin && $is && $length > 0){
+ $tmp = ($bytes / $length) * 100;
+ print "<script language='javascript'>document.getElementById('progress').style.width = '$tmp%';</script>\n";
+ ob_flush();
+ }
+
+ }
+
+ }
+ fclose($connection);
+ return $contents;
+ }
+ /**
+ * Encode html
+ *
+ * @param string $str string to encode
+ * @return string encoded string
+ */
+ function htmlEncode($str) {
+ $str = urlencode($str);
+ return $str;
+ }
+ /**
+ * addField()
+ *
+ * Add a POST field to the headers.
+ * @param string $fieldname field name
+ * @param string $value value
+ */
+
+ function addField($fieldname, $value) {
+ $this -> fields .= $fieldname."=".$this -> htmlEncode($value)."&";
+ }
+ /**
+ * addHeader()
+ *
+ * Add a HTTP header.
+ * @param string $header The header, as it would appear in a HTTP request.
+ */
+
+ function addHeader($header) {
+ $this -> http_headers[] = $header;
+ }
+}
+/**
+ * Zip class, from phpbb.com
+ * @package install
+ * @author phpbb group
+ *
+ */
+class zip
+{
+ var $datasec = array();
+ var $ctrl_dir = array();
+ var $eof_cdh = "\x50\x4b\x05\x06\x00\x00\x00\x00";
+
+ var $old_offset = 0;
+ var $datasec_len = 0;
+ var $length = 0;
+ var $done = 0;
+
+ function zip($mode, $file)
+ {
+ return $this->fp = fopen($file, $mode . 'b');
+ }
+
+ function a($l){
+ $this->done += $l;
+ $tmp = ($this->done / $this->length) * 100;
+ print "<script language='javascript'>document.getElementById('progress').style.width = '$tmp%';</script>\n";
+ }
+ function extract($dst)
+ {
+ global $cache;
+ // Loop the file, looking for files and folders
+ $dd_try = false;
+ rewind($this->fp);
+
+ while (!feof($this->fp))
+ {
+ // Check if the signature is valid...
+ $signature = fread($this->fp, 4);
+ $this->a(4);
+
+ switch ($signature)
+ {
+ // 'Local File Header'
+ case "\x50\x4b\x03\x04":
+ // Lets get everything we need.
+ // We don't store the version needed to extract, the general purpose bit flag or the date and time fields
+ $data = unpack("@4/vc_method/@10/Vcrc/Vc_size/Vuc_size/vname_len/vextra_field", fread($this->fp, 26));
+ $this->a(26);
+ $file_name = fread($this->fp, $data['name_len']); // filename
+ $this->a($data['name_len']);
+
+ if ($data['extra_field'])
+ {
+ fread($this->fp, $data['extra_field']); // extra field
+ $this->a($data['extra_field']);
+ }
+
+ $target_filename = "$dst$file_name";
+
+ if (!$data['uc_size'] && !$data['crc'] && substr($file_name, -1, 1) == '/')
+ {
+ if (!is_dir($target_filename))
+ {
+ $str = '';
+ $folders = explode('/', $target_filename);
+
+ // Create and folders and subfolders if they do not exist
+ foreach ($folders as $folder)
+ {
+ $str = (!empty($str)) ? $str . '/' . $folder : $folder;
+ if (!is_dir($str))
+ {
+ $cache->_mkdir($str);
+ }
+ }
+ }
+ // This is a directory, we are not writting files
+ continue;
+ }
+
+ if (!$data['uc_size'])
+ {
+ $content = '';
+ }
+ else
+ {
+ $content = fread($this->fp, $data['c_size']);
+ $this->a($data['c_size']);
+ }
+
+
+ //$fp = fopen($target_filename, "w");
+
+ switch ($data['c_method'])
+ {
+ case 0:
+ break;
+ case 8:
+ // Deflate
+ $content = gzinflate($content, $data['uc_size']);
+ break;
+
+ case 12:
+ // Bzip2
+ $content = bzdecompress($content);
+ break;
+ }
+
+ $p = array(
+ "mkdir" => true,
+ "dir" => $dst
+ );
+ $cache->write($file_name, "w", $content, $p);
+ break;
+
+ // We hit the 'Central Directory Header', we can stop because nothing else in here requires our attention
+ // or we hit the end of the central directory record, we can safely end the loop as we are totally finished with looking for files and folders
+ case "\x50\x4b\x01\x02":
+ // This case should simply never happen.. but it does exist..
+ case "\x50\x4b\x05\x06":
+ break 2;
+
+ // 'Packed to Removable Disk', ignore it and look for the next signature...
+ case 'PK00':
+ continue 2;
+
+ // We have encountered a header that is weird. Lets look for better data...
+ default:
+ if (!$dd_try)
+ {
+ // Unexpected header. Trying to detect wrong placed 'Data Descriptor';
+ $dd_try = true;
+ fseek($this->fp, 8, SEEK_CUR); // Jump over 'crc-32'(4) 'compressed-size'(4), 'uncompressed-size'(4)
+ $this->a(8);
+ continue 2;
+ }
+ //trigger_error("Unexpected header, ending loop");
+ break 2;
+ }
+ $dd_try = false;
+ }
+ }
+}
+?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|