-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconsole.php
More file actions
executable file
·41 lines (35 loc) · 822 Bytes
/
console.php
File metadata and controls
executable file
·41 lines (35 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/php
<?php
/**
Command Line tool to work with this shortener.
**/
include_once("base.php");
include_once("utils.php");
$action = $argv[1];
$param = $argv[2];
if($action == "store"){
$url = $param;
if(is_url($url)) {
$hits = isset($argv[3]) && is_int($argv[3])?$argv[3]:0;
$new_id = store_url($url, array("max_hits"=>$hits));
echo complete_url($new_id);
} else {
echo "no maus, eso no es un url:\n$url";
}
} elseif($action == "ret") {
$url = get_url($param);
if($url["status"] != "ERR") {
echo "your url is:\n ".$url["url"];
} else {
echo $url["cause"];
}
} elseif($action == "info") {
echo "here is where the info for $param should be shown";
} else {
echo "no valid action given, options are:
- store URL [MAX_HITS]
- ret CODE
- info CODE (working on this)";
}
echo "\n";
?>