Bladeren bron

Port wikipedia3d to FastAPI and remove legacy PHP

Lukas Goldschmidt 1 maand geleden
bovenliggende
commit
2c66f0c066

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+.venv/
+.uvicorn.pid
+uvicorn.log
+__pycache__/
+*.pyc

+ 70 - 0
PROJECT.md

@@ -0,0 +1,70 @@
+# PROJECT — Wikipedia3D Revival
+
+## Summary
+A 3D semantic web explorer built around Wikipedia/DBpedia that lets users **walk through knowledge**. The aim is to preserve the original “spatial discovery” feel while modernizing the tech stack and data sources.
+
+## Current state (2026 snapshot)
+- **Frontend:** legacy JS (jQuery + MooTools + old Three.js), global namespaces, no build step.
+- **Backend:** PHP proxies for CORS + lightweight API access.
+- **APIs:** Wikipedia API, DBpedia SPARQL, GeoNames; old Google Maps JS API with panoramio; AlchemyAPI (dead).
+- **Hosting:** originally on Apache; works with PHP built-in server for local dev.
+
+## Unique features worth preserving
+- Real-time 3D spawning of Wikipedia entities
+- Spatial browsing with first-person camera
+- Map-driven “find nearby” discovery
+- Favourites + blacklist + quick language switching
+- Lightweight, static-ish deployment (no heavy backend)
+
+## Known breakpoints
+- Panoramio library removed → map layer needs modernization
+- AlchemyAPI is shut down → remove/replace
+- HTTP endpoints + mixed content → fail under HTTPS
+- Hard-coded domain URLs → break local use
+
+## Success criteria (modernization)
+- Runs on modern browsers (no legacy polyfills)
+- Fully local-dev friendly (one command)
+- CORS-safe and configurable API endpoints
+- Maintains the signature UX: 3D walkable graph + map discovery
+- Easy deploy to static hosting or simple Node/PHP server
+
+---
+
+## Roadmap
+
+### Phase 1 — Stabilize (1–2 days)
+- Replace hard-coded URLs with relative or config values
+- Consolidate configuration into a single `config.js`
+- Add minimal dev script: `npm run dev` or `php -S`
+
+### Phase 2 — Frontend modernization (1–2 weeks)
+- Upgrade to modern Three.js (ES modules)
+- Replace MooTools and outdated jQuery plugins
+- Refactor core logic into modules (`browser`, `item`, `data`, `ui`)
+- Add linting + formatting
+
+### Phase 3 — Data layer refresh (1 week)
+- Add Wikidata SPARQL as primary
+- Cache + rate-limit API requests in proxy
+- Replace deprecated endpoints (AlchemyAPI, Panoramio)
+
+### Phase 4 — Experience upgrades (optional)
+- Better layout algorithms for nodes
+- A “timeline trail” of explored topics
+- WebXR / VR mode (optional)
+- Mobile-friendly UI pass
+
+---
+
+## Risks / considerations
+- API changes may alter data availability and result structures.
+- Rewriting the UI may unintentionally lose the “feel” of the original.
+- The proxy should be secured to prevent abuse in public deployments.
+
+---
+
+## Immediate recommendation
+Start with **Phase 1** (URL fixes + config), then build a clean **Phase 2** modern frontend while preserving the original UI layout and controls.
+
+If you want, I can begin Phase 1 now and open a modernization branch for Phase 2.

+ 95 - 0
README.md

@@ -0,0 +1,95 @@
+# Wikipedia3D (legacy revival)
+
+A 2011-era WebGL + Semantic Web mashup that renders Wikipedia/DBpedia entities in a navigable 3D space, with map-based discovery and a rich UI for favourites, blacklisting, and exploration. This repo contains the original PHP/JS frontend and lightweight proxy scripts used for API calls.
+
+---
+
+## Quick assessment (what you have today)
+
+**Strengths**
+- Unique concept still feels fresh: spatial exploration of knowledge, fast discovery loop (search → spawn 3D item → navigate → branch).
+- Feature-rich UX: favourites, blacklist, keyboard navigation, skybox themes, map-driven discovery.
+- Fully client-driven rendering with Three.js and simple PHP utilities—no heavy backend required.
+
+**Pain points / risks**
+- **Very old JS stack** (jQuery 1.6, MooTools, ancient Three.js) and global namespace design.
+- **Deprecated APIs**: Google Maps “panoramio” library is discontinued; AlchemyAPI is defunct.
+- **Hard-coded domain URLs** (`wikipedia3d.world.eu.org`) break local use and make the app fragile.
+- **Mixed-content/HTTP**: many endpoints are `http://` which modern browsers block on `https://`.
+- **CORS + proxy reliance**: API calls are routed via PHP proxies; security + reliability needs care.
+
+---
+
+## Quick local hosting (FastAPI replacement)
+
+The legacy PHP proxy has been replaced by a small FastAPI app that also serves the static site.
+
+```bash
+cd /home/lucky/.openclaw/workspace/wikipedia3d
+python3 -m venv .venv
+source .venv/bin/activate
+pip install -r server/requirements.txt
+uvicorn server.app:app --reload --port 8088
+```
+
+Open:
+- Landing page: **http://localhost:8088/**
+- App itself: **http://localhost:8088/wikipedia3d/**
+
+> ⚠️ For best results run over **HTTP**, not HTTPS, because the code uses legacy HTTP endpoints.
+
+### What changed
+- `server/app.py` implements `/proxy` (replacement for `ba-simple-proxy.php`).
+- `wikipedia3d/index.html` and `/index.html` are static HTML replacements for the old PHP pages.
+- Proxy + icon URLs now point to relative paths to work locally.
+
+---
+
+## Outlook: modernizing while keeping the soul
+
+**Goal:** Preserve the core experience (3D exploration + semantic discovery + map-driven expansion) while upgrading to a modern, maintainable stack.
+
+### Phase 1 — Stabilize (lowest effort, highest payoff)
+- Replace hard-coded URLs with relative paths.
+- Add `.env` or config file for API endpoints/keys (Google Maps, GeoNames).
+- Move inline scripts to files; reduce global pollution.
+- Add a tiny local dev server script (Node or PHP).
+
+### Phase 2 — Modern frontend
+- Upgrade to a current Three.js and refactor rendering to ES modules.
+- Replace MooTools and legacy jQuery usage with vanilla JS or a minimal modern library.
+- Use `fetch()` + async/await instead of jQuery AJAX.
+- Replace the deprecated Google Maps bits (Panoramio) with Maps JS API + Places/StreetView or Mapbox.
+
+### Phase 3 — Data + semantics refresh
+- Migrate from DBpedia-only to **Wikidata SPARQL** as primary, keep DBpedia as fallback.
+- Replace AlchemyAPI (dead) with modern entity extraction or just remove it.
+- Add caching and rate limiting in the proxy.
+
+### Phase 4 — Experience upgrade (keep the magic)
+- Improved camera controls (orbit + FPS toggle).
+- Smooth item layout + collision avoidance.
+- Mini-map + bookmarks + “topic trails” visualization.
+- Optional VR/WebXR mode while retaining keyboard-first navigation.
+
+---
+
+## Key dependencies (legacy)
+- jQuery 1.6.2, jQuery UI 1.8
+- MooTools 1.3
+- Three.js (very old build)
+- Google Maps JS API (panoramio library deprecated)
+- DBpedia SPARQL, Wikipedia API, GeoNames
+- PHP proxy scripts (ba-simple-proxy.php)
+
+---
+
+## Next steps (suggested)
+1. Confirm the app runs locally with the PHP server.
+2. Apply the URL fixes above.
+3. Decide on a modern map provider (Google Maps w/ key vs Mapbox).
+4. I can then create a clean “modernization branch” with ES modules + updated Three.js while preserving the UI flow.
+
+---
+
+If you want, I can start a staged refactor plan and implement Phase 1 and Phase 2 step-by-step.

+ 0 - 0
index.php → index.html


+ 27 - 0
kill.sh

@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Stops the Wikipedia3D FastAPI server.
+
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+PID_FILE="$ROOT_DIR/.uvicorn.pid"
+
+if [[ -f "$PID_FILE" ]]; then
+  PID="$(cat "$PID_FILE")"
+  if kill -0 "$PID" 2>/dev/null; then
+    kill "$PID"
+    echo "Stopped server (pid $PID)."
+  else
+    echo "PID file found but process not running."
+  fi
+  rm -f "$PID_FILE"
+  exit 0
+fi
+
+# Fallback if pid file is missing.
+if pgrep -f "uvicorn server.app:app" >/dev/null; then
+  pkill -f "uvicorn server.app:app"
+  echo "Stopped server via pkill."
+else
+  echo "Server not running."
+fi

+ 9 - 0
restart.sh

@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Restarts the Wikipedia3D FastAPI server.
+
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+"$ROOT_DIR/kill.sh"
+"$ROOT_DIR/run.sh"

+ 30 - 0
run.sh

@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Runs the Wikipedia3D FastAPI server in the background.
+# Uses a project-local venv to avoid global Python pollution.
+
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+VENV_DIR="$ROOT_DIR/.venv"
+PID_FILE="$ROOT_DIR/.uvicorn.pid"
+
+if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
+  echo "Server already running (pid $(cat "$PID_FILE"))."
+  exit 0
+fi
+
+if [[ ! -d "$VENV_DIR" ]]; then
+  python3 -m venv "$VENV_DIR"
+fi
+
+# shellcheck disable=SC1091
+source "$VENV_DIR/bin/activate"
+
+pip install -r "$ROOT_DIR/server/requirements.txt" >/dev/null
+
+nohup uvicorn server.app:app --host 0.0.0.0 --port 8088 --reload \
+  >"$ROOT_DIR/uvicorn.log" 2>&1 &
+
+echo $! > "$PID_FILE"
+
+echo "Started Wikipedia3D FastAPI (pid $(cat "$PID_FILE"))."

+ 95 - 0
server/app.py

@@ -0,0 +1,95 @@
+"""FastAPI replacement for the legacy PHP proxy + static hosting.
+
+Why this exists:
+- Replace ba-simple-proxy.php (CORS proxy) with a safer, modern service.
+- Serve the static Wikipedia3D frontend without Apache/PHP.
+"""
+
+from __future__ import annotations
+
+import os
+from pathlib import Path
+from typing import Optional
+from urllib.parse import urlparse
+
+import httpx
+from fastapi import FastAPI, HTTPException, Query, Request
+from fastapi.responses import FileResponse, JSONResponse, Response
+from fastapi.staticfiles import StaticFiles
+
+PROJECT_ROOT = Path(__file__).resolve().parents[1]
+APP_DIR = PROJECT_ROOT / "wikipedia3d"
+
+# Allowlist keeps the proxy safe; extend as needed.
+ALLOWED_HOST_SUFFIXES = {
+    "wikipedia.org",
+    "wikimedia.org",
+    "dbpedia.org",
+    "geonames.org",
+    "query.wikidata.org",
+}
+
+
+def _is_allowed_url(raw_url: str) -> bool:
+    try:
+        parsed = urlparse(raw_url)
+    except Exception:
+        return False
+
+    if parsed.scheme not in {"http", "https"}:
+        return False
+    if not parsed.hostname:
+        return False
+
+    host = parsed.hostname.lower()
+    return any(host == suffix or host.endswith("." + suffix) for suffix in ALLOWED_HOST_SUFFIXES)
+
+
+app = FastAPI(title="Wikipedia3D Proxy")
+
+# Serve the static site (including index.html we generate).
+app.mount("/static", StaticFiles(directory=PROJECT_ROOT), name="static")
+
+
+@app.get("/")
+def root() -> FileResponse:
+    return FileResponse(PROJECT_ROOT / "index.html")
+
+
+@app.get("/wikipedia3d/")
+def app_root() -> FileResponse:
+    return FileResponse(APP_DIR / "index.html")
+
+
+@app.get("/proxy")
+async def proxy(
+    request: Request,
+    url: str = Query(..., description="Absolute URL to fetch"),
+    mode: Optional[str] = Query(None, description="Use 'native' to stream raw content"),
+) -> Response:
+    if not _is_allowed_url(url):
+        raise HTTPException(status_code=400, detail="URL not allowed")
+
+    # Forward user agent to upstream where helpful.
+    headers = {"User-Agent": request.headers.get("user-agent", "Wikipedia3D-Proxy")}
+
+    async with httpx.AsyncClient(timeout=20.0, follow_redirects=True) as client:
+        upstream = await client.get(url, headers=headers)
+
+    if mode == "native":
+        # Return upstream content + content-type only (mimics PHP native mode).
+        content_type = upstream.headers.get("content-type", "application/octet-stream")
+        return Response(content=upstream.content, media_type=content_type)
+
+    # JSON mode (mimics ba-simple-proxy.php default).
+    payload = {
+        "contents": upstream.json() if "application/json" in upstream.headers.get("content-type", "") else upstream.text,
+        "status": {"http_code": upstream.status_code},
+    }
+    return JSONResponse(payload)
+
+
+# Convenience: serve assets directly under root (matching old paths)
+# Example: /wikipedia3d/images/..., /css/... etc.
+app.mount("/wikipedia3d", StaticFiles(directory=APP_DIR), name="wikipedia3d")
+app.mount("/", StaticFiles(directory=PROJECT_ROOT), name="root-static")

+ 3 - 0
server/requirements.txt

@@ -0,0 +1,3 @@
+fastapi>=0.110
+uvicorn[standard]>=0.24
+httpx>=0.26

+ 0 - 259
wikipedia3d/ba-simple-proxy.php

@@ -1,259 +0,0 @@
-<?PHP
-error_reporting (1);
-// Script: Simple PHP Proxy: Get external HTML, JSON and more!
-//
-// *Version: 1.6, Last updated: 1/24/2009*
-//
-// Project Home - http://benalman.com/projects/php-simple-proxy/
-// GitHub       - http://github.com/cowboy/php-simple-proxy/
-// Source       - http://github.com/cowboy/php-simple-proxy/raw/master/ba-simple-proxy.php
-//
-// About: License
-//
-// Copyright (c) 2010 "Cowboy" Ben Alman,
-// Dual licensed under the MIT and GPL licenses.
-// http://benalman.com/about/license/
-//
-// About: Examples
-//
-// This working example, complete with fully commented code, illustrates one way
-// in which this PHP script can be used.
-//
-// Simple - http://benalman.com/code/projects/php-simple-proxy/examples/simple/
-//
-// About: Release History
-//
-// 1.6 - (1/24/2009) Now defaults to JSON mode, which can now be changed to
-//       native mode by specifying ?mode=native. Native and JSONP modes are
-//       disabled by default because of possible XSS vulnerability issues, but
-//       are configurable in the PHP script along with a url validation regex.
-// 1.5 - (12/27/2009) Initial release
-//
-// Topic: GET Parameters
-//
-// Certain GET (query string) parameters may be passed into ba-simple-proxy.php
-// to control its behavior, this is a list of these parameters.
-//
-//   url - The remote URL resource to fetch. Any GET parameters to be passed
-//     through to the remote URL resource must be urlencoded in this parameter.
-//   mode - If mode=native, the response will be sent using the same content
-//     type and headers that the remote URL resource returned. If omitted, the
-//     response will be JSON (or JSONP). <Native requests> and <JSONP requests>
-//     are disabled by default, see <Configuration Options> for more information.
-//   callback - If specified, the response JSON will be wrapped in this named
-//     function call. This parameter and <JSONP requests> are disabled by
-//     default, see <Configuration Options> for more information.
-//   user_agent - This value will be sent to the remote URL request as the
-//     `User-Agent:` HTTP request header. If omitted, the browser user agent
-//     will be passed through.
-//   send_cookies - If send_cookies=1, all cookies will be forwarded through to
-//     the remote URL request.
-//   send_session - If send_session=1 and send_cookies=1, the SID cookie will be
-//     forwarded through to the remote URL request.
-//   full_headers - If a JSON request and full_headers=1, the JSON response will
-//     contain detailed header information.
-//   full_status - If a JSON request and full_status=1, the JSON response will
-//     contain detailed cURL status information, otherwise it will just contain
-//     the `http_code` property.
-//
-// Topic: POST Parameters
-//
-// All POST parameters are automatically passed through to the remote URL
-// request.
-//
-// Topic: JSON requests
-//
-// This request will return the contents of the specified url in JSON format.
-//
-// Request:
-//
-// > ba-simple-proxy.php?url=http://example.com/
-//
-// Response:
-//
-// > { "contents": "<html>...</html>", "headers": {...}, "status": {...} }
-//
-// JSON object properties:
-//
-//   contents - (String) The contents of the remote URL resource.
-//   headers - (Object) A hash of HTTP headers returned by the remote URL
-//     resource.
-//   status - (Object) A hash of status codes returned by cURL.
-//
-// Topic: JSONP requests
-//
-// This request will return the contents of the specified url in JSONP format
-// (but only if $enable_jsonp is enabled in the PHP script).
-//
-// Request:
-//
-// > ba-simple-proxy.php?url=http://example.com/&callback=foo
-//
-// Response:
-//
-// > foo({ "contents": "<html>...</html>", "headers": {...}, "status": {...} })
-//
-// JSON object properties:
-//
-//   contents - (String) The contents of the remote URL resource.
-//   headers - (Object) A hash of HTTP headers returned by the remote URL
-//     resource.
-//   status - (Object) A hash of status codes returned by cURL.
-//
-// Topic: Native requests
-//
-// This request will return the contents of the specified url in the format it
-// was received in, including the same content-type and other headers (but only
-// if $enable_native is enabled in the PHP script).
-//
-// Request:
-//
-// > ba-simple-proxy.php?url=http://example.com/&mode=native
-//
-// Response:
-//
-// > <html>...</html>
-//
-// Topic: Notes
-//
-// * Assumes magic_quotes_gpc = Off in php.ini
-//
-// Topic: Configuration Options
-//
-// These variables can be manually edited in the PHP file if necessary.
-//
-//   $enable_jsonp - Only enable <JSONP requests> if you really need to. If you
-//     install this script on the same server as the page you're calling it
-//     from, plain JSON will work. Defaults to false.
-//   $enable_native - You can enable <Native requests>, but you should only do
-//     this if you also whitelist specific URLs using $valid_url_regex, to avoid
-//     possible XSS vulnerabilities. Defaults to false.
-//   $valid_url_regex - This regex is matched against the url parameter to
-//     ensure that it is valid. This setting only needs to be used if either
-//     $enable_jsonp or $enable_native are enabled. Defaults to '/.*/' which
-//     validates all URLs.
-//
-// ############################################################################
-include("libcurlemu.inc.php");
-
-// Change these configuration options if needed, see above descriptions for info.
-$enable_jsonp = false;
-$enable_native = true;
-$valid_url_regex = '/^http\:\/\/.*/';
-
-// ############################################################################
-//$script_directory = substr($_SERVER['REQUEST_URL'], 0, strrpos($_SERVER['REQUEST_URL'], '/'));
-
-$script_directory = substr($_SERVER['REQUEST_URL'], 0, strrpos($_SERVER['REQUEST_URL'], '/'));
-
-//$script_directory = "http://www.world.eu.org/~lucky/wiki_browser/";
-
-$url = $_GET['url'];
-
-if (!$url) {
-
-	// Passed url not specified.
-	$contents = 'ERROR: url not specified';
-	$status = array('http_code' => 'ERROR');
-
-} else {
-	if (!preg_match($valid_url_regex, $url)) {
-
-		// Passed url doesn't match $valid_url_regex.
-	$url = $script_directory . $url;
-	print($url); 
-	}
-	$ch = curl_init($url);
-
-	if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
-		curl_setopt($ch, CURLOPT_POST, true);
-		curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
-	}
-
-	if ($_GET['send_cookies']) {
-		$cookie = array();
-		foreach ($_COOKIE as $key => $value) {
-			$cookie[] = $key . '=' . $value;
-		}
-		if ($_GET['send_session']) {
-			$cookie[] = SID;
-		}
-		$cookie = implode('; ', $cookie);
-
-		curl_setopt($ch, CURLOPT_COOKIE, $cookie);
-	}
-
-//	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
-	curl_setopt($ch, CURLOPT_HEADER, true);
-	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
-	curl_setopt($ch, CURLOPT_USERAGENT, $_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT']);
-
-	list($header, $contents) = preg_split('/([\r\n][\r\n])\\1/', curl_exec($ch), 2);
-
-	$status = curl_getinfo($ch);
-
-	curl_close($ch);
-}
-
-// Split header text into an array.
-$header_text = preg_split('/[\r\n]+/', $header);
-
-if ($_GET['mode'] == 'native') {
-	if (!$enable_native) {
-		$contents = 'ERROR: invalid mode';
-		$status = array('http_code' => 'ERROR');
-	}
-
-	// Propagate headers to response.
-	foreach ($header_text as $header) {
-		if (preg_match('/^(?:Content-Type|Content-Language|Set-Cookie):/i', $header)) {
-			header($header);
-		}
-	}
-
-	print $contents;
-
-} else {
-
-	// $data will be serialized into JSON data.
-	$data = array();
-
-	// Propagate all HTTP headers into the JSON data object.
-	if ($_GET['full_headers']) {
-		$data['headers'] = array();
-
-		foreach ($header_text as $header) {
-			preg_match('/^(.+?):\s+(.*)$/', $header, $matches);
-			if ($matches) {
-				$data['headers'][$matches[1]] = $matches[2];
-			}
-		}
-	}
-
-	// Propagate all cURL request / response info to the JSON data object.
-	if ($_GET['full_status']) {
-		$data['status'] = $status;
-	} else {
-		$data['status'] = array();
-		$data['status']['http_code'] = $status['http_code'];
-	}
-
-	// Set the JSON data object contents, decoding it from JSON if possible.
-	$decoded_json = json_decode($contents);
-	$data['contents'] = $decoded_json ? $decoded_json : $contents;
-
-	// Generate appropriate content-type header.
-	$is_xhr = strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
-	header('Content-type: application/' . ($is_xhr ? 'json' : 'x-javascript'));
-
-	// Get JSONP callback.
-	$jsonp_callback = $enable_jsonp && isset($_GET['callback']) ? $_GET['callback'] : null;
-
-	// Generate JSON/JSONP string
-	$json = json_encode($data);
-
-	print $jsonp_callback ? "$jsonp_callback($json)" : $json;
-
-}
-?>

