Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dodgepudding/shorturl
shorturl using mongoDB
https://github.com/dodgepudding/shorturl
Last synced: about 6 hours ago
JSON representation
shorturl using mongoDB
- Host: GitHub
- URL: https://github.com/dodgepudding/shorturl
- Owner: dodgepudding
- Created: 2013-03-25T08:00:52.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-05-29T06:06:13.000Z (over 11 years ago)
- Last Synced: 2024-08-01T16:44:00.072Z (3 months ago)
- Language: PHP
- Size: 609 KB
- Stars: 17
- Watchers: 6
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
shorturl
========shorturl using mongoDB, auto generate the short url QRcode, with simple API interface
Requirement
--------
* PHP 5.0+
* php_mongo.soInstall
--------
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:
```RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]```
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
}
```* visit http://domain.com/add.php to open control panel
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 interfaceAPIs
-------
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 successDemo
-------
http://s.4wer.com/add.php