Add red error boxes in return messages

This is continuing development on the interface, they will fade
in the next commit
This commit is contained in:
Arctic Code
2013-08-26 01:33:14 -05:00
parent c3848688a5
commit cfe1a23a33
3 changed files with 37 additions and 16 deletions

View File

@@ -31,16 +31,16 @@ class api{
$apisql = "INSERT INTO `apiuse` (time, name, apikey, ip, type, allowed, misc) VALUES (NOW(), '$name', '$apikey', '$ip', 'Link Shorten', '$canshort', '$link')";
if(!$result = $apidb->query($apisql)) return 'ERROR: ['.$apidb->error.']';
}
if($canshort != 1) return 'You are not authorized to shorten links';
if($canshort != 1) return '<div id="error">You are not authorized to shorten links</div>';
$sql = "SELECT * FROM `links` WHERE `link` = '$link' LIMIT 1;";
if($result = $sdb->query($sql)){
if($row = $result->fetch_assoc()){
$short = $row['shortlink'];
return "Existing link: <a href=\"http://unps.us/?l=$short\" target=\"$short\">http://unps.us/?l=$short</a>";
return "<div id=\"error\">Existing link: <a href=\"http://unps.us/?l=$short\" target=\"$short\">http://unps.us/?l=$short</a></div>";
}
}
if(checkRemoteFile($link) !== true) return "Dead Link: $link";
if(checkRemoteFile($link) !== true) return "<div id=\"error\">Dead Link: $link</div>";
$short = substr(number_format(time() * mt_rand(),0,'',''),0,10);
$short = base_convert($short, 10, 36);
@@ -52,7 +52,7 @@ class api{
endif;
if($result = $sdb->query($sql)): return "Shortened: <a href=\"http://unps.us/?l=$short\" target=\"$short\">http://unps.us/?l=$short</a><br />Your link deletion password (write this down): $dpass";
else: return 'ERROR: ['.$sdb->error.']';
else: return '<div id="error">ERROR: ['.$sdb->error.']</div>';
endif;
}
@@ -68,7 +68,7 @@ class api{
$apisql = "INSERT INTO `apiuse` (time, name, apikey, ip, type, allowed, misc) VALUES (NOW(), '$name', '$apikey', '$ip', 'Short Link Delete', '$canshort', '$link')";
if(!$result = $apidb->query($apisql)) return 'ERROR: ['.$apidb->error.']';
}
if($canshort != 1) return 'You are not authorized to delete short links';
if($canshort != 1) return '<div id="error">You are not authorized to delete short links</div>';
$sql = "SELECT * FROM `links` WHERE `shortlink` = '$link' LIMIT 1;";
if($result = $sdb->query($sql)){
@@ -80,12 +80,12 @@ class api{
if($apikey == $password){
$sql = "DELETE FROM `links` WHERE `shortlink` = '$link' AND `dpass` = '$apikey' LIMIT 1;";
if(!$result = $sdb->query($sql)) return 'ERROR: ['.$sdb->error.']';
if(!$result = $sdb->query($sql)) return '<div id="error">ERROR: ['.$sdb->error.'</div>]';
echo "Deleted: $link";
return;
}else{ return "The password doesn't match. Delete $link aborted!"; }
}else{ return "<div id=\"error\">The password doesn't match. Delete $link aborted!</div>"; }
}
}else{ return 'ERROR: ['.$sdb->error.']'; }
}else{ return '<div id="error">ERROR: ['.$sdb->error.']</div>'; }
}
function reportLink($apidb, $apikey, $sdb, $link, $reason){
@@ -100,10 +100,10 @@ class api{
$apisql = "INSERT INTO `apiuse` (time, name, apikey, ip, type, allowed, misc) VALUES (NOW(), '$name', '$apikey', '$ip', 'Report Link', '$canshort', '$link')";
if(!$result = $apidb->query($apisql)) return 'ERROR: ['.$apidb->error.']';
}
if($canshort != 1) return 'You are not authorized to shorten links, meaning you also can\'t report false negatives';
if($canshort != 1) return '<div id="error">You are not authorized to shorten links, meaning you also can\'t report false negatives</div>';
$sql = "INSERT INTO `manual` (time, apikey, ip, link, reason) VALUES(NOW(), '$apikey', '$ip', '$link', '$reason');";
if(!$result = $sdb->query($sql)) return 'ERROR: ['.$sdb->error.']';
if(!$result = $sdb->query($sql)) return '<div id="error">ERROR: ['.$sdb->error.']</div>';
return "Reported $link. Please check back in a day or two";
}