private function getSession() { return randHash(); }
} } } } } if (!$data['enabled']) { $page = 'disabled'; } elseif ($data['paid']) { $page = 'paid'; } elseif ($data['eligible'] && $data['address_eligible']) { $page = 'eligible'; } else { $page = 'visit_later'; } $data['page'] = $page; $_SESSION['address_input_name'] = randHash(rand(25, 35)); $data['address_input_name'] = $_SESSION['address_input_name']; $data['rewards'] = implode(', ', $possible_rewards); $q = $sql->query("SELECT url_name, name FROM Faucetinabox_Pages ORDER BY id"); $data["user_pages"] = $q->fetchAll(); $allowed = array("page", "name", "rewards", "short", "error", "paid", "captcha_valid", "captcha", "captcha_info", "time_left", "referral", "reflink", "template", "user_pages", "timer", "unit", "address", "balance", "disable_admin_panel", "address_input_name", "block_adblock", "button_timer"); preg_match_all('/\\$data\\[([\'"])(custom_(?:(?!\\1).)*)\\1\\]/', file_get_contents("templates/{$template}/index.php"), $matches); foreach (array_unique($matches[2]) as $box) { $key = "{$box}_{$template}"; if (!array_key_exists($key, $data)) { $data[$key] = ''; } $allowed[] = $key; } foreach (array_keys($data) as $key) { if (!in_array($key, $allowed)) {
private function login($inp, $user, $sess) { // need rewriting $inp = $inp['obj']; // let all users to login // if( isset($user['uid']) ) // if( $user['uid'] == 'guest' ){ if (isset($inp['login'])) { $login = $inp['login']; // $loginuser = $this->db->getObjectByVal('uid', $login, 'user', $this->root); $loginuser = $this->db->getUser($login); if ($loginuser != false && !isset($loginuser['nologin'])) { if (isset($inp['response'])) { $resp = strtolower($inp['response']); $sessuserdata = $this->db->getSessionUserData($sess['sid']); if (isset($sessuserdata['serverdata']['chal']) && isset($loginuser['pass'])) { if ($resp === md5($sessuserdata['serverdata']['chal'] . $loginuser['pass'])) { unset($sessuserdata['serverdata']['chal']); $sess['data'] = $sessuserdata; $sess['uid'] = $loginuser['uid']; //$this->db->putObject_($sess, 'sess auth', $this->root); $sess['authed'] = '1'; $this->db->saveSession($sess); $userdata = $this->db->getUserData($sess['uid']); $ret['objs']['userinfo'] = isset($userdata['userinfo']) ? $userdata['userinfo'] : array(); $ret['objs']['userdata'] = isset($userdata['userdata']) ? $userdata['userdata'] : array(); $ret['result'] = 'success'; } else { $ret['result'] = 'failed'; } } else { $ret['result'] = 'failed'; } } else { $randhash = randHash(); $ret['chal'] = $randhash; $ret['result'] = 'challange'; //store challange $sess['serverdata']['chal'] = $randhash; $this->db->saveSession($sess); // $this->db->putObject_($sess, 'sess chal', $this->root); } } else { $ret['result'] = 'this user is nologin'; } } else { $ret['result'] = 'specify login'; } return $ret; // } // $ret['result'] = 'notsid'; // $ret['result'] = 'only guest session can login. Just create new session.'; // return $ret; // $ret['result'] = 'unavailable'; // return $ret; }