--- nanourl-0.1.orig/create.php +++ nanourl-0.1/create.php @@ -1,58 +1,63 @@ -NanoURL - Create a shorter link + +<? + $server = $_SERVER['SERVER_NAME']; + echo "$server "; +?> +NanoURL - Create a shorter link -

Insert URL into DB

+

Create a NanoURL

TinyURL was created!
"; + if(! ($connection = @ mysql_connect($nanourlHost, $nanourlUser, $nanourlPassword)) ) { + echo mysql_error(); + die("could not connect"); + } + if(! (mysql_select_db($nanourlDB, $connection))) { + die("cannot select DB"); + } + + srand( ((int)((double)microtime()*1000003)) ); //seeding... + do { + $hash = ''; + + for($i = 0; $i< 5; $i++) { + $random = (rand()%36); + if($random <26) { + $random = $random + 97; //map to lowercase ASCII + } else { + $random = $random + 22; //map to number ASCII + } + $hash = $hash . chr($random); + } + $result = mysql_query("INSERT INTO urls VALUES ('$hash', '$newurl')"); + + //on the off chance this didn't work (collisions of hashes + //most likely...) do it all again + } while(! ($result)); + + //build the forwarding URL + $fwdurl = "$server/nanourl/".$hash; + //echo out the create signature + echo "

NanoURL was created!


"; //echo out the stuff where we draw the hash out of - echo "
"; - //provide a link to click to. - echo "link to " . $fwdurl . ""; + echo "
"; + //provide a link to click to. + echo "link to " . $fwdurl . ""; } - + ?>

-Create a url
+
Create a url
URL: 
--- nanourl-0.1.orig/redirect.php +++ nanourl-0.1/redirect.php @@ -1,12 +1,13 @@ NanoURL - Create a shorter link -

Hash " " not in DB!

+

Hash " " was not in found!

