WIA/public_html/api/links.php

23 lines
696 B
PHP
Raw Normal View History

2011-10-04 05:49:42 -04:00
<?php
2011-10-17 09:05:40 -04:00
$conf = json_decode(file_get_contents('../../conf/wia.conf'));
2011-10-04 05:49:42 -04:00
include_once('../lib/database.php');
2011-10-16 06:33:28 -04:00
$db = new Database($conf->db->hostname,$conf->db->username,$conf->db->password,$conf->db->database);
2011-10-04 05:49:42 -04:00
$key = $_GET['link_key'];
2011-10-16 06:33:28 -04:00
if($key != $db->site->key) die('{"message":"Access Denied."}');
2011-10-04 05:49:42 -04:00
$url = $_GET['url'];
$title = $_GET['title'];
if(filter_var($url,FILTER_VALIDATE_URL) == false || !preg_match('{http://}',$url))
die('{"message":"Malformed URL."}');
if($db->connect_error) die('{"message":"No Database Connection."}');
$db->query("INSERT INTO wia_links (url,text,status) VALUES ('$url','$title',0)");
if($db->error) die('{"message":"Could Not Add."}');
$db->close();
?>
{}