Skip to content

Commit

Permalink
deleted old structure
Browse files Browse the repository at this point in the history
  • Loading branch information
K. M. Lawson committed Jul 5, 2012
2 parents a551a24 + e337ef7 commit 7d0f4cc
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 0 deletions.
76 changes: 76 additions & 0 deletions check.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

// This is a simple API created in response to SaveMLAK request to have ability to confirm whether or not a given link has
// been submitted to our seed database. - Konrad

$u = isset($_GET['u']) ? $_GET['u'] : false; //The url to supply for the command
$c = isset($_GET['c']) ? $_GET['c'] : false; //The command

require_once('inc/common.php');


if(!$c) {
echo "ERROR: No request command found.\n";
}

if (!$u) {
echo "ERROR: No request parameter found.\n";
exit;
}



//This script only supports a 'url' command, otherwise return error

switch($c)
{
//URL CHECK COMMAND
// USAGE: jdarchive.org/check/url/[address to check]
// RETURNS: JSON of the information we have for the url or the fact it does not exist
case 'url' :
echo getinfo($u);
break;

default:
echo "ERROR: The '$command' command is not supported.\n";
break;
}


function getinfo($url) {

if($url==""){
echo "ERROR: No url was supplied.";
return;
}

//echo $url."<br />";

$urlquery= "SELECT * FROM `seeds` WHERE `url` LIKE '".$url."%'";

$numresults=mysql_query($urlquery);
$numrows=mysql_num_rows($numresults);
echo "NUMROWS: $numrows";
if($numrows>0){
$row=mysql_fetch_array($numresults);
$response = array(
"found" => 1,
"title" => $row["title"],
"url" => $row["url"],
"id" => $row["sid"],
"frequency" => $row["frequency"],
"scope" => $row["scope"],
"submitter" => $row["name"],
"added" => $row["added"],
"archived" => $row["isArchived"]
);

} else {
$response = array(
"found" => 0
);
}

return json_encode($response);

}
Binary file removed check/.DS_Store
Binary file not shown.
79 changes: 79 additions & 0 deletions check/index.php.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

// This is a simple API created in response to SaveMLAK request to have ability to confirm whether or not a given link has
// been submitted to our seed database. - Konrad

// .htaccess has been set to allow for /command/parameter/parameter structured URIs
// simplify the resulting info:

require_once('../inc/common.php');

$requestURI = explode('/', $_SERVER['REQUEST_URI']);
$scriptName = explode('/',$_SERVER['SCRIPT_NAME']);

for($i= 0;$i < sizeof($scriptName);$i++)
{
if ($requestURI[$i] == $scriptName[$i])
{
unset($requestURI[$i]);
}
}

$query = array_values($requestURI);

//There should be one command and one parameter

if(!$query[0]) {
echo "ERROR: No request command found.\n";
} else {
$command=$query[0];
}

if (count($query)<2) {
echo "ERROR: No request parameter found.\n";
exit;
}



//This script only supports a 'url' command, otherwise return error

switch($command)
{
//URL CHECK COMMAND
// USAGE: jdarchive.org/check/url/[address to check]
// RETURNS: JSON of the information we have for the url or the fact it does not exist
case 'url' :
//collapse all parameters that follow, assume it is all one url
$url=$query;
//exclude the command, the rest will be the url
unset($url[0]);
$url=implode("/",$url);
getinfo($url);
break;

default:
echo "ERROR: The '$command' command is not supported.\n";
break;
}


function getinfo($url) {

if($url==""){
echo "ERROR: No url was supplied.";
return;
}

$urlquery= "SELECT * FROM `seeds` WHERE `url` LIKE '".$url."' LIMIT 1";

$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);

if($numrows>0){
echo "FOUND";
} else {
echo "NOT FOUND";
}

}

0 comments on commit 7d0f4cc

Please sign in to comment.