getAuthDataByTask($task); $client = new Browser('http://letitbit.net/tmpl/login.php','POST'); $client->addPostParameter(array( 'log' => $data->login, 'pas' => $data->password, )); $response = $client->ssend(); $upload_id = text::random('numeric', 12); $client->setUrl('http://letitbit.net/'); $client->setMethod('GET'); $response = $client->send(); $body = $response->getBody(); $pattern = '#
setUrl($server); $client->setMethod('POST'); $client->addPostParameter(array( 'xmode'=>$m[2], 'pbmode' => $m[3], 'owner' => $m[4], 'pin' => $m[5], 'base' => $m[6], 'host' => $m[7], 'css_name' => $m[8], 'tmpl_name' => $m[9], )); $client->addUpload('file_0', $task->files->path, $task->files->name); $request = $client->send(); $body = $request->getBody(); $pattern = "#action='(.*?)' target='_parent'"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*"; $pattern .= ".*#s"; if(!preg_match($pattern, $body, $o)){ throw new Exception('Не удается распарсить форму №2'); } $client->setUrl($o[1]); $client->setMethod('POST'); $client->addPostParameter(array( 'file_name[]'=>$o[2], 'file_name_orig[]'=>$o[3], 'file_status[]'=>$o[4], 'file_size[]'=>$o[5], 'file_descr[]'=>$o[6], 'file_mime[]'=>$o[7], 'number_of_files'=>$o[8], 'ip'=>$o[9], 'host'=>$o[10], 'duration'=>$o[11], 'target_dir'=>$o[12], 'owner'=>$o[13], 'pin'=>$o[14], 'base'=>$o[15], 'host'=>$o[16], )); $end_url = $client->send()->getHeader('LOCATION'); $client->setUrl($end_url); $client->setMethod('GET'); $body = $client->send()->getBody(); $pattern = '#

.*

\s*#s'; if(!preg_match($pattern, $body,$k)){ throw new Exception('Немогу распарсить страницу с сылками на файл'); } $task->status_upload = 1; $task->link = $k[1]; $task->save(); return TRUE; } } ?>