/** * @package:SMS * @MyHelper::countMyFriends(). * @Author:Techno Services */ function countMyFriends() { $ci =& get_instance(); if (current_url() == base_url()) { $user_id = getSession('token'); } else { $user_id = getIdByUsername(getUsernameByUrl()); } return $ci->friend_model->countMyFriends($user_id); }
<? require_once("global.inc.php"); unset ($user, $_SESSION['user']); if ($_POST['submit']) { $secretcode = '3485ghfgh98ghfdghq31qqqzxfjkdfgddkjwer08448534gdfgbdfg'; /* Used for activation code generation */ $username = secureData($_POST['username']); $rulername = secureData($_POST['rulername']); $planetname = secureData($_POST['planetname']); $password = secureData($_POST['password']); $password2 = secureData($_POST['password2']); $email = secureData($_POST['email']); $email2 = secureData($_POST['email2']); if (getIdByUsername($username)) { $msg = '<font color=red>That username is already taken.</font>'; } elseif (getIdByRulername($rulername)) { $msg = '<font color=red>That rulername is already taken.</font>'; } elseif (getIdByPlanetname($planetname)) { $msg = '<font color=red>That planetname is already taken.</font>'; } elseif (getIdByEmail($email)) { $msg = '<font color=red>The email address you\'re trying to use, is already taken.</font>'; } elseif ($password != $password2) { $msg = '<font color=red>The passwords don\'t match!</font>'; } elseif ($email != $email2) { $msg = '<font color=red>The e-mails don\'t match!</font>'; } elseif (!$username || !$planetname || !$password || !$password2 || !$email) { $msg = '<font color=red>Empty fields are not allowed.</font>'; } else { $activation_code = md5($username.time().$email.$secretcode); /* Generate a unique md5 has by using the username, current time, email address and a private code. */ $galaxy_id = getRandomGalaxyId(); if (getFreeGalaxySpot($galaxy_id)) { $galaxy_spot = getFreeGalaxySpot($galaxy_id); } else { $msg = 'Registration failed. Your data was inserted correctly, but the galaxy spot is not right. Contact the crew'; } $password = md5($password); $sql_newplayer = "INSERT INTO `$table[players]` (`username` , `password` , `email` , `activated` , `activation_code` , `rulername`,`planetname` , `galaxy_id` , `galaxy_spot`) VALUES ('$username', '$password', '$email', '0', '$activation_code', '$rulername','$planetname', '$galaxy_id', '$galaxy_spot')"; mysql_query($sql_newplayer) or die(mysql_error());