error_log($e); $D->fb_user = null; } } if ($D->fb_user) { $D->fb_logoutUrl = $facebook->getLogoutUrl(); if (isset($_GET['code'])) { $fb_email = $D->fb_user_profile['email']; $usersimple = $this->db1->fetch_field("SELECT iduser FROM users WHERE email='" . $fb_email . "' AND auth=''"); if ($usersimple) { $D->msg_alert = 'The email that this facebook account is using is already registered'; session_destroy(); } else { $r = $this->db1->query("SELECT username FROM users WHERE email='" . $fb_email . "' AND auth='facebook'"); if (!($obj = $db2->fetch_object($r))) { $code = uniqueCode(11, 1, 'users', 'code'); $fb_pass = getCode(10, 1); $salt = md5(uniqid(rand(), true)); $hash = hash('sha512', $salt . $fb_pass); $ip = $this->db1->escape(ip2long($_SERVER['REMOTE_ADDR'])); $fb_id = $D->fb_user_profile['id']; $fb_first_name = $this->db1->e($D->fb_user_profile['first_name']); $fb_last_name = $this->db1->e($D->fb_user_profile['last_name']); $fb_gender = $D->fb_user_profile['gender']; $fb_username = $D->fb_user_profile['name']; $fb_username = str_replace(' ', '', $fb_username); $fb_username = str_replace('.', '', $fb_username); //if the username does not work, use your email if (!validateUsername($fb_username)) { $newUser = explode('@', $fb_email); $fb_username = str_replace('.', '', $newUser[0]);
if ($this->user->id != $idowner) { $this->db1->query("DELETE FROM notifications WHERE notif_type=3 AND idresult=" . $idcomment . " AND from_user_id=" . $this->user->id); $nnotifications = $this->network->getNumNotifications($idowner); if ($nnotifications <= 0) { $nnotifications = 0; } else { $nnotifications = $nnotifications - 1; } $this->db1->query("UPDATE users SET num_notifications=" . $nnotifications . " WHERE iduser="******" LIMIT 1"); } } echo '1: Ok'; return; } if ($action == 6) { $codep = uniqueCode(11, 1, 'posts', 'code'); $r = $this->db1->query("INSERT INTO posts SET code='" . $codep . "', iduser="******", post='" . $txtshare . "', typepost='share', valueattach='" . $ip . ':' . $idowner . "', whendate='" . time() . "'"); $idpost = $this->db1->insert_id(); $this->db1->query('INSERT INTO activities SET iduser='******', idresult=' . $idpost . ', iduser2=' . $idowner . ',action=6, iditem=' . $ip . ', typeitem=1, date="' . time() . '"'); $this->db1->query("UPDATE users SET num_posts=num_posts+1 WHERE iduser="******" LIMIT 1"); //$this->db1->query("UPDATE posts SET numshares=numshares+1 WHERE idpost=".$ip." LIMIT 1"); $idOwnerPost = $this->network->idOwnerPost($ip); if ($this->user->id != $idOwnerPost) { $this->db1->query("UPDATE posts SET numshares=numshares+1 WHERE idpost=" . $ip . " LIMIT 1"); $this->db1->query("INSERT INTO notifications SET notif_type=5, idresult=" . $idpost . ", to_user_id=" . $idOwnerPost . ", from_user_id=" . $this->user->id . ", notif_object_type=1, notif_object_id=" . $ip . ",date='" . time() . "'"); $this->db1->query("UPDATE users SET num_notifications=num_notifications+1 WHERE iduser=" . $idOwnerPost . ' LIMIT 1'); } if (!empty($txtshare)) { preg_match_all('~([#])([^\\s#]+)~', str_replace(array('\\r', '\\n'), ' ', $txtstatus), $matchedHashtags); if (!empty($matchedHashtags[0])) { foreach ($matchedHashtags[0] as $match) {