Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F7105
http_error.php
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 11:15 PM
2014-11-21 23:15:39 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
http_error.php
View Options
<?PHP
$curl
=
curl_init
();
$data
=
""
;
$readed_data
=
false
;
function
query_http_data
(
$curl
,
$in
)
{
global
$data
,
$readed_data
;
$data
.=
$in
;
$len
=
strlen
(
$data
);
$readed_data
=
true
;
return
$len
;
}
function
login
(
$username
,
$password
)
{
$message
=
"lgname="
.
urlencode
(
$username
).
"&lgpassword="
.
urlencode
(
$password
);
$query_url
=
"http://commons.wikimedia.org/w/api.php?format=php&action=login"
;
$query_data
=
array
(
"lgname"
=>
$username
,
"lgpassword"
=>
$password
);
$result
=
query_http
(
$query_url
,
array
(
CURLOPT_POST
=>
true
,
CURLOPT_POSTFIELDS
=>
$query_data
)
);
echo
$result
[
'data'
].
"<br><br><br>"
;
$login_first
=
unserialize
(
$result
[
'data'
]
);
$login_token
=
$login_first
[
"login"
][
"token"
];
$message
=
"lgname="
.
urlencode
(
$username
).
"&lgpassword="
.
urlencode
(
$password
).
"&lgtoken="
.
urlencode
(
$login_token
);
$query_url
=
"http://commons.wikimedia.org/w/api.php?format=php&action=login"
;
$query_data
=
array
(
"lgname"
=>
$username
,
"lgpassword"
=>
$password
,
"lgtoken"
=>
$login_token
);
$result
=
query_http
(
$query_url
,
array
(
CURLOPT_POST
=>
true
,
CURLOPT_POSTFIELDS
=>
$query_data
)
);
echo
$result
[
'data'
];
}
function
query_http
(
$url
,
$options
=
array
(),
$exit
=
false
)
{
global
$data
,
$readed_data
,
$curl
;
$data
=
""
;
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_USERAGENT
,
"CommonsHelper2/1.0 Beta (http://toolserver.org/~commonshelper2/index.php jan@toolserver.org)"
);
curl_setopt
(
$curl
,
CURLOPT_WRITEFUNCTION
,
'query_http_data'
);
curl_setopt_array
(
$curl
,
$options
);
curl_exec
(
$curl
);
if
(
$exit
)
curl_exit
(
$curl
);
while
(
!
$readed_data
)
continue
;
$readed_data
=
false
;
return
array
(
'data'
=>
$data
);
}
login
(
"<username>"
,
"<password>"
);
?>
File Metadata
Details
Attached
Mime Type
text/x-php
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6641
Default Alt Text
http_error.php (1 KB)
Attached To
Mode
T28624: ERR_INVALID_REQ when trying upload a file with API
Attached
Detach File
Event Timeline
Log In to Comment