示例#1
0
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) {
        $msg = 'shorturl can not be null';
    }
}
?>
<!DOCTYPE html>
<html>
<head>
示例#2
0
 case 'count':
     $url = $_GET['url'];
     if (!preg_match("/^http\\:\\/\\/" . $option['domain'] . "/is", $url)) {
         $url = "http://" . $option['domain'] . "/" . $url;
     }
     $count = $murl->getsum($url);
     if ($count) {
         die(strval($count));
     } else {
         die('0');
     }
     break;
 case 'edit':
     $surl = $_GET['source'];
     $url = $_GET['url'];
     $re = $murl->edit($surl, $url);
     if ($re) {
         die(strval($re));
     } else {
         die('0');
     }
     break;
 case 'set':
     $surl = $_GET['source'];
     $url = $_GET['url'];
     $re = $murl->set($surl, $url);
     if ($re) {
         die(strval($re));
     } else {
         die('0');
     }