Git Product home page Git Product logo

shorturl-1's Introduction

shorturl

shorturl using mongoDB, auto generate the short url QRcode, with simple API interface

Requirement

  • PHP 5.0+
  • php_mongo.so

Install

setup rewrite rule redirect to /index.php for nginx.conf (insert to location scope):

	if (!-e $request_filename) {
	   rewrite  ^(.*)$  /index.php?s=$1  last;
	}

for apache .htaccess:

<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>

change parameters in config.php

array(
	'domain'=>'example.com', // your domain name
	'host'=>'localhost', // your mongoDB host
	'port'=>27017,  //your mongoDB port
	'db'=>'shorturl', //your mongoDB databbase
	'table'=>'url', //table name to store urls
	'sumtable'=>'click', //tabale name to store summary
	'username'=>'', //if mongoDB username and password needed
	'password'=>'', //if mongoDB username and password needed
	'keys'=>'23456789abcdefghijkmnpqrstuvwxyz', //the alphabet for shorturl auto generate
	'keylength'=>6, //the short string length
}

Files

zh-cn/* ##Chinese versioin
include/shorturl.class.php ##MongoDB Model file
include/QRcode.class.php ##QRcode library
index.php ##shorturl revert
add.php ##add shorturl panel
edit.php ##change url panel
config.php ##configuration
qrcode.php ##output qrcode image
api.php ##API interface

APIs

Apis below returns 0 for failed.

  • get the visits of shorturl
    GET api.php?a=count&url={shorturl}
    return the number

  • change the exist shorturl to another long url
    GET api.php?a=edit&source={new long url}&url={shorturl}
    return the shorturl if success

  • set a new shorturl pointed to long url
    GET api.php?a=set&source={long url}&url={shorturl}
    the url for shorturl param is not required, it will generate a random shorturl if null.it will return the shorturl if success.

  • delete a short url
    GET api.php?a=del&url={shorturl}
    return 1 if success

  • check for long url
    GET api.php?url={shorturl}
    return the long url if success

Demo

http://s.4wer.com/add.php

shorturl-1's People

Contributors

dodgepudding avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.