function vkPost($url, $message = 'message', $title = 'title', $descr = 'descr') { global $url_vk, $url_site; $o = '../cache/cookie.txt'; $h = _params($o, $url_vk, true); if ($h['my_id'] == 0) { _auth($o, $d, true); $h = _params($o, $url_vk, true); } if ($h['my_id'] != 0) { $r = _status($o, $h['post_hash'], $url, $message, $title, $descr, $h['user_id']); $c = preg_match_all('/page_wall_count_all/smi', $r, $f); if ($c == 0) { return false; } else { return true; } } }
function save(&$var, $new_fact = NULL) { global $dbh; // did we get an ajax request with teh word in the post? if ($new_fact == NULL) { $new_fact = $_REQUEST['value']; } // authorize the user based on ip, session, input format, etc. if (!_auth($new_fact)) { load_form($var); return FALSE; } $new_uid = 0; $new_ip = $_SERVER['REMOTE_ADDR']; $new_session = $_SESSION['sid']; $new_fid = NULL; // Get the last submitted fact word $query = "\nSELECT id, fid FROM fact\nORDER BY id DESC\nLIMIT 1\t\n\t"; $result = mysql_query($query); // Is the last submitted fact word unpaired? while ($row = mysql_fetch_assoc($result)) { $new_fid = $row['fid'] == 0 ? $row['id'] : NULL; // If unpaired, pair it with a backwards fid reference } $query = sprintf("\nINSERT INTO fact (uid, fact, fid, ip, session) \nVALUES (%d, '%s', %d, '%s', '%s') \n\t", mysql_real_escape_string($new_uid), mysql_real_escape_string($new_fact), mysql_real_escape_string($new_fid), mysql_real_escape_string($new_ip), mysql_real_escape_string($new_session)); $result = mysql_query($query); if ($result) { set_message('Fact word submitted successfully'); $var['template_file'] = 'op'; $var['output'] = ' <em>You may not submit another fact until someone else has submitted.</em> '; } else { set_message('Fact failed to submit. Please try again.'); $load_form($var); } return TRUE; }