public function login($username, $password) { $this->logger->writeln('Login zu Subcentral'); $this->req = new URLRequest('http://www.subcentral.de/index.php?form=UserLogin', $this->cookieJar); $this->cookieJar = $this->req->getCookieJar(); $this->req->setType('POST'); $this->req->setOption(CURLOPT_COOKIESESSION, TRUE); // beginne neue session $this->req->setOption(CURLOPT_COOKIEFILE, FALSE); $d = $this->req->getData(); $d->loginUsername = $username; $d->loginPassword = $password; $d->useCookies = '1'; $d->url = ''; $html = $this->req->init()->process(); // check? $q1 = new jQuery('div#main p.success', $html); $q2 = new jQuery('div#main div..success', $html); if (count($q1) == 0 && $q2 === 0) { //file_put_contents('D:\html.html',$html); $this->logger->writeln('Fehler beim Login. div#main p.success nicht gefunden.'); throw new \Psc\Exception('Kein Login möglich! div#main p.success nicht gefunden. Output ist: ' . mb_substr($html, 0, 800) . '...'); } $this->sessionId = NULL; // ist nicht mehr in der neuen subcentral //Preg::qmatch($html,'/index\.php\?s=(.*)$/'); $this->logger->writeln('Login erfolgreich'); /* das ist der redirect, den die Seite auch machen würde */ //$this->req = new URLRequest('http://www.subcentral.de/'.$link); //$html = $this->req->init()->process(); return $html; }
/** * @return Psc\URL\Request */ protected function getRequest() { if (!isset($this->request)) { $this->request = new \Psc\URL\Request($this->expandUrl($this->url)); $this->request->setAuthentication($this->hostConfig->req('cmf.user'), $this->hostConfig->req('cmf.password'), CURLAUTH_BASIC); $this->request->setHeaderField('X-Psc-Cms-Connection', 'tests'); $this->request->setHeaderField('X-Psc-Cms-Debug-Level', 15); if ($this->method == 'GET' || $this->method == 'POST') { $this->request->setType($this->method); } else { $this->request->setType('POST'); $this->request->setHeaderField('X-Psc-Cms-Request-Method', $this->method); } $this->setContentType('html'); // this is great for debugging, but it slows down 50% if ($this->sendDebugSessionCookie && $this->hostConfig->get('uagent-key') != NULL) { $this->request->setHeaderField('Cookie', 'XDEBUG_SESSION=' . $this->hostConfig->get('uagent-key')); } } return $this->request; }