示例#1
0
文件: index.php 项目: laiello/murl
<?php

/* index.php ( lilURL implementation ) */
include $_SERVER['DOCUMENT_ROOT'] . '/includes/conf.php';
// <- site-specific settings
//Si pas de requête de création, et si le script appelé n'est pas uniquement l'index (/ ou index.php)
if (isset($_REQUEST['longurl']) || $_SERVER['REQUEST_URI'] != "/") {
    include $_SERVER['DOCUMENT_ROOT'] . '/includes/lilurl.php';
    // <- lilURL class file
    $lilurl = new lilURL();
}
$msg = '';
$no_content = false;
// if the form has been submitted
if (isset($_REQUEST['longurl']) && strpos($_REQUEST['longurl'], 'http://murl.fr/') === false) {
    # Escape bad characters from the user's url
    $longurl = trim(mysql_escape_string($_REQUEST['longurl']));
    # Anti-spam
    $spam = 0;
    foreach ($words as $word) {
        if (strstr($longurl, $word)) {
            $msg = '<p class="error">Spam detecté !<br /><b>' . $word . '</b> n\'est pas accepté ici ...</p>';
            $spam = 1;
            break;
        }
    }
    # Not a spam
    if (!$spam) {
        # set the protocol to not ok by default
        $protocol_ok = false;
        # if there's a list of allowed protocols,
示例#2
0
<?php

/* index.php ( lilURL implementation ) */
require_once 'includes/conf.php';
// <- site-specific settings
require_once 'includes/urlcodec.php';
// <- lilURL class file
$lilurl = new lilURL();
$msg = '';
// if the form has been submitted
if (isset($_POST['longurl'])) {
    // escape bad characters from the user's url
    $longurl = trim(mysql_escape_string($_POST['longurl']));
    // set the protocol to not ok by default
    $protocol_ok = false;
    // if there's a list of allowed protocols,
    // check to make sure that the user's url uses one of them
    if (count($allowed_protocols)) {
        foreach ($allowed_protocols as $ap) {
            if (strtolower(substr($longurl, 0, strlen($ap))) == strtolower($ap)) {
                $protocol_ok = true;
                break;
            }
        }
    } else {
        $protocol_ok = true;
    }
    // add the url to the database
    if ($protocol_ok && $lilurl->add_url($longurl)) {
        if (REWRITE) {
            $url = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . $lilurl->get_id($longurl);
示例#3
0
文件: index.php 项目: RobLoach/ur1.ca
        $msg = '<p class="error">Blacklisted Host!</p>';
    } elseif (!$protocol_ok) {
        $msg = '<p class="error">Invalid protocol!</p>';
    } elseif ($lilurl->add_url($longurl)) {
        if (REWRITE) {
            $url = 'http://' . $_SERVER['SERVER_NAME'] . '/' . $lilurl->get_id($longurl);
        } else {
            $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . '?id=' . $lilurl->get_id($longurl);
        }
        $msg = '<p class="success">Your ur1 is: <a href="' . $url . '">' . $url . '</a></p>';
    } else {
        $msg = '<p class="error">Creation of your ur1 failed for some reason.</p>';
    }
} else {
    // This is a read transaction, use the slave database
    $lilurl = new lilURL(READ_ONLY);
    if (isset($_GET['id'])) {
        $id = mysql_escape_string($_GET['id']);
    } elseif (REWRITE) {
        $explodo = explode('/', $_SERVER['REQUEST_URI']);
        $id = mysql_escape_string($explodo[count($explodo) - 1]);
    } else {
        $id = '';
    }
    // if the id isn't empty and it's not this file, redirect to it's url
    if ($id != '' && $id != basename($_SERVER['PHP_SELF'])) {
        $location = $lilurl->get_url($id);
        if ($location != -1) {
            $surbl = new Net_DNSBL_SURBL();
            $dnsbl = new Net_DNSBL();
            if ($surbl->isListed($location) || $dnsbl->isListed(parse_url($location, PHP_URL_HOST))) {