-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanager.php
More file actions
48 lines (45 loc) · 798 Bytes
/
manager.php
File metadata and controls
48 lines (45 loc) · 798 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
42
43
44
45
46
47
48
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('theurlondatabase.db');
}
}
function getRandomUrl()
{
$fMin = 65;
$fMax = 90;
$sMin = 97;
$sMax = 122;
$noOfTimes = rand(5, 10);
$url = "";
for($i = 0;$i <= $noOfTimes;$i++)
{
$useMin = rand(0, 100) > 50;
if ($useMin)
{
$url = $url . chr(rand($fMin, $fMax));
} else {
$url = $url . chr(rand($sMin, $sMax));
}
}
return $url;
}
function createNewUrl($fullUrl, $database)
{
if (!$fullUrl)
{
die();
}
$url = getRandomUrl();
$newUrl="INSERT INTO URLDEFS (URL, FULLURL) VALUES ('" . $url . "','" . $fullUrl . "');";
$ret = $database->exec($newUrl);
if(!$ret)
{
echo $database->lastErrorMsg();
}
return $url;
}
$db = new MyDB();
?>