#!/usr/bin/php
# This script dumps the TightURL database to stdout in the format:
# id: 0 url: X
#
# It probably will not be part of any release since it is of dubious value,
# (what it does a simple SQL dump would do just as well), however it may be
# enhanced into something more worthwhile like an XML exporter.
# If you happen to get a copy of it, it is covered under the GPL 2.0 version
# 2.0 or later.

<?php
define
("VERSION""0.2.0.0");
define("REQUIRED_PHP_VERSION""4.3.0");

// System defaults,  DO NOT EDIT THIS FILE
// Edit tighturl.config.inc.php instead!

global $conn$db$svcname;

$dbhost "localhost";
$dbuser "dbuser";
$dbpass "dbpass";
$dbname "tighturl";
$dbtable "urls";

// Text strings and style variables
$svcname "URLSquisher";

// You REALLY don't want to edit below here unless you know what you're doing.

// *************************************************************************

  
if (version_compare(phpversion(), REQUIRED_PHP_VERSION)<0) {
    die(
"$svcname Error: TightURL ".VERSION." needs PHP >= ".REQUIRED_PHP_VERSION." (you are using ".phpversion().")");
  }

// ****** !All overridable configuration variables must go above this line! ******

  
(include("tighturl.lib.inc.php")) or die_HTML($svcname"Error: Cannot locate tighturl.lib.inc.php.");
  if (
file_exists("tighturl.config.inc.php")) include("tighturl.config.inc.php");

  
// Connect to MySQL, open database.
  
$conn = @mysql_connect($dbhost$dbuser$dbpass) or die("$svcname Error: Cannot connect to database.");
  
$db mysql_select_db($dbname$conn) or die("$svcname Error: Cannot select database. "mysql_error());
  
// Figure out what kind of request this is and service it.
   
  
$req "SELECT * FROM $dbtable order by id;";
  
$set mysql_query($req);
  
$rows = @mysql_num_rows($set) or $rows 0;

  for (
$i 0$i <$rows$i++) {

    
$row mysql_fetch_array($set);
    
$id $row["id"];
    
$url $row["url"];

    echo 
"id: $id  url: $url\n";
  }
  exit;

// *************************************************************************

?>