示例#1
0
    // 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);
        } else {
            $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . '?id=' . $lilurl->get_id($longurl);
        }
        $msg = '<p class="success">URL is: <a href="' . $url . '">' . $url . '</a></p>';
        $msg = '<p class="success">URL is: <a href="' . $url . '">' . $url . '</a><br /><input type="text" id="copybox" value="' . $url . '" onselect="select_text();" onkeyup="select_text();" onclick="select_text();" readonly="readonly"/> <br />ready to be copied to your clipboard</p>
				<script language="JavaScript" type="text/javascript">
					<!--
						function select_text()
							{
						el = document.getElementById(\'copybox\');
						if (el.createTextRange) 
						{
							var oRange = el.createTextRange();
示例#2
0
文件: index.php 项目: RobLoach/ur1.ca
    }
    $hostname = strtolower(parse_url($longurl, PHP_URL_HOST));
    $surbl = new Net_DNSBL_SURBL();
    // Check the user's IP address against SpamHaus
    $dnsbl = new Net_DNSBL();
    if ($dnsbl->isListed($_SERVER['REMOTE_ADDR'])) {
        $msg = '<p class="error">Your computer is blacklisted; cannot make ur1s!</p>';
    } elseif (in_array($hostname, $redirectors)) {
        $msg = '<p class="error">Already shortened!</p>';
    } elseif ($surbl->isListed($longurl)) {
        $msg = '<p class="error">Blacklisted URL!</p>';
    } elseif ($dnsbl->isListed($hostname)) {
        $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) {