--- nanourl-0.1.orig/apache.conf +++ nanourl-0.1/apache.conf @@ -0,0 +1,15 @@ + +Alias /nanourl /usr/share/nanourl + + Options -Indexes + DirectoryIndex create.php + Order Allow,Deny + Allow from All + + RewriteEngine on + RewriteBase /nanourl + RewriteRule ^create.php$ create.php [L] + RewriteRule ^redirect(.*)$ redirect$1 [L] + RewriteRule ^(.....)$ redirect.php?num=$1 [L] + + --- nanourl-0.1.orig/debian/README.Debian +++ nanourl-0.1/debian/README.Debian @@ -0,0 +1,16 @@ +nanourl for Debian +------------------ + +For this Debian package, rather than dropping the php files into +the web root, an apache alias is used. + +You will need to create the database and database user. The file +/etc/nanourl.sql contains the required sql statements. Ensure that +the mysql server host is appropriate. There is no requirement +that the mysql server be on localhost. + +As the mysql root user, the following may suffice: +mysql -u root -p < nanourl.sql + + -- Stefani Banerian Wed, 25 Jan 2006 14:17:44 -0800 + --- nanourl-0.1.orig/debian/changelog +++ nanourl-0.1/debian/changelog @@ -0,0 +1,66 @@ +nanourl (0.1-7.1ubuntu1) intrepid; urgency=low + + [ Alessio Treglia ] + * Removed unnecessary depend on apache (LP: #268773). + * Set Architecture field to all. + + [ Luca Falavigna ] + * Implemented no-op upgrade and failed-upgrade targets to fix weird + errors while upgrading from 0.1-7.1. + * Use ln -fs when creating symlinks to avoid errors during configure + phase if they are already present. + + -- Luca Falavigna Mon, 06 Oct 2008 09:25:52 +0000 + +nanourl (0.1-7.1) unstable; urgency=high + + * Non-maintainer upload during BSP. + * Fix unconditional use of debconf in postrm (Closes: #417008). + * Add php5 alternatives to dependencies (Closes: #424838). + + -- Luk Claes Sat, 19 May 2007 17:32:50 +0200 + +nanourl (0.1-7) unstable; urgency=low + + * fixed postinst script to enable apache2 mod_rewrite. + * (Closes: #347701) + + -- Stefani Banerian Wed, 25 Jan 2006 14:17:44 -0800 + +nanourl (0.1-6) unstable; urgency=low + + * removed more unused steps in rules, unneeded files from build dir. + * Initial upload (Closes: #335738) + + -- Stefani Banerian Tue, 6 Dec 2005 10:59:39 -0800 + +nanourl (0.1-5) unstable; urgency=low + + * removed unused steps in rules, unneeded files from build dir. + + -- Stefani Banerian Mon, 28 Nov 2005 12:46:39 -0800 + +nanourl (0.1-4) unstable; urgency=low + + * added postinst/postrm scripts and autogenerated optional passwd + + -- Stefani Banerian Mon, 21 Nov 2005 16:06:08 -0800 + +nanourl (0.1-3) unstable; urgency=low + + * fixed create.php and nanourl.conf + + -- Stefani Banerian Tue, 15 Nov 2005 14:06:08 -0800 + +nanourl (0.1-2) unstable; urgency=low + + * bug cleanup due to lintian error report + + -- Stefani Banerian Tue, 15 Nov 2005 13:05:14 -0800 + +nanourl (0.1-1) unstable; urgency=low + + * Initial Release. + + -- Stefani Banerian Tue, 15 Nov 2005 13:04:53 -0800 + --- nanourl-0.1.orig/debian/nanourl.postrm +++ nanourl-0.1/debian/nanourl.postrm @@ -0,0 +1,37 @@ +#!/bin/bash -e + +if [ -f /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule +fi + +if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi +${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"} + +case "$1" in + purge|remove|disappear) + + rm -f /etc/nanourl/* + if [ -d /var/lib/mysql/nanoDB ]; then + rm -rf /var/lib/mysql/nanoDB + fi + for HTTPD in apache apache2 apache-ssl; do + if [ -h /etc/$HTTPD/conf.d/nanourl ]; then + rm /etc/$HTTPD/conf.d/nanourl + fi + done + ;; + upgrade|failed-upgrade) + ;; + *) + echo "postrm called with unknown argument '$1'" 1>&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + --- nanourl-0.1.orig/debian/compat +++ nanourl-0.1/debian/compat @@ -0,0 +1 @@ +4 --- nanourl-0.1.orig/debian/control +++ nanourl-0.1/debian/control @@ -0,0 +1,17 @@ +Source: nanourl +Section: web +Priority: optional +Maintainer: Ubuntu MOTU Developers +XSBC-Original-Maintainer: Stefani Banerian +Build-Depends: debhelper (>= 4.0.0) +Standards-Version: 3.6.2 + +Package: nanourl +Architecture: all +Depends: php5 | php4, php5-mysql | php4-mysql, mysql-client +Suggests: mysql-server +Description: Lightweight analog of TinyURL + NanoURL is an implementation of the TinyURL website for + your localhost. All that it needs are 2 PHP files, + php + mySQL support, and a simple mySQL database. + --- nanourl-0.1.orig/debian/nanourl.manpages +++ nanourl-0.1/debian/nanourl.manpages @@ -0,0 +1 @@ +debian/nanourl.1 --- nanourl-0.1.orig/debian/nanourl.dirs +++ nanourl-0.1/debian/nanourl.dirs @@ -0,0 +1,3 @@ +usr/share/nanourl +usr/share/doc/nanourl +etc/nanourl --- nanourl-0.1.orig/debian/nanourl.examples +++ nanourl-0.1/debian/nanourl.examples @@ -0,0 +1,3 @@ +debian/examples/apache.conf +debian/examples/nanourl.conf +debian/examples/nanourl.sql --- nanourl-0.1.orig/debian/nanourl.postinst +++ nanourl-0.1/debian/nanourl.postinst @@ -0,0 +1,103 @@ +#!/bin/bash -e + +. /usr/share/debconf/confmodule + +if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi +${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"} + +export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin + +case "$1" in + configure) + nanourl_cfgdir=/etc/nanourl + + # (re)create the credentials file + dc=$nanourl_cfgdir/nanourl.conf; + ds=$nanourl_cfgdir/nanourl.sql; + + if [ ! -e "$dc" ]; then + pass=`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)'`; + if [ ! -d "$nanourl_cfgdir" ]; then install -o 0 -g 0 -m 0755 -d $nanourl_cfgdir; fi + echo "> $dc + echo " \$nanourlUser = \"nanoUser\";" >> $dc + echo " \$nanourlDB = \"nanoDB\";" >> $dc + echo " \$nanourlHost = \"localhost\";" >> $dc + echo " \$nanourlPassword = \""$pass"\";" >> $dc + echo "?>" >> $dc + + # If this dir chmod go+w then the admin did it. But this file should not. + chown 0:0 $dc + chmod 0644 $dc + + # create db and table sql + use_db_query=`/bin/echo -e \ + "USE mysql; "` + echo $use_db_query >> $ds + + insert_query=`/bin/echo -e \ + "INSERT INTO user VALUES ('localhost','nanoUser',PASSWORD('"$pass"'),'N','N','N','N','N','N','Y','N','Y','N','N','Y','N','N','N','Y','Y','Y','Y','Y','Y','','','','',0,0,0); "` + echo $insert_query >> $ds + + insert_query=`/bin/echo -e \ + "INSERT INTO db VALUES ('localhost','nanoDB','nanoUser','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); "` + echo $insert_query >> $ds + + create_db_query=`/bin/echo -e \ + "CREATE DATABASE /*!32312 IF NOT EXISTS*/ nanoDB; "` + echo $create_db_query >> $ds + use_db_query=`/bin/echo -e \ + "USE nanoDB; "` + echo $use_db_query >> $ds + + create_tables_query=`/bin/echo -e \ + "CREATE TABLE urls ( hash char(5) NOT NULL, url LONGBLOB, PRIMARY KEY (hash)) type=MyISAM; "` + echo $create_tables_query >> $ds + # If this dir chmod go+w then the admin did it. But this file should not. + chown 0:0 $ds + chmod 0644 $ds + + fi + + for HTTPD in apache apache-ssl ; do + if [ -d /etc/$HTTPD/conf.d ]; then + ln -fs /etc/nanourl/apache.conf /etc/$HTTPD/conf.d/nanourl + apache-modconf $HTTPD enable mod_rewrite + fi + done + HTTPD="apache2" + if [ -d /etc/$HTTPD ]; then + if [ -d /etc/$HTTPD/conf.d ]; then + ln -fs /etc/nanourl/apache.conf /etc/$HTTPD/conf.d/nanourl + fi + if [ -d /etc/$HTTPD/mods-available ]; then + if [ ! -h /etc/$HTTPD/mods-enabled/rewrite.load ]; then + ln -s /etc/$HTTPD/mods-available/rewrite.load /etc/$HTTPD/mods-enabled/rewrite.load + fi + if [ ! -h /etc/$HTTPD/mods-enabled/php4.load ]; then + ln -s /etc/$HTTPD/mods-available/php4.load /etc/$HTTPD/mods-enabled/php4.load + ln -s /etc/$HTTPD/mods-available/php4.conf /etc/$HTTPD/mods-enabled/php4.conf + fi + fi + fi + + ;; + + abort-upgrade|abort-remove|abort-configure) + ;; + + *) + echo "postinst called with unknown argument '$1'" 1>&2 + exit 1 + ;; +esac + +db_stop + + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + --- nanourl-0.1.orig/debian/nanourl.1 +++ nanourl-0.1/debian/nanourl.1 @@ -0,0 +1,50 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH NANOURL 1 "November 21, 2005" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +nanourl \- create small urls +.SH SYNOPSIS +.B nanourl +.br +.SH DESCRIPTION +This manual page documents briefly the +.B nanourl +package. +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +\fBnanourl\fP is a small package that mimics the behaviour of +TinyURL. It creates a snall URL which facilitates sending/notifying +others of some link. +.SH OPTIONS +There is no command line version to use. It relies on apache/php/mysql. +.SH SEE ALSO +.BR README.Debian +.br +.SH FILES +.BR /etc/nanourl/nanourl.conf +.br +.BR /etc/nanourl/nanourl.sql +.br +.BR /etc/nanourl/apache.conf +.br +.SH AUTHOR +nanourl was written by Acidus (acidus@msblabs.org). +.PP +This manual page was written by s banerian , +for the Debian project (but may be used by others). --- nanourl-0.1.orig/debian/copyright +++ nanourl-0.1/debian/copyright @@ -0,0 +1,36 @@ +This package was debianized by Stefani Banerian on +Mon, 28 Nov 2005 11:24:24 -0800. + +It was downloaded from http://www.msblabs.org/nanourl/nanourl.tar.gz + +Copyright Holder: acidus@msblabs.org + +License: + +Copyright (c) 2005, Acidus, Most Significant Bit Labs (acidus@msblabs.org) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + + * Neither the name of Most Significant Bit Labs nor the names of its +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- nanourl-0.1.orig/debian/rules +++ nanourl-0.1/debian/rules @@ -0,0 +1,59 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +PACKAGE = nanourl +DESTDIR=$(CURDIR)/debian/$(PACKAGE) + +INSTALL = install +INSTALL_FILE = $(INSTALL) -p -oroot -groot -m644 +INSTALL_PROGRAM = $(INSTALL) -p -oroot -groot -m755 +INSTALL_SCRIPT = $(INSTALL) -p -oroot -groot -m755 +INSTALL_DIR = $(INSTALL) -p -d -oroot -groot -m755 + + +build: + dh_testdir + +clean: + dh_testdir + dh_testroot + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/nanourl. + ${INSTALL_FILE} *.php $(DESTDIR)/usr/share/$(PACKAGE) + ${INSTALL_FILE} apache.conf $(DESTDIR)/etc/$(PACKAGE) + ln -s /etc/nanourl/nanourl.conf $(DESTDIR)/usr/share/$(PACKAGE) + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install + dh_installman + dh_link + dh_compress + dh_fixperms + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure --- nanourl-0.1.orig/debian/docs +++ nanourl-0.1/debian/docs @@ -0,0 +1 @@ +README --- nanourl-0.1.orig/debian/examples/apache.conf +++ nanourl-0.1/debian/examples/apache.conf @@ -0,0 +1,15 @@ + +Alias /nanourl /usr/share/nanourl + + Options -Indexes + DirectoryIndex create.php + Order Allow,Deny + Allow from All + + RewriteEngine on + RewriteBase /nanourl + RewriteRule ^create.php$ create.php [L] + RewriteRule ^redirect(.*)$ redirect$1 [L] + RewriteRule ^(.....)$ redirect.php?num=$1 [L] + + --- nanourl-0.1.orig/debian/examples/nanourl.conf +++ nanourl-0.1/debian/examples/nanourl.conf @@ -0,0 +1,8 @@ + + --- nanourl-0.1.orig/debian/examples/nanourl.sql +++ nanourl-0.1/debian/examples/nanourl.sql @@ -0,0 +1,7 @@ + +USE mysql; +INSERT INTO `user` VALUES ('localhost','nanoUser',PASSWORD('nanoPasswd'),'N','N','N','N','N','N','Y','N','Y','N','N','Y','N','N','N','Y','Y','Y','Y','Y','Y','','','','',0,0,0); +INSERT INTO `db` VALUES ('localhost','nanoDB','nanoUser','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); +CREATE DATABASE /*!32312 IF NOT EXISTS*/ nanoDB; +USE nanoDB; +CREATE TABLE urls ( hash char(5) NOT NULL, url LONGBLOB, PRIMARY KEY (hash)) type=MyISAM;