+ 0 - 135
wikipedia3d/camtest.php

@@ -1,135 +0,0 @@
-<!DOCTYPE HTML>
-<html xmlns="http://www.w3.org/1999/xhtml">
-	<head>
-		<title>Wikipedia 3D</title>
-		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-		<link rel="stylesheet" href="css/wb.css" type="text/css">
-		<link rel="stylesheet" href="css/ui-darkness/jquery-ui-1.8.15.custom.css" type="text/css">
-		<script type="text/javascript"
-		src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
-		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools.js"></script>
-		<script type="text/javascript" src="js/query-min.js"></script>
-		<script type="text/javascript" src="js/"></script>
-
-	</head>
-	<body>
-		<script type="text/javascript">
-if(!Detector.webgl)
-Detector.addGetWebGLMessage();
-
-var container, timer;
-
-var camera, scene, webglRenderer;
-var cameraCube, sceneCube;
-
-var mesh, zmesh, lightMesh, geometry;
-var spheres = [];
-
-var directionalLight, pointLight;
-
-var mouseX = 0;
-var mouseY = 0;
-
-var windowHalfX = window.innerWidth / 2;
-var windowHalfY = window.innerHeight / 2;
-
-init();
-animate();
-
-function init() {
-container = document.createElement('div');
-document.body.appendChild(container);
-camera = new LG.THREE.FirstPersonCamera({
-fov : 33,
-aspect : 800 / 600,
-near : 1,
-far : 30000,
-//				target : this.ctarget,
-lookSpeed : 1.8,
-movementSpeed : 220,
-noFly : true,
-activeLook : false,
-domElemnt : container,
-verticalMin : Math.PI * 0.35,
-verticalMax : Math.PI * 0.65
-});
-scene = new THREE.Scene();
-plane = new THREE.Mesh(new THREE.PlaneGeometry(2200, 2200, 20, 20), new THREE.MeshBasicMaterial({
-color : 0x339933,
-wireframe : true
-}));
-plane.rotation.x = -90 * Math.PI / 180;
-plane.position.y = -170;
-
-scene.addObject(plane);
-
-		pointLight = new THREE.PointLight(0xFFFFFF);
-		pointLight.position.x = 300;
-		pointLight.position.y = 1000;
-		pointLight.position.z = 630;
-		scene.addLight(pointLight);
-
-
-
-var jsonLoader = new THREE.JSONLoader();
-jsonLoader.load( { model: "js/Building_97.js", callback: function( geometry ) { createScene( geometry) } } );
-
-camera.Browser = {
-offset : {
-left : 0,
-top : 0
-},
-width : window.innerWidth,
-height : window.innerHeight,
-click_items : [plane],
-projector : new THREE.Projector()
-
-};
-plane.clicked=function(){
-console.log("clicked");
-camera.panTo(new THREE.Vector3(0,10,10),45,-10)
-};
-plane.mouseIn=function(){
-};
-plane.mouseOut=function(){
-};
-
-webglRenderer = new THREE.WebGLRenderer();
-webglRenderer.setSize(window.innerWidth, window.innerHeight);
-//webglRenderer.autoClear = false;
-container.appendChild(webglRenderer.domElement);
-
-}
-
-function animate() {
-
-requestAnimationFrame(animate);
-
-render();
-
-}
-
-function render() {
-timer = new Date().getTime() * 0.0001;
-
-//webglRenderer.clear();
-
-webglRenderer.render(scene, camera);
-
-}
-function createScene( geometry ) {
-
-	var mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
-	console.log(mesh);
-//	mesh.scale = new THREE.Vector3(20,20,20);
-	mesh.scale.x = 25;
-	mesh.scale.y = 25;
-	mesh.scale.z = 25;
-	mesh.position.y -=130;
-	mesh.geometry.materials[10].transparent=true;
-	
-	scene.addObject(mesh);
-}
-		</script>
-	</body>
-</html>

+ 0 - 1162
wikipedia3d/class_HTTPRetriever.php

