Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $url = new AnrDaemon\Net\Url("http://test.example.org/login");
- fwrite(STDERR, 'Enter password: ');
- $form = [
- "login" => 'admin',
- "password" => trim(fgets(STDIN)),
- ];
- $curl = curl_init($url);
- curl_setopt_array($curl, [
- CURLOPT_COOKIEFILE => '',
- CURLOPT_COOKIESESSION => true,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_CONNECTTIMEOUT_MS => 500,
- //CURLOPT_URL => '',
- //CURLOPT_HTTPGET => true,
- CURLOPT_POSTFIELDS => $form,
- ]);
- curl_exec($curl);
- if(curl_getinfo($curl, CURLINFO_RESPONSE_CODE) != 303)
- die("Unauthorized.");
- $url = $url->parse("/backend/item?page=5&id=0");
- try
- {
- $form = [
- "action" => "save",
- "section_id" => 384,
- "series" => 'series',
- "name" => 'name',
- "content" => 'content',
- ];
- curl_setopt_array($curl, [
- CURLOPT_URL => $url,
- //CURLOPT_HTTPGET => true,
- CURLOPT_POSTFIELDS => $form,
- ]);
- curl_exec($curl);
- if(curl_getinfo($curl, CURLINFO_RESPONSE_CODE) != 303)
- throw new \ErrorException("Send failed");
- print "Sent {$form['series']}.\n";
- }
- catch(\ErrorException $e)
- {
- error_log($e);
- print("Error posting {$form['series']} ({$e->getMessage()}).\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement