<div><font size="+3">HTTP:X</font><br /><br /><font size="+1">This plugin is an API to download files, webpages to the server or send information using the HTTP protocol.<br />It is not used to send files to clients. That is impossible.<br /></font><br /><br />More information and stuff will come...<br /><br />I know... another one?<br />A lot have changed.<br />It's an API now. It will be easier to work with.<br />New functions have been added.<br />Major parts are edited to avoid problems.<br />Automatic updating of this and other plugins has been added.<br /><br /><div style="margin: 5px;">
<div class="smallfont" style="margin-bottom: 2px;">
<b>Examples</b> <input value="Show" style="margin: 0px; padding: 0px; width: 45px; font-size: 10px;" onclick="if(this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != 'inline')
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'inline'; this.innerText = ''; this.value = 'Hide'; }
else
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value='Show'; }" type="button">
</div>
<div class="alt2" style="border: 1px inset; padding: 6px;">
<div class="spoiler" style="display: none;"><br /><br /><div style="margin: 5px;">
<div class="smallfont" style="margin-bottom: 2px;">
<b>GET, POST & Raw POST</b> <input value="Show" style="margin: 0px; padding: 0px; width: 45px; font-size: 10px;" onclick="if(this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != 'inline')
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'inline'; this.innerText = ''; this.value = 'Hide'; }
else
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value='Show'; }" type="button">
</div>
<div class="alt2" style="border: 1px inset; padding: 6px;">
<div class="spoiler" style="display: none;"><br /><!-- Code block -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<pre class="alt2" dir="ltr" style="margin: 0px;padding: 6px;border: 1px inset;width: auto; height: px; text-align: left; overflow: auto"><div class="pawn" style="font-family: monospace;"><span style="color: #339900;">#include <amxmodx></span>
<span style="color: #339900;">#include <httpx></span>
<span style="color: #ff0000;">public</span> plugin_init<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #00c0c0;">register_plugin</span><span style="color: #000000;">(</span><span style="color: #800080;">"HTTP:X GET, POST, Raw POST"</span>, <span style="color: #800080;">"1.0"</span>, <span style="color: #800080;">"[ --{-@ ]"</span><span style="color: #000000;">)</span>;
HTTPX_AddPostVar<span style="color: #000000;">(</span><span style="color: #800080;">"This is a POST variable"</span>, <span style="color: #800080;">"This is the POST value"</span><span style="color: #000000;">)</span>;
HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">"DivinityX.eu/posttest.php?This%20is%20a%20GET%20variable=This%20is%20the%20GET%20value"</span>, _, <span style="color: #800080;">"Complete"</span>, _, _, REQUEST_POST<span style="color: #000000;">)</span>;
HTTPX_AddPostVar<span style="color: #000000;">(</span><span style="color: #800080;">"This is a POST variable"</span>, <span style="color: #800080;">"This is the POST value"</span><span style="color: #000000;">)</span>;
HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">"DivinityX.eu/posttest2.php"</span>, _, <span style="color: #800080;">"Complete"</span>, _, _, REQUEST_POST<span style="color: #000000;">)</span>;
HTTPX_AddPostRaw<span style="color: #000000;">(</span><span style="color: #800080;">"This data is 100% raw! I can write whatever I want! ()YDF)/Y^"</span>PORKF_PSJUVYO U^<span style="color: #800080;">"V¤OUMC¤O()U;^"</span>=<span style="color: #000000;">)</span><span style="color: #339900;">#XI:");</span>
HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">"DivinityX.eu/posttest2.php"</span>, _, <span style="color: #800080;">"Complete"</span>, _, _, REQUEST_POST<span style="color: #000000;">)</span>;
<span style="color: #000000;">}</span>
<span style="color: #ff0000;">public</span> Complete<span style="color: #000000;">(</span>Index, Error<span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #007700;">new</span> Data<span style="color: #000000;">[</span><span style="color: #0000dd;">256</span><span style="color: #000000;">]</span>;
<span style="color: #0000ff;">while</span> <span style="color: #000000;">(</span> HTTPX_GetData<span style="color: #000000;">(</span>Data, charsmax<span style="color: #000000;">(</span>Data<span style="color: #000000;">)</span><span style="color: #000000;">)</span> <span style="color: #000000;">)</span>
<span style="color: #00c0c0;">server_print</span><span style="color: #000000;">(</span><span style="color: #800080;">"%s"</span>, Data<span style="color: #000000;">)</span>;
<span style="color: #000000;">}</span></div></pre>
</div>
<!-- /Code block -->posttest.php:<br /><div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB"><?php
<br />
<br /></span><span style="color: #007700">if ( isset(</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">) ) {
<br /> echo </span><span style="color: #DD0000">"GET, variables:rn"</span><span style="color: #007700">;
<br /> </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">);
<br />}
<br />
<br />if ( isset(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">) ) {
<br /> echo </span><span style="color: #DD0000">"POST, variables:rn"</span><span style="color: #007700">;
<br /> </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">);
<br />}
<br />
<br /></span><span style="color: #0000BB">?></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>posttest2.php:<br /><div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB"><?php
<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"POST, raw:rn"</span><span style="color: #007700">;
<br />echo </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'php://input'</span><span style="color: #007700">);
<br />echo </span><span style="color: #DD0000">"rn"</span><span style="color: #007700">;
<br /></span><span style="color: #0000BB">?></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div><div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<hr /><code style="margin:0px" dir="ltr" style="text-align:left">GET, variables:<br />Array<br />(<br /> [This_is_a_GET_variable] => This is the GET value<br />)<br />POST, variables:<br />Array<br />(<br /> [This_is_a_POST_variable] => This is the POST value<br />)<br /><br />POST, raw:<br />This+is+a+POST+variable=This+is+the+POST+value<br /><br />POST, raw:<br />This data is 100% raw! I can write whatever I want! ()YDF)/Y"PORKF_PSJUVYO U"V-ñOUMC-ñO()U;"=)#XI:</code><hr />
</div></div>
</div>
</div><br /><br /><div style="margin: 5px;">
<div class="smallfont" style="margin-bottom: 2px;">
<b>Searching webpage for a specific word</b> <input value="Show" style="margin: 0px; padding: 0px; width: 45px; font-size: 10px;" onclick="if(this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != 'inline')
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'inline'; this.innerText = ''; this.value = 'Hide'; }
else
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value='Show'; }" type="button">
</div>
<div class="alt2" style="border: 1px inset; padding: 6px;">
<div class="spoiler" style="display: none;"><br /><!-- Code block -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<pre class="alt2" dir="ltr" style="margin: 0px;padding: 6px;border: 1px inset;width: auto; height: px; text-align: left; overflow: auto"><div class="pawn" style="font-family: monospace;"><span style="color: #339900;">#include <amxmodx></span>
<span style="color: #339900;">#include <httpx></span>
<span style="color: #007700;">new</span> Buffer<span style="color: #000000;">[</span><span style="color: #0000dd;">1024</span><span style="color: #000000;">]</span>;
<span style="color: #ff0000;">public</span> plugin_init<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #00c0c0;">register_plugin</span><span style="color: #000000;">(</span><span style="color: #800080;">"HTTP:X Searching chunks example"</span>, <span style="color: #800080;">"1.0"</span>, <span style="color: #800080;">"[ --{-@ ]"</span><span style="color: #000000;">)</span>;
HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">"[url="""]http://www.amxmodx.org"</span>,[/url]_, _, <span style="color: #800080;">"Progress"</span><span style="color: #000000;">)</span>;
<span style="color: #000000;">}</span>
<span style="color: #ff0000;">public</span> Progress<span style="color: #000000;">(</span>Index<span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #007700;">new</span> len, len2;
<span style="color: #00c0c0;">server_print</span><span style="color: #000000;">(</span><span style="color: #800080;">"Downloaded data: %d/%d (+%d)"</span>, HTTPX_GetBytesReceived<span style="color: #000000;">(</span>Index<span style="color: #000000;">)</span>, HTTPX_GetFilesize<span style="color: #000000;">(</span>Index<span style="color: #000000;">)</span>, HTTPX_GetNewBytesReceived<span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>;
<span style="color: #0000ff;">while</span> <span style="color: #000000;">(</span> <span style="color: #000000;">(</span> len = HTTPX_GetData<span style="color: #000000;">(</span>Buffer, charsmax<span style="color: #000000;">(</span>Buffer<span style="color: #000000;">)</span><span style="color: #000000;">)</span> <span style="color: #000000;">)</span> <span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #00c0c0;">server_print</span><span style="color: #000000;">(</span><span style="color: #800080;">"Reading data %d/%d"</span>, len, HTTPX_GetNewBytesReceived<span style="color: #000000;">(</span><span style="color: #000000;">)</span> - len2<span style="color: #000000;">)</span>;
len2 += len;
<span style="color: #0000ff;">if</span> <span style="color: #000000;">(</span> <span style="color: #00c0c0;">contain</span><span style="color: #000000;">(</span>Buffer, <span style="color: #800080;">"Context"</span><span style="color: #000000;">)</span> != <span style="color: #0000dd;">-1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #00c0c0;">server_print</span><span style="color: #000000;">(</span><span style="color: #800080;">"Gaben was found"</span><span style="color: #000000;">)</span>;
<span style="color: #0000ff;">return</span> PLUGIN_HANDLED <span style="color: #cf0020;">// This will stop the download.</span>
<span style="color: #000000;">}</span>
<span style="color: #000000;">}</span>
<span style="color: #0000ff;">return</span> PLUGIN_CONTINUE
<span style="color: #000000;">}</span></div></pre>
</div>
<!-- /Code block --><div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<hr /><code style="margin:0px" dir="ltr" style="text-align:left">Downloaded data: 2446/-1 (+2446)<br />Reading data 1023/2446<br />Reading data 1023/1423<br />Reading data 400/400<br />Downloaded data: 6443/-1 (+3997)<br />Reading data 1023/3997<br />Reading data 1023/2974<br />Reading data 1023/1951<br />Reading data 928/928<br />Gaben was found</code><hr />
</div></div>
</div>
</div><br /><br /><div style="margin: 5px;">
<div class="smallfont" style="margin-bottom: 2px;">
<b>Simple autoupdater</b> <input value="Show" style="margin: 0px; padding: 0px; width: 45px; font-size: 10px;" onclick="if(this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != 'inline')
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'inline'; this.innerText = ''; this.value = 'Hide'; }
else
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value='Show'; }" type="button">
</div>
<div class="alt2" style="border: 1px inset; padding: 6px;">
<div class="spoiler" style="display: none;"><br /><!-- Code block -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<pre class="alt2" dir="ltr" style="margin: 0px;padding: 6px;border: 1px inset;width: auto; height: px; text-align: left; overflow: auto"><div class="pawn" style="font-family: monospace;"><span style="color: #339900;">#include <amxmodx></span>
<span style="color: #339900;">#define AUTOUPDATE_FILE_ID "76775"</span>
<span style="color: #339900;">#define AUTOUPDATE_HOW_OFTEN 604800 // 1d = 86400, 1w = 604800, 30d = 2592000</span>
<span style="color: #ff0000;">public</span> plugin_init<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #00c0c0;">register_plugin</span><span style="color: #000000;">(</span><span style="color: #800080;">"HTTP:X Autoupdate example 1"</span>, <span style="color: #800080;">"1.0"</span>, <span style="color: #800080;">"[ --{-@ ]"</span><span style="color: #000000;">)</span>;
UpdatePlugin<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;
<span style="color: #000000;">}</span>
UpdatePlugin<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #0000ff;">if</span> <span style="color: #000000;">(</span> <span style="color: #00c0c0;">callfunc_begin</span><span style="color: #000000;">(</span><span style="color: #800080;">"AutoupdatePlugin"</span>, <span style="color: #800080;">"httpx.amxx"</span><span style="color: #000000;">)</span> == <span style="color: #0000dd;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #00c0c0;">callfunc_push_int</span><span style="color: #000000;">(</span><span style="color: #00c0c0;">get_plugin</span><span style="color: #000000;">(</span><span style="color: #0000dd;">-1</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>;
<span style="color: #00c0c0;">callfunc_push_str</span><span style="color: #000000;">(</span>AUTOUPDATE_FILE_ID, <span style="color: #007700;">false</span><span style="color: #000000;">)</span>;
<span style="color: #00c0c0;">callfunc_push_int</span><span style="color: #000000;">(</span>AUTOUPDATE_HOW_OFTEN<span style="color: #000000;">)</span>;
<span style="color: #00c0c0;">callfunc_end</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>;
<span style="color: #000000;">}</span>
<span style="color: #000000;">}</span></div></pre>
</div>
<!-- /Code block --></div>
</div>
</div><br /><br /><div style="margin: 5px;">
<div class="smallfont" style="margin-bottom: 2px;">
<b>Advanced autoupdater</b> <input value="Show" style="margin: 0px; padding: 0px; width: 45px; font-size: 10px;" onclick="if(this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != 'inline')
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'inline'; this.innerText = ''; this.value = 'Hide'; }
else
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value='Show'; }" type="button">
</div>
<div class="alt2" style="border: 1px inset; padding: 6px;">
<div class="spoiler" style="display: none;"><br /><!-- Code block -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<pre class="alt2" dir="ltr" style="margin: 0px;padding: 6px;border: 1px inset;width: auto; height: px; text-align: left; overflow: auto"><div class="pawn" style="font-family: monospace;"><span style="color: #339900;">#include <amxmodx></span>
<span style="color: #007700;">enum</span> <span style="color: #000000;">{</span>
REQUEST_GET,
REQUEST_POST
<span style="color: #000000;">}</span>
native HTTPX_Download<span style="color: #000000;">(</span><span style="color: #ff0000;">const</span> URL<span style="color: #000000;">[</span><span style="color: #000000;">]</span>, <span style="color: #ff0000;">const</span> Filename<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, <span style="color: #ff0000;">const</span> CompleteHandler<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, <span style="color: #ff0000;">const</span> ProgressHandler<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, Port = <span style="color: #0000dd;">0</span>, RequestType = REQUEST_GET, <span style="color: #ff0000;">const</span> Username<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, <span style="color: #ff0000;">const</span> Password<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, ... <span style="color: #ff0000; font-style: italic;">/* For possible future use */</span><span style="color: #000000;">)</span>
native HTTPX_GetData<span style="color: #000000;">(</span>data<span style="color: #000000;">[</span><span style="color: #000000;">]</span>, len<span style="color: #000000;">)</span>
<span style="color: #339900;">#define AUTOUPDATE_FILE_ID "76775"</span>
<span style="color: #339900;">#define AUTOUPDATE_HOW_OFTEN 0</span>
<span style="color: #007700;">new</span> <span style="color: #ff0000;">const</span> VersionNum = <span style="color: #0000dd;">99</span>;
<span style="color: #007700;">new</span> <span style="color: #ff0000;">const</span> VersionString<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">"1.00"</span>;
<span style="color: #ff0000;">public</span> plugin_init<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #00c0c0;">register_plugin</span><span style="color: #000000;">(</span><span style="color: #800080;">"HTTP:X Autoupdate example 2"</span>, VersionString, <span style="color: #800080;">"[ --{-@ ]"</span><span style="color: #000000;">)</span>;
HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">"[url="http://your.website.com/your_plugin/version.txt""]http://your.website.com/your_plugin/version.txt"</span>,[/url]<span style="color: #800080;">""</span>, <span style="color: #800080;">"Complete"</span>, <span style="color: #800080;">""</span>, <span style="color: #0000dd;">80</span>, REQUEST_GET, <span style="color: #800080;">""</span>, <span style="color: #800080;">""</span>, <span style="color: #0000dd;">0</span>, <span style="color: #0000dd;">-1</span><span style="color: #000000;">)</span>;
<span style="color: #000000;">}</span>
<span style="color: #ff0000;">public</span> Complete<span style="color: #000000;">(</span>DownloadID, Error<span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #0000ff;">if</span> <span style="color: #000000;">(</span> Error <span style="color: #000000;">)</span>
<span style="color: #0000ff;">return</span>;
<span style="color: #007700;">new</span> temp<span style="color: #000000;">[</span><span style="color: #0000dd;">16</span><span style="color: #000000;">]</span>;
HTTPX_GetData<span style="color: #000000;">(</span>temp, charsmax<span style="color: #000000;">(</span>temp<span style="color: #000000;">)</span><span style="color: #000000;">)</span>;
<span style="color: #0000ff;">if</span> <span style="color: #000000;">(</span> <span style="color: #00c0c0;">str_to_num</span><span style="color: #000000;">(</span>temp<span style="color: #000000;">)</span> > VersionNum <span style="color: #000000;">)</span>
UpdatePlugin<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;
<span style="color: #000000;">}</span>
UpdatePlugin<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #0000ff;">if</span> <span style="color: #000000;">(</span> <span style="color: #00c0c0;">callfunc_begin</span><span style="color: #000000;">(</span><span style="color: #800080;">"AutoupdatePlugin"</span>, <span style="color: #800080;">"httpx.amxx"</span><span style="color: #000000;">)</span> == <span style="color: #0000dd;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
<span style="color: #00c0c0;">callfunc_push_int</span><span style="color: #000000;">(</span><span style="color: #00c0c0;">get_plugin</span><span style="color: #000000;">(</span><span style="color: #0000dd;">-1</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>;
<span style="color: #00c0c0;">callfunc_push_str</span><span style="color: #000000;">(</span>AUTOUPDATE_FILE_ID, <span style="color: #007700;">false</span><span style="color: #000000;">)</span>;
<span style="color: #00c0c0;">callfunc_push_int</span><span style="color: #000000;">(</span>AUTOUPDATE_HOW_OFTEN<span style="color: #000000;">)</span>;
<span style="color: #00c0c0;">callfunc_end</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>;
<span style="color: #000000;">}</span>
<span style="color: #000000;">}</span></div></pre>
</div>
<!-- /Code block --></div>
</div>
</div><br /><br /></div>
</div>
</div><br /><br /><div style="margin: 5px;">
<div class="smallfont" style="margin-bottom: 2px;">
<b>httpx.inc</b> <input value="Show" style="margin: 0px; padding: 0px; width: 45px; font-size: 10px;" onclick="if(this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != 'inline')
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'inline'; this.innerText = ''; this.value = 'Hide'; }
else
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value='Show'; }" type="button">
</div>
<div class="alt2" style="border: 1px inset; padding: 6px;">
<div class="spoiler" style="display: none;"><br /><!-- Code block -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<pre class="alt2" dir="ltr" style="margin: 0px;padding: 6px;border: 1px inset;width: auto; height: px; text-align: left; overflow: auto"><div class="pawn" style="font-family: monospace;"><span style="color: #339900;">#if defined _HTTPX_included</span>
<span style="color: #339900;">#endinput</span>
<span style="color: #339900;">#endif</span>
<span style="color: #339900;">#define _HTTPX_included</span>
<span style="color: #007700;">enum</span> <span style="color: #000000;">{</span>
REQUEST_GET,
REQUEST_POST
<span style="color: #000000;">}</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_IsFilesizeLarge(DownloadID)
*
* If the filesize in bytes is beyond the limitations of integers the function will return true.
**/</span>
native <span style="color: #ff0000;">bool</span>:HTTPX_IsFilesizeLarge<span style="color: #000000;">(</span>DownloadID<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_GetBytesReceived(DownloadID)
*
* Returns total ammount of bytes received for DownloadID.
**/</span>
native HTTPX_GetBytesReceived<span style="color: #000000;">(</span>DownloadID<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_GetBytesReceivedLarge(DownloadID, string[], len)
*
* Formats total ammount of bytes received for DownloadID in string form.
**/</span>
native HTTPX_GetBytesReceivedLarge<span style="color: #000000;">(</span>DownloadID, string<span style="color: #000000;">[</span><span style="color: #000000;">]</span>, len<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_GetNewBytesReceived()
*
* Returns the ammount of bytes that was received in this chunk.
**/</span>
native HTTPX_GetNewBytesReceived<span style="color: #000000;">(</span><span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_GetFilesize(DownloadID)
*
* Returns the filesize of DownloadID.
* If unknown it will return -1.
**/</span>
native HTTPX_GetFilesize<span style="color: #000000;">(</span>DownloadID<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_GetFilesizeLarge(DownloadID, string[], len)
*
* Formats the large filesize of DownloadID in string form.
**/</span>
native HTTPX_GetFilesizeLarge<span style="color: #000000;">(</span>DownloadID, string<span style="color: #000000;">[</span><span style="color: #000000;">]</span>, len<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_GetFilename(DownloadID)
*
* Returns the filename of DownloadID.
**/</span>
native HTTPX_GetFilename<span style="color: #000000;">(</span>DownloadID, name<span style="color: #000000;">[</span><span style="color: #000000;">]</span>, len<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_GetData(data[], len)
*
* Fills variable data[] with the last chunk downloaded.
*
* len decides maxlen for the data[] variable.
* Remember, this is raw data.
* No need to make room for null at the end unless you're passing it to any function that is
* trying to automatically find the end by searching for null (any string function).
*
* The function will return the ammount of bytes that was written to the data[] variable.
*
* By looping this function until it returns 0, you can get all the data.
**/</span>
native HTTPX_GetData<span style="color: #000000;">(</span>data<span style="color: #000000;">[</span><span style="color: #000000;">]</span>, len<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* Automatic updating
* Updates current plugin automatically (from AlliedModders webpage only to prevent spreading of malicious code).
*
*
* file_id[] has to be the same as it is on the forum webpage. (Check the link of the .amxx file ("Get Plugin" link))
*
*
* If frequency is supplied you can set how often to update the file. If none is provided it will update as soon as possible.
* Please use this respectfully. Don't overload the AM forums.
*
* You can however provide your own method of determining whether the file needs to be updated or not before calling this function.
* That way you don't stress AM servers when not required. An example of this is in the HTTPX source which uses this method.
*
* Examples:
* 1d = 86400
* 1w = 604800
* 30d = 2592000
*
*
* IMPORTANT!
* The reason for this not being a native is that it does not halt the plugin if HTTPX is not running. HTTPX and automatic updating is optional.
* Use this example instead. the File ID is the attachment in your post on the AM forums. Only use the ID, not the whole URL.
* For example:
* The plugin Name Replacer by anakin_cstrike, @http://forums.allied...hlight=replacer
* Scroll down and hover the "Get Plugin", there you see the file ID. Just replace the placeholder with that value.
* #define AUTOUPDATE_FILE_ID "76775"
* Add the time or create your own method of deciding when it's supposed to be updated and you're done.
#define AUTOUPDATE_FILE_ID "REPLACE_THIS_WITH_YOUR_FILE_ID"
#define AUTOUPDATE_HOW_OFTEN REPLACE_THIS_WITH_DESIRED_FREQUENCY // 1d = 86400, 1w = 604800, 30d = 2592000
UpdatePlugin() {
if ( callfunc_begin("AutoupdatePlugin", "httpx.amxx") == 1 ) { // Don't touch.
callfunc_push_int(get_plugin(-1)) // Plugin ID (to get the filename). Don't touch.
callfunc_push_str(AUTOUPDATE_FILE_ID, false) // The file_id in string format. Touch above.
callfunc_push_int(AUTOUPDATE_HOW_OFTEN) // Frequency of the automatic updates. Touch above.
callfunc_end() // Don't touch.
}
}
**/</span>
<span style="color: #ff0000; font-style: italic;">/**
* bool:HTTPX_IsPaused(DownloadID)
*
* Returns true if the download is paused. Otherwise returns false.
**/</span>
native <span style="color: #ff0000;">bool</span>:HTTPX_IsPaused<span style="color: #000000;">(</span>DownloadID<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_Paused(DownloadID)
*
* Pauses the download.
**/</span>
native HTTPX_Pause<span style="color: #000000;">(</span>DownloadID<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_Unpause(DownloadID)
*
* Unpauses the download.
**/</span>
native HTTPX_Unpause<span style="color: #000000;">(</span>DownloadID<span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_Abort(DownloadID, bool:DeleteFile = true)
*
* Aborts the transfer of selected download DownloadID.
* If DeleteFile is set to true the partially downloaded file will be deleted.
**/</span>
native HTTPX_Abort<span style="color: #000000;">(</span>DownloadID, <span style="color: #ff0000;">bool</span>:DeleteFile = <span style="color: #007700;">true</span><span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_AddPostVar(const variable[], const value[])
*
* Adds a POST variable to the request.
* This function is used before HTTPX_Download() or HTTP_AddToQue(), similar to set/show hudmessage.
* It can be used multiple times before each download.
**/</span>
native HTTPX_AddPostVar<span style="color: #000000;">(</span><span style="color: #ff0000;">const</span> variable<span style="color: #000000;">[</span><span style="color: #000000;">]</span>, <span style="color: #ff0000;">const</span> value<span style="color: #000000;">[</span><span style="color: #000000;">]</span><span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_AddPostRaw(const data[])
*
* Adds raw POST data to the request.
* This function is used before HTTPX_Download() or HTTP_AddToQue(), similar to set/show hudmessage.
* It can be used multiple times before each download.
**/</span>
native HTTPX_AddPostRaw<span style="color: #000000;">(</span><span style="color: #ff0000;">const</span> data<span style="color: #000000;">[</span><span style="color: #000000;">]</span><span style="color: #000000;">)</span>
<span style="color: #ff0000; font-style: italic;">/**
* Number of parameters for the callbacks are 1 (DownloadID) for the progress event and 2 (DownloadID, Error) for the complete event.
* Error codes:
* 0 Download done. No problems encountered.
* Positive returns is unhandled HTTP return codes. For example 404.
* Negative is internal errors.
* -1 No response code was found in the HTTP response header or it was outside the accepted range (200-307).
* -2 Server is sending bad data or sizes for a chunked transfer or HTTPX has problems reading them.
* -3 Nothing received in last packet. Most likely due to an error.
* -4 HTTPX was redirected but could not follow due to a socket error.
* -5 HTTPX was redirected too many times. Usually happens when server is insisting on a SSL/TLS connection which HTTPX does not support.
**/</span>
<span style="color: #ff0000; font-style: italic;">/**
* HTTPX_Download(const URL[], const Filename[] = "", const CompleteHandler[] = "", const ProgressHandler[] = "", Port = (80<<443), RequestType = REQUEST_GET, const Username[] = "", const Password[] = "", ...)
*
* Begins download of a URL. Read parameters for information.
*
*
* Parameters:
*
* const URL[]
* URL that you want to download.
*
* (Optional) const Filename[]
* Where should the information be stored? If no filename is entered it will download as a "stream".
* This means the data will be thrown away after it passes the buffer.
* You can read the data on progress forward and make use of it there.
*
* (Optional) const CompleteHandler[] = ""
* The function you want called when the download is complete.
*
* (Optional) const ProgressHandler[] = ""
* The function you want called when the download is in progress.
* This will be called every time data is downloaded.
*
* (Optional) Port = 0
* The port that should be used.
* If this is left at default it will use 80 for http and 443 for https (when supported).
*
* (Optional) RequestType = REQUEST_GET
* What type of request should be used.
* If this is left at default it will use GET.
* Possible values so far are REQUEST_GET and REQUEST_POST.
*
* (Optional) const Username[] = ""
* (Optional) const Password[] = ""
* These are used to login to sites that require you to.
* It's only used for Basic authentication, not POST for example.
*
* Returns an DownloadID of the download that may be used to abort the download.
**/</span>
native HTTPX_Download<span style="color: #000000;">(</span><span style="color: #ff0000;">const</span> URL<span style="color: #000000;">[</span><span style="color: #000000;">]</span>, <span style="color: #ff0000;">const</span> Filename<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, <span style="color: #ff0000;">const</span> CompleteHandler<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, <span style="color: #ff0000;">const</span> ProgressHandler<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, Port = <span style="color: #0000dd;">0</span>, RequestType = REQUEST_GET, <span style="color: #ff0000;">const</span> Username<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, <span style="color: #ff0000;">const</span> Password<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">""</span>, ... <span style="color: #ff0000; font-style: italic;">/* For possible future use */</span><span style="color: #000000;">)</span></div></pre>
</div>
<!-- /Code block --></div>
</div>
</div></div>
<br /> <div style="padding:6px">
<fieldset class="fieldset">
<legend>Attached Files</legend>
<table cellpadding="0" cellspacing="3" border="0">
<tr>
<td><img class="inlineimg" src="https://forums.allie...attach/sma.gif"alt="File Type: sma" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td>
<a href="http://www.amxmodx.o...27"><strong>GetPlugin</strong></a> or
<a href="https://forums.allie...1463847187">GetSource</a> (httpx.sma - 40.5 KB)
</td>
</tr><tr>
<td><img class="inlineimg" src="https://forums.allie...attach/inc.gif"alt="File Type: inc" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td>
<a href="https://forums.allie...">httpx.inc</a>(7.8 KB)
</td>
</tr>
</table>
</fieldset>
</div>
Wyświetl pełny artykuł
Witamy w Nieoficjalnym polskim support'cie AMX Mod X
Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
|
Guest Message by DevFuse

HTTP:X
Temat rozp. Adminek AMXX.PL, 21.05.2016 17:37
Brak odpowiedzi do tego tematu
Użytkownicy przeglądający ten temat: 0
0 użytkowników, 0 gości, 0 anonimowych