@@ -1,1162 +0,0 @@
-<?php
-/* HTTP Retriever
- * Version v1.1.10
- * Copyright 2004-2007, Steve Blinch
- * http://code.blitzaffe.com
- * ============================================================================
- *
- * DESCRIPTION
- *
- * Provides a pure-PHP implementation of an HTTP v1.1 client, including support
- * for chunked transfer encoding and user agent spoofing.  Both GET and POST
- * requests are supported.
- *
- * This can be used in place of something like CURL or WGET for HTTP requests.
- * Native SSL (HTTPS) requests are also supported if the OpenSSL extension is 
- * installed under PHP v4.3.0 or greater.
- *
- * If native SSL support is not available, the class will also check for the
- * CURL extension; if it's installed, it will transparently be used for SSL
- * (HTTPS) requests.
- *
- * If neither native SSL support nor the CURL extension are available, and
- * libcurlemu (a CURL emulation library available from our web site) is found,
- * the class will also check for the CURL console binary (usually in 
- * /usr/bin/curl); if it's installed, it will transparently be used for SSL
- * requests.
- *
- * In short, if it's possible to make an HTTP/HTTPS request from your server,
- * this class can most likely do it.
- *
- *
- * HISTORY
- *
- * 1.1.10 (13-Feb-2006)
- *		- Fixed bug wherein libcurlemu may not be correctly included when
- *		  needed.
- *		- Fixed bug wherein stream read timeouts may not be recognized
- *		- Adjusted timeout handling code to better handle timeout conditions
- *		- Added intelligent caching support
- *		- Caching is now better-handled for high-volume requests
- *		- Added postprocessing callback support
- *		- Improved redirect support
- *		- Fixed bug in which POST requests couldn't use GET-style query strings
- *		- Added header cleanup between requests
- *		- Added partial proxy support via $http->curl_proxy (only useable when
- *		  $http->force_curl is TRUE; internal support not yet implemented)
- *
- *
- * 1.1.9 (11-Oct-2006)
- *		- Added set_transfer_display() and default_transfer_callback()
- *		  methods for transfer progress tracking
- *		- Suppressed possible "fatal protocol error" when remote SSL server
- *		  closes the connection early
- *		- Added get_content_type() method
- *		- make_query_string() now handles arrays
- *
- * 1.1.8 (19-Jun-2006)
- *		- Added set_progress_display() and default_progress_callback()
- *		  methods for debug output
- *		- Added support for relative URLs in HTTP redirects
- *		- Added cookie support (sending and receiving)
- *		- Numerous bug fixes
- *
- * 1.1.7 (18-Apr-2006)
- *		- Added support for automatically following HTTP redirects
- *		- Added ::get_error() method to get any available error message (be
- *		  it an HTTP result error or an internal/connection error)
- *		- Added ::cache_hit variable to determine whether the page was cached
- *
- * 1.1.6 (04-Mar-2006)
- *		- Added stream_timeout class variable.
- *		- Added progress_callback class variable.
- *		- Added support for braindead servers that ignore Connection: close
- *
- *
- * EXAMPLE
- *
- * // HTTPRetriever usage example
- * require_once("class_HTTPRetriever.php");
- * $http = &new HTTPRetriever();
- *
- *
- * // Example GET request:
- * // ----------------------------------------------------------------------------
- * $keyword = "blitzaffe code"; // search Google for this keyword
- * if (!$http->get("http://www.google.com/search?hl=en&q=%22".urlencode($keyword)."%22&btnG=Search&meta=")) {
- *     echo "HTTP request error: #{$http->result_code}: {$http->result_text}";
- *     return false;
- * }
- * echo "HTTP response headers:<br><pre>";
- * var_dump($http->response_headers);
- * echo "</pre><br>";
- * 
- * echo "Page content:<br><pre>";
- * echo $http->response;
- * echo "</pre>";
- * // ----------------------------------------------------------------------------
- *  
- *
- * // Example POST request:
- * // ----------------------------------------------------------------------------
- * $keyword = "blitzaffe code"; // search Google for this keyword
- * $values = array(
- *     "hl"=>"en",
- *     "q"=>"%22".urlencode($keyword)."%22",
- *     "btnG"=>"Search",
- *     "meta"=>""
- * );
- * // Note: This example is just to demonstrate the POST equivalent of the GET
- * // example above; running this script will return a 501 Not Implemented, as
- * // Google does not support POST requests.
- * if (!$http->post("http://www.google.com/search",$http->make_query_string($values))) {
- *     echo "HTTP request error: #{$http->result_code}: {$http->result_text}";
- *     return false;
- * }
- * echo "HTTP response headers:<br><pre>";
- * var_dump($http->response_headers);
- * echo "</pre><br>";
- * 
- * echo "Page content:<br><pre>";
- * echo $http->response;
- * echo "</pre>";
- * // ----------------------------------------------------------------------------
- *
- *
- * LICENSE
- *
- * This script is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * This script is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- * details.
- *	
- * You should have received a copy of the GNU General Public License along
- * with this script; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-// define user agent ID's
-define("UA_EXPLORER",0);
-define("UA_MOZILLA",1);
-define("UA_FIREFOX",2);
-define("UA_OPERA",3);
-
-// define progress message severity levels
-define('HRP_DEBUG',0);
-define('HRP_INFO',1);
-define('HRP_ERROR',2);
-
-if (!defined("CURL_PATH")) define("CURL_PATH","/usr/bin/curl");
-
-// if the CURL extension is not loaded, but the CURL Emulation Library is found, try
-// to load it
-if (!extension_loaded("curl") && !defined('HTTPR_NO_REDECLARE_CURL') ) {
-	foreach (array(dirname(__FILE__)."/",dirname(__FILE__)."/libcurlemu/") as $k=>$libcurlemupath) {
-		$libcurlemuinc = $libcurlemupath.'libcurlemu.inc.php';
-		if (is_readable($libcurlemuinc)) require_once($libcurlemuinc);
-	}
-}
-
-class HTTPRetriever {
-	
-	// Constructor
-	function HTTPRetriever() {
-		// default HTTP headers to send with all requests
-		$this->headers = array(
-			"Referer"=>"",
-			"User-Agent"=>"HTTPRetriever/1.0",
-			"Connection"=>"close"
-		);
-		
-		// HTTP version (has no effect if using CURL)
-		$this->version = "1.1";
-		
-		// Normally, CURL is only used for HTTPS requests; setting this to
-		// TRUE will force CURL for HTTP requests as well.  Not recommended.
-		$this->force_curl = false;	
-		
-		// If you don't want to use CURL at all, set this to TRUE.
-		$this->disable_curl = false;
-		
-		// If HTTPS request return an error message about SSL certificates in
-		// $this->error and you don't care about security, set this to TRUE
-		$this->insecure_ssl = false;
-		
-		// Set the maximum time to wait for a connection
-		$this->connect_timeout = 15;
-		
-		// Set the maximum time to allow a transfer to run, or 0 to disable.
-		$this->max_time = 0;
-		
-		// Set the maximum time for a socket read/write operation, or 0 to disable.
-		$this->stream_timeout = 0;
-		
-		// If you're making an HTTPS request to a host whose SSL certificate
-		// doesn't match its domain name, AND YOU FULLY UNDERSTAND THE
-		// SECURITY IMPLICATIONS OF IGNORING THIS PROBLEM, set this to TRUE.
-		$this->ignore_ssl_hostname = false;
-		
-		// If TRUE, the get() and post() methods will close the connection
-		// and return immediately after receiving the HTTP result code
-		$this->result_close = false;
-		
-		// If set to a positive integer value, retrieved pages will be cached
-		// for this number of seconds.  Any subsequent calls within the cache
-		// period will return the cached page, without contacting the remote
-		// server.
-		$this->caching = false;
-		
-		// If TRUE and $this->caching is not false, retrieved pages/files will be
-		// cached only if they appear to be static.
-		$this->caching_intelligent = false;
-		
-		// If TRUE, cached files will be stored in subdirectories corresponding
-		// to the first 2 letters of the hash filename
-		$this->caching_highvolume = false;
-
-		// If $this->caching is enabled, this specifies the folder under which
-		// cached pages are saved.
-		$this->cache_path = '/tmp/';
-		
-		// Set these to perform basic HTTP authentication
-		$this->auth_username = '';
-		$this->auth_password = '';
-
-		// Optionally set this to a valid callback method to have HTTPRetriever
-		// provide page preprocessing capabilities to your script.  If set, this
-		// method should accept two arguments: an object representing an instance
-		// of HTTPRetriever, and a string containing the page contents
-		$this->page_preprocessor = null;
-		
-		// Optionally set this to a valid callback method to have HTTPRetriever
-		// provide progress messages.  Your callback must accept 2 parameters:
-		// an integer representing the severity (0=debug, 1=information, 2=error),
-		// and a string representing the progress message
-		$this->progress_callback = null;
-		
-		// Optionally set this to a valid callback method to have HTTPRetriever
-		// provide bytes-transferred messages.  Your callbcak must accept 2
-		// parameters: an integer representing the number of bytes transferred,
-		// and an integer representing the total number of bytes expected (or
-		// -1 if unknown).
-		$this->transfer_callback = null;
-		
-		// Set this to TRUE if you HTTPRetriever to transparently follow HTTP
-		// redirects (code 301, 302, 303, and 307).  Optionally set this to a
-		// numeric value to limit the maximum number of redirects to the specified
-		// value.  (Redirection loops are detected automatically.)
-		// Note that non-GET/HEAD requests will NOT be redirected except on code
-		// 303, as per HTTP standards.
-		$this->follow_redirects = false;
-	}
-	
-	// Send an HTTP GET request to $url; if $ipaddress is specified, the
-	// connection will be made to the selected IP instead of resolving the 
-	// hostname in $url.
-	//
-	// If $cookies is set, it should be an array in one of two formats.
-	//
-	// Either: $cookies[ 'cookiename' ] = array (
-	//		'/path/'=>array(
-	//			'expires'=>time(),
-	//			'domain'=>'yourdomain.com',
-	//			'value'=>'cookievalue'
-	//		)
-	// );
-	//
-	// Or, a more simplified format:
-	//	$cookies[ 'cookiename' ] = 'value';
-	//
-	// The former format will automatically check to make sure that the path, domain,
-	// and expiration values match the HTTP request, and will only send the cookie if
-	// they do match.  The latter will force the cookie to be set for the HTTP request
-	// unconditionally.
-	// 
-	function get($url,$ipaddress = false,$cookies = false) {
-		$this->method = "GET";
-		$this->post_data = "";
-		$this->connect_ip = $ipaddress;
-		return $this->_execute_request($url,$cookies);
-	}
-	
-	// Send an HTTP POST request to $url containing the POST data $data.  See ::get()
-	// for a description of the remaining arguments.
-	function post($url,$data="",$ipaddress = false,$cookies = false) {
-		$this->method = "POST";
-		$this->post_data = $data;
-		$this->connect_ip = $ipaddress;
-		return $this->_execute_request($url,$cookies);
-	}
-	
-	// Send an HTTP HEAD request to $url.  See ::get() for a description of the arguments.	
-	function head($url,$ipaddress = false,$cookies = false) {
-		$this->method = "HEAD";
-		$this->post_data = "";
-		$this->connect_ip = $ipaddress;
-		return $this->_execute_request($url,$cookies);
-	}
-		
-	// send an alternate (non-GET/POST) HTTP request to $url
-	function custom($method,$url,$data="",$ipaddress = false,$cookies = false) {
-		$this->method = $method;
-		$this->post_data = $data;
-		$this->connect_ip = $ipaddress;
-		return $this->_execute_request($url,$cookies);
-	}	
-	
-	function array_to_query($arrayname,$arraycontents) {
-		$output = "";
-		foreach ($arraycontents as $key=>$value) {
-			if (is_array($value)) {
-				$output .= $this->array_to_query(sprintf('%s[%s]',$arrayname,urlencode($key)),$value);
-			} else {
-				$output .= sprintf('%s[%s]=%s&',$arrayname,urlencode($key),urlencode($value));
-			}
-		}
-		return $output;
-	}
-	
-	// builds a query string from the associative array array $data;
-	// returns a string that can be passed to $this->post()
-	function make_query_string($data) {
-		$output = "";
-		if (is_array($data)) {
-			foreach ($data as $name=>$value) {
-				if (is_array($value)) {
-					$output .= $this->array_to_query(urlencode($name),$value);
-				} elseif (is_scalar($value)) {
-					$output .= urlencode($name)."=".urlencode($value)."&";
-				} else {
-					$output .= urlencode($name)."=".urlencode(serialize($value)).'&';
-				}
-			}
-		}
-		return substr($output,0,strlen($output)-1);
-	}
-
-	
-	// this is pretty limited... but really, if you're going to spoof you UA, you'll probably
-	// want to use a Windows OS for the spoof anyway
-	//
-	// if you want to set the user agent to a custom string, just assign your string to
-	// $this->headers["User-Agent"] directly
-	function set_user_agent($agenttype,$agentversion,$windowsversion) {
-		$useragents = array(
-			"Mozilla/4.0 (compatible; MSIE %agent%; Windows NT %os%)", // IE
-			"Mozilla/5.0 (Windows; U; Windows NT %os%; en-US; rv:%agent%) Gecko/20040514", // Moz
-			"Mozilla/5.0 (Windows; U; Windows NT %os%; en-US; rv:1.7) Gecko/20040803 Firefox/%agent%", // FFox
-			"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT %os%) Opera %agent%  [en]", // Opera
-		);
-		$agent = $useragents[$agenttype];
-		$this->headers["User-Agent"] = str_replace(array("%agent%","%os%"),array($agentversion,$windowsversion),$agent);
-	}
-	
-	// this isn't presently used as it's now handled inline by the request parser
-	function remove_chunkiness() {
-		$remaining = $this->response;
-		$this->response = "";
-		
-		while ($remaining) {
-			$hexlen = strpos($remaining,"\r");
-			$chunksize = substr($remaining,0,$hexlen);
-			$argstart = strpos($chunksize,';');
-			if ($argstart!==false) $chunksize = substr($chunksize,0,$argstart);
-			$chunksize = (int) @hexdec($chunksize);
-
-			$this->response .= substr($remaining,$hexlen+2,$chunksize);
-			$remaining = substr($remaining,$hexlen+2+$chunksize+2);
-
-			if (!$chunksize) {
-				// either we're done, or something's borked... exit
-				$this->response .= $remaining;
-				return;
-			}
-		}
-	}
-	
-	// (internal) store a page in the cache
-	function _cache_store($token,$url) {
-
-		if ($this->caching_intelligent) {
-			$urlinfo = parse_url($url);
-			if ($this->method=='POST') {
-				$this->progress(HRP_DEBUG,"POST request; not caching");
-				return;
-			} else if (strlen($urlinfo['query'])) {
-				$this->progress(HRP_DEBUG,"Request used query string; not caching");
-				return;
-			} else {
-				$this->progress(HRP_DEBUG,"Request appears to be static and cacheable");
-			}
-		}
-
-		$values = array(
-			"stats"=>$this->stats,
-			"result_code"=>$this->result_code,
-			"result_text"=>$this->result_text,
-			"version"=>$this->version,
-			"response"=>$this->response,
-			"response_headers"=>$this->response_headers,
-			"response_cookies"=>$this->response_cookies,
-			"raw_response"=>$this->raw_response,
-		);
-		$values = serialize($values);
-
-		$cache_dir = $this->cache_path;
-		if (substr($cache_dir,-1)!='/') $cache_dir .= '/';
-		
-		if ($this->caching_highvolume) {
-			$cache_dir .= substr($token,0,2) . '/';
-			if (!is_dir($cache_dir)) @mkdir($cache_dir);
-		}
-		
-		$filename = $cache_dir.$token.'.tmp';
-
-		$fp = @fopen($filename,"w");
-		if (!$fp) {
-			$this->progress(HRP_DEBUG,"Unable to create cache file");
-			return false;
-		}
-		fwrite($fp,$values);
-		fclose($fp);
-
-		$this->progress(HRP_DEBUG,"HTTP response stored to cache");
-	}
-	
-	// (internal) fetch a page from the cache
-	function _cache_fetch($token) {
-		$this->cache_hit = false;
-		$this->progress(HRP_DEBUG,"Checking for cached page value");
-
-		$cache_dir = $this->cache_path;
-		if (substr($cache_dir,-1)!='/') $cache_dir .= '/';
-		
-		if ($this->caching_highvolume) $cache_dir .= substr($token,0,2) . '/';
-		
-		$filename = $cache_dir.$token.'.tmp';
-		if (!file_exists($filename)) {
-			$this->progress(HRP_DEBUG,"Page not available in cache");
-			return false;
-		}
-		
-		if (time()-filemtime($filename)>$this->caching) {
-			$this->progress(HRP_DEBUG,"Page in cache is expired");
-			@unlink($filename);
-			return false;
-		}
-		
-		if ($values = file_get_contents($filename)) {
-			$values = unserialize($values);
-			if (!$values) {
-				$this->progress(HRP_DEBUG,"Invalid cache contents");
-				return false;
-			}
-			
-			$this->stats = $values["stats"];
-			$this->result_code = $values["result_code"];
-			$this->result_text = $values["result_text"];
-			$this->version = $values["version"];
-			$this->response = $values["response"];
-			$this->response_headers = $values["response_headers"];
-			$this->response_cookies = $values["response_cookies"];
-			$this->raw_response = $values["raw_response"];
-			
-			$this->progress(HRP_DEBUG,"Page loaded from cache");
-			$this->cache_hit = true;
-			return true;
-		} else {
-			$this->progress(HRP_DEBUG,"Error reading cache file");
-			return false;
-		}
-	}
-	
-	function parent_path($path) {
-		if (substr($path,0,1)=='/') $path = substr($path,1);
-		if (substr($path,-1)=='/') $path = substr($path,0,strlen($path)-1);
-		$path = explode('/',$path);
-		array_pop($path);
-		return count($path) ? ('/' . implode('/',$path)) : '';
-	}
-	
-	// $cookies should be an array in one of two formats.
-	//
-	// Either: $cookies[ 'cookiename' ] = array (
-	//		'/path/'=>array(
-	//			'expires'=>time(),
-	//			'domain'=>'yourdomain.com',
-	//			'value'=>'cookievalue'
-	//		)
-	// );
-	//
-	// Or, a more simplified format:
-	//	$cookies[ 'cookiename' ] = 'value';
-	//
-	// The former format will automatically check to make sure that the path, domain,
-	// and expiration values match the HTTP request, and will only send the cookie if
-	// they do match.  The latter will force the cookie to be set for the HTTP request
-	// unconditionally.
-	// 	
-	function response_to_request_cookies($cookies,$urlinfo) {
-		
-		// check for simplified cookie format (name=value)
-		$cookiekeys = array_keys($cookies);
-		if (!count($cookiekeys)) return;
-		
-		$testkey = array_pop($cookiekeys);
-		if (!is_array($cookies[ $testkey ])) {
-			foreach ($cookies as $k=>$v) $this->request_cookies[$k] = $v;
-			return;
-		}
-		
-		// must not be simplified format, so parse as complex format:
-		foreach ($cookies as $name=>$paths) {
-			foreach ($paths as $path=>$values) {
-				// make sure the cookie isn't expired
-				if ( isset($values['expires']) && ($values['expires']<time()) ) continue;
-				
-				$cookiehost = $values['domain'];
-				$requesthost = $urlinfo['host'];
-				// make sure the cookie is valid for this host
-				$domain_match = (
-					($requesthost==$cookiehost) ||
-					(substr($requesthost,-(strlen($cookiehost)+1))=='.'.$cookiehost)
-				);				
-				
-				// make sure the cookie is valid for this path
-				$cookiepath = $path; if (substr($cookiepath,-1)!='/') $cookiepath .= '/';
-				$requestpath = $urlinfo['path']; if (substr($requestpath,-1)!='/') $requestpath .= '/';
-				if (substr($requestpath,0,strlen($cookiepath))!=$cookiepath) continue;
-				
-				$this->request_cookies[$name] = $values['value'];
-			}
-		}
-	}					
-	
-	// Execute the request for a particular URL, and transparently follow
-	// HTTP redirects if enabled.  If $cookies is specified, it is assumed
-	// to be an array received from $this->response_cookies and will be
-	// processed to determine which cookies are valid for this host/URL.
-	function _execute_request($url,$cookies = false) {
-		// valid codes for which we transparently follow a redirect
-		$redirect_codes = array(301,302,303,307);
-		// valid methods for which we transparently follow a redirect
-		$redirect_methods = array('GET','HEAD');
-
-		$request_result = false;
-		
-		$this->followed_redirect = false;
-		$this->response_cookies = array();
-		$this->cookie_headers = '';
-
-		$previous_redirects = array();
-		do {
-			// send the request
-			$request_result = $this->_send_request($url,$cookies);
-			$lasturl = $url;
-			$url = false;
-
-			// see if a redirect code was received
-			if ($this->follow_redirects && in_array($this->result_code,$redirect_codes)) {
-				
-				// only redirect on a code 303 or if the method was GET/HEAD
-				if ( ($this->result_code==303) || in_array($this->method,$redirect_methods) ) {
-					
-					// parse the information from the OLD URL so that we can handle
-					// relative links
-					$oldurlinfo = parse_url($lasturl);
-					
-					$url = $this->response_headers['Location'];
-					
-					// parse the information in the new URL, and fill in any blanks
-					// using values from the old URL
-					$urlinfo = parse_url($url);
-					foreach ($oldurlinfo as $k=>$v) {
-						if (!$urlinfo[$k]) $urlinfo[$k] = $v;
-					}
-					
-					// create an absolute path
-					if (substr($urlinfo['path'],0,1)!='/') {
-						$baseurl = $oldurlinfo['path'];
-						if (substr($baseurl,-1)!='/') $baseurl = $this->parent_path($url) . '/';
-						$urlinfo['path'] = $baseurl . $urlinfo['path'];
-					}
-					
-					// rebuild the URL
-					$url = $this->rebuild_url($urlinfo);
-
-					$this->method = "GET";
-					$this->post_data = "";
-					
-					$this->progress(HRP_INFO,'Redirected to '.$url);
-				}
-			}
-			
-			if ( $url && strlen($url) ) {
-				
-				if (isset($previous_redirects[$url])) {
-					$this->error = "Infinite redirection loop";
-					$request_result = false;
-					break;
-				}
-				if ( is_numeric($this->follow_redirects) && (count($previous_redirects)>$this->follow_redirects) ) {
-					$this->error = "Exceeded redirection limit";
-					$request_result = false;
-					break;
-				}
-
-				$previous_redirects[$url] = true;
-			}
-
-		} while ($url && strlen($url));
-
-		// clear headers that shouldn't persist across multiple requests
-		$per_request_headers = array('Host','Content-Length');
-		foreach ($per_request_headers as $k=>$v) unset($this->headers[$v]);
-		
-		if (count($previous_redirects)>1) $this->followed_redirect = array_keys($previous_redirects);
-		
-		return $request_result;
-	}
-	
-	// private - sends an HTTP request to $url
-	function _send_request($url,$cookies = false) {
-		$this->progress(HRP_INFO,"Initiating {$this->method} request for $url");
-		if ($this->caching) {
-			$cachetoken = md5($url.'|'.$this->post_data);
-			if ($this->_cache_fetch($cachetoken)) return true;
-		}
-		
-		$time_request_start = $this->getmicrotime();
-		
-		$urldata = parse_url($url);
-		$this->urldata = &$urldata;
-		$http_host = $urldata['host'] . (isset($urldata['port']) ? ':'.$urldata['port'] : '');
-		
-		if (!isset($urldata["port"]) || !$urldata["port"]) $urldata["port"] = ($urldata["scheme"]=="https") ? 443 : 80;
-		if (!isset($urldata["path"]) || !$urldata["path"]) $urldata["path"] = '/';
-		
-		if (!empty($urldata['user'])) $this->auth_username = $urldata['user'];
-		if (!empty($urldata['pass'])) $this->auth_password = $urldata['pass'];
-		
-		//echo "Sending HTTP/{$this->version} {$this->method} request for ".$urldata["host"].":".$urldata["port"]." page ".$urldata["path"]."<br>";
-		
-		if ($this->version>"1.0") $this->headers["Host"] = $http_host;
-		if ($this->method=="POST") {
-			$this->headers["Content-Length"] = strlen($this->post_data);
-			if (!isset($this->headers["Content-Type"])) $this->headers["Content-Type"] = "application/x-www-form-urlencoded";
-		}
-		
-		if ( !empty($this->auth_username) || !empty($this->auth_password) ) {
-			$this->headers['Authorization'] = 'Basic '.base64_encode($this->auth_username.':'.$this->auth_password);
-		} else {
-			unset($this->headers['Authorization']);
-		}
-		
-		if (is_array($cookies)) {
-			$this->response_to_request_cookies($cookies,$urldata);
-		}
-		
-		if (!empty($urldata["query"])) $urldata["path"] .= "?".$urldata["query"];
-		$request = $this->method." ".$urldata["path"]." HTTP/".$this->version."\r\n";
-		$request .= $this->build_headers();
-		$request .= $this->post_data;
-		
-		$this->response = "";
-		
-		// clear headers that shouldn't persist across multiple requests
-		// (we can do this here as we've already built the request, including headers, above)
-		$per_request_headers = array('Host','Content-Length');
-		foreach ($per_request_headers as $k=>$v) unset($this->headers[$v]);
-		
-		// Native SSL support requires the OpenSSL extension, and was introduced in PHP 4.3.0
-		$php_ssl_support = extension_loaded("openssl") && version_compare(phpversion(),"4.3.0")>=0;
-		
-		// if this is a plain HTTP request, or if it's an HTTPS request and OpenSSL support is available,
-		// natively perform the HTTP request
-		if ( ( ($urldata["scheme"]=="http") || ($php_ssl_support && ($urldata["scheme"]=="https")) ) && (!$this->force_curl) ) {
-			$curl_mode = false;
-
-			$hostname = $this->connect_ip ? $this->connect_ip : $urldata['host'];
-			if ($urldata["scheme"]=="https") $hostname = 'ssl://'.$hostname;
-			
-			$time_connect_start = $this->getmicrotime();
-
-			$this->progress(HRP_INFO,'Opening socket connection to '.$hostname.' port '.$urldata['port']);
-
-			$this->expected_bytes = -1;
-			$this->received_bytes = 0;
-			
-			$fp = @fsockopen ($hostname,$urldata["port"],$errno,$errstr,$this->connect_timeout);
-			$time_connected = $this->getmicrotime();
-			$connect_time = $time_connected - $time_connect_start;
-			if ($fp) {
-				if ($this->stream_timeout) stream_set_timeout($fp,$this->stream_timeout);
-				$this->progress(HRP_INFO,"Connected; sending request");
-				
-				$this->progress(HRP_DEBUG,$request);
-				fputs ($fp, $request);
-				$this->raw_request = $request;
-				
-				if ($this->stream_timeout) {
-					$meta = socket_get_status($fp);
-					if ($meta['timed_out']) {
-						$this->error = "Exceeded socket write timeout of ".$this->stream_timeout." seconds";
-						$this->progress(HRP_ERROR,$this->error);
-						return false;
-					}
-				}
-				
-				$this->progress(HRP_INFO,"Request sent; awaiting reply");
-				
-				$headers_received = false;
-				$data_length = false;
-				$chunked = false;
-				$iterations = 0;
-				while (!feof($fp)) {
-					if ($data_length>0) {
-						$line = fread($fp,$data_length);
-						$this->progress(HRP_DEBUG,"[DL] Got a line: [{$line}] " . gettype($line));
-
-						if ($line!==false) $data_length -= strlen($line);
-					} else {
-						$line = @fgets($fp,10240);
-						$this->progress(HRP_DEBUG,"[NDL] Got a line: [{$line}] " . gettype($line));
-						
-						if ( ($chunked) && ($line!==false) ) {
-							$line = trim($line);
-							if (!strlen($line)) continue;
-							
-							list($data_length,) = explode(';',$line,2);
-							$data_length = (int) hexdec(trim($data_length));
-							
-							if ($data_length==0) {
-								$this->progress(HRP_DEBUG,"Done");
-								// end of chunked data
-								break;
-							}
-							$this->progress(HRP_DEBUG,"Chunk length $data_length (0x$line)");
-							continue;
-						}
-					}
-					
-					if ($line===false) {
-						$meta = socket_get_status($fp);
-						if ($meta['timed_out']) {
-							if ($this->stream_timeout) {
-								$this->error = "Exceeded socket read timeout of ".$this->stream_timeout." seconds";
-							} else {
-								$this->error = "Exceeded default socket read timeout";
-							}
-							$this->progress(HRP_ERROR,$this->error);
-							return false;
-						} else {
-							$this->progress(HRP_ERROR,'No data but not timed out');
-						}
-						continue;
-					}					
-
-					// check time limits if requested
-					if ($this->max_time>0) {
-						if ($this->getmicrotime() - $time_request_start > $this->max_time) {
-							$this->error = "Exceeded maximum transfer time of ".$this->max_time." seconds";
-							$this->progress(HRP_ERROR,$this->error);
-							return false;
-							break;
-						}
-					}
-
-					$this->response .= $line;
-					
-					$iterations++;
-					if ($headers_received) {
-						if ($time_connected>0) {
-							$time_firstdata = $this->getmicrotime();
-							$process_time = $time_firstdata - $time_connected;
-							$time_connected = 0;
-						}
-						$this->received_bytes += strlen($line);
-						if ($iterations % 20 == 0) {
-							$this->update_transfer_counters();
-						}
-					}
-
-					
-					// some dumbass webservers don't respect Connection: close and just
-					// leave the connection open, so we have to be diligent about
-					// calculating the content length so we can disconnect at the end of
-					// the response
-					if ( (!$headers_received) && (trim($line)=="") ) {
-						$headers_received = true;
-						$this->progress(HRP_DEBUG,"Got headers: {$this->response}");
-
-						if (preg_match('/^Content-Length: ([0-9]+)/im',$this->response,$matches)) {
-							$data_length = (int) $matches[1];
-							$this->progress(HRP_DEBUG,"Content length is $data_length");
-							$this->expected_bytes = $data_length;
-							$this->update_transfer_counters();
-						} else {
-							$this->progress(HRP_DEBUG,"No data length specified");
-						}
-						if (preg_match("/^Transfer-Encoding: chunked/im",$this->response,$matches)) {
-							$chunked = true;
-							$this->progress(HRP_DEBUG,"Chunked transfer encoding requested");
-						} else {
-							$this->progress(HRP_DEBUG,"CTE not requested");
-						}
-						
-						if (preg_match_all("/^Set-Cookie: ((.*?)\=(.*?)(?:;\s*(.*))?)$/im",$this->response,$cookielist,PREG_SET_ORDER)) {
-							foreach ($cookielist as $k=>$cookie) $this->cookie_headers .= $cookie[0]."\n";
-							
-							// get the path for which cookies will be valid if no path is specified
-							$cookiepath = preg_replace('/\/{2,}/','',$urldata['path']);
-							if (substr($cookiepath,-1)!='/') {
-								$cookiepath = explode('/',$cookiepath);
-								array_pop($cookiepath);
-								$cookiepath = implode('/',$cookiepath) . '/';
-							}
-							// process each cookie
-							foreach ($cookielist as $k=>$cookiedata) {
-								list(,$rawcookie,$name,$value,$attributedata) = $cookiedata;
-								$attributedata = explode(';',trim($attributedata));
-								$attributes = array();
-
-								$cookie = array(
-									'value'=>$value,
-									'raw'=>trim($rawcookie),
-								);
-								foreach ($attributedata as $k=>$attribute) {
-									list($attrname,$attrvalue) = explode('=',trim($attribute));
-									$cookie[$attrname] = $attrvalue;
-								}
-
-								if (!isset($cookie['domain']) || !$cookie['domain']) $cookie['domain'] = $urldata['host'];
-								if (!isset($cookie['path']) || !$cookie['path']) $cookie['path'] = $cookiepath;
-								if (isset($cookie['expires']) && $cookie['expires']) $cookie['expires'] = strtotime($cookie['expires']);
-								
-								if (!$this->validate_response_cookie($cookie,$urldata['host'])) continue;
-								
-								// do not store expired cookies; if one exists, unset it
-								if ( isset($cookie['expires']) && ($cookie['expires']<time()) ) {
-									unset($this->response_cookies[ $name ][ $cookie['path'] ]);
-									continue;
-								}
-								
-								$this->response_cookies[ $name ][ $cookie['path'] ] = $cookie;
-							}
-						}
-					}
-					
-					if ($this->result_close) {
-						if (preg_match_all("/HTTP\/([0-9\.]+) ([0-9]+) (.*?)[\r\n]/",$this->response,$matches)) {
-							$resultcodes = $matches[2];
-							foreach ($resultcodes as $k=>$code) {
-								if ($code!=100) {
-									$this->progress(HRP_INFO,'HTTP result code received; closing connection');
-
-									$this->result_code = $code;
-									$this->result_text = $matches[3][$k];
-									fclose($fp);
-					
-									return ($this->result_code==200);
-								}
-							}
-						}
-					}
-				}
-				if (feof($fp)) $this->progress(HRP_DEBUG,'EOF on socket');
-				@fclose ($fp);
-				
-				$this->update_transfer_counters();
-				
-				if (is_array($this->response_cookies)) {
-					// make sure paths are sorted in the order in which they should be applied
-					// when setting response cookies
-					foreach ($this->response_cookies as $name=>$paths) {
-						ksort($this->response_cookies[$name]);
-					}
-				}
-				$this->progress(HRP_INFO,'Request complete');
-			} else {
-				$this->error = strtoupper($urldata["scheme"])." connection to ".$hostname." port ".$urldata["port"]." failed";
-				$this->progress(HRP_ERROR,$this->error);
-				return false;
-			}
-
-		// perform an HTTP/HTTPS request using CURL
-		} elseif ( !$this->disable_curl && ( ($urldata["scheme"]=="https") || ($this->force_curl) ) ) {
-			$this->progress(HRP_INFO,'Passing HTTP request for $url to CURL');
-			$curl_mode = true;
-			if (!$this->_curl_request($url)) return false;
-			
-		// unknown protocol
-		} else {
-			$this->error = "Unsupported protocol: ".$urldata["scheme"];
-			$this->progress(HRP_ERROR,$this->error);
-			return false;
-		}
-		
-		$this->raw_response = $this->response;
-
-		$totallength = strlen($this->response);
-		
-		do {
-			$headerlength = strpos($this->response,"\r\n\r\n");
-
-			$response_headers = explode("\r\n",substr($this->response,0,$headerlength));
-			$http_status = trim(array_shift($response_headers));
-			foreach ($response_headers as $line) {
-				list($k,$v) = explode(":",$line,2);
-				$this->response_headers[trim($k)] = trim($v);
-			}
-			$this->response = substr($this->response,$headerlength+4);
-	
-			/* // Handled in-transfer now
-			if (($this->response_headers['Transfer-Encoding']=="chunked") && (!$curl_mode)) {
-				$this->remove_chunkiness();
-			}
-			*/
-		
-			if (!preg_match("/^HTTP\/([0-9\.]+) ([0-9]+) (.*?)$/",$http_status,$matches)) {
-				$matches = array("",$this->version,0,"HTTP request error");
-			}
-			list (,$response_version,$this->result_code,$this->result_text) = $matches;
-
-			// skip HTTP result code 100 (Continue) responses
-		} while (($this->result_code==100) && ($headerlength));
-		
-		// record some statistics, roughly compatible with CURL's curl_getinfo()
-		if (!$curl_mode) {
-			$total_time = $this->getmicrotime() - $time_request_start;
-			$transfer_time = $total_time - $connect_time;
-			$this->stats = array(
-				"total_time"=>$total_time,
-				"connect_time"=>$connect_time,	// time between connection request and connection established
-				"process_time"=>$process_time,	// time between HTTP request and first data (non-headers) received
-				"url"=>$url,
-				"content_type"=>$this->response_headers["Content-Type"],
-				"http_code"=>$this->result_code,
-				"header_size"=>$headerlength,
-				"request_size"=>$totallength,
-				"filetime"=>strtotime($this->response_headers["Date"]),
-				"pretransfer_time"=>$connect_time,
-				"size_download"=>$totallength,
-				"speed_download"=>$transfer_time > 0 ? round($totallength / $transfer_time) : 0,
-				"download_content_length"=>$totallength,
-				"upload_content_length"=>0,
-				"starttransfer_time"=>$connect_time,
-			);
-		}
-		
-		
-		$ok = ($this->result_code==200);
-		if ($ok) {
-			// if a page preprocessor is defined, call it to process the page contents
-			if (is_callable($this->page_preprocessor)) $this->response = call_user_func($this->page_preprocessor,$this,$this->response);
-			
-			// if caching is enabled, save the page
-			if ($this->caching) $this->_cache_store($cachetoken,$url);
-		}
-
-		return $ok;
-	}
-	
-	function validate_response_cookie($cookie,$actual_hostname) {
-		// make sure the cookie can't be set for a TLD, eg: '.com'		
-		$cookiehost = $cookie['domain'];
-		$p = strrpos($cookiehost,'.');
-		if ($p===false) return false;
-		
-		$tld = strtolower(substr($cookiehost,$p+1));
-		$special_domains = array("com", "edu", "net", "org", "gov", "mil", "int");
-		$periods_required = in_array($tld,$special_domains) ? 1 : 2;
-		
-		$periods = substr_count($cookiehost,'.');
-		if ($periods<$periods_required) return false;
-		
-		if (substr($actual_hostname,0,1)!='.') $actual_hostname = '.'.$actual_hostname;
-		if (substr($cookiehost,0,1)!='.') $cookiehost = '.'.$cookiehost;
-		$domain_match = (
-			($actual_hostname==$cookiehost) ||
-			(substr($actual_hostname,-strlen($cookiehost))==$cookiehost)
-		);
-		
-		return $domain_match;
-
-	}
-	
-	function build_headers() {
-		$headers = "";
-		foreach ($this->headers as $name=>$value) {
-			$value = trim($value);
-			if (empty($value)) continue;
-			$headers .= "{$name}: {$value}\r\n";
-		}
-
-		if (isset($this->request_cookies) && is_array($this->request_cookies)) {
-			$cookielist = array();
-			foreach ($this->request_cookies as $name=>$value) {
-				$cookielist[] = "{$name}={$value}";
-			}
-			if (count($cookielist)) $headers .= "Cookie: ".implode('; ',$cookielist)."\r\n";
-		}
-		
-		
-		$headers .= "\r\n";
-		
-		return $headers;
-	}
-	
-	// opposite of parse_url()
-	function rebuild_url($urlinfo) {
-		$url = $urlinfo['scheme'].'://';
-		
-		if ($urlinfo['user'] || $urlinfo['pass']) {
-			$url .= $urlinfo['user'];
-			if ($urlinfo['pass']) {
-				if ($urlinfo['user']) $url .= ':';
-				$url .= $urlinfo['pass'];
-			}
-			$url .= '@';
-		}
-		
-		$url .= $urlinfo['host'];
-		if ($urlinfo['port']) $url .= ':'.$urlinfo['port'];
-		
-		$url .= $urlinfo['path'];
-		
-		if ($urlinfo['query']) $url .= '?'.$urlinfo['query'];
-		if ($urlinfo['fragment']) $url .= '#'.$urlinfo['fragment'];
-		
-		return $url;
-	}
-	
-	function _replace_hostname(&$url,$new_hostname) {
-		$parts = parse_url($url);
-		$old_hostname = $parts['host'];
-		
-		$parts['host'] = $new_hostname;
-		
-		$url = $this->rebuild_url($parts);
-				
-		return $old_hostname;
-	}
-	
-	function _curl_request($url) {
-		$this->error = false;
-
-		// if a direct connection IP address was specified,	replace the hostname
-		// in the URL with the IP address, and set the Host: header to the
-		// original hostname
-		if ($this->connect_ip) {
-			$old_hostname = $this->_replace_hostname($url,$this->connect_ip);
-			$this->headers["Host"] = $old_hostname;
-		}
-		
-
-		unset($this->headers["Content-Length"]);
-		$headers = explode("\n",$this->build_headers());
-		
-		$ch = curl_init();
-		curl_setopt($ch,CURLOPT_URL, $url); 
-		curl_setopt($ch,CURLOPT_USERAGENT, $this->headers["User-Agent"]); 
-		curl_setopt($ch,CURLOPT_HEADER, 1); 
-		curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1); 
-//		curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 1); // native method doesn't support this yet, so it's disabled for consistency
-		curl_setopt($ch,CURLOPT_TIMEOUT, 10);
-		if ($this->curl_proxy) {
-			curl_setopt($ch,CURLOPT_PROXY,$this->curl_proxy);
-		}
-		curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
-		
-		if ($this->method=="POST") {
-			curl_setopt($ch,CURLOPT_POST,1);
-			curl_setopt($ch,CURLOPT_POSTFIELDS,$this->post_data);
-		}
-		if ($this->insecure_ssl) {
-			curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
-		}
-		if ($this->ignore_ssl_hostname) {
-			curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,1);
-		}
-		
-		$this->response = curl_exec ($ch);
-		if (curl_errno($ch)!=0) {
-			$this->error = "CURL error #".curl_errno($ch).": ".curl_error($ch);
-		}
-		
-		$this->stats = curl_getinfo($ch);
-		curl_close($ch);
-		
-		return ($this->error === false);
-	}
-	
-	function progress($level,$msg) {
-		if (is_callable($this->progress_callback)) call_user_func($this->progress_callback,$level,$msg);
-	}
-	
-	// Gets any available HTTPRetriever error message (including both internal
-	// errors and HTTP errors)
-	function get_error() {
-		return $this->error ? $this->error : 'HTTP ' . $this->result_code.': '.$this->result_text;
-	}
-	
-	function get_content_type() {
-		if (!$ctype = $this->response_headers['Content-Type']) {
-			$ctype = $this->response_headers['Content-type'];
-		}
-		list($ctype,) = explode(';',$ctype);
-		
-		return strtolower($ctype);
-	}
-	
-	function update_transfer_counters() {
-		if (is_callable($this->transfer_callback)) call_user_func($this->transfer_callback,$this->received_bytes,$this->expected_bytes);
-	}
-
-	function set_transfer_display($enabled = true) {
-		if ($enabled) {
-			$this->transfer_callback = array(&$this,'default_transfer_callback');
-		} else {
-			unset($this->transfer_callback);
-		}
-	}
-	
-	function set_progress_display($enabled = true) {
-		if ($enabled) {
-			$this->progress_callback = array(&$this,'default_progress_callback');
-		} else {
-			unset($this->progress_callback);
-		}
-	}
-	
-	function default_progress_callback($severity,$message) {
-		$severities = array(
-			HRP_DEBUG=>'debug',
-			HRP_INFO=>'info',
-			HRP_ERROR=>'error',
-		);
-		
-		echo date('Y-m-d H:i:sa').' ['.$severities[$severity].'] '.$message."\n";
-		flush();
-	}
-
-	function default_transfer_callback($transferred,$expected) {
-		$msg = "Transferred " . round($transferred/1024,1);
-		if ($expected>=0) $msg .= "/" . round($expected/1024,1);
-		$msg .=	"KB";
-		if ($expected>0) $msg .= " (".round($transferred*100/$expected,1)."%)";
-		echo date('Y-m-d H:i:sa')." $msg\n";
-		flush();
-	}	
-	
-	function getmicrotime() { 
-		list($usec, $sec) = explode(" ",microtime()); 
-		return ((float)$usec + (float)$sec); 
-	}	
-}
-?>

