Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function _post($endpoint = '', array $params = [], $cookieStorage = false) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $endpoint);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- if ($cookieStorage != FALSE) {
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36');
- curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieStorage);
- curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieStorage);
- }
- $response = curl_exec($ch);
- curl_close($ch);
- return $response;
- }
- public function login($username = '', $password = '') {
- $result = $this->_post(self::$BASE_URL . '/ucp.php?mode=login', [
- 'username' => $username,
- 'password' => $password,
- 'redirect' => '/viewforum.php',
- 'login' => 'Login',
- 'sid' => ''
- ], $this->cookieFile);
- if (preg_match('/' . $username . '/i', $result)) {
- return TRUE;
- } elseif (preg_match('/whoops/i', $result)) {
- return $result;
- } else {
- return FALSE;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement