function load()
 {
     global $config;
     if ($this->exists() == true) {
         $this->import();
     } else {
         if (viscacha_function_exists('xml_parser_create')) {
             $rssnews = get_remote('http://version.viscacha.org/news/rss');
             include 'classes/magpie_rss/rss_fetch.inc.php';
             $rss = new MagpieRSS($rssnews);
             $news = '';
             foreach ($rss->items as $item) {
                 $news .= '<li><a href="' . htmlspecialchars($item['link']) . '" style="font-weight: bold;" target="_blank">' . htmlspecialchars($item['title']) . '</a>';
                 if (isset($item['description'])) {
                     $news .= '<br /><span style="font-size: 0.9em;">' . htmlspecialchars($item['description']) . '</span>';
                 }
                 $news .= '</li>';
             }
             if (!empty($news)) {
                 $news = '<ul>' . $news . '</ul>';
             }
         } else {
             $news = get_remote('http://version.viscacha.org/news');
         }
         $this->data = array('comp' => get_remote('http://version.viscacha.org/compare/?version=' . base64_encode($config['version'])), 'version' => get_remote('http://version.viscacha.org/version'), 'news' => $news);
         $this->export();
     }
 }
function isWindows()
{
    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
        return true;
    } elseif (isset($_SERVER['OS']) && strpos(strtolower($_SERVER['OS']), 'Windows') !== false) {
        return true;
    } elseif (viscacha_function_exists('php_uname') && stristr(@php_uname(), 'windows')) {
    } else {
        return false;
    }
}
Пример #3
0
 function DB($host = 'localhost', $user = '******', $pwd = '', $dbname = '', $dbprefix = '', $open = true)
 {
     $this->system = 'mysql';
     if (version_compare(PHP_VERSION, "4.3.0", ">=") && viscacha_function_exists('mysql_real_escape_string') == true) {
         $this->escaper = 'mysql_real_escape_string';
     } else {
         $this->escaper = 'mysql_escape_string';
     }
     $this->errlogfile = 'data/errlog_' . $this->system . '.inc.php';
     parent::DB_Driver($host, $user, $pwd, $dbname, $dbprefix, $open);
     $this->freeResult = $this->persistence == 1;
 }
function CanGZIP() {
	if (headers_sent() || connection_aborted() || !extension_loaded("zlib") || !viscacha_function_exists('gzcompress')){
		return false;
	}
	if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false) {
		return "x-gzip";
	}
	if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false) {
		return "gzip";
	}
	return false;
}
 function VeriWord()
 {
     // Get Font-Files
     $handle = opendir($this->dir_font);
     $pre = 'captcha_';
     while ($file = readdir($handle)) {
         if ($file != "." && $file != ".." && !is_dir($this->dir_font . $file)) {
             $nfo = pathinfo($this->dir_font . $file);
             $prefix = substr($nfo['basename'], 0, strlen($pre));
             if ($nfo['extension'] == 'ttf' && $prefix == $pre) {
                 $this->fonts[] = $nfo['basename'];
             }
         }
     }
     // Get Noise-Files
     $handle = opendir($this->dir_noise);
     while ($file = readdir($handle)) {
         if ($file != "." && $file != ".." && !is_dir($this->dir_noise . $file)) {
             $nfo = pathinfo($this->dir_noise . $file);
             if ($nfo['extension'] == 'jpg' || $nfo['extension'] == 'jpeg') {
                 $this->noises[] = $nfo['basename'];
             }
         }
     }
     ImageTypes();
     $lang = new lang();
     $lang->group("thumbnail.class");
     $this->lang = $lang->return_array();
     if (viscacha_function_exists('imagejpeg') && IMG_JPEG) {
         define('IMAGEJPEG', true);
     } else {
         define('IMAGEJPEG', false);
     }
     if (viscacha_function_exists('imagegif') && IMG_GIF) {
         define('IMAGEGIF', true);
     } else {
         define('IMAGEGIF', false);
     }
     if (viscacha_function_exists('imagepng') && IMG_PNG) {
         define('IMAGEPNG', true);
     } else {
         define('IMAGEPNG', false);
     }
     srand((double) microtime() * time());
     mt_srand((double) microtime() * 1000000);
 }
	function readRssInfo() {
		if (!viscacha_function_exists('xml_parser_create')) {
			return false;
		}

		global $config;
		$rssData = get_remote('http://version.viscacha.org/news/rss/?version='.base64_encode($config['version']));

		$xml = xml_parser_create();
		xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, true);
		xml_set_element_handler($xml, array($this, "startRssElement"), array($this, "endRssElement"));
		xml_set_character_data_handler($xml, array($this, "getRssElementData"));
		$success = xml_parse($xml, $rssData);
		xml_parser_free($xml);

		if (!$success || empty($this->data['news'])) {
			$this->data['news'] = '';
			return false;
		}
		else {
			$this->data['news'] = '<ul>'.$this->data['news'].'</ul>';
			return true;
		}
	}
 /**
  * Instaniate an XML parser under PHP4
  *
  * Unfortunately PHP4's support for character encodings
  * and especially XML and character encodings sucks.  As
  * long as the documents you parse only contain characters
  * from the ISO-8859-1 character set (a superset of ASCII,
  * and a subset of UTF-8) you're fine.  However once you
  * step out of that comfy little world things get mad, bad,
  * and dangerous to know.
  *
  * The following code is based on SJM's work with FoF
  * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
  *
  */
 function php4_create_parser($source, $in_enc, $detect)
 {
     if (!$detect) {
         return array(xml_parser_create($in_enc), $source);
     }
     if (!$in_enc) {
         if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
             $in_enc = strtoupper($m[1]);
             $this->source_encoding = $in_enc;
         } else {
             $in_enc = 'UTF-8';
         }
     }
     if ($this->known_encoding($in_enc)) {
         return array(xml_parser_create($in_enc), $source);
     }
     // the dectected encoding is not one of the simple encodings PHP knows
     // attempt to use the iconv extension to
     // cast the XML to a known encoding
     // @see http://php.net/iconv
     if (viscacha_function_exists('iconv')) {
         $encoded_source = iconv($in_enc, 'UTF-8', $source);
         if ($encoded_source) {
             return array(xml_parser_create('UTF-8'), $encoded_source);
         }
     }
     // iconv didn't work, try mb_convert_encoding
     // @see http://php.net/mbstring
     if (viscacha_function_exists('mb_convert_encoding')) {
         $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc);
         if ($encoded_source) {
             return array(xml_parser_create('UTF-8'), $encoded_source);
         }
     }
     // else
     $this->error("Feed is in an unsupported character encoding. ({$in_enc}) " . "You may see strange artifacts, and mangled characters.", E_USER_NOTICE);
     return array(xml_parser_create(), $source);
 }
    unset($input);
}
if (get_magic_quotes_gpc() == 1) {
    $_GET = $gpc->stripslashes($_GET);
    $_POST = $gpc->stripslashes($_POST);
    $_REQUEST = $gpc->stripslashes($_REQUEST);
}
// Thanks to phpBB for this 6 lines
if (isset($_POST['GLOBALS']) || isset($_FILES['GLOBALS']) || isset($_GET['GLOBALS']) || isset($_COOKIE['GLOBALS'])) {
    trigger_error("Hacking attempt (Globals)", E_USER_ERROR);
}
if (isset($_SESSION) && !is_array($_SESSION)) {
    trigger_error("Hacking attempt (Session Variable)", E_USER_ERROR);
}
$http_svars = array('PHP_SELF', 'HTTP_USER_AGENT', 'SERVER_SOFTWARE', 'REMOTE_ADDR', 'SCRIPT_NAME', 'SERVER_PORT', 'SERVER_NAME', 'HTTP_REFERER', 'HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'REQUEST_URI', 'HTTP_ACCEPT_ENCODING', 'DOCUMENT_ROOT');
if (viscacha_function_exists('getallheaders')) {
    $ref = @getallheaders();
} else {
    $ref = array();
}
foreach ($http_svars as $http_var) {
    $func_key = '';
    if (substr($http_var, 0, 5) == 'HTTP_') {
        $func_key = strtolower(str_replace('_', ' ', substr($http_var, 5)));
        $func_key = str_replace(' ', '-', ucwords($func_key));
    }
    if (empty($_SERVER[$http_var]) && !empty($ref[$func_key])) {
        $_SERVER[$http_var] = $ref[$func_key];
    } else {
        $_SERVER[$http_var] = getenv($http_var);
    }
Пример #9
0
            // (?:p)? => p?
            $list = preg_replace('#\\(\\?\\:(.)\\)\\?#', '\\1?', $list);
            // (?:a|b|c|d|...)? => [abcd...]?
            // TODO: a|bb|c => [ac]|bb
            static $callback_2;
            if (!isset($callback_2)) {
                $callback_2 = create_function('$matches', 'return "[" . str_replace("|", "", $matches[1]) . "]";');
            }
            $list = preg_replace_callback('#\\(\\?\\:((?:.\\|)+.)\\)#', $callback_2, $list);
        }
        // return $list without trailing pipe
        return substr($list, 0, -1);
    }
}
// End Class GeSHi
if (!viscacha_function_exists('geshi_highlight')) {
    /**
     * Easy way to highlight stuff. Behaves just like highlight_string
     *
     * @param string The code to highlight
     * @param string The language to highlight the code in
     * @param string The path to the language files. You can leave this blank if you need
     *               as from version 1.0.7 the path should be automatically detected
     * @param boolean Whether to return the result or to echo
     * @return string The code highlighted (if $return is true)
     * @since 1.0.2
     */
    function geshi_highlight($string, $language, $path = null, $return = false)
    {
        $geshi = new GeSHi($string, $language, $path);
        $geshi->set_header_type(GESHI_HEADER_NONE);
 function error($errcomment)
 {
     // Try to get better results for line and file.
     if (viscacha_function_exists('debug_backtrace') == true) {
         $backtraceInfo = debug_backtrace();
         // 0 is class.mysql.php, 1 is the calling code...
         if (isset($backtraceInfo[1]) == true) {
             $errline = $backtraceInfo[1]['line'];
             $errfile = $backtraceInfo[1]['file'];
         }
     }
     if ($this->logerrors) {
         if (file_exists($this->errlogfile)) {
             $lines = file($this->errlogfile);
             foreach ($lines as $key => $value) {
                 $value = trim($value);
                 if (empty($value)) {
                     unset($lines[$key]);
                 } else {
                     $lines[$key] = $value;
                     // Also trim it for the file
                 }
             }
         } else {
             $lines = array();
         }
         $cols = array($this->errno(), makeOneLine($this->errstr()), $errfile, $errline, makeOneLine($_SERVER['REQUEST_URI']), time(), makeOneLine($errcomment));
         $lines[] = implode("\t", $cols);
         @file_put_contents($this->errlogfile, implode("\n", $lines));
     }
     $errcomment = nl2br($errcomment);
     return "DB ERROR " . $this->errno() . ": " . $this->errstr() . "<br />File: {$errfile} on line {$errline}<br />Query: <code>{$errcomment}</code>";
 }
Пример #11
0
"></td>
	  </tr>
	 </table>
	</form>
	<?php 
    echo foot();
} elseif ($job == 'datetime2') {
    echo head();
    $c->getdata();
    $c->updateconfig('new_dformat4', int);
    $c->updateconfig('timezone', str);
    $c->savedata();
    ok('admin.php?action=settings&job=settings');
} elseif ($job == 'http') {
    $config = $gpc->prepare($config);
    if (!extension_loaded("zlib") || !viscacha_function_exists('gzcompress')) {
        $gzip = '<span style="color: #aa0000;">' . $lang->phrase('admin_not_enabled') . '</span>';
    } else {
        $gzip = '<span style="color: #00aa00;">' . $lang->phrase('admin_enabled') . '</span>';
    }
    echo head();
    ?>
	<form name="form" method="post" action="admin.php?action=settings&job=http2">
	 <table class="border" border="0" cellspacing="0" cellpadding="4" align="center">
	  <tr>
	   <td class="obox" colspan="2"><?php 
    echo $lang->phrase('admin_headers_cookies_gzip');
    ?>
</td>
	  </tr>
	  <tr>
Пример #12
0
 function privSwapBackMagicQuotes()
 {
     $v_result = 1;
     // ----- Look if function exists
     if (!viscacha_function_exists("get_magic_quotes_runtime") || !viscacha_function_exists("set_magic_quotes_runtime")) {
         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Look if something to do
     if ($this->magic_quotes_status != -1) {
         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Swap back magic_quotes
     if ($this->magic_quotes_status == 1) {
         @set_magic_quotes_runtime($this->magic_quotes_status);
     }
     // ----- Return
     return $v_result;
 }
 function error($errcomment)
 {
     // Try to get better results for line and file.
     if (viscacha_function_exists('debug_backtrace') == true) {
         $backtraceInfo = debug_backtrace();
         // 0 is class.mysql.php, 1 is the calling code...
         if (isset($backtraceInfo[1]) == true) {
             $errline = $backtraceInfo[1]['line'];
             $errfile = $backtraceInfo[1]['file'];
         }
     }
     if ($this->logerrors) {
         $logs = array();
         if (file_exists($this->errlogfile)) {
             $logs = file($this->errlogfile);
             $logs = array_empty_trim($logs);
         }
         $row = array($this->errno(), $this->errstr(), $errfile, $errline, $errcomment, $_SERVER['REQUEST_URI'], time(), PHP_VERSION . " (" . PHP_OS . ")");
         $row = array_map('makeOneLine', $row);
         $logs[] = implode("\t", $row);
         @file_put_contents($this->errlogfile, implode("\n", $logs));
     }
     $errcomment = nl2br($errcomment);
     return "Database error " . $this->errno() . ": " . $this->errstr() . "<br />File: {$errfile} on line {$errline}<br />Query: <code>{$errcomment}</code>";
 }
Пример #14
0
 function OpenSocket($server, $port)
 {
     if (viscacha_function_exists("dns_get_record")) {
         $record = dns_get_record("_xmpp-client._tcp.{$server}", DNS_SRV);
         if (!empty($record)) {
             $server = $record[0]["target"];
             $port = $record[0]["port"];
         }
     }
     if ($this->active_socket = @fsockopen($server, $port)) {
         @socket_set_blocking($this->active_socket, 0);
         @socket_set_timeout($this->active_socket, 31536000);
         return TRUE;
     } else {
         return FALSE;
     }
 }
Пример #15
0
function pemftp_class_module()
{
    if (extension_loaded('ftp')) {
        return 'ext';
    } else {
        $mod_sockets = true;
        if (!extension_loaded('sockets')) {
            if (!viscacha_function_exists('dl')) {
                $mod_sockets = false;
            } else {
                $prefix = PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : '';
                if (!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) {
                    $mod_sockets = false;
                }
            }
        }
        if ($mod_sockets == true) {
            return 'sockets';
        } elseif ($mod_sockets == false && viscacha_function_exists('fsockopen')) {
            return 'pure';
        } else {
            die('Viscacha needs at least fsockopen, sockets extension or ftp extension to work! Please enable one of this features or you cannot use Viscacha!');
        }
    }
}
Пример #16
0
function pemftp_class_module()
{
    if (extension_loaded('ftp')) {
        return 'ext';
    } else {
        $mod_sockets = true;
        if (!extension_loaded('sockets')) {
            if (!viscacha_function_exists('dl')) {
                $mod_sockets = false;
            } else {
                $prefix = PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : '';
                if (!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) {
                    $mod_sockets = false;
                }
            }
        }
        if ($mod_sockets == true) {
            return 'sockets';
        } elseif ($mod_sockets == false && viscacha_function_exists('fsockopen')) {
            return 'pure';
        } else {
            return null;
        }
    }
}
function gzAbortNotLoaded()
{
    if (!extension_loaded("zlib") || !viscacha_function_exists('readgzfile')) {
        global $lang;
        error('javascript:history.back(-1);', $lang->phrase('admin_gzip_not_loaded'));
    }
}
 function output($format = 'png')
 {
     if (($format == 'jpeg' || $format == 'jpe' || $format == 'jpeg') && viscacha_function_exists('imagejpeg')) {
         header("Content-Type: image/jpeg");
         imagejpeg($this->img, '', 90);
     } elseif ($format == 'gif' && viscacha_function_exists('imagegif')) {
         header("Content-Type: image/gif");
         imagegif($this->img);
     } else {
         header("Content-Type: image/png");
         imagepng($this->img);
     }
     $this->destroy();
     exit;
 }
Пример #19
0
 /**
  * Upload a file.
  *
  * Checks if the file is acceptable and uploads it to PHP's default upload diretory
  *
  * @param	string	Name of form field
  * @return	boolean
  */
 function upload($index)
 {
     global $imagetype_extension;
     if (!isset($_FILES[$index]) || !is_array($_FILES[$index])) {
         $this->error = UPLOAD_ERR_FILE_INDEX;
         return false;
     }
     // Copy PHP's global $_FILES array to a local array
     $indexes = array('extension', 'size', 'width', 'height', 'tmp_name', 'raw_name', 'form', 'type', 'name', 'image', 'filename');
     foreach ($indexes as $key) {
         $this->file[$key] = isset($_FILES[$index][$key]) ? $_FILES[$index][$key] : null;
     }
     // Set input field name
     $this->file['form'] = $index;
     // Get extension
     $this->file['extension'] = strtolower(get_extension($this->file['name']));
     // Get file size
     if (empty($this->file['size']) == true) {
         $this->file['size'] = filesize($this->file['tmp_name']);
     }
     // Set mime type
     if (empty($this->file['type']) == true) {
         if (viscacha_function_exists('mime_content_type') == true) {
             $this->file['type'] = mime_content_type($this->file['name']);
         }
     }
     // Check image data (height, width, image)
     if (in_array($this->file['extension'], $imagetype_extension) == true) {
         $this->file['image'] = true;
         $properties = @getimagesize($this->file['tmp_name']);
         if (is_array($properties) == false) {
             $this->file['image'] = false;
         } else {
             $this->file['width'] = $properties[0];
             $this->file['height'] = $properties[1];
             if (empty($this->file['type']) == true) {
                 $this->file['type'] = image_type_to_mime_type($properties[2]);
             }
         }
     } else {
         $this->file['image'] = false;
     }
     // Set raw_name
     $this->file['raw_name'] = substr($this->file['name'], 0, -(strlen($this->file['extension']) + 1));
     $this->file['filename'] = $this->file['name'];
     // test max file size
     if ($this->max_filesize > 0 && $this->file['size'] > $this->max_filesize) {
         $this->error = UPLOAD_ERR_FILE_SIZE;
         return false;
     }
     // test max image size
     if ($this->file['image'] == true) {
         if ($this->max_image_width > 0 && $this->file['width'] > $this->max_image_width) {
             $this->error = UPLOAD_ERR_IMAGE_WIDTH;
             return false;
         }
         if ($this->max_image_height > 0 && $this->file['height'] > $this->max_image_height) {
             $this->error = UPLOAD_ERR_IMAGE_HEIGHT;
             return false;
         }
     }
     // check to see if the file is of type specified
     if (count($this->file_types) > 0) {
         if (in_array($this->file['extension'], $this->file_types) == false) {
             $this->error = UPLOAD_ERR_FILE_TYPE;
             return false;
         }
     }
     if (!is_uploaded_file($this->file['tmp_name'])) {
         $this->copy_func = 'copy';
     }
     return true;
 }
Пример #20
0
 function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "")
 {
     $temp_dir = "";
     $cmdline_params = "";
     $cookie_headers = '';
     if ($this->passcookies && $this->_redirectaddr) {
         $this->setcookies();
     }
     $URI_PARTS = parse_url($URI);
     if (empty($url)) {
         $url = "/";
     }
     $headers = $http_method . " " . $url . " " . $this->_httpversion . "\r\n";
     if (!empty($this->agent)) {
         $headers .= "User-Agent: " . $this->agent . "\r\n";
     }
     if (!empty($this->host) && !isset($this->rawheaders['Host'])) {
         $headers .= "Host: " . convert_host_to_idna($this->host);
         if (!empty($this->port)) {
             $headers .= ":" . $this->port;
         }
         $headers .= "\r\n";
     }
     if (!empty($this->accept)) {
         $headers .= "Accept: " . $this->accept . "\r\n";
     }
     if ($this->use_gzip && viscacha_function_exists('gzinflate')) {
         // make sure PHP was built with --with-zlib
         // and we can handle gzipp'ed data
         $headers .= "Accept-encoding: gzip\r\n";
     }
     if (!empty($this->referer)) {
         $headers .= "Referer: " . $this->referer . "\r\n";
     }
     if (!empty($this->cookies)) {
         if (!is_array($this->cookies)) {
             $this->cookies = (array) $this->cookies;
         }
         reset($this->cookies);
         if (count($this->cookies) > 0) {
             $cookie_headers .= 'Cookie: ';
             foreach ($this->cookies as $cookieKey => $cookieVal) {
                 $cookie_headers .= $cookieKey . "=" . urlencode($cookieVal) . "; ";
             }
             $headers .= substr($cookie_headers, 0, -2) . "\r\n";
         }
     }
     if (!empty($this->rawheaders)) {
         if (!is_array($this->rawheaders)) {
             $this->rawheaders = (array) $this->rawheaders;
         }
         while (list($headerKey, $headerVal) = each($this->rawheaders)) {
             $headers .= $headerKey . ": " . $headerVal . "\r\n";
         }
     }
     if (!empty($content_type)) {
         $headers .= "Content-type: {$content_type}";
         if ($content_type == "multipart/form-data") {
             $headers .= "; boundary=" . $this->_mime_boundary;
         }
         $headers .= "\r\n";
     }
     if (!empty($body)) {
         $headers .= "Content-length: " . strlen($body) . "\r\n";
     }
     if (!empty($this->user) || !empty($this->pass)) {
         $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n";
     }
     //add proxy auth headers
     if (!empty($this->proxy_user)) {
         $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n";
     }
     $headers .= "\r\n";
     // set the read timeout if needed
     if ($this->read_timeout > 0) {
         socket_set_timeout($fp, $this->read_timeout);
     }
     $this->timed_out = false;
     fwrite($fp, $headers . $body, strlen($headers . $body));
     $this->_redirectaddr = false;
     unset($this->headers);
     // content was returned gzip encoded?
     $is_gzipped = false;
     while ($currentHeader = fgets($fp, $this->_maxlinelen)) {
         if ($this->read_timeout > 0 && $this->_check_timeout($fp)) {
             $this->status = -100;
             return false;
         }
         if ($currentHeader == "\r\n") {
             break;
         }
         // if a header begins with Location: or URI:, set the redirect
         if (preg_match("/^(Location:|URI:)/i", $currentHeader)) {
             // get URL portion of the redirect
             preg_match("/^(Location:|URI:)[ ]+(.*)/i", chop($currentHeader), $matches);
             // look for :// in the Location header to see if hostname is included
             if (!preg_match("|\\:\\/\\/|", $matches[2])) {
                 // no host in the path, so prepend
                 $this->_redirectaddr = $URI_PARTS["scheme"] . "://" . $this->host . ":" . $this->port;
                 // eliminate double slash
                 if (!preg_match("|^/|", $matches[2])) {
                     $this->_redirectaddr .= "/" . $matches[2];
                 } else {
                     $this->_redirectaddr .= $matches[2];
                 }
             } else {
                 $this->_redirectaddr = $matches[2];
             }
         }
         if (preg_match("|^HTTP/|", $currentHeader)) {
             if (preg_match("|^HTTP/[^\\s]*\\s(.*?)\\s|", $currentHeader, $status)) {
                 $this->status = $status[1];
             }
             $this->response_code = $currentHeader;
         }
         if (preg_match("/Content-Encoding: gzip/", $currentHeader)) {
             $is_gzipped = true;
         }
         $this->headers[] = $currentHeader;
     }
     $results = '';
     do {
         $_data = fread($fp, $this->maxlength);
         if (strlen($_data) == 0) {
             break;
         }
         $results .= $_data;
     } while (true);
     // gunzip
     if ($is_gzipped) {
         // per http://www.php.net/manual/en/function.gzencode.php
         $results = substr($results, 10);
         $results = gzinflate($results);
     }
     if ($this->read_timeout > 0 && $this->_check_timeout($fp)) {
         $this->status = -100;
         return false;
     }
     // check if there is a a redirect meta tag
     if (preg_match("'<meta[\\s]*http-equiv[^>]*?content[\\s]*=[\\s]*[\"\\']?\\d+;[\\s]*URL[\\s]*=[\\s]*([^\"\\']*?)[\"\\']?>'i", $results, $match)) {
         $this->_redirectaddr = $this->_expandlinks($match[1], $URI);
     }
     // have we hit our frame depth and is there frame src to fetch?
     if ($this->_framedepth < $this->maxframes && preg_match_all("'<frame\\s+.*src[\\s]*=[\\'\"]?([^\\'\"\\>]+)'i", $results, $match)) {
         $this->results[] = $results;
         for ($x = 0; $x < count($match[1]); $x++) {
             $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host);
         }
     } elseif (is_array($this->results)) {
         $this->results[] = $results;
     } else {
         $this->results = $results;
     }
     return true;
 }
 function create_thumbnail($attachment)
 {
     global $config;
     $thumbnail = NULL;
     $ext = get_extension($attachment);
     if ($ext == 'gif' or $ext == 'png' or $ext == 'jpg' or $ext == 'jpeg' or $ext == 'jpe') {
         $imageinfo = getimagesize($attachment);
         $new_width = $width = $imageinfo[0];
         $new_height = $height = $imageinfo[1];
         if ($width > $config['tpcthumbwidth'] or $height > $config['tpcthumbheight']) {
             switch ($imageinfo[2]) {
                 case 1:
                     if (!(viscacha_function_exists('imagecreatefromgif') and $image = @imagecreatefromgif($attachment))) {
                         $this->create_error($this->lang['tne_giferror']);
                     }
                     break;
                 case 2:
                     if (!(viscacha_function_exists('imagecreatefromjpeg') and $image = imagecreatefromjpeg($attachment))) {
                         $this->create_error($this->lang['tne_jpgerror']);
                     }
                     break;
                 case 3:
                     if (!(viscacha_function_exists('imagecreatefrompng') and $image = imagecreatefrompng($attachment))) {
                         $this->create_error($this->lang['tne_pngerror']);
                     }
                     break;
             }
             if ($image) {
                 $xratio = $width / $config['tpcthumbwidth'];
                 $yratio = $height / $config['tpcthumbheight'];
                 if ($xratio > $yratio) {
                     $new_width = round($width / $xratio);
                     $new_height = round($height / $xratio);
                 } else {
                     $new_width = round($width / $yratio);
                     $new_height = round($height / $yratio);
                 }
                 if ($config['gdversion'] == 1) {
                     if (!($thumbnail = @imagecreate($new_width, $new_height))) {
                         $this->create_error($this->lang['tne_gd1error']);
                     }
                     imagecopyresized($thumbnail, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
                 } else {
                     if (!($thumbnail = @imagecreatetruecolor($new_width, $new_height))) {
                         $this->create_error($this->lang['tne_truecolorerror']);
                     }
                     @imagecopyresampled($thumbnail, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
                     if (!version_compare(PHP_VERSION, '4.3.2', 'eq')) {
                         $this->UnsharpMask($thumbnail);
                     }
                     if ($ext == 'png') {
                         imagetruecolortopalette($thumbnail, true, 256);
                     }
                 }
                 return $thumbnail;
             } else {
                 $this->create_error($this->lang['tne_imageerror']);
             }
         } else {
             if ($imageinfo[0] == 0 and $imageinfo[1] == 0) {
                 return FALSE;
             }
         }
     }
     $this->set_cacheuri($attachment);
     return NULL;
 }
Пример #22
0
     $dirs[] = array('dir' => "designs/{$info['stylesheet']}/", 'func' => '');
 }
 $tempdir = "temp/";
 $error = false;
 $settings = $tempdir . 'design.ini';
 $myini = new INI();
 $myini->write($settings, $info);
 require_once 'classes/class.zip.php';
 $archive = new PclZip($tempdir . $file);
 $v_list = $archive->create($settings, PCLZIP_OPT_REMOVE_PATH, $tempdir);
 if ($v_list == 0) {
     $error = true;
 } else {
     foreach ($dirs as $dir) {
         $archive = new PclZip($tempdir . $file);
         if (!empty($dir['func']) && viscacha_function_exists($dir['func'])) {
             $list = $dir['func']($dir['dir']);
             $v_list = $archive->add($list, PCLZIP_OPT_REMOVE_PATH, $dir['dir'], PCLZIP_OPT_ADD_PATH, extract_dir($dir['dir'], false));
         } else {
             $v_list = $archive->add($dir['dir'], PCLZIP_OPT_REMOVE_PATH, $dir['dir'], PCLZIP_OPT_ADD_PATH, extract_dir($dir['dir'], false));
         }
         if ($v_list == 0) {
             $error = true;
             break;
         }
     }
 }
 if ($error) {
     echo head();
     unset($archive);
     $filesystem->unlink($tempdir . $file);
 function validateType($type)
 {
     /* check image type availability*/
     $is_available = FALSE;
     switch ($type) {
         case 'jpeg':
         case 'jpg':
             if (viscacha_function_exists("imagejpeg")) {
                 $is_available = TRUE;
             }
             break;
         case 'gif':
             if (viscacha_function_exists("imagegif")) {
                 $is_available = TRUE;
             }
             break;
         case 'png':
             if (viscacha_function_exists("imagepng")) {
                 $is_available = TRUE;
             }
             break;
         case 'wbmp':
             if (viscacha_function_exists("imagewbmp")) {
                 $is_available = TRUE;
             }
             break;
         case 'swf':
             if (class_exists("swfmovie")) {
                 $is_available = TRUE;
             }
             break;
     }
     if (!$is_available && viscacha_function_exists("imagejpeg")) {
         /* if not available, cast image type to jpeg*/
         return "jpeg";
     } else {
         if (!$is_available && !viscacha_function_exists("imagejpeg")) {
             die("No image support on this PHP server");
         } else {
             return $type;
         }
     }
 }
Пример #24
0
function pemftp_class_module()
{
    $mod_sockets = true;
    if (!extension_loaded('sockets')) {
        if (!viscacha_function_exists('dl')) {
            $mod_sockets = false;
        } else {
            $prefix = PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : '';
            if (!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) {
                $mod_sockets = false;
            }
        }
    }
    return $mod_sockets ? "sockets" : "pure";
}
Пример #25
0
 function SetCompression($compress)
 {
     //Set page compression
     if (viscacha_function_exists('gzcompress')) {
         $this->compress = $compress;
     } else {
         $this->compress = false;
     }
 }
function serverload($int = false)
{
    if ($int == false) {
        $unknown = '-';
    } else {
        $unknown = -1;
    }
    if (isWindows() == true) {
        return $unknown;
    }
    if (@file_exists("/proc/loadavg")) {
        $load = @file_get_contents("/proc/loadavg");
        $serverload = explode(" ", $load);
        $serverload[0] = round($serverload[0], 4);
    }
    if (viscacha_function_exists('sys_getloadavg')) {
        $serverload = @sys_getloadavg();
    }
    if (empty($serverload[0]) && viscacha_function_exists('exec') == true) {
        $load = @exec("uptime");
        $load = preg_split("~load averages?: ~i", $load);
        if (isset($load[1])) {
            $serverload = explode(",", $load[1]);
        }
    }
    if (isset($serverload[0])) {
        $returnload = trim($serverload[0]);
    }
    if (empty($returnload)) {
        $returnload = $unknown;
    }
    return $returnload;
}
function get_backtrace($skip)
{
    global $config;
    if (viscacha_function_exists('debug_backtrace')) {
        $backtrace = debug_backtrace();
    } else {
        $output = '<p>Backtrace is not available!</p>';
        return $output;
    }
    $path = realpath($config['fpath']);
    $output = '';
    foreach ($backtrace as $number => $trace) {
        // We skip the first one, because it only shows this file/function
        if ($number < $skip) {
            continue;
        }
        if (isset($trace['file'])) {
            // Strip the current directory from path
            $trace['file'] = str_replace(array($path, '\\'), array('', '/'), $trace['file']);
            $trace['file'] = substr($trace['file'], 1);
        }
        $args = array();
        if (isset($trace['args']) && is_array($trace['args'])) {
            foreach ($trace['args'] as $argument) {
                switch (gettype($argument)) {
                    case 'integer':
                    case 'double':
                        $args[] = $argument;
                        break;
                    case 'string':
                        $argument = htmlspecialchars(substr($argument, 0, 64)) . (strlen($argument) > 64 ? '...' : '');
                        $args[] = "'{$argument}'";
                        break;
                    case 'array':
                        $args[] = 'Array(' . count($argument) . ')';
                        break;
                    case 'object':
                        $args[] = 'Object(' . get_class($argument) . ')';
                        break;
                    case 'resource':
                        $args[] = 'Resource(' . strstr($a, '#') . ')';
                        break;
                    case 'boolean':
                        $args[] = $argument ? 'true' : 'false';
                        break;
                    case 'NULL':
                        $args[] = 'NULL';
                        break;
                    default:
                        $args[] = 'Unknown';
                }
            }
        }
        $trace['file'] = !isset($trace['file']) ? 'N/A' : $trace['file'];
        $trace['line'] = !isset($trace['line']) ? 'N/A' : $trace['line'];
        $trace['class'] = !isset($trace['class']) ? '' : $trace['class'];
        $trace['type'] = !isset($trace['type']) ? '' : $trace['type'];
        $output .= '<ul class="code">';
        $output .= '<li class="linetwo"><b>File:</b> ' . htmlspecialchars($trace['file']) . '</li>';
        $output .= '<li class="lineone"><b>Line:</b> ' . $trace['line'] . '</li>';
        $output .= '<li class="linetwo"><b>Call:</b> ' . htmlspecialchars($trace['class'] . $trace['type'] . $trace['function']) . '(' . (count($args) ? implode(', ', $args) : '') . ')</li>';
        $output .= '</ul>';
    }
    return $output;
}