+ 0 - 423
wikipedia3d/class_http.php

@@ -1,423 +0,0 @@
-<?php
-/*
-* Filename.......: class_http.php
-* Author.........: Troy Wolf [troy@troywolf.com]
-* Last Modified..: Date: 2006/03/06 10:15:00
-* Description....: Screen-scraping class with caching. Includes image_cache.php
-                   companion script. Includes static methods to extract data
-                   out of HTML tables into arrays or XML. Now supports sending
-                   XML requests and custom verbs with support for making
-                   WebDAV requests to Microsoft Exchange Server.
-*/
-
-class http {
-    var $log;
-    var $dir;
-    var $name;
-    var $filename;
-    var $url;
-    var $port;
-    var $verb;
-    var $status;
-    var $header;
-    var $body;
-    var $ttl;
-    var $headers;
-    var $postvars;
-    var $xmlrequest;
-    var $connect_timeout;
-    var $data_ts;
-    
-    /*
-    The class constructor. Configure defaults.
-    */ 
-    function http() {
-        $this->log = "New http() object instantiated.<br />\n";
-        
-        /*
-        Seconds to attempt socket connection before giving up.
-        */
-        $this->connect_timeout = 30; 
-        
-        /*
-        Seconds to wait for stream to do its thing and return.
-        In my experience, if you do nothing, this defaults to 60 seconds.
-        Now here is the kicker--if you set this to 10 seconds and the request
-        actually takes 83 seconds, your script will sit and wait the entire 83
-        seconds before returning the failure! So I'm not sure what the real
-        point is. For example, if it takes 83 seconds and does in fact succeed,
-        but you had the timeout set at 60, you will return a failure even though
-        the communication worked. Point is, set this higher than anything you
-        think you'll need. Either way you have to wait!
-        */
-        $this->stream_timeout = 60;
-        
-        /*
-        Set the 'dir' property to the directory where you want to store the cached
-        content. I suggest a folder that is not web-accessible.
-        End this value with a "/".
-        */
-        $this->dir = realpath("./")."/"; //Default to current dir.
-
-        $this->clean();               
-
-        return true;
-    }
-    
-    /*
-    fetch() method to get the content. fetch() will use 'ttl' property to
-    determine whether to get the content from the url or the cache.
-    */
-    function fetch($url="", $ttl=0, $name="", $user="", $pwd="", $verb="GET") {
-        $this->log .= "--------------------------------<br />fetch() called<br />\n";
-        $this->log .= "url: ".$url."<br />\n";
-        $this->status = "";
-        $this->header = "";
-        $this->body = "";
-        if (!$url) {
-            $this->log .= "OOPS: You need to pass a URL!<br />";
-            return false;
-        }
-        $this->url = $url;
-        $this->ttl = $ttl;
-        $this->name = $name;
-        $need_to_save = false;
-        if ($this->ttl == "0") {
-            if (!$fh = $this->getFromUrl($url, $user, $pwd, $verb)) {
-                return false;
-            }
-        } else {
-            if (strlen(trim($this->name)) == 0) { $this->name = MD5($url); }
-            $this->filename = $this->dir."http_".$this->name;
-            $this->log .= "Filename: ".$this->filename."<br />";
-            $this->getFile_ts();
-            if ($this->ttl == "daily") {
-                if (date('Y-m-d',$this->data_ts) != date('Y-m-d',time())) {
-                    $this->log .= "cache has expired<br />";
-                    if (!$fh = $this->getFromUrl($url, $user, $pwd, $verb)) {
-                        return false;
-                    }
-                    $need_to_save = true;
-                    if ($this->getFromUrl()) { return $this->saveToCache(); }
-                    } else {
-                        if (!$fh = $this->getFromCache()) {
-                        return false;
-                    }
-                }
-            } else {
-                if ((time() - $this->data_ts) >= $this->ttl) {
-                    $this->log .= "cache has expired<br />";
-                    if (!$fh = $this->getFromUrl($url, $user, $pwd, $verb)) {
-                        return false;
-                    }
-                    $need_to_save = true;
-                } else {
-                    if (!$fh = $this->getFromCache()) {
-                        return false;
-                    }
-                }
-            }
-        }
-        
-        /*
-        Get response header.
-        */
-        $this->header = fgets($fh, 1024);
-        $this->status = substr($this->header,9,3);
-        while ((trim($line = fgets($fh, 1024)) != "") && (!feof($fh))) {
-            $this->header .= $line;
-            if ($this->status=="401" and strpos($line,"WWW-Authenticate: Basic realm=\"")===0) {
-                fclose($fh);
-                $this->log .= "Could not authenticate<br />\n";
-                return FALSE;
-            }
-        }
-        
-        /*
-        Get response body.
-        */
-        while (!feof($fh)) {
-            $this->body .= fgets($fh, 1024);
-        }
-        fclose($fh);
-        if ($need_to_save) { $this->saveToCache(); }
-        return $this->status;
-    }
-    
-    /*
-    PRIVATE getFromUrl() method to scrape content from url.
-    */
-    function getFromUrl($url, $user="", $pwd="", $verb="GET") {
-        $this->log .= "getFromUrl() called<br />";
-        preg_match("~([a-z]*://)?([^:^/]*)(:([0-9]{1,5}))?(/.*)?~i", $url, $parts);
-        $protocol = $parts[1];
-        $server = $parts[2];
-        $port = $parts[4];
-        $path = $parts[5];
-        if ($port == "") {
-            if (strtolower($protocol) == "https://") {
-                $port = "443";
-            } else {
-                $port = "80";
-            }
-        }
-
-        if ($path == "") { $path = "/"; }
-        
-        if (!$sock = @fsockopen(((strtolower($protocol) == "https://")?"ssl://":"").$server, $port, $errno, $errstr, $this->connect_timeout)) {
-            $this->log .= "Could not open connection. Error "
-                .$errno.": ".$errstr."<br />\n";
-            return false;
-        }
-        
-        stream_set_timeout($sock, $this->stream_timeout);
-        
-        $this->headers["Host"] = $server.":".$port;
-        
-        if ($user != "" && $pwd != "") {
-            $this->log .= "Authentication will be attempted<br />\n";
-            $this->headers["Authorization"] = "Basic ".base64_encode($user.":".$pwd);
-        }
-        
-        if (count($this->postvars) > 0) {
-            $this->log .= "Variables will be POSTed<br />\n";
-            $request = "POST ".$path." HTTP/1.0\r\n";
-            $post_string = "";
-            foreach ($this->postvars as $key=>$value) {
-                $post_string .= "&".urlencode($key)."=".urlencode($value);
-            }
-            $post_string = substr($post_string,1);
-            $this->headers["Content-Type"] = "application/x-www-form-urlencoded";
-            $this->headers["Content-Length"] = strlen($post_string);
-        } elseif (strlen($this->xmlrequest) > 0) {
-            $this->log .= "XML request will be sent<br />\n";
-            $request = $verb." ".$path." HTTP/1.0\r\n";
-            $this->headers["Content-Length"] = strlen($this->xmlrequest);
-        } else {
-            $request = $verb." ".$path." HTTP/1.0\r\n";
-        }
-
-        #echo "<br />request: ".$request;
-
-        
-        if (fwrite($sock, $request) === FALSE) {
-            fclose($sock);
-            $this->log .= "Error writing request type to socket<br />\n";
-            return false;
-        }
-        
-        foreach ($this->headers as $key=>$value) {
-            if (fwrite($sock, $key.": ".$value."\r\n") === FALSE) {
-                fclose($sock);
-                $this->log .= "Error writing headers to socket<br />\n";
-                return false;
-            }
-        }
-        
-        if (fwrite($sock, "\r\n") === FALSE) {
-            fclose($sock);
-            $this->log .= "Error writing end-of-line to socket<br />\n";
-            return false;
-        }
-        
-        #echo "<br />post_string: ".$post_string;
-        if (count($this->postvars) > 0) {
-            if (fwrite($sock, $post_string."\r\n") === FALSE) {
-                fclose($sock);
-                $this->log .= "Error writing POST string to socket<br />\n";
-                return false;
-            }
-        } elseif (strlen($this->xmlrequest) > 0) {
-            if (fwrite($sock, $this->xmlrequest."\r\n") === FALSE) {
-                fclose($sock);
-                $this->log .= "Error writing xml request string to socket<br />\n";
-                return false;
-            }
-        }
-        
-        return $sock;
-    }
-    
-    /*
-    PRIVATE clean() method to reset the instance back to mostly new state.
-    */
-    function clean()
-    {
-        $this->status = "";
-        $this->header = "";
-        $this->body = "";
-        $this->headers = array();
-        $this->postvars = array();
-        /*
-        Try to use user agent of the user making this request. If not available,
-        default to IE6.0 on WinXP, SP1.
-        */
-        if (isset($_SERVER['HTTP_USER_AGENT'])) {
-            $this->headers["User-Agent"] = $_SERVER['HTTP_USER_AGENT'];
-        } else {
-            $this->headers["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
-        }
-        
-        /*
-        Set referrer to the current script since in essence, it is the referring
-        page.
-        */
-        if (substr($_SERVER['SERVER_PROTOCOL'],0,5) == "HTTPS") {
-            $this->headers["Referer"] = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
-        } else {
-            $this->headers["Referer"] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
-        }
-    }
-    
-    /*
-    PRIVATE getFromCache() method to retrieve content from cache file.
-    */
-    function getFromCache() {
-        $this->log .= "getFromCache() called<br />";
-        //create file pointer
-        if (!$fp=@fopen($this->filename,"r")) {
-            $this->log .= "Could not open ".$this->filename."<br />";
-            return false;
-        }
-        return $fp;
-    }
-    
-    /*
-    PRIVATE saveToCache() method to save content to cache file.
-    */
-    function saveToCache() {
-        $this->log .= "saveToCache() called<br />";
-        
-        //create file pointer
-        if (!$fp=@fopen($this->filename,"w")) {
-            $this->log .= "Could not open ".$this->filename."<br />";
-            return false;
-        }
-        //write to file
-        if (!@fwrite($fp,$this->header."\r\n".$this->body)) {
-            $this->log .= "Could not write to ".$this->filename."<br />";
-            fclose($fp);
-            return false;
-        }
-        //close file pointer
-        fclose($fp);
-        return true;
-    }
-    
-    /*
-    PRIVATE getFile_ts() method to get cache file modified date.
-    */
-    function getFile_ts() {
-        $this->log .= "getFile_ts() called<br />";
-        if (!file_exists($this->filename)) {
-            $this->data_ts = 0;
-            $this->log .= $this->filename." does not exist<br />";
-            return false;
-        }
-        $this->data_ts = filemtime($this->filename);
-        return true;
-    }
-    
-    /*
-    Static method table_into_array()
-    Generic function to return data array from HTML table data
-    rawHTML: the page source
-    needle: optional string to start parsing source from
-    needle_within: 0 = needle is BEFORE table, 1 = needle is within table
-    allowed_tags: list of tags to NOT strip from data, e.g. "<a><b>"
-    */
-    function table_into_array($rawHTML,$needle="",$needle_within=0,$allowed_tags="") {
-        $upperHTML = strtoupper($rawHTML);
-        $idx = 0;
-        if (strlen($needle) > 0) {
-            $needle = strtoupper($needle);
-            $idx = strpos($upperHTML,$needle);
-            if ($idx === false) { return false; }
-            if ($needle_within == 1) {
-                $cnt = 0;
-                while(($cnt < 100) && (substr($upperHTML,$idx,6) != "<TABLE")) {
-                    $idx = strrpos(substr($upperHTML,0,$idx-1),"<");
-                    $cnt++;
-                }
-            }
-        }
-        $aryData = array();
-        $rowIdx = 0;
-        /*	If this table has a header row, it may use TD or TH, so 
-        check special for this first row. */
-        $tmp = strpos($upperHTML,"<TR",$idx);
-        if ($tmp === false) { return false; }
-        $tmp2 = strpos($upperHTML,"</TR>",$tmp);
-        if ($tmp2 === false) { return false; }
-        $row = substr($rawHTML,$tmp,$tmp2-$tmp);
-        $pattern = "/<TH>|<TH\ |<TD>|<TD\ /";
-        preg_match($pattern,strtoupper($row),$matches);
-        $hdrTag = $matches[0];
-        
-        while ($tmp = strpos(strtoupper($row),$hdrTag) !== false) {
-            $tmp = strpos(strtoupper($row),">",$tmp);
-            if ($tmp === false) { return false; }
-            $tmp++;
-            $tmp2 = strpos(strtoupper($row),"</T");
-            $aryData[$rowIdx][] = trim(strip_tags(substr($row,$tmp,$tmp2-$tmp),$allowed_tags));
-            $row = substr($row,$tmp2+5);
-            preg_match($pattern,strtoupper($row),$matches);
-            $hdrTag = $matches[0];
-        }
-        $idx = strpos($upperHTML,"</TR>",$idx)+5;
-        $rowIdx++;
-        
-        /* Now parse the rest of the rows. */
-        $tmp = strpos($upperHTML,"<TR",$idx);
-        if ($tmp === false) { return false; }
-        $tmp2 = strpos($upperHTML,"</TABLE>",$idx);
-        if ($tmp2 === false) { return false; }
-        $table = substr($rawHTML,$tmp,$tmp2-$tmp);
-        
-        while ($tmp = strpos(strtoupper($table),"<TR") !== false) {
-            $tmp2 = strpos(strtoupper($table),"</TR");
-            if ($tmp2 === false) { return false; }
-            $row = substr($table,$tmp,$tmp2-$tmp);
-            
-            while ($tmp = strpos(strtoupper($row),"<TD") !== false) {
-            $tmp = strpos(strtoupper($row),">",$tmp);
-            if ($tmp === false) { return false; }
-            $tmp++;
-            $tmp2 = strpos(strtoupper($row),"</TD");
-            $aryData[$rowIdx][] = trim(strip_tags(substr($row,$tmp,$tmp2-$tmp),$allowed_tags));
-            $row = substr($row,$tmp2+5);
-            }
-            $table = substr($table,strpos(strtoupper($table),"</TR>")+5);
-            $rowIdx++;
-        }
-        return $aryData;
-    }
-    
-    /*
-    Static method table_into_xml()
-    Generic function to return xml dataset from HTML table data
-    rawHTML: the page source
-    needle: optional string to start parsing source from
-    allowedTags: list of tags to NOT strip from data, e.g. "<a><b>"
-    */
-    function table_into_xml($rawHTML,$needle="",$needle_within=0,$allowedTags="") {
-        if (!$aryTable = http::table_into_array($rawHTML,$needle,$needle_within,$allowedTags)) { return false; }
-        $xml = "<?xml version=\"1.0\" standalone=\"yes\" \?\>\n";
-        $xml .= "<TABLE>\n";
-        $rowIdx = 0;
-        foreach ($aryTable as $row) {
-            $xml .= "\t<ROW id=\"".$rowIdx."\">\n";
-            $colIdx = 0;
-            foreach ($row as $col) {
-                $xml .= "\t\t<COL id=\"".$colIdx."\">".trim(utf8_encode(htmlspecialchars($col)))."</COL>\n";
-                $colIdx++;
-            }
-            $xml .= "\t</ROW>\n";
-            $rowIdx++;
-        }
-        $xml .= "</TABLE>";
-        return $xml;
-    }
-}
-
-?>

+ 0 - 240
wikipedia3d/imgsrch.php

@@ -1,240 +0,0 @@
-<?php 
-/**
- * @author Lukas Goldschmidt / lukas.goldschmidt@googlemail.com 
- * @name Google image search and cache
- * Take a wikipedia page title and return a jsonp wrapped object of thumbnails
- * cache results on the way
- * */
-//error_reporting(E_ALL);
-//ini_set('display_errors', '1');
- $enable_jsonp = true;
- $Conf["db_server"]="localhost";
- $Conf["db_name"]="image_cache";
- $Conf["db_user"]="image_cache_user";
- $Conf["db_pass"]="user_image_cache";
- 
-/**
- * our target servers
- */
- $google_servers = array(
-	"http://images.google.co.in/",
-	"http://images.google.co.uk/",
-	"http://images.google.it/",
-	"http://images.google.at/",
-	"http://images.google.de/",
-	"http://images.google.hu/",
-	"http://images.google.nl/",
-	"http://images.google.fi/",
-	"http://images.google.no/",
-	"http://images.google.pl/",
-	"http://images.google.ru/",
-	"http://images.google.es/",
-	"http://images.google.fr/",
-	"http://images.google.se/",
-	"http://images.google.sk/"
-);
- 
- 
- 
- 
-/**
- * make the search url 
- */
-function createGoogleUrl($imagesOf,$numberOfImages) {
-	global $google_servers;
-	$numberOfPages = abs(($numberOfImages/20));
-	$j=0;
-	for($i=0; $i<$numberOfPages; $i++ ) {
-		$thegoogle=$google_servers[rand(0,count($google_servers)-1)];
-		$returnArray[] = $thegoogle."images?q=".rawurlencode($imagesOf)."&hl=en&lr=&start=".$j."&sa=N&gbv=1";            
-		$j += 20;
-	}
-	return $returnArray;
-}
-
-/**
- * get the page
- */
-function getHtml($url){
-	$returnStr="";
-	$fp=fopen($url, "r");
-	if($fp){
-		while (!feof($fp)) {
-			$returnStr.=fgetc($fp);
-		}
-		fclose($fp);
-	}
-	return $returnStr;
-}
-
-/**
- * parse results
- */
-function parse_gResult($str, $ent_id, $offset,$num){
-	global $Conf;
-	//echo $str;
-	//
-	// for each image on the page i want:
-	// img_url, w, h, ref_url
-	// thmb_url, w, h, 
-	// only seven items , so what i write that in 20 min !
-	// 
-	$img=array();	
-	$reg = "/<a href=\"\/imgres([^>]*)>/si";
-	preg_match_all($reg, $str, $matches);   
-	$ic=$offset+1;
-	if(count($matches[0]) < 1 && $offset == 0){
-
-	//	mark_noGoogleImage($ent_id);
-	//	return $str;
-	}
-	foreach ($matches[0] as $value) {
-
-/*
-href=/imgres?imgurl=http://img2.timeinc.net/people/i/2008/stylewatch/gallery/milanparis/salma_hayek.jpg
-
-&imgrefurl=http://search.people.com/TIISearch/people/search/search.html%3Fsearch%3Dbreakup
-&usg=__3oY4-uFNJMoDMUcfCG7kiXe1zzE=
-&h=400&w=300&sz=24&hl=en&start=79
-&tbnid=RTeVMtZMbddqnM:
-&tbnh=124
-&tbnw=93
-
-&prev=/images%3Fq%3Dhayek%2Bactress%26start%3D60%26gbv%3D1%26hl%3Den%26lr%3D%26sa%3DN%26ie%3DUTF-8> 
-*/
-		$reg = "/\/imgres\?imgurl=([^&]*)&amp;imgrefurl=/si";
-		preg_match_all($reg, $value, $matches1);   
-		$img["img_url"]=$matches1[1][0];
-		$reg = "/&amp;imgrefurl=([^&]*)&amp;usg=__/si";
-		preg_match_all($reg, $value, $matches1);   
-		$img["ref_url"]=$matches1[1][0];
-		$reg = "/&amp;h=([^&]*)&amp;/si";
-		preg_match_all($reg, $value, $matches1);   
-		$img["img_h"]=$matches1[1][0];
-		$reg = "/&amp;w=([^&]*)&amp;/si";
-		preg_match_all($reg, $value, $matches1);   
-		$img["img_w"]=$matches1[1][0];
-		$reg = "/&amp;tbnid=([^&]*)&amp;/si";
-		preg_match_all($reg, $value, $matches1);   
-		$img["thmb_id"]=$matches1[1][0];
-		$reg = "/&amp;tbnh=([^&]*)&amp;/si";
-		preg_match_all($reg, $value, $matches1);   
-		$img["thmb_h"]=$matches1[1][0];
-		$reg = "/&amp;tbnw=([^&]*)&amp;/si";
-		preg_match_all($reg, $value, $matches1);   
-		$img["thmb_w"]=$matches1[1][0];
-
-// google thumbnailurl looks like this		
-// http://tbn2.google.com/images?q=tbn:Wd4OG7eBzgovTM:http://www.topnews.in/light/files/salma-hayek3.jpg		
-		$img["thmb_url"]="http://tbn".rand(1,3).".google.com/images?q=tbn:";
-		$img["thmb_url"].=$img["thmb_id"].$img["img_url"];
-		$ret[]=$img;
-
-$sql = 'INSERT INTO `'.$Conf["db_name"].'`.`image` (
-		`id`, 
-		`title`, 
-		`wpage_id`, 
-		`thmb_url`, 
-		`thmb_w`, 
-		`thmb_h`, 
-		`ref_url`, 
-		`img_url`, 
-		`img_w`, 
-		`img_h`, 
-		`date`, 
-		`404`) VALUES (
-		NULL,	NULL, 
-		\''.$ent_id.'\', 
-		\''.$img['thmb_url'].'\', 
-		\''.$img['thmb_w'].'\', 
-		\''.$img['thmb_h'].'\', 
-		\''.$img['ref_url'].'\', 
-		\''.$img['img_url'].'\', 
-		\''.$img['img_w'].'\', 
-		\''.$img['img_h'].'\', 
-		NOW(), 
-		\'0\');';		
-		$result = mysql_query($sql);
-		
-	}
-	return $ret;
-}	
-
-
-/*
- * here the script starts
- * 
- */
-$connection = mysql_connect($Conf["db_server"], $Conf["db_user"], $Conf["db_pass"]);
-if (!$connection) {   die('Not connected : ' . mysql_error());}
-mysql_select_db($Conf["db_name"], $connection);
- 
- 
- 
-$wpage = $_GET['wpage'];
-
-if (!$wpage) {
-	// Passed url not specified.
-	$contents = 'ERROR: url not specified';
-	$status = array('http_code' => 'ERROR');
-	
-} else {
-// first lst us see if we know already what we want
-	$sql = 'SELECT * FROM `'.$Conf["db_name"].'`.`wpage` w , `'.$Conf["db_name"].'`.`image` i WHERE `w`.`text`=\''.$wpage.'\' AND `i`.`wpage_id`=`w`.`id`;'; 
-
-	$result = mysql_query($sql);
-	if (!$result) {  die('Invalid query: ' . mysql_error());}
-	if(mysql_num_rows($result) > 0){ 
-	while ($row = mysql_fetch_assoc($result)){
-		$contents[]=$row;		
-	
-	}
-	$status = array('http_code' => 'OK');
-// if so pack it in to the contents
-	} else {// else get some data and cache it 
-		$sql = 'INSERT INTO `'.$Conf["db_name"].'`.`wpage` (
-				`id`,
-				`text`, 
-				`cachetime` 
-		
-		) VALUES (
-			NULL,
-			\''.$wpage.'\',
-			NOW()
-		
-		);';
-		$result = mysql_query($sql);
-		$id=mysql_insert_id();
-		$url=createGoogleUrl($wpage,20);
-		$offset=0;
-		$ret = parse_gResult(getHtml($url[0]), $id, $offset,20);
-		$status = array('http_code' => 'OK');
-		$contents = $ret;
-	}
-
-
-
-}
-
-
-// Set the JSON data object contents, decoding it from JSON if possible.
-$decoded_json = json_decode($contents);
-$data['status'] = $status;
-
-$data['contents'] = $decoded_json ? $decoded_json : $contents;
-
-// Generate appropriate content-type header.
-$is_xhr = strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
-header('Content-type: application/' . ($is_xhr ? 'json' : 'x-javascript'));
-
-// Get JSONP callback.
-$jsonp_callback = $enable_jsonp && isset($_GET['callback']) ? $_GET['callback'] : null;
-
-// Generate JSON/JSONP string
-$json = json_encode($data);
-
-print $jsonp_callback ? "$jsonp_callback($json)" : $json;
-
-
-
-?>

+ 9 - 17
wikipedia3d/index.php → wikipedia3d/index.html

@@ -31,25 +31,17 @@
 		<script type="text/javascript" src="js/sha1.js"></script>
 		<script src="js/query-min.js" type="text/javascript"></script>
 		<script src="js/jsw.js" type="text/javascript"></script>
-		<script type="text/javascript">
-
-			DEF_LANG = '<?php
-if (isset($_REQUEST["lang"])) {
-	print($_REQUEST["lang"]);
-} else if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
-	print(substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2));
-} else {
-	print("en");
-}
-?>';
 
-			DEF_WPAGE = '<?php
-if (isset($_REQUEST["p"])) {
-	print($_REQUEST["p"]);
-} else {
+		<script type="text/javascript">
+			// Replace PHP defaults with client-side logic.
+			(function() {
+				var params = new URLSearchParams(window.location.search);
+				var lang = params.get("lang") || (navigator.language || "en").slice(0, 2);
+				var page = params.get("p") || "";
+				window.DEF_LANG = lang;
+				window.DEF_WPAGE = page;
+			})();
 
-}
-?>';
 			DEF_BG = 'images/cube/night_1/';
 			BG_ARR = {
 				'Moonlight' : 'images/cube/night_1/',

+ 0 - 200
wikipedia3d/indexc.php

@@ -1,200 +0,0 @@
-<!DOCTYPE HTML>
-<html xmlns="http://www.w3.org/1999/xhtml">
-	<head>
-		<title>Wikipedia 3D</title>
-		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-		<link rel="stylesheet" href="css/wb.css" type="text/css">
-		<link rel="stylesheet" href="css/ui-darkness/jquery-ui-1.8.15.custom.css" type="text/css">
-		<script src="js/query-min.js" type="text/javascript"></script>
-		<script src="js/jsw-min.js" type="text/javascript"></script>
-		<script type="text/javascript"
-		src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
-		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools.js"></script>
-		<script src="js/" type="text/javascript"></script>
-		<script type="text/javascript">
-
-			DEF_LANG = '<?php
-if (isset($_REQUEST["lang"])) {
-	print($_REQUEST["lang"]);
-} else if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
-	print(substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2));
-} else {
-	print("en");
-}
-?>';
-
-			DEF_WPAGE = '<?php
-if (isset($_REQUEST["p"])) {
-	print($_REQUEST["p"]);
-} else {
-
-}
-?>';
-			DEF_BG = 'images/cube/night_1/';
-			BG_ARR = {
-				'Moonlight' : 'images/cube/night_1/',
-				'Daylight' : 'images/cube/plain_sky_1/',
-				'Mars Scene 1' : 'images/cube/mars_1/'
-			};
-
-		</script>
-		<script type="text/javascript" src="js/main.js"></script>
-	</head>
-	<body  onunload="GUnload();">
-
-		<div id="centered">
-			<div id="hd">
-				<h1>Wikipedia 3D</h1>
-			</div>
-			<div id="main">
-				<div id="content" onmouseover="self.focus();"><img src="images/loading.gif" alt="loadinf"/>
-				</div>
-				<div style="margin:0; padding:.4em; ">
-					<div id="tabs"  style="display: none;">
-						<ul>
-							<li>
-								<a href="#tabs-Controls">Controls</a>
-							</li>
-							<li>
-								<a href="#tabs-GMap">Map</a>
-							</li>
-							<li>
-								<a href="#tabs-Favourites">Favourites</a>
-							</li>
-							<li>
-								<a href="#tabs-Blacklist">Blacklist</a>
-							</li>
-							<li>
-								<a href="#tabs-Options">Options</a>
-							</li>
-							<li>
-								<a href="#tabs-Help">Help</a>
-							</li>
-							<li>
-								<a href="#tabs-About">About</a>
-							</li>
-						</ul>
-						<div id="tabs-Controls">
-							<form onSubmit="return false;" method="post">
-								<span id="toolbar" class="ui-widget-header ui-corner-all" > <select id="langsel"></select>
-									<button id="reset" >
-										clear
-									</button>
-									<input type="text" id="ac" value="" onmouseover="self.focus();return true;"/>
-								</span>
-							</form>
-						</div>
-						<div id="tabs-GMap">
-							<iframe height="320" id="mapFrame" src="gmap_iframe.html" width="800" SCROLLING="no"></iframe>
-						</div>
-						<div id="tabs-Favourites"></div>
-						<div id="tabs-Blacklist"></div>
-						<div id="tabs-Options">
-							<p>
-								<fieldset style="display:inline; padding:8px;">
-									<legend>
-										Appearance:
-									</legend>
-									Backgound (Skycube) : <select id="bgsel"></select>
-								</fieldset>
-								<fieldset style="display:inline; padding:8px;">
-									<legend>
-										Options:
-									</legend>
-									Maximal Number of Examples to fetch : <input  type="text" id="maxtypefetch" />
-								</fieldset>
-							</p>
-						</div>
-						<div id="tabs-Help">
-							<h3>A 3D Wikipedia Interface</h3>
-							<ul style="text-align:left;">
-								<li>
-									<b>Type</b> something in the textfield in the Controls Tab and
-									wait for the autocomplete to return some results ...
-<br />								try <b>different languages</b> by changing the option in the Controls Tab 
-									
-								</li>
-								<li>
-									<h4>Keyboard Commands:</h4>
-									<ul style="text-align:left;">
-									<li><b>- W -</b>: Forward</li>
-									<li><b>- S -</b>: Backward</li>
-									<li><b>- A -</b>: Left </li>
-									<li><b>- D -</b>: Right</li>
-									<li><b>- R -</b>: Up </li>
-									<li><b>- F -</b>: Down</li>
-									<li><b>- PageUP -</b>: Previous item</li>
-									<li><b>- PageDOWN -</b>: Next item</li>
-									<li><b>- SPACE -</b>: toggle point of view</li>
-
-								</ul><br />
-									 or use arrow keys to move around. <br />
-									 Click and drag the mouse to look around !
-									
-								</li>
-								<li>
-									Double Clicking on the map, opens Wikipedia entries of the surrounding area.
-									
-								</li>
-								<li>
-Drag Favourites to the 3D Area to open them, each item will open in the language it was saved in, if available the corresponding item in the currently selected language will also be opened.
-To remove an item from the favourites list, simply drag and drop it over the trashcan symbol.									
-								</li>
-							</ul>
-							<img src="images/HELP_Image_1a.png" />
-	
-							<ul style="text-align:left;">
-								<li> A: <b>Click textlabel</b> to show the WikiPage text. To open related items CONTROL+Click for one or SHIFT+Click for many random links corresponding to that subject.
-								</li>
-								<li> B . the language of the subject .
-								</li>
-								<li> C . removes an item from the grid 
-								</li>
-								<li> D . blacklists an item, so it will not show up as random subject
-								</li>
-								<li> E . Placemark Icon, click it to scroll the map at the bottom to that location.<br />
-									SHIFT+Click to find Wikipedia Pages near that location. 
-								</li>
-								<li> F . make the item a favourite item, favourites are automatically saved in your Browser
-								</li>
-								<li> G . Solo that item. removes all other items but this one.
-								</li>
-								<li> H . Wikipedia Categories.  Clicking shows a list, CONTROL+Click opens exactly one and SHIFT+Click several random items. 
-								</li>
-								<li> I . <a href="http://en.wikipedia.org/wiki/YAGO_%28ontology%29" target="_blank">YAGO</a> types.  Clicking shows a list, CONTROL+Click opens exactly one and SHIFT+Click several random items.
-								</li>
-								<li> J . <b>click</b> on an items image to move your viewpoint (camera) to it
-
-								</li>
-							</ul>
-
-						</div>
-
-						<div id="tabs-About">
-							<h3>A 3D Wikipedia Interface</h3>
-							<p style="">
-								Started as a skills demo by <a href="#">Lukas Goldschmidt</a>
-								<br />
-								Libraries used : <a href="http://jquery.com/" target="_blank">JQuery</a>,<a href="http://jqueryui.com/" target="_blank">JQuery-UI</a>, <a href="http://moo4q.com/" target="_blank">Moo4Q</a> (<a href="http://mootools.net/" target="_blank">MooTools</a>), <a href="https://github.com/mrdoob/three.js/" target="_blank">Three.js</a>, <a href="http://code.google.com/p/colorjizz/" target="_blank">ColorJizz</a>
-								<br />
-								APIs used : <a href="http://www.mediawiki.org/wiki/API:Main_page" target="_blank">Wikipedia API</a>, <a href="http://dbpedia.org/sparql" target="_blank">DBPedia SPARQL</a>, <a href="http://www.geonames.org/" target="_blank">Geonames.org</a>
-								<br />
-								IDE used :
-								<br />
-								<a href="http://www.aptana.com/" target="_blank"><img src="http://b.vimeocdn.com/ps/362/36243_300.jpg" alt="aptana logo" style="border:0; width:24px; height:24px;" /> Aptana Studio 3</a>
-							</p>
-						</div>
-					</div>
-				</div>
-			</div>
-			<div id="ft">
-				<hr />
-				&copy; 2011 <a href="mailto:lukas.goldschmidt@googlemail.com">lukas goldschmidt</a>
-				<br>
-			</div>
-		</div>
-		<div id="dialog-message" style="display: none;" title="A Message"></div>
-		<div id="dialog-busy" title="Working ..."><img src="images/websedit-ag-bar2.gif" alt="loading"/>
-		</div>
-	</body>
-</html>

+ 0 - 56
wikipedia3d/js/index.php

@@ -1,56 +0,0 @@
-<?php
-//error_reporting(E_ALL);
-ini_set('display_errors', '0');
-require '../jsmin.php';
-
-$scripts = array('jquery-1.6.2.min.js', 'jquery-ui-1.8.15.custom.min.js', 'jquery.ui.map.full.min.js', 'jquery.timers.js', 'jquery.Storage.js', 'urlEncode.js', 'jquery.sparql.js', 'Three.js', 'Detector.js', 'RequestAnimationFrame.js', 'LG.js', 'FPC.js', 'wp_languages.js', '../dbp_onto.js', 'ColorJizz_js_0.2.js', 'sha1.js' ); /// ,  'jsw.js');
-$cachedir = "cache";
-$fmt = "fmtime_list.txt";
-$delimiter1 = "###\n";
-
-$delimiter2 = ":::";
-
-$fh = fopen($fmt, "rb");
-$contents = fread($fh, filesize($fmt));
-fclose($fh);
-$pairs = explode($delimiter1, $contents);
-foreach ($pairs as $pair) {
-	$val = explode($delimiter2, $pair);
-	if ($val[1] != "") {
-		$mtime[$val[0]] = $val[1];
-
-	}
-}
-// print_r($mtime);
-
-header('Content-Type: application/javascript');
-ob_start('ob_gzhandler');
-$fh = fopen($fmt, 'wb') or die("can't open file");
-$first = true;
-foreach ($scripts as $script) {
-
-	if (file_exists($cachedir . "/" . $script . "_" . filemtime($script))) {
-		echo file_get_contents($cachedir . "/" . $script . "_" . filemtime($script));
-	} else {
-		$cmp = JSMin::minify(file_get_contents($script));
-		//$cmp = file_get_contents($script);
-		$fh2 = fopen($cachedir . "/" . $script . "_" . filemtime($script), 'wb') or die("can't open file");
-		fwrite($fh2, $cmp);
-		fclose($fh2);
-		echo $cmp;
-
-	}
-	if ($first) {
-		$first = false;
-		$delimiter = "";
-	} else {
-		$delimiter = $delimiter1;
-	}
-	$stringData = $delimiter . $script . $delimiter2 . filemtime($script);
-	fwrite($fh, $stringData);
-
-}
-fclose($fh);
-
-ob_end_flush();
-?>

+ 6 - 6
wikipedia3d/js/main.js

