Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // MAKE SURE YOU HAVE A CONNECTION TO MYSQL... Or comment line 12 (and don't insert anything into your DB)
- function valid($input){
- $input = trim($input);
- return isset($input) && $input!=null && $input!="";
- }
- function clean($input){
- if(get_magic_quotes_gpc()){
- $input = stripslashes($input);
- }
- $input = mysql_real_escape_string($input);
- $input = htmlentities($input, ENT_COMPAT, "UTF-8");
- return $input;
- }
- function done($msg){
- echo json_encode(array("message"=>$msg));
- }
- if(valid($_POST['message']) && valid($_POST['token'])){
- $msg = clean($_POST['message']);
- $token = clean($_POST['token']);
- if($token == "YourTokenHere"){ // This really should not be hardcoded
- // Post $msg to your site
- // Post $msg to Twitter
- done("Posted!");
- }else{
- done("Invalid Token");
- }
- }else{
- done("Unclean Variables");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment