示例#1
0
<?php

require 'include/shorturl.class.php';
$option = (include 'config.php');
$url = trim($_GET['s'], '/');
if ($url) {
    $murl = new ShortUrl($option);
    if (!preg_match("/^http\\:\\/\\/" . $option['domain'] . "/si", $url)) {
        $url = "http://" . $option['domain'] . "/" . $url;
    }
    $result = $murl->get($url);
    if ($result) {
        header('Location: ' . $result);
    } else {
        header("HTTP/1.1 404 Not Found");
        echo '404 page not found!';
    }
} else {
    header("HTTP/1.1 404 Not Found");
    echo '404 page not found!';
}
示例#2
0
<?php

require 'include/shorturl.class.php';
$option = (include 'config.php');
$sourceurl = trim(urldecode($_POST['url']));
$url = trim($_POST['shorturl']);
$shorturl = trim($_POST['shorturl']);
if ($url) {
    $murl = new ShortUrl($option);
    if (!empty($url) && !preg_match("/^http\\:\\/\\/" . $option['domain'] . "/is", $url)) {
        $url = "http://" . $option['domain'] . "/" . $url;
    }
    $oldurl = $murl->get($url);
    if (empty($sourceurl)) {
        if (!$oldurl) {
            $msg = 'This shorturl does not exist!';
        } else {
            $sourceurl = $oldurl;
        }
    } else {
        if ($oldurl) {
            if ($oldurl != $sourceurl) {
                $re = $murl->edit($sourceurl, $url);
            }
            $msg = 'Change success';
        } else {
            $msg = 'This shorturl does not exist, please generate one first!';
        }
    }
} else {
    if ($_POST) {
示例#3
0
        if ($re) {
            die(strval($re));
        } else {
            die('0');
        }
        break;
    case 'del':
        $url = $_GET['url'];
        $re = $murl->delete($url);
        if ($re) {
            die('1');
        } else {
            die('0');
        }
        break;
    default:
        $url = trim($_GET['url']);
        if (empty($url)) {
            die('0');
        }
        if (!preg_match("/^http\\:\\/\\/" . $option['domain'] . "/is", $url)) {
            $url = "http://" . $option['domain'] . "/" . $url;
        }
        $source = $murl->get($url);
        if ($source) {
            die(strval($source));
        } else {
            die('0');
        }
        break;
}