@@ -65,13 +65,13 @@ LG.wb.Class.Browser = new Class(/** @lends LG.wb.Class.Browser.prototype */
 	ydis : 411,
 	zdis : 500,
 	/** FavMe Icon Image	*/
-	favmeUrl : 'http://wikipedia3d.world.eu.org/wikipedia3d/images/Favorite-icon.png',
+	favmeUrl : '/wikipedia3d/images/Favorite-icon.png',
 	/** DelMe Icon Image	*/
-	delmeUrl : 'http://wikipedia3d.world.eu.org/wikipedia3d/images/Remove-icon.png',
+	delmeUrl : '/wikipedia3d/images/Remove-icon.png',
 	/** BlMe Icon Image	*/
-	blmeUrl : 'http://wikipedia3d.world.eu.org/wikipedia3d/images/blacklist.png',
+	blmeUrl : '/wikipedia3d/images/blacklist.png',
 	/** SoloMe Icon Image	*/
-	solomeUrl : 'http://wikipedia3d.world.eu.org/wikipedia3d/images/eye-icon.png',
+	solomeUrl : '/wikipedia3d/images/eye-icon.png',
 
 
 	/** object to hold our item instances */
@@ -105,8 +105,8 @@ LG.wb.Class.Browser = new Class(/** @lends LG.wb.Class.Browser.prototype */
 		this.cur_lang = DEF_LANG;
 		this.alurl = 'http://access.alchemyapi.com/calls/url/URLGetRankedNamedEntities';
 		this.wpurl = 'http://' + DEF_LANG + '.wikipedia.org/w/api.php';
-		this.proxyurl = "http://wikipedia3d.world.eu.org/wikipedia3d/ba-simple-proxy.php?mode=native&url=";
-		this.proxyurl_json = "http://wikipedia3d.world.eu.org/wikipedia3d/ba-simple-proxy.php?url=";
+		this.proxyurl = "/proxy?mode=native&url=";
+		this.proxyurl_json = "/proxy?url=";
 		//this.img_url = "http://www.world.eu.org/~lucky/wiki_browser/imgsrch.php?wpage=";
 		//		this.dbp_onto_url = "http://www.world.eu.org/~lucky/wiki_browser/dbpedia.ontology.owx"; // URL of the ontology
 		this.dbp_onto_url = "/dbpedia.ontology.owx";

+ 15 - 15
wikipedia3d/js/wb_item.js

@@ -26,16 +26,16 @@ LG.wb.Class.Item = new Class(/** @lends LG.wb.Class.Item.prototype */
 	/** an array for RDF Types */
 	rdf_type : [],
 	/** Default Thumbnail URL	*/
-	scriptRoot : 'http://wikipedia3d.world.eu.org/wikipedia3d/',
-	deftbUrl : 'http://wikipedia3d.world.eu.org/wikipedia3d/images/wikipedia_256.png',
+	scriptRoot : '/wikipedia3d/',
+	deftbUrl : '/wikipedia3d/images/wikipedia_256.png',
 	/** FavMe Icon Image	*/
-	favmeUrl : 'http://wikipedia3d.world.eu.org/wikipedia3d/images/Favorite-icon.png',
+	favmeUrl : '/wikipedia3d/images/Favorite-icon.png',
 	/** DelMe Icon Image	*/
-	delmeUrl : 'http://wikipedia3d.world.eu.org/wikipedia3d/images/Remove-icon.png',
+	delmeUrl : '/wikipedia3d/images/Remove-icon.png',
 	/** BlMe Icon Image	*/
-	blmeUrl : 'http://wikipedia3d.world.eu.org/wikipedia3d/images/blacklist.png',
+	blmeUrl : '/wikipedia3d/images/blacklist.png',
 	/** SoloMe Icon Image	*/
-	solomeUrl : 'http://wikipedia3d.world.eu.org/wikipedia3d/images/eye-icon.png',
+	solomeUrl : '/wikipedia3d/images/eye-icon.png',
 
 	dbp_resource : new String(),
 	dbp_data : new String(),
@@ -509,7 +509,7 @@ y
 	process : function() {
 		var that = this;
 		// default place mark icon
-		var myicon =  "http://wikipedia3d.world.eu.org/wikipedia3d/images/map_icons/world.png";
+		var myicon =  "/wikipedia3d/images/map_icons/world.png";
 		// default zoom
 		var zoom = 14;		
 		// Type handling
@@ -596,16 +596,16 @@ y
 				});
 //				AncientGreekCities
 				if(yago_type == 'DestroyedLandmarks') {
-					myicon =  "http://wikipedia3d.world.eu.org/wikipedia3d/images/map_icons/ruins-2.png";
+					myicon =  "/wikipedia3d/images/map_icons/ruins-2.png";
 					zoom = 14; 		
 				}
 				if(yago_type ==  'Bridge102898711') {
 					zoom=16;
-					myicon =  "http://wikipedia3d.world.eu.org/wikipedia3d/images/map_icons/bridge_modern.png";
+					myicon =  "/wikipedia3d/images/map_icons/bridge_modern.png";
 				}
 				if(yago_type ==  'AncientGreekCities') {
 					zoom=14;
-					myicon =  "http://wikipedia3d.world.eu.org/wikipedia3d/images/map_icons/monument.png";
+					myicon =  "/wikipedia3d/images/map_icons/monument.png";
 				}
 				
 			} else if(val.search(/dbpedia\.org\/ontology/) > 0) {
@@ -693,19 +693,19 @@ y
 				if(that.Browser.reasoner.isSubClassOf(dbp_type, 'City')) {
 //					 alert(that.normalized + " is a City");
 					zoom = 11;
-					myicon =  "http://wikipedia3d.world.eu.org/wikipedia3d/images/map_icons/house.png";
+					myicon =  "/wikipedia3d/images/map_icons/house.png";
 				}
 				if(that.Browser.reasoner.isSubClassOf(dbp_type, 'Artist')) {
 //					 alert(that.normalized + " is a Artist");
 				}
 				if(that.Browser.reasoner.isSubClassOf(dbp_type, 'Airport')) {
-					myicon =  "http://wikipedia3d.world.eu.org/wikipedia3d/images/map_icons/airport.png";
+					myicon =  "/wikipedia3d/images/map_icons/airport.png";
 				}
 				if(that.Browser.reasoner.isSubClassOf(dbp_type, 'MountainRange')) {
-					myicon =  "http://wikipedia3d.world.eu.org/wikipedia3d/images/map_icons/mountains.png";
+					myicon =  "/wikipedia3d/images/map_icons/mountains.png";
 				}
 				if(that.Browser.reasoner.isSubClassOf(dbp_type, 'MilitaryConflict')) {
-					myicon =  "http://wikipedia3d.world.eu.org/wikipedia3d/images/map_icons/war.png";
+					myicon =  "/wikipedia3d/images/map_icons/war.png";
 				}
 
 			}
@@ -717,7 +717,7 @@ y
 	},
 	process_geoData : function(){
 		if(this.marker_icon == undefined){
-			var myicon = "http://wikipedia3d.world.eu.org/wikipedia3d/images/map_icons/world.png";
+			var myicon = "/wikipedia3d/images/map_icons/world.png";
 			
 		}else {
 			var myicon = this.marker_icon;

+ 0 - 375
wikipedia3d/jsmin.php

@@ -1,375 +0,0 @@
-<?php
-/**
- * jsmin.php - PHP implementation of Douglas Crockford's JSMin.
- *
- * This is pretty much a direct port of jsmin.c to PHP with just a few
- * PHP-specific performance tweaks. Also, whereas jsmin.c reads from stdin and
- * outputs to stdout, this library accepts a string as input and returns another
- * string as output.
- *
- * PHP 5 or higher is required.
- *
- * Permission is hereby granted to use this version of the library under the
- * same terms as jsmin.c, which has the following license:
- *
- * --
- * Copyright (c) 2002 Douglas Crockford  (www.crockford.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is furnished to do
- * so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * The Software shall be used for Good, not Evil.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- * --
- *
- * @package JSMin
- * @author Ryan Grove <ryan@wonko.com>
- * @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
- * @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
- * @license http://opensource.org/licenses/mit-license.php MIT License
- * @version 1.1.1 (2008-03-02)
- * @link https://github.com/rgrove/jsmin-php/
- */
-
-class JSMin {
-  const ORD_LF            = 10;
-  const ORD_SPACE         = 32;
-  const ACTION_KEEP_A     = 1;
-  const ACTION_DELETE_A   = 2;
-  const ACTION_DELETE_A_B = 3;
-
-  protected $a           = '';
-  protected $b           = '';
-  protected $input       = '';
-  protected $inputIndex  = 0;
-  protected $inputLength = 0;
-  protected $lookAhead   = null;
-  protected $output      = '';
-
-  // -- Public Static Methods --------------------------------------------------
-
-  /**
-   * Minify Javascript
-   *
-   * @uses __construct()
-   * @uses min()
-   * @param string $js Javascript to be minified
-   * @return string
-   */
-  public static function minify($js) {
-    $jsmin = new JSMin($js);
-    return $jsmin->min();
-  }
-
-  // -- Public Instance Methods ------------------------------------------------
-
-  /**
-   * Constructor
-   *
-   * @param string $input Javascript to be minified
-   */
-  public function __construct($input) {
-    $this->input       = str_replace("\r\n", "\n", $input);
-    $this->inputLength = strlen($this->input);
-  }
-
-  // -- Protected Instance Methods ---------------------------------------------
-
-  /**
-   * Action -- do something! What to do is determined by the $command argument.
-   *
-   * action treats a string as a single character. Wow!
-   * action recognizes a regular expression if it is preceded by ( or , or =.
-   *
-   * @uses next()
-   * @uses get()
-   * @throws JSMinException If parser errors are found:
-   *         - Unterminated string literal
-   *         - Unterminated regular expression set in regex literal
-   *         - Unterminated regular expression literal
-   * @param int $command One of class constants:
-   *      ACTION_KEEP_A      Output A. Copy B to A. Get the next B.
-   *      ACTION_DELETE_A    Copy B to A. Get the next B. (Delete A).
-   *      ACTION_DELETE_A_B  Get the next B. (Delete B).
-  */
-  protected function action($command) {
-    switch($command) {
-      case self::ACTION_KEEP_A:
-        $this->output .= $this->a;
-
-      case self::ACTION_DELETE_A:
-        $this->a = $this->b;
-
-        if ($this->a === "'" || $this->a === '"') {
-          for (;;) {
-            $this->output .= $this->a;
-            $this->a       = $this->get();
-
-            if ($this->a === $this->b) {
-              break;
-            }
-
-            if (ord($this->a) <= self::ORD_LF) {
-              throw new JSMinException('Unterminated string literal.');
-            }
-
-            if ($this->a === '\\') {
-              $this->output .= $this->a;
-              $this->a       = $this->get();
-            }
-          }
-        }
-
-      case self::ACTION_DELETE_A_B:
-        $this->b = $this->next();
-
-        if ($this->b === '/' && (
-            $this->a === '(' || $this->a === ',' || $this->a === '=' ||
-            $this->a === ':' || $this->a === '[' || $this->a === '!' ||
-            $this->a === '&' || $this->a === '|' || $this->a === '?' ||
-            $this->a === '{' || $this->a === '}' || $this->a === ';' ||
-            $this->a === "\n" )) {
-
-          $this->output .= $this->a . $this->b;
-
-          for (;;) {
-            $this->a = $this->get();
-
-            if ($this->a === '[') {
-              /*
-                inside a regex [...] set, which MAY contain a '/' itself. Example: mootools Form.Validator near line 460:
-                  return Form.Validator.getValidator('IsEmpty').test(element) || (/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]\.?){0,63}[a-z0-9!#$%&'*+/=?^_`{|}~-]@(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\])$/i).test(element.get('value'));
-              */
-              for (;;) {
-                $this->output .= $this->a;
-                $this->a = $this->get();
-
-                if ($this->a === ']') {
-                    break;
-                } elseif ($this->a === '\\') {
-                  $this->output .= $this->a;
-                  $this->a       = $this->get();
-                } elseif (ord($this->a) <= self::ORD_LF) {
-                  throw new JSMinException('Unterminated regular expression set in regex literal.');
-                }
-              }
-            } elseif ($this->a === '/') {
-              break;
-            } elseif ($this->a === '\\') {
-              $this->output .= $this->a;
-              $this->a       = $this->get();
-            } elseif (ord($this->a) <= self::ORD_LF) {
-              throw new JSMinException('Unterminated regular expression literal.');
-            }
-
-            $this->output .= $this->a;
-          }
-
-          $this->b = $this->next();
-        }
-    }
-  }
-
-  /**
-   * Get next char. Convert ctrl char to space.
-   *
-   * @return string|null
-   */
-  protected function get() {
-    $c = $this->lookAhead;
-    $this->lookAhead = null;
-
-    if ($c === null) {
-      if ($this->inputIndex < $this->inputLength) {
-        $c = substr($this->input, $this->inputIndex, 1);
-        $this->inputIndex += 1;
-      } else {
-        $c = null;
-      }
-    }
-
-    if ($c === "\r") {
-      return "\n";
-    }
-
-    if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) {
-      return $c;
-    }
-
-    return ' ';
-  }
-
-  /**
-   * Is $c a letter, digit, underscore, dollar sign, or non-ASCII character.
-   *
-   * @return bool
-   */
-  protected function isAlphaNum($c) {
-    return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
-  }
-
-  /**
-   * Perform minification, return result
-   *
-   * @uses action()
-   * @uses isAlphaNum()
-   * @return string
-   */
-  protected function min() {
-    $this->a = "\n";
-    $this->action(self::ACTION_DELETE_A_B);
-
-    while ($this->a !== null) {
-      switch ($this->a) {
-        case ' ':
-          if ($this->isAlphaNum($this->b)) {
-            $this->action(self::ACTION_KEEP_A);
-          } else {
-            $this->action(self::ACTION_DELETE_A);
-          }
-          break;
-
-        case "\n":
-          switch ($this->b) {
-            case '{':
-            case '[':
-            case '(':
-            case '+':
-            case '-':
-              $this->action(self::ACTION_KEEP_A);
-              break;
-
-            case ' ':
-              $this->action(self::ACTION_DELETE_A_B);
-              break;
-
-            default:
-              if ($this->isAlphaNum($this->b)) {
-                $this->action(self::ACTION_KEEP_A);
-              }
-              else {
-                $this->action(self::ACTION_DELETE_A);
-              }
-          }
-          break;
-
-        default:
-          switch ($this->b) {
-            case ' ':
-              if ($this->isAlphaNum($this->a)) {
-                $this->action(self::ACTION_KEEP_A);
-                break;
-              }
-
-              $this->action(self::ACTION_DELETE_A_B);
-              break;
-
-            case "\n":
-              switch ($this->a) {
-                case '}':
-                case ']':
-                case ')':
-                case '+':
-                case '-':
-                case '"':
-                case "'":
-                  $this->action(self::ACTION_KEEP_A);
-                  break;
-
-                default:
-                  if ($this->isAlphaNum($this->a)) {
-                    $this->action(self::ACTION_KEEP_A);
-                  }
-                  else {
-                    $this->action(self::ACTION_DELETE_A_B);
-                  }
-              }
-              break;
-
-            default:
-              $this->action(self::ACTION_KEEP_A);
-              break;
-          }
-      }
-    }
-
-    return $this->output;
-  }
-
-  /**
-   * Get the next character, skipping over comments. peek() is used to see
-   *  if a '/' is followed by a '/' or '*'.
-   *
-   * @uses get()
-   * @uses peek()
-   * @throws JSMinException On unterminated comment.
-   * @return string
-   */
-  protected function next() {
-    $c = $this->get();
-
-    if ($c === '/') {
-      switch($this->peek()) {
-        case '/':
-          for (;;) {
-            $c = $this->get();
-
-            if (ord($c) <= self::ORD_LF) {
-              return $c;
-            }
-          }
-
-        case '*':
-          $this->get();
-
-          for (;;) {
-            switch($this->get()) {
-              case '*':
-                if ($this->peek() === '/') {
-                  $this->get();
-                  return ' ';
-                }
-                break;
-
-              case null:
-                throw new JSMinException('Unterminated comment.');
-            }
-          }
-
-        default:
-          return $c;
-      }
-    }
-
-    return $c;
-  }
-
-  /**
-   * Get next char. If is ctrl character, translate to a space or newline.
-   *
-   * @uses get()
-   * @return string|null
-   */
-  protected function peek() {
-    $this->lookAhead = $this->get();
-    return $this->lookAhead;
-  }
-}
-
-// -- Exceptions ---------------------------------------------------------------
-class JSMinException extends Exception {}
-?>

+ 0 - 0
wikipedia3d/json.php


+ 0 - 111
wikipedia3d/libcurlemu.inc.php

@@ -1,111 +0,0 @@
-<?php
-/* CURL Extension Emulation Library
- * Version 1.0.4
- * Copyright 2004-2007, Steve Blinch
- * http://code.blitzaffe.com
- * ============================================================================
- *
- * DESCRIPTION
- *
- * Provides a pure-PHP implementation of the PHP CURL extension, for use on
- * systems which do not already have the CURL extension installed.  It emulates
- * all of the curl_* functions normally provided by the CURL extension itself.
- *
- * This will automatically detect and use the best CURL implementation available
- * on your server.  It will attempt the following, in order:
- *
- * 1) Check for the existence of the "real" CURL PHP Extension.  If it is
- *    loaded, the library will do nothing (and it will not interfere with the
- *    "real" extension).
- * 2) Check for the existence of the CURL console binary (usually located in
- *    /usr/bin/curl).  If found, the library will emulate the CURL PHP
- *    extension (including all curl_* functions) and use the console binary
- *    to execute all requests.
- * 3) If neither the "real" CURL PHP Extension nor the CURL console binary
- *    are available, the library will emulate the CURL PHP extension (including
- *    all curl_* functions) using a native, pure-PHP HTTP client implementation.
- *    This implementation is somewhat limited, but it provides support for most
- *    of the common CURL options.  HTTPS (SSL) support is available in this
- *    mode under PHP 4.3.0 if the OpenSSL Extension is loaded.
- *
- * Thus, by including this library in your project, you can rely on having some
- * level of CURL support regardless of the configuration of the server on which
- * it is being used.
- *
- *
- * HISTORY
- *
- * 1.0.4 (not released)
- *		- Fixed HTTPRetriever double-inclusion bug.
- *
- * 
- * USAGE
- *
- * Simply copy all of the libcurlemu files into your project directory, then:
- *
- * require_once("libcurlemu.inc.php");
- *
- * After this, you can use all of the curl_* functions documented in the PHP
- * Manual.
- *
- *
- * EXAMPLE
- *
- * // CURL Extension Emulation Library Example
- * //
- * // Usage should be straightforward; you simply use this script exactly as you
- * // would normally use the PHP CURL extension functions.
- *
- * // first, include libcurlemu.inc.php
- * require_once('libcurlemu.inc.php');
- *
- * // at this point, libcurlemu has detected the best available CURL solution
- * // (either the CURL extension, if available, or the CURL commandline binary,
- * // if available, or as a last resort, HTTPRetriever, our native-PHP HTTP
- * // client implementation) and has implemented the curl_* functions if
- * // necessary, so you can use CURL normally and safely assume that all CURL
- * // functions are available.
- *
- * // the rest of this example code is copied straight from the PHP manual's
- * // reference for the curl_init() function, and will work fine with libcurlemu
- *
- * // create a new CURL resource
- * $ch = curl_init();
- * 
- * // set URL and other appropriate options
- * curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
- * curl_setopt($ch, CURLOPT_HEADER, false);
- * 
- * // grab URL and pass it to the browser
- * curl_exec($ch);
- * 
- * // close CURL resource, and free up system resources
- * curl_close($ch);
- *
- *
- * LICENSE
- *
- * This script is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * This script is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- * details.
- *	
- * You should have received a copy of the GNU General Public License along
- * with this script; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-if (!extension_loaded('curl') && !function_exists('curl_init')) {
-	define('CURLEXT_MISSING_ABORT',true);
-	require_once(dirname(__FILE__)."/libcurlexternal.inc.php");
-	
-	if (!function_exists('curl_init')) {
-		if (!class_exists('HTTPRetriever')) require_once(dirname(__FILE__)."/class_HTTPRetriever.php");
-		require_once(dirname(__FILE__)."/libcurlnative.inc.php");
-	}
-}
-?>

+ 0 - 637
wikipedia3d/libcurlexternal.inc.php

@@ -1,637 +0,0 @@
-<?php
-/* CURL Extension Emulation Library (Console Binary)
- * Copyright 2004-2007, Steve Blinch
- * http://code.blitzaffe.com
- * ============================================================================
- *
- * DESCRIPTION
- *
- * Provides a pure-PHP implementation of the PHP CURL extension, for use on
- * systems which do not already have the CURL extension installed.  It emulates
- * all of the curl_* functions normally provided by the CURL extension itself
- * by wrapping the CURL console binary.
- *
- * This library will automatically detect whether or not the "real" CURL
- * extension is installed, and if so, it will not interfere.  Thus, it can be
- * used to ensure that, one way or another, the CURL functions are available
- * for use.
- *
- * This library is actually a wrapper for the CURL console application (usually
- * found in /usr/bin/curl), so you must have the CURL binary installed in order
- * to use this script.
- *
- *
- * USAGE
- *
- * Please see the PHP documentation under the "CURL, Client URL Library 
- * Functions" section for information about using this library.  Almost all of
- * the documentation and examples in the PHP manual should work with this
- * library.
- *
- *
- * LICENSE
- *
- * This script is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * This script is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- * details.
- *	
- * You should have received a copy of the GNU General Public License along
- * with this script; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-// if the real CURL PHP extension is installed, exit without doing anything
-if (!extension_loaded("curl")) {
-
-// if the CURL path was not defined by the calling script, define it
-if (!defined("CURL_PATH")) define("CURL_PATH","/usr/bin/curl");
-
-// if the CURL binary was not found, do one of the following:
-//   - if CURLEXT_MISSING_ABORT was defined, then exit without implementing the CURL functions
-//   - if CURLEXT_MISSING_IGNORE was defined, then implement the CURL functions anyway (even
-//     though they won't work without the CURL binary installed)
-//   - otherwise, raise a fatal error and halt the script
-if (!@is_executable(CURL_PATH)) {
-	
- 	if (defined("CURLEXT_MISSING_ABORT") && CURLEXT_MISSING_ABORT) {
- 		return;
- 	} elseif (defined("CURLEXT_MISSING_IGNORE") && CURLEXT_MISSING_IGNORE) {
- 		// proceed and implement the CURL functions anyway, even though they won't work
- 	} else {
-		trigger_error("CURL extension is not loaded, and the commandline version of CURL was not found at ".CURL_PATH,E_USER_ERROR);
-	}
-}
-
-define("CURLEXT_VERSION","1.0.0");
-
-define('CURLOPT_NOTHING',0);
-define('CURLOPT_FILE',10001);
-define('CURLOPT_URL',10002);
-define('CURLOPT_PORT',3);
-define('CURLOPT_PROXY',10004);
-define('CURLOPT_USERPWD',10005);
-define('CURLOPT_PROXYUSERPWD',10006);
-define('CURLOPT_RANGE',10007);
-define('CURLOPT_INFILE',10009);
-define('CURLOPT_ERRORBUFFER',10010);
-define('CURLOPT_WRITEFUNCTION',20011);
-define('CURLOPT_READFUNCTION',20012);
-define('CURLOPT_TIMEOUT',13);
-define('CURLOPT_INFILESIZE',14);
-define('CURLOPT_POSTFIELDS',10015);
-define('CURLOPT_REFERER',10016);
-define('CURLOPT_FTPPORT',10017);
-define('CURLOPT_USERAGENT',10018);
-define('CURLOPT_LOW_SPEED_LIMIT',19);
-define('CURLOPT_LOW_SPEED_TIME',20);
-define('CURLOPT_RESUME_FROM',21);
-define('CURLOPT_COOKIE',10022);
-define('CURLOPT_HTTPHEADER',10023);
-define('CURLOPT_HTTPPOST',10024);
-define('CURLOPT_SSLCERT',10025);
-define('CURLOPT_SSLCERTPASSWD',10026);
-define('CURLOPT_SSLKEYPASSWD',10026);
-define('CURLOPT_CRLF',27);
-define('CURLOPT_QUOTE',10028);
-define('CURLOPT_WRITEHEADER',10029);
-define('CURLOPT_COOKIEFILE',10031);
-define('CURLOPT_SSLVERSION',32);
-define('CURLOPT_TIMECONDITION',33);
-define('CURLOPT_TIMEVALUE',34);
-define('CURLOPT_HTTPREQUEST',10035);
-define('CURLOPT_CUSTOMREQUEST',10036);
-define('CURLOPT_STDERR',10037);
-define('CURLOPT_POSTQUOTE',10039);
-define('CURLOPT_WRITEINFO',10040);
-define('CURLOPT_VERBOSE',41);
-define('CURLOPT_HEADER',42);
-define('CURLOPT_NOPROGRESS',43);
-define('CURLOPT_NOBODY',44);
-define('CURLOPT_FAILONERROR',45);
-define('CURLOPT_UPLOAD',46);
-define('CURLOPT_POST',47);
-define('CURLOPT_FTPLISTONLY',48);
-define('CURLOPT_FTPAPPEND',50);
-define('CURLOPT_NETRC',51);
-define('CURLOPT_FOLLOWLOCATION',52);
-define('CURLOPT_FTPASCII',53);
-define('CURLOPT_TRANSFERTEXT',53);
-define('CURLOPT_PUT',54);
-define('CURLOPT_MUTE',55);
-define('CURLOPT_PROGRESSFUNCTION',20056);
-define('CURLOPT_PROGRESSDATA',10057);
-define('CURLOPT_AUTOREFERER',58);
-define('CURLOPT_PROXYPORT',59);
-define('CURLOPT_POSTFIELDSIZE',60);
-define('CURLOPT_HTTPPROXYTUNNEL',61);
-define('CURLOPT_INTERFACE',10062);
-define('CURLOPT_KRB4LEVEL',10063);
-define('CURLOPT_SSL_VERIFYPEER',64);
-define('CURLOPT_CAINFO',10065);
-define('CURLOPT_PASSWDFUNCTION',20066);
-define('CURLOPT_PASSWDDATA',10067);
-define('CURLOPT_MAXREDIRS',68);
-define('CURLOPT_FILETIME',10069);
-define('CURLOPT_TELNETOPTIONS',10070);
-define('CURLOPT_MAXCONNECTS',71);
-define('CURLOPT_CLOSEPOLICY',72);
-define('CURLOPT_CLOSEFUNCTION',20073);
-define('CURLOPT_FRESH_CONNECT',74);
-define('CURLOPT_FORBID_REUSE',75);
-define('CURLOPT_RANDOM_FILE',10076);
-define('CURLOPT_EGDSOCKET',10077);
-define('CURLOPT_CONNECTTIMEOUT',78);
-define('CURLOPT_HEADERFUNCTION',20079);
-define('CURLOPT_HTTPGET',80);
-define('CURLOPT_SSL_VERIFYHOST',81);
-define('CURLOPT_COOKIEJAR',10082);
-define('CURLOPT_SSL_CIPHER_LIST',10083);
-define('CURLOPT_HTTP_VERSION',84);
-define('CURLOPT_FTP_USE_EPSV',85);
-define('CURLOPT_SSLCERTTYPE',10086);
-define('CURLOPT_SSLKEY',10087);
-define('CURLOPT_SSLKEYTYPE',10088);
-define('CURLOPT_SSLENGINE',10089);
-define('CURLOPT_SSLENGINE_DEFAULT',90);
-define('CURLOPT_DNS_USE_GLOBAL_CACHE',91);
-define('CURLOPT_DNS_CACHE_TIMEOUT',92);
-define('CURLOPT_PREQUOTE',10093); 
-
-define('CURLINFO_EFFECTIVE_URL',1);
-define('CURLINFO_HTTP_CODE',2);
-define('CURLINFO_FILETIME',14);
-define('CURLINFO_TOTAL_TIME',3);
-define('CURLINFO_NAMELOOKUP_TIME',4);
-define('CURLINFO_CONNECT_TIME',5);
-define('CURLINFO_PRETRANSFER_TIME',6);
-define('CURLINFO_STARTTRANSFER_TIME',17);
-define('CURLINFO_REDIRECT_TIME',19);
-define('CURLINFO_REDIRECT_COUNT',20);
-define('CURLINFO_SIZE_UPLOAD',7);
-define('CURLINFO_SIZE_DOWNLOAD',8);
-define('CURLINFO_SPEED_DOWNLOAD',9);
-define('CURLINFO_SPEED_UPLOAD',10);
-define('CURLINFO_HEADER_SIZE',11);
-define('CURLINFO_REQUEST_SIZE',12);
-define('CURLINFO_SSL_VERIFYRESULT',13);
-define('CURLINFO_CONTENT_LENGTH_DOWNLOAD',15);
-define('CURLINFO_CONTENT_LENGTH_UPLOAD',16);
-define('CURLINFO_CONTENT_TYPE',18);
-
-
-define("TIMECOND_ISUNMODSINCE",1);
-define("TIMECOND_IFMODSINCE",2);
-
-
-function _curlopt_name($curlopt) {
-	foreach (get_defined_constants() as $k=>$v) {
-		if ( (substr($k,0,8)=="CURLOPT_") && ($v==$curlopt)) return $k;
-	}
-	return false;
-}
-
-// Initialize a CURL emulation session
-function curl_init($url=false) {
-	$i = $GLOBALS["_CURLEXT_OPT"]["index"]++;
-	$GLOBALS["_CURLEXT_OPT"][$i] = array("url"=>$url);
-	
-	return $i;
-}
-
-// Set an option for a CURL emulation transfer 
-function curl_setopt($ch,$option,$value) {
-	
-	$opt = &$GLOBALS["_CURLEXT_OPT"][$ch];
-	if (!$opt["args"]) $opt["args"] = array();
-	$args = &$opt["args"];
-	if (!$opt["settings"]) $opt["settings"] = array();
-	$settings = &$opt["settings"];
-	
-	switch($option) {
-		case CURLOPT_URL:
-			$opt["url"] = $value;
-			break;
-		case CURLOPT_VERBOSE:
-			$opt["verbose"] = $value>0;
-			break;
-		case CURLOPT_USERPWD:
-			if ($value==="") $value = false;
-			$settings["user"] = $value;
-			break;
-		case CURLOPT_PROXYUSERPWD:
-			if ($value==="") $value = false;
-			$settings["proxy-user"] = $value;
-			break;
-		case CURLOPT_COOKIE:
-			if ($value==="") $value = false;
-			if ( is_bool($value) || (strpos($value,"=")!==false) ) $settings["cookie"] = $value;
-			break;
-		case CURLOPT_COOKIEFILE:
-			if ($value==="") $value = false;
-			$settings["cookie"] = $value;
-			break;
-		case CURLOPT_COOKIEJAR:
-			if ($value==="") $value = false;
-			$settings["cookie-jar"] = $value;
-			break;
-		case CURLOPT_CUSTOMREQUEST:
-			if ($value==="") $value = false;
-			$settings["request"] = $value;
-			break;
-		case CURLOPT_PROXY:
-			if ($value==="") $value = false;
-			$settings["proxy"] = $value;
-			break;
-		case CURLOPT_INTERFACE:
-			if ($value==="") $value = false;
-			$settings["interface"] = $value;
-			break;
-		case CURLOPT_KRB4LEVEL:
-			if ($value==="") $value = false;
-			$settings["krb4"] = $value;
-			break;
-		case CURLOPT_SSLCERT:
-			$pass = "";
-			if (is_string($settings["cert"])) {
-				list(,$pass) = explode(":",$settings["cert"]);
-				if (strlen($pass)) $pass = ":$pass";
-			}
-			$settings["cert"] = $value.$pass;
-			break;
-		case CURLOPT_SSLCERTPASSWD:
-			$filename = "";
-			if (is_string($settings["cert"])) {
-				list($filename,) = explode(":",$settings["cert"]);
-			}
-			$settings["cert"] = $filename.":".$value;
-			break;
-		case CURLOPT_RANGE:
-			if ($value==="") $value = false;
-			$settings["range"] = $value;
-			break;
-		case CURLOPT_REFERER:
-			if ($value==="") $value = false;
-			$settings["referer"] = $value;
-			break;
-		case CURLOPT_NOBODY:
-			$settings["head"] = $value>0;
-			break;
-		case CURLOPT_FAILONERROR:
-			$opt["fail_on_error"] = $value>0;
-			break;
-		case CURLOPT_USERAGENT:
-			$settings["user-agent"] = $value;
-			break;
-		case CURLOPT_HEADER:
-			$settings["include"] = $value>0;
-			break;
-		case CURLOPT_RETURNTRANSFER:
-			$opt["return_transfer"] = $value>0;
-			break;
-		case CURLOPT_TIMEOUT:
-			$settings["max-time"] = (int) $value;
-			break;
-		case CURLOPT_HTTPHEADER:
-			reset($value);
-			foreach ($value as $k=>$header) $args[] = "header=".$header;
-			break;
-		case CURLOPT_POST:
-			$settings["data"]["enabled"] = $value>0;
-			break;
-		case CURLOPT_POSTFIELDS:
-			if ($value==="") $value = false;
-			$settings["data"]["value"] = $value;
-			break;
-		case CURLOPT_SSL_VERIFYPEER:
-			$settings["insecure"] = ($value==0);
-			break;
-		case CURLOPT_SSL_VERIFYHOST:
-			// not supported by the commandline client
-			break;
-		case CURLOPT_FOLLOWLOCATION:
-			$settings["location"] = $value>0;
-			break;
-		case CURLOPT_PUT:
-			$settings["upload-file"]["enabled"] = $value>0;
-			break;
-		case CURLOPT_INFILE:
-			if ($value==="") $value = false;
-			
-			if (is_resource($value)) {
-				
-				// Ugh, this is a terrible hack.  The CURL extension accepts a file handle, but
-				// the CURL binary obviously wants a filename.  Since you can't derive a filename
-				// from a file handle, we have to make a copy of the file from the file handle,
-				// then pass the temporary filename to the CURL binary.
-				
-				$tmpfilename = tempnam("/tmp","cif");
-				$fp = @fopen($tmpfilename,"w");
-				if (!$fp) {
-					trigger_error("CURL emulation library could not create a temporary file for CURLOPT_INFILE; upload aborted",E_USER_WARNING);
-				} else {
-					while (!feof($value)) {
-						$contents = fread($value,8192);
-						fwrite($fp,$contents);
-					}
-					fclose($fp);
-					// if a temporary file was previously created, unlink it
-					if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"])) unlink($settings["upload-file"]["value"]);
-					
-					// set the new upload-file filename
-					$settings["upload-file"]["value"] = $tmpfilename;
-				}
-			} else {
-				trigger_error("CURLOPT_INFILE must specify a valid file resource",E_USER_WARNING);
-			}
-			
-			break;
-		case CURLOPT_MUTE:
-			// we're already mute, no?
-			break;
-		case CURLOPT_LOW_SPEED_LIMIT:
-			$settings["speed-limit"] = (int) $value;
-			break;
-		case CURLOPT_LOW_SPEED_TIME:
-			$settings["speed-time"] = (int) $value;
-			break;
-		case CURLOPT_RESUME_FROM:
-			$settings["continue-at"] = (int) $value;
-			break;
-		case CURLOPT_CAINFO:
-			if ($value==="") $value = false;
-			$settings["cacert"] = $value;
-			break;
-		case CURLOPT_SSLVERSION:
-			$value = (int) $value;
-			switch($value) {
-				case 2:
-				case 3:
-					unset($settings["sslv2"]);
-					unset($settings["sslv3"]);
-					$settings["sslv".$value] = true;
-					break;
-			}
-			break;
-		case CURLOPT_TIMECONDITION:
-			// untested - I'm lazy :)
-			if (!isset($settings["time-cond"]["enabled"])) $settings["time-cond"]["enabled"] = false;
-			if (!$settings["time-cond"]["value"]) $settings["time-cond"]["value"] = 1;
-
-			$settings["time-cond"]["value"] = abs($settings["time-cond"]["value"]);
-			if ($value==TIMECOND_ISUNMODSINCE) {
-				$settings["time-cond"]["value"] *= -1;
-			}			
-			
-			break;
-		case CURLOPT_TIMEVALUE:
-			// untested - I'm lazy :)
-			if ($settings["time-cond"]["value"]) {
-				$sign = $settings["time-cond"]["value"] / abs($settings["time-cond"]["value"]);
-			} else {
-				$sign = 1;
-			}
-			$settings["time-cond"]["value"] = (int) $value * $sign;
-			break;
-		case CURLOPT_FILE:
-			if (is_resource($value)) {
-				$opt["output_handle"] = $value;
-			} else {
-				trigger_error("CURLOPT_FILE must specify a valid file resource",E_USER_WARNING);
-			}
-			break;
-		case CURLOPT_WRITEHEADER:
-			if (is_resource($value)) {
-				$opt["header_handle"] = $value;
-			} else {
-				trigger_error("CURLOPT_WRITEHEADER must specify a valid file resource",E_USER_WARNING);
-			}
-			break;
-		case CURLOPT_STDERR:
-			// not implemented for now - not really relevant
-			break;
-		// FTP stuff not implemented
-		case CURLOPT_QUOTE:
-		case CURLOPT_POSTQUOTE:
-		case CURLOPT_UPLOAD:
-		case CURLOPT_FTPLISTONLY:
-		case CURLOPT_FTPAPPEND:
-		case CURLOPT_FTPPORT:
-		// Other stuff not implemented
-		case CURLOPT_NETRC:
-		default:
-			trigger_error("CURL emulation does not implement CURL option "._curlopt_name($option),E_USER_WARNING);
-			break;
-	}
-}
-
-// Perform a CURL emulation session
-function curl_exec($ch) {
-	$opt = &$GLOBALS["_CURLEXT_OPT"][$ch];
-	$url = $opt["url"];
-	$verbose = $opt["verbose"];
-	
-	// ask commandline CURL to return its statistics at the end of its output
-	$opt["settings"]["write-out"] = "%{http_code}|%{time_total}|%{time_namelookup}|%{time_connect}|%{time_pretransfer}|%{time_starttransfer}|%{size_download}|%{size_upload}|%{size_header}|%{size_request}|%{speed_download}|%{speed_upload}|||||||%{content_type}|%{url_effective}";
-	$writeout_order = array(
-		CURLINFO_HTTP_CODE,
-		CURLINFO_TOTAL_TIME,
-		CURLINFO_NAMELOOKUP_TIME,
-		CURLINFO_CONNECT_TIME,
-		CURLINFO_PRETRANSFER_TIME,
-		CURLINFO_STARTTRANSFER_TIME,
-		CURLINFO_SIZE_DOWNLOAD,
-		CURLINFO_SIZE_UPLOAD,
-		CURLINFO_HEADER_SIZE,
-		CURLINFO_REQUEST_SIZE,
-		CURLINFO_SPEED_DOWNLOAD,
-		CURLINFO_SPEED_UPLOAD,
-
-		// the following 5 items are not provided by commandline CURL, and thus are left empty
-		CURLINFO_FILETIME,
-		CURLINFO_REDIRECT_TIME,
-		CURLINFO_SSL_VERIFYRESULT,
-		CURLINFO_CONTENT_LENGTH_DOWNLOAD,
-		CURLINFO_CONTENT_LENGTH_UPLOAD,
-		CURLINFO_REDIRECT_COUNT,
-
-		CURLINFO_CONTENT_TYPE,
-		CURLINFO_EFFECTIVE_URL,
-	);
-
-	// if the CURLOPT_NOBODY option was specified (to remove the body from the output),
-	// but an output file handle was set, we need to tell CURL to return the body so
-	// that we can write it to the output handle and strip it from the output
-	if ($opt["settings"]["head"] && $opt["output_handle"]) {
-		unset($opt["settings"]["head"]);
-		$strip_body = true;
-	}
-	// if the CURLOPT_HEADER option was NOT specified, but a header file handle was
-	// specified, we again need to tell CURL to return the headers so we can write
-	// them, then strip them from the output
-	if (!isset($opt["settings"]["include"]) && isset($opt["header_handle"])) {
-		$opt["settings"]["include"] = true;
-		$strip_headers = true;
-	}
-
-	// build the CURL argument list
-	$arguments = "";
-	foreach ($opt["args"] as $k=>$arg) {
-		list($argname,$argval) = explode('=',$arg,2);
-		$arguments .= "--$argname ".escapeshellarg($argval)." ";
-	}	
-	foreach ($opt["settings"] as $argname=>$argval) {
-		if (is_array($argval)) {
-			if (isset($argval["enabled"]) && !$argval["enabled"]) continue;
-			$argval = $argval["value"];
-		}
-		if ($argval===false) continue;
-		if (is_bool($argval)) $argval = "";
-		$arguments .= "--$argname ".escapeshellarg($argval)." ";
-	}
-
-	// build the CURL commandline and execute it
-	$cmd = CURL_PATH." ".$arguments." ".escapeshellarg($url);
-	
-	if ($verbose) echo "libcurlemu: Executing: $cmd\n";
-	exec($cmd,$output,$ret);
-	
-	if ($verbose) {
-		echo "libcurlemu: Result: ";
-		var_dump($output);
-		echo "libcurlemu: Exit code: $ret\n";
-	}
-	
-	// check for errors
-	$opt["errno"] = $ret;
-	if ($ret) $opt["error"] = "CURL error #$ret";
-	
-	// die if CURLOPT_FAILONERROR is set and the HTTP result code is greater than 300
-	if ($opt["fail_on_error"]) {
-		if (preg_match("/^HTTP\/1.[0-9]+ ([0-9]{3}) /",$output[0],$matches)) {
-			$resultcode = (int) $matches[1];
-			if ($resultcode>300) die;
-		} else {
-			die; // couldn't get result code!
-		}
-	}
-	
-	// pull the statistics out from the output
-	$stats = explode('|',array_pop($output));
-	foreach ($writeout_order as $k=>$item) {
-		$opt["stats"][$item] = $stats[$k];
-	}
-
-	// build the response string
-	$output = implode("\r\n",$output);
-
-	
-	// find the header end position if needed
-	if ($strip_headers || $strip_body || isset($opt["header_handle"])) {
-		$headerpos = strpos($output,"\r\n\r\n");
-	}
-
-	// if a file handle was provided for header output, extract the headers
-	// and write them to the handle
-	if (isset($opt["header_handle"])) {
-		$headers = substr($output,0,$headerpos);
-		fwrite($opt["header_handle"],$headers);
-	}
-	
-	// if the caller did not request headers in the output, strip them
-	if ($strip_headers) {
-		$output = substr($output,$headerpos+4);
-	}
-	
-	// if the caller did not request the response body in the output, strip it
-	if ($strip_body) {
-		if ($strip_headers) {
-			$body = $output;
-			$output = "";
-		} else {
-			$body = substr($output,$headerpos+4);
-			$output = substr($output,0,$headerpos);
-		}
-	}
-	
-	// if a file handle was provided for output, write the output to it
-	if (isset($opt["output_handle"])) {
-		fwrite($opt["output_handle"],$output);
-		
-	// if the caller requested that the response be returned, return it
-	} elseif ($opt["return_transfer"]) {
-		return $output;
-		
-	// otherwise, just echo the output to stdout
-	} else {
-		echo $output;
-	}
-	return true;
-}
-
-function curl_close($ch) {
-	$opt = &$GLOBALS["_CURLEXT_OPT"][$ch];
-	
-	if ($opt["settings"]) {
-		$settings = &$opt["settings"];
-		// if the user used CURLOPT_INFILE to specify a file to upload, remove the
-		// temporary file created for the CURL binary
-		if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"])) unlink($settings["upload-file"]["value"]);
-	}
-
-	unset($GLOBALS["_CURLEXT_OPT"][$ch]);
-}
-
-function curl_errno($ch) {
-	return (int) $GLOBALS["_CURLEXT_OPT"][$ch]["errno"];
-}
-
-function curl_error($ch) {
-	return $GLOBALS["_CURLEXT_OPT"][$ch]["error"];
-}
-
-function curl_getinfo($ch,$opt=NULL) {
-	if ($opt) {
-		return $GLOBALS["_CURLEXT_OPT"][$ch]["stats"][$opt];
-	} else {
-		$curlinfo_tags = array(
-			"url"=>CURLINFO_EFFECTIVE_URL,
-			"content_type"=>CURLINFO_CONTENT_TYPE,
-			"http_code"=>CURLINFO_HTTP_CODE,
-			"header_size"=>CURLINFO_HEADER_SIZE,
-			"request_size"=>CURLINFO_REQUEST_SIZE,
-			"filetime"=>CURLINFO_FILETIME,
-			"ssl_verify_result"=>CURLINFO_SSL_VERIFYRESULT,
-			"redirect_count"=>CURLINFO_REDIRECT_COUNT,
-			"total_time"=>CURLINFO_TOTAL_TIME,
-			"namelookup_time"=>CURLINFO_NAMELOOKUP_TIME,
-			"connect_time"=>CURLINFO_CONNECT_TIME,
-			"pretransfer_time"=>CURLINFO_PRETRANSFER_TIME,
-			"size_upload"=>CURLINFO_SIZE_UPLOAD,
-			"size_download"=>CURLINFO_SIZE_DOWNLOAD,
-			"speed_download"=>CURLINFO_SPEED_DOWNLOAD,
-			"speed_upload"=>CURLINFO_SPEED_UPLOAD,
-			"download_content_length"=>CURLINFO_CONTENT_LENGTH_DOWNLOAD,
-			"upload_content_length"=>CURLINFO_CONTENT_LENGTH_UPLOAD,
-			"starttransfer_time"=>CURLINFO_STARTTRANSFER_TIME,
-			"redirect_time"=>CURLINFO_REDIRECT_TIME
-		);
-		$res = array();
-		foreach ($curlinfo_tags as $tag=>$opt) {
-			$res[$tag] = $GLOBALS["_CURLEXT_OPT"][$ch]["stats"][$opt];
-		}
-		return $res;
-	}
-}
-
-function curl_version() {
-	return "libcurlemu/".CURLEXT_VERSION."-ext";
-}
-
-}
-?>

+ 0 - 453
wikipedia3d/libcurlnative.inc.php

@@ -1,453 +0,0 @@
-<?php
-/* CURL Extension Emulation Library (Native PHP)
- * Copyright 2004-2007, Steve Blinch
- * http://code.blitzaffe.com
- * ============================================================================
- *
- * DESCRIPTION
- *
- * Provides a pure-PHP implementation of the PHP CURL extension, for use on
- * systems which do not already have the CURL extension installed.  It emulates
- * all of the curl_* functions normally provided by the CURL extension itself,
- * and uses an internal, native-PHP HTTP library to make requests.
- *
- * This library will automatically detect whether or not the "real" CURL
- * extension is installed, and if so, it will not interfere.  Thus, it can be
- * used to ensure that, one way or another, the CURL functions are available
- * for use.
- *
- * Note that this is only a *rough* emulation of CURL; it is not exact, and
- * many of CURL's options are not implemented.  For a more precise emulation of
- * CURL, you may want to try our other libcurlexternal library which is based on
- * the CURL console binary (and is virtually identical to the CURL extension).
- *
- *
- * USAGE
- *
- * Please see the PHP documentation under the "CURL, Client URL Library 
- * Functions" section for information about using this library.  Almost all of
- * the documentation and examples in the PHP manual should work with this
- * library.
- *
- *
- * LICENSE
- *
- * This script is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * This script is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- * details.
- *	
- * You should have received a copy of the GNU General Public License along
- * with this script; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- 
-// if the real CURL PHP extension is installed, exit without doing anything;
-// if libcurlemu is installed and providing a wrapper for the CURL binary,
-// exit without doing anything
-if (!extension_loaded("curl") && !function_exists("curl_init")) {
-
-
-// if the CURL binary was not found, do one of the following:
-//   - if CURLNAT_MISSING_ABORT was defined, then exit without
-//     implementing the CURL functions
-//   - otherwise, raise a fatal error and halt the script
-if (!class_exists("HTTPRetriever")) {
-	if (is_readable(dirname(__FILE__)."/class_HTTPRetriever.php")) {
-		define("HTTPR_NO_REDECLARE_CURL",true);
-		require_once(dirname(__FILE__)."/class_HTTPRetriever.php");
-	} else {
-	 	if (defined("CURLNAT_MISSING_ABORT") && CURLNAT_MISSING_ABORT) {
-	 		return;
-	 	} else {
-			trigger_error("CURL extension is not loaded, libcurlemu is not loaded, and the HTTPRetriever class is unavailable",E_USER_ERROR);
-		}
-	}
-}
-
-define("CURLNAT_VERSION","1.0.0");
-
-define('CURLOPT_NOTHING',0);
-define('CURLOPT_FILE',10001);
-define('CURLOPT_URL',10002);
-define('CURLOPT_PORT',3);
-define('CURLOPT_PROXY',10004);
-define('CURLOPT_USERPWD',10005);
-define('CURLOPT_PROXYUSERPWD',10006);
-define('CURLOPT_RANGE',10007);
-define('CURLOPT_INFILE',10009);
-define('CURLOPT_ERRORBUFFER',10010);
-define('CURLOPT_WRITEFUNCTION',20011);
-define('CURLOPT_READFUNCTION',20012);
-define('CURLOPT_TIMEOUT',13);
-define('CURLOPT_INFILESIZE',14);
-define('CURLOPT_POSTFIELDS',10015);
-define('CURLOPT_REFERER',10016);
-define('CURLOPT_FTPPORT',10017);
-define('CURLOPT_USERAGENT',10018);
-define('CURLOPT_LOW_SPEED_LIMIT',19);
-define('CURLOPT_LOW_SPEED_TIME',20);
-define('CURLOPT_RESUME_FROM',21);
-define('CURLOPT_COOKIE',10022);
-define('CURLOPT_HTTPHEADER',10023);
-define('CURLOPT_HTTPPOST',10024);
-define('CURLOPT_SSLCERT',10025);
-define('CURLOPT_SSLCERTPASSWD',10026);
-define('CURLOPT_SSLKEYPASSWD',10026);
-define('CURLOPT_CRLF',27);
-define('CURLOPT_QUOTE',10028);
-define('CURLOPT_WRITEHEADER',10029);
-define('CURLOPT_COOKIEFILE',10031);
-define('CURLOPT_SSLVERSION',32);
-define('CURLOPT_TIMECONDITION',33);
-define('CURLOPT_TIMEVALUE',34);
-define('CURLOPT_HTTPREQUEST',10035);
-define('CURLOPT_CUSTOMREQUEST',10036);
-define('CURLOPT_STDERR',10037);
-define('CURLOPT_POSTQUOTE',10039);
-define('CURLOPT_WRITEINFO',10040);
-define('CURLOPT_VERBOSE',41);
-define('CURLOPT_HEADER',42);
-define('CURLOPT_NOPROGRESS',43);
-define('CURLOPT_NOBODY',44);
-define('CURLOPT_FAILONERROR',45);
-define('CURLOPT_UPLOAD',46);
-define('CURLOPT_POST',47);
-define('CURLOPT_FTPLISTONLY',48);
-define('CURLOPT_FTPAPPEND',50);
-define('CURLOPT_NETRC',51);
-define('CURLOPT_FOLLOWLOCATION',52);
-define('CURLOPT_FTPASCII',53);
-define('CURLOPT_TRANSFERTEXT',53);
-define('CURLOPT_PUT',54);
-define('CURLOPT_MUTE',55);
-define('CURLOPT_PROGRESSFUNCTION',20056);
-define('CURLOPT_PROGRESSDATA',10057);
-define('CURLOPT_AUTOREFERER',58);
-define('CURLOPT_PROXYPORT',59);
-define('CURLOPT_POSTFIELDSIZE',60);
-define('CURLOPT_HTTPPROXYTUNNEL',61);
-define('CURLOPT_INTERFACE',10062);
-define('CURLOPT_KRB4LEVEL',10063);
-define('CURLOPT_SSL_VERIFYPEER',64);
-define('CURLOPT_CAINFO',10065);
-define('CURLOPT_PASSWDFUNCTION',20066);
-define('CURLOPT_PASSWDDATA',10067);
-define('CURLOPT_MAXREDIRS',68);
-define('CURLOPT_FILETIME',10069);
-define('CURLOPT_TELNETOPTIONS',10070);
-define('CURLOPT_MAXCONNECTS',71);
-define('CURLOPT_CLOSEPOLICY',72);
-define('CURLOPT_CLOSEFUNCTION',20073);
-define('CURLOPT_FRESH_CONNECT',74);
-define('CURLOPT_FORBID_REUSE',75);
-define('CURLOPT_RANDOM_FILE',10076);
-define('CURLOPT_EGDSOCKET',10077);
-define('CURLOPT_CONNECTTIMEOUT',78);
-define('CURLOPT_HEADERFUNCTION',20079);
-define('CURLOPT_HTTPGET',80);
-define('CURLOPT_SSL_VERIFYHOST',81);
-define('CURLOPT_COOKIEJAR',10082);
-define('CURLOPT_SSL_CIPHER_LIST',10083);
-define('CURLOPT_HTTP_VERSION',84);
-define('CURLOPT_FTP_USE_EPSV',85);
-define('CURLOPT_SSLCERTTYPE',10086);
-define('CURLOPT_SSLKEY',10087);
-define('CURLOPT_SSLKEYTYPE',10088);
-define('CURLOPT_SSLENGINE',10089);
-define('CURLOPT_SSLENGINE_DEFAULT',90);
-define('CURLOPT_DNS_USE_GLOBAL_CACHE',91);
-define('CURLOPT_DNS_CACHE_TIMEOUT',92);
-define('CURLOPT_PREQUOTE',10093); 
-
-define('CURLINFO_EFFECTIVE_URL',1);
-define('CURLINFO_HTTP_CODE',2);
-define('CURLINFO_FILETIME',14);
-define('CURLINFO_TOTAL_TIME',3);
-define('CURLINFO_NAMELOOKUP_TIME',4);
-define('CURLINFO_CONNECT_TIME',5);
-define('CURLINFO_PRETRANSFER_TIME',6);
-define('CURLINFO_STARTTRANSFER_TIME',17);
-define('CURLINFO_REDIRECT_TIME',19);
-define('CURLINFO_REDIRECT_COUNT',20);
-define('CURLINFO_SIZE_UPLOAD',7);
-define('CURLINFO_SIZE_DOWNLOAD',8);
-define('CURLINFO_SPEED_DOWNLOAD',9);
-define('CURLINFO_SPEED_UPLOAD',10);
-define('CURLINFO_HEADER_SIZE',11);
-define('CURLINFO_REQUEST_SIZE',12);
-define('CURLINFO_SSL_VERIFYRESULT',13);
-define('CURLINFO_CONTENT_LENGTH_DOWNLOAD',15);
-define('CURLINFO_CONTENT_LENGTH_UPLOAD',16);
-define('CURLINFO_CONTENT_TYPE',18);
-
-
-define("TIMECOND_ISUNMODSINCE",1);
-define("TIMECOND_IFMODSINCE",2);
-
-
-function _curlopt_name($curlopt) {
-	foreach (get_defined_constants() as $k=>$v) {
-		if ( (substr($k,0,8)=="CURLOPT_") && ($v==$curlopt)) return $k;
-	}
-	return false;
-}
-
-// Initialize a CURL emulation session
-function curl_init() {
-	$i = $GLOBALS["_CURLNAT_OPT"]["index"]++;
-	$GLOBALS["_CURLNAT_OPT"][$i] = array();
-	$GLOBALS["_CURLNAT_OPT"][$i]["http"] = &new HTTPRetriever();
-	$GLOBALS["_CURLNAT_OPT"][$i]["include_body"] = true;
-	return $i;
-}
-
-// Set an option for a CURL emulation transfer 
-function curl_setopt($ch,$option,$value) {
-	
-	$opt = &$GLOBALS["_CURLNAT_OPT"][$ch];
-	if (!$opt["args"]) $opt["args"] = array();
-	$args = &$opt["args"];
-	if (!$opt["settings"]) $opt["settings"] = array();
-	$settings = &$opt["settings"];
-	$http = &$opt["http"];
-	
-	switch($option) {
-		case CURLOPT_URL:
-			$opt["url"] = $value;
-			break;
-		case CURLOPT_CUSTOMREQUEST:
-			$opt["method"] = $value;
-			break;
-		case CURLOPT_REFERER:
-			$http->headers["Referer"] = $value;
-			break;
-		case CURLOPT_NOBODY:
-			$opt["include_body"] = $value==0;
-			break;
-		case CURLOPT_FAILONERROR:
-			$opt["fail_on_error"] = $value>0;
-			break;
-		case CURLOPT_USERAGENT:
-			$http->headers["User-Agent"] = $value;
-			break;
-		case CURLOPT_HEADER:
-			$opt["include_headers"] = $value>0;
-			break;
-		case CURLOPT_RETURNTRANSFER:
-			$opt["return_transfer"] = $value>0;
-			break;
-		case CURLOPT_TIMEOUT:
-			$opt["max-time"] = (int) $value;
-			break;
-		case CURLOPT_HTTPHEADER:
-			reset($value);
-			foreach ($value as $k=>$header) {
-				list($headername,$headervalue) = explode(":",$header);
-				$http->headers[$headername] = ltrim($headervalue);
-			}
-			break;
-		case CURLOPT_POST:
-			$opt["post"] = $value>0;
-			break;
-		case CURLOPT_POSTFIELDS:
-			$opt["postdata"] = $value;
-			break;
-		case CURLOPT_MUTE:
-			// we're already mute, no?
-			break;
-		case CURLOPT_FILE:
-			if (is_resource($value)) {
-				$opt["output_handle"] = $value;
-			} else {
-				trigger_error("CURLOPT_FILE must specify a valid file resource",E_USER_WARNING);
-			}
-			break;
-		case CURLOPT_WRITEHEADER:
-			if (is_resource($value)) {
-				$opt["header_handle"] = $value;
-			} else {
-				trigger_error("CURLOPT_WRITEHEADER must specify a valid file resource",E_USER_WARNING);
-			}
-			break;
-		case CURLOPT_STDERR:
-			// not implemented for now - not really relevant
-			break;
-
-		case CURLOPT_SSL_VERIFYPEER:
-		case CURLOPT_SSL_VERIFYHOST:
-			// these are automatically disabled using ssl:// anyway
-			break;
-			
-		case CURLOPT_USERPWD:
-			list($curl_user,$curl_pass) = explode(':',$value,2);
-			$http->auth_username = $curl_user;
-			$http->auth_password = $curl_pass;
-			break;
-
-		// Important stuff not implemented (as it's not yet supported by HTTPRetriever)
-		case CURLOPT_PUT:
-		case CURLOPT_INFILE:
-		case CURLOPT_FOLLOWLOCATION:
-		case CURLOPT_PROXYUSERPWD:
-		case CURLOPT_COOKIE:
-		case CURLOPT_COOKIEFILE:
-		case CURLOPT_PROXY:
-		case CURLOPT_RANGE:
-		case CURLOPT_RESUME_FROM:
-
-		// Things that cannot (reasonably) be implemented here
-		case CURLOPT_LOW_SPEED_LIMIT:
-		case CURLOPT_LOW_SPEED_TIME:
-		case CURLOPT_KRB4LEVEL:
-		case CURLOPT_SSLCERT:
-		case CURLOPT_SSLCERTPASSWD:
-		case CURLOPT_SSLVERSION:
-		case CURLOPT_INTERFACE:
-		case CURLOPT_CAINFO:
-		case CURLOPT_TIMECONDITION:
-		case CURLOPT_TIMEVALUE:
-	
-		// FTP stuff not implemented
-		case CURLOPT_QUOTE:
-		case CURLOPT_POSTQUOTE:
-		case CURLOPT_UPLOAD:
-		case CURLOPT_FTPLISTONLY:
-		case CURLOPT_FTPAPPEND:
-		case CURLOPT_FTPPORT:
-		
-		// Other stuff not implemented
-		case CURLOPT_VERBOSE:
-		case CURLOPT_NETRC:
-		default:
-			trigger_error("CURL emulation does not implement CURL option "._curlopt_name($option),E_USER_WARNING);
-			break;
-	}
-}
-
-// Perform a CURL emulation session
-function curl_exec($ch) {
-	$opt = &$GLOBALS["_CURLNAT_OPT"][$ch];
-	$url = $opt["url"];
-
-	$http = &$opt["http"];
-	$http->disable_curl = true; // avoid problems with recursion, since we *ARE* CURL
-	
-	// set time limits if requested
-	if ($opt["max-time"]) {
-		$http->connect_timeout = $opt["max-time"];
-		$http->max_time = $opt["max-time"];
-	}
-	
-	if ($opt["post"]) {
-		$res = $http->post($url,$opt["postdata"]);
-	} elseif ($opt["method"]) {
-		$res = $http->custom($opt["method"],$url,$opt["postdata"]);
-	} else {
-		$res = $http->get($url);
-	}
-		
-	// check for errors
-	$opt["errno"] = (!$res && $http->error) ? 1 : 0;
-	if ($opt["errno"]) $opt["error"] = $http->error;
-	
-	// die if CURLOPT_FAILONERROR is set and the HTTP result code is greater than 300
-	if ($opt["fail_on_error"]) {
-		if ($http->result_code>300) die;
-	}
-	
-	$opt["stats"] = $http->stats;
-
-
-	$headers = "";
-	foreach ($http->headers as $k => $v) {
-		$headers .= "$k: $v\r\n";
-	}
-
-	// if a file handle was provided for header output, extract the headers
-	// and write them to the handle
-	if (isset($opt["header_handle"])) {
-		fwrite($opt["header_handle"],$headers);
-	}
-	
-	$output = ($opt["include_headers"] ? $headers."\r\n" : "") . ($opt["include_body"] ? $http->response : "");
-	
-	// if a file handle was provided for output, write the output to it
-	if (isset($opt["output_handle"])) {
-		fwrite($opt["output_handle"],$output);
-		
-	// if the caller requested that the response be returned, return it
-	} elseif ($opt["return_transfer"]) {
-		return $output;
-		
-	// otherwise, just echo the output to stdout
-	} else {
-		echo $output;
-	}
-	return true;
-}
-
-function curl_close($ch) {
-	$opt = &$GLOBALS["_CURLNAT_OPT"][$ch];
-	
-	if ($opt["settings"]) {
-		$settings = &$opt["settings"];
-		// if the user used CURLOPT_INFILE to specify a file to upload, remove the
-		// temporary file created for the CURL binary
-		if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"])) unlink($settings["upload-file"]["value"]);
-	}
-
-	unset($GLOBALS["_CURLNAT_OPT"][$ch]);
-}
-
-function curl_errno($ch) {
-	return (int) $GLOBALS["_CURLNAT_OPT"][$ch]["errno"];
-}
-
-function curl_error($ch) {
-	return $GLOBALS["_CURLNAT_OPT"][$ch]["error"];
-}
-
-function curl_getinfo($ch,$opt=NULL) {
-	if ($opt) {
-		$curlinfo_tags = array(
-			CURLINFO_EFFECTIVE_URL=>"url",
-			CURLINFO_CONTENT_TYPE=>"content_type",
-			CURLINFO_HTTP_CODE=>"http_code",
-			CURLINFO_HEADER_SIZE=>"header_size",
-			CURLINFO_REQUEST_SIZE=>"request_size",
-			CURLINFO_FILETIME=>"filetime",
-			CURLINFO_SSL_VERIFYRESULT=>"ssl_verify_result",
-			CURLINFO_REDIRECT_COUNT=>"redirect_count",
-			CURLINFO_TOTAL_TIME=>"total_time",
-			CURLINFO_NAMELOOKUP_TIME=>"namelookup_time",
-			CURLINFO_CONNECT_TIME=>"connect_time",
-			CURLINFO_PRETRANSFER_TIME=>"pretransfer_time",
-			CURLINFO_SIZE_UPLOAD=>"size_upload",
-			CURLINFO_SIZE_DOWNLOAD=>"size_download",
-			CURLINFO_SPEED_DOWNLOAD=>"speed_download",
-			CURLINFO_SPEED_UPLOAD=>"speed_upload",
-			CURLINFO_CONTENT_LENGTH_DOWNLOAD=>"download_content_length",
-			CURLINFO_CONTENT_LENGTH_UPLOAD=>"upload_content_length",
-			CURLINFO_STARTTRANSFER_TIME=>"starttransfer_time",
-			CURLINFO_REDIRECT_TIME=>"redirect_time"
-		);
-		
-		$key = $curlinfo_tags[$opt];
-		return $GLOBALS["_CURLNAT_OPT"][$ch]["stats"][$key];
-	} else {
-		return $GLOBALS["_CURLNAT_OPT"][$ch]["stats"];
-	}
-}
-
-function curl_version() {
-	return "libcurlemu/".CURLNAT_VERSION."-nat";
-}
-
-}
-?>

+ 0 - 54
wikipedia3d/proxy.php

@@ -1,54 +0,0 @@
-<?php
-// FILE: proxy.php
-//
-// LAST MODIFIED: 2006-03-23
-//
-// AUTHOR: Troy Wolf <troy@troywolf.com>
-//
-// DESCRIPTION: Allow scripts to request content they otherwise may not be
-// able to. For example, AJAX (XmlHttpRequest) requests from a
-// client script are only allowed to make requests to the same
-// host that the script is served from. This is to prevent
-// "cross-domain" scripting. With proxy.php, the javascript
-// client can pass the requested URL in and get back the
-// response from the external server.
-//
-// USAGE: "proxy_url" required parameter. For example:
-// http://www.mydomain.com/proxy.php?proxy_url=http://www.yahoo.com
-//
-
-// proxy.php requires Troy's class_http. http://www.troywolf.com/articles
-// Alter the path according to your environment.
-require_once ("class_http.php");
-
-$proxy_url = isset($_GET['proxy_url']) ? $_GET['proxy_url'] : false;
-if (!$proxy_url) {
-	header("HTTP/1.0 400 Bad Request");
-	echo "proxy.php failed because proxy_url parameter is missing";
-	exit();
-}
-
-// Instantiate the http object used to make the web requests.
-// More info about this object at www.troywolf.com/articles
-if (!$h = new http()) {
-	header("HTTP/1.0 501 Script Error");
-	echo "proxy.php failed trying to initialize the http object";
-	exit();
-}
-
-$h -> url = $proxy_url;
-$h -> postvars = $_POST;
-if (!$h -> fetch($h -> url)) {
-	header("HTTP/1.0 501 Script Error");
-	echo "proxy.php had an error attempting to query the url";
-	exit();
-}
-
-// Forward the headers to the client.
-$ary_headers = split("\n", $h -> header);
-foreach ($ary_headers as $hdr) { header($hdr);
-}
-
-// Send the response body to the client.
-echo $h -> body;
-?>

+ 0 - 80
wikipedia3d/wp_languages.php

@@ -1,80 +0,0 @@
-<?php
-
-//error_reporting(E_ALL);
-ini_set('display_errors', '0');
-
-$url = "http://meta.wikimedia.org/wiki/Special:SiteMatrix";
-$userAgent = "Wiki3D-experiment http://www.world.eu.org/~lucky/wiki_browser/ - by <lukas.goldschmidt@googlemail.com> ";
-
-function get_content($url) {
-	$userAgent = "Wiki3D-experiment http://www.world.eu.org/~lucky/wiki_browser/ - by <lukas.goldschmidt@googlemail.com> ";
-	$ch = curl_init();
-
-	curl_setopt($ch, CURLOPT_URL, $url);
-	curl_setopt($ch, CURLOPT_HEADER, 0);
-	curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
-
-	ob_start();
-
-	curl_exec($ch);
-	curl_close($ch);
-	$string = ob_get_contents();
-
-	ob_end_clean();
-
-	return $string;
-
-}
-
-$raw = get_content($url);
-$newlines = array("\t", "\n", "\r", "\x20\x20", "\0", "\x0B");
-$content = str_replace($newlines, "", html_entity_decode($raw));
-
-$start = strpos($content, "<table class=\"wikitable\" id=\"mw-sitematrix-table\">");
-$end = strpos($content, "</td></tr></table>", $start) + 18;
-
-$table = substr($content, $start, $end - $start);
-
-preg_match_all("|<tr(.*)</tr>|U", $table, $rows);
-header("Content-type: text/javascript");
-
-echo <<<TEXT
-/**
- * Wikipedia SiteMatrix  \n
-TEXT;
-echo " *\n";
-echo " * Automatically generated ". date("g:i:s A D, F jS Y",time ()). "\n";
-echo " *\n";
-echo <<<TEXT
- */
-
- var wp_languages = new Array(\n
-TEXT;
-$first = true;
-foreach ($rows[0] as $row) {
-	if (strpos($row, "<th") === false) {
-		preg_match_all("|<td>(.*)</td>|U", $row, $cells);
-		$name = json_encode(trim(strip_tags($cells[1][0])));
-		$id = $cells[1][1];
-		$url_ = $cells[1][1];
-		preg_match_all("|\"(.*)\"|U", $url_, $tmp);
-		if (strlen($id) > 0 && strpos($id, "<del>") === false && strpos($name, "Total") === false) {
-			$id = strip_tags($id);
-			if(strlen($name) < 3 ){
-				$name = json_encode($id);
-			} 
-			$url_ = json_encode($tmp[1][0]."/");
-			if($first) $comma = ""; else $comma=",\n";
-			
-			echo $comma."{\"lang\": \"{$id}\", \"name\": {$name},  \"url\":  {$url_} }";
-			$first = false;
-
-		}
-	}
-}
-echo <<<TEXT
-\n);
-
-TEXT;
-echo "// Finished \n";
-?>