public static function remove($type, $value)
 {
     global $db;
     if (blacklist::check($type, $value)) {
         $db->query('delete from blacklist where type="' . $type . '" and value="' . $value . '"');
         if ($db->affected_rows() > -1) {
             $status = 'done';
         } else {
             $status = 'error';
         }
     } else {
         $status = 'noEntry';
     }
     return $status;
 }
Example #2
0
 public function add()
 {
     global $db, $game;
     $user = new user();
     if ($user->get('name', $this->data['name']) == 'noUser') {
         if ($user->get('email', $this->data['email']) == 'noUser') {
             if (!blacklist::check('ip', $this->data['ip'])) {
                 if (!blacklist::check('email', $this->data['email'])) {
                     $ok = 1;
                     $this->data['id'] = misc::newId('users');
                     $db->query('insert into users (id, name, password, email, level, joined, lastVisit, ip, template, locale) values ("' . $this->data['id'] . '", "' . $this->data['name'] . '", "' . $this->data['password'] . '", "' . $this->data['email'] . '", "' . $this->data['level'] . '", "' . $this->data['joined'] . '", "' . $this->data['lastVisit'] . '", "' . $this->data['ip'] . '", "' . $this->data['template'] . '", "' . $this->data['locale'] . '")');
                     if ($db->affected_rows() == -1) {
                         $ok = 0;
                     }
                     $preferences = array();
                     foreach ($game['users']['preferences'] as $key => $preference) {
                         $preferences[] = '("' . $this->data['id'] . '", "' . $key . '", "' . $preference . '")';
                     }
                     $preferences = implode(', ', $preferences);
                     $db->query('insert into preferences (user, name, value) values ' . $preferences);
                     if ($db->affected_rows() == -1) {
                         $ok = 0;
                     }
                     if ($ok) {
                         $status = 'done';
                     } else {
                         $status = 'error';
                     }
                 } else {
                     $status = 'emailBanned';
                 }
             } else {
                 $status = 'ipBanned';
             }
         } else {
             $status = 'emailInUse';
         }
     } else {
         $status = 'nameTaken';
     }
     return $status;
 }