2013-08-11 21:21:53 +00:00
< ? php
2013-08-26 06:33:14 +00:00
session_start ();
$catches = explode ( " : " , $_SESSION [ 'catch' ]);
$catchid = $catches [ 0 ];
$catchVal = $catches [ 1 ];
if ( empty ( $_GET [ 'token' ]) || $_GET [ 'token' ] != $_SESSION [ 'token' ] || empty ( $_POST [ $catchid ]) || $_POST [ $catchid ] != $catchVal ){
die ( " Oh Noes! Something happened and I can't continue.<br />Please try again by using the form located at <a href= \" http://unps.us \" >http://unps.us</a>. " );
}
2013-08-11 21:21:53 +00:00
require ( 'api/api.backend.php' );
require ( 'api/dbsettings.php' );
$key = '9a211e90b0a0570ed33e47428231e702af47b6f54fb347960f661184e063a1d0' ; // KEEP THIS PRIVATE! This is the only thing that authenticates the application
function sanitize ( $input ){
2013-08-26 06:33:14 +00:00
if ( $input == null ) die ( " <div id= \" error \" >Sanatize() - No Input Provided, Aborting</div> " );
2013-08-11 21:21:53 +00:00
include ( 'api/dbsettings.php' );
$output = strip_tags ( $input );
$output = stripslashes ( $output );
$output = $apidb -> real_escape_string ( $output );
return $output ;
}
$unpsAPI = new api ();
if ( ! empty ( $_POST [ 'link' ]) && ! empty ( $_POST [ 'linkmod' ])){
switch ( $_POST [ 'linkmod' ]){
case " shorten " :
$short = sanitize ( $_POST [ 'link' ]);
echo $unpsAPI -> shorten ( $apidb , $key , $shortdb , $short );
break ;
case " dellink " :
2013-08-26 06:33:14 +00:00
if ( empty ( $_POST [ 'password' ])) die ( " <div id= \" error \" >Something went wrong somewhere, but there's no password here</div> " );
2013-08-11 21:21:53 +00:00
$link = sanitize ( $_POST [ 'link' ]);
$password = sanitize ( $_POST [ 'password' ]);
$link = explode ( " = " , $link );
2013-08-26 06:33:14 +00:00
if ( count ( $link ) != 2 ){
die ( " <div id= \" error \" >I'm sorry, but something went wrong... did you paste the whole link?</div> " );
}
2013-08-11 21:21:53 +00:00
$link = $link [ 1 ];
echo $unpsAPI -> delShort ( $apidb , $key , $shortdb , $link , $password );
break ;
case " replink " :
2013-08-26 06:33:14 +00:00
if ( empty ( $_POST [ 'report-details' ])) die ( " <div id= \" error \" >Something went wrong somewhere, but I can't find the reason for reporting this link</div> " );
2013-08-11 21:21:53 +00:00
$link = sanitize ( $_POST [ 'link' ]);
$details = sanitize ( $_POST [ 'report-details' ]);
echo $unpsAPI -> reportLink ( $apidb , $key , $shortdb , $link , $details );
break ;
default :
2013-08-26 06:33:14 +00:00
die ( " <div id= \" error \" >I don't know what you want to do... [-Check linkmod-]</div> " );
2013-08-11 21:21:53 +00:00
}
2013-08-26 06:33:14 +00:00
} else { die ( " <div id= \" error \" >I can't do my job if I'm not given a link to work on...</div> " ); }
2013-08-11 21:21:53 +00:00
?>