Skip to content

Instantly share code, notes, and snippets.

@lizheming
Created January 17, 2013 06:52
Show Gist options
  • Save lizheming/4554221 to your computer and use it in GitHub Desktop.
Save lizheming/4554221 to your computer and use it in GitHub Desktop.
wechat.php
<?php
include "config.php";
function sql_query($sqlcon){
$con=mysql_connect(DATABASE_HOST, DATABASE_USER,DATABASE_PSSWORD);
mysql_select_db(DATABASE_DB_NAME);
mysql_query("SET NAMES 'utf8'");
$result = mysql_query($sqlcon);
mysql_close($con);
return $result;
}
switch($_GET['do']) {
case 'auth':
$user = sql_query("SELECT * FROM user WHERE username = '".$_POST['usr']."'");
$user = mysql_fetch_array($user);
$pwd = md5($user['username'].$user['password']);
if($pwd === $_POST['auth']) {
echo 'success';
} else {
echo 'failed';
}
break;
case 'post':
$user = sql_query("SELECT * FROM user WHERE username = '".$_POST['usr']."'");
$user = mysql_fetch_array($user);
$pwd = md5($user['username'].$user['password']);
if($pwd === $_POST['auth']) {
$userid = $user['id'];
$content = $_POST['content'];
$time = time();
$res = sql_query("INSERT INTO entry VALUES ('','0','$content','$time','微信','$userid')");
if($res) {
echo 'success';
} else {
echo 'failed';
}
} else {
echo '绑定失效,请重新绑定';
}
break;
default:
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment