Skocz do zawartości

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.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

HTTP:X


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 Adminek AMXX.PL

    Admin :)

  • Bot

Reputacja: 156
Profesjonalista

  • Postów:7 490
  • Lokalizacja:AMXX.PL
Offline

Napisano 21.05.2016 17:37

<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 &amp; 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 &lt;amxmodx&gt;</span>
<span style="color: #339900;">#include &lt;httpx&gt;</span>

<span style="color: #ff0000;">public</span> plugin_init<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
&nbsp; &nbsp; <span style="color: #00c0c0;">register_plugin</span><span style="color: #000000;">(</span><span style="color: #800080;">&quot;HTTP:X GET, POST, Raw POST&quot;</span>, <span style="color: #800080;">&quot;1.0&quot;</span>, <span style="color: #800080;">&quot;[ --{-@ ]&quot;</span><span style="color: #000000;">)</span>;
&nbsp; &nbsp;
&nbsp; &nbsp; HTTPX_AddPostVar<span style="color: #000000;">(</span><span style="color: #800080;">&quot;This is a POST variable&quot;</span>, <span style="color: #800080;">&quot;This is the POST value&quot;</span><span style="color: #000000;">)</span>;
&nbsp; &nbsp; HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">&quot;DivinityX.eu/posttest.php?This%20is%20a%20GET%20variable=This%20is%20the%20GET%20value&quot;</span>, _, <span style="color: #800080;">&quot;Complete&quot;</span>, _, _, REQUEST_POST<span style="color: #000000;">)</span>;

&nbsp; &nbsp; HTTPX_AddPostVar<span style="color: #000000;">(</span><span style="color: #800080;">&quot;This is a POST variable&quot;</span>, <span style="color: #800080;">&quot;This is the POST value&quot;</span><span style="color: #000000;">)</span>;
&nbsp; &nbsp; HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">&quot;DivinityX.eu/posttest2.php&quot;</span>, _, <span style="color: #800080;">&quot;Complete&quot;</span>, _, _, REQUEST_POST<span style="color: #000000;">)</span>;

&nbsp; &nbsp; HTTPX_AddPostRaw<span style="color: #000000;">(</span><span style="color: #800080;">&quot;This data is 100% raw! I can write whatever I want! ()YDF)/Y^&quot;</span>PORKF_PSJUVYO U^<span style="color: #800080;">&quot;V¤OUMC¤O()U;^&quot;</span>=<span style="color: #000000;">)</span><span style="color: #339900;">#XI:&quot;);</span>
&nbsp; &nbsp; HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">&quot;DivinityX.eu/posttest2.php&quot;</span>, _, <span style="color: #800080;">&quot;Complete&quot;</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>
&nbsp; &nbsp; <span style="color: #007700;">new</span> Data<span style="color: #000000;">[</span><span style="color: #0000dd;">256</span><span style="color: #000000;">]</span>;
&nbsp; &nbsp; <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>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00c0c0;">server_print</span><span style="color: #000000;">(</span><span style="color: #800080;">&quot;%s&quot;</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">&lt;?php
<br />
<br /></span><span style="color: #007700">if&nbsp;(&nbsp;isset(</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">)&nbsp;)&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"GET,&nbsp;variables:rn"</span><span style="color: #007700">;
<br />&nbsp;&nbsp;&nbsp;&nbsp;</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&nbsp;(&nbsp;isset(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">)&nbsp;)&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"POST,&nbsp;variables:rn"</span><span style="color: #007700">;
<br />&nbsp;&nbsp;&nbsp;&nbsp;</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">?&gt;</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">&lt;?php
<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"POST,&nbsp;raw:rn"</span><span style="color: #007700">;
<br />echo&nbsp;</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&nbsp;</span><span style="color: #DD0000">"rn"</span><span style="color: #007700">;
<br /></span><span style="color: #0000BB">?&gt;</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 />&nbsp; &nbsp; [This_is_a_GET_variable] =&gt; This is the GET value<br />)<br />POST, variables:<br />Array<br />(<br />&nbsp; &nbsp; [This_is_a_POST_variable] =&gt; 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&quot;PORKF_PSJUVYO U&quot;V-ñOUMC-ñO()U;&quot;=)#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 &lt;amxmodx&gt;</span>
<span style="color: #339900;">#include &lt;httpx&gt;</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>
&nbsp; &nbsp; <span style="color: #00c0c0;">register_plugin</span><span style="color: #000000;">(</span><span style="color: #800080;">&quot;HTTP:X Searching chunks example&quot;</span>, <span style="color: #800080;">&quot;1.0&quot;</span>, <span style="color: #800080;">&quot;[ --{-@ ]&quot;</span><span style="color: #000000;">)</span>;

&nbsp; &nbsp; HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">&quot;[url="""]http://www.amxmodx.org&quot;</span>,[/url]_, _, <span style="color: #800080;">&quot;Progress&quot;</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>
&nbsp; &nbsp; <span style="color: #007700;">new</span> len, len2;

&nbsp; &nbsp; <span style="color: #00c0c0;">server_print</span><span style="color: #000000;">(</span><span style="color: #800080;">&quot;Downloaded data: %d/%d (+%d)&quot;</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>;

&nbsp; &nbsp; <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>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00c0c0;">server_print</span><span style="color: #000000;">(</span><span style="color: #800080;">&quot;Reading data %d/%d&quot;</span>, len, HTTPX_GetNewBytesReceived<span style="color: #000000;">(</span><span style="color: #000000;">)</span> - len2<span style="color: #000000;">)</span>;
&nbsp; &nbsp; &nbsp; &nbsp; len2 += len;
&nbsp; &nbsp; &nbsp; &nbsp; <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;">&quot;Context&quot;</span><span style="color: #000000;">)</span> != <span style="color: #0000dd;">-1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00c0c0;">server_print</span><span style="color: #000000;">(</span><span style="color: #800080;">&quot;Gaben was found&quot;</span><span style="color: #000000;">)</span>;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span> PLUGIN_HANDLED <span style="color: #cf0020;">// This will stop the download.</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">}</span>
&nbsp; &nbsp; <span style="color: #000000;">}</span>
&nbsp; &nbsp; <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 &lt;amxmodx&gt;</span>

<span style="color: #339900;">#define AUTOUPDATE_FILE_ID &quot;76775&quot;</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>
&nbsp; &nbsp; <span style="color: #00c0c0;">register_plugin</span><span style="color: #000000;">(</span><span style="color: #800080;">&quot;HTTP:X Autoupdate example 1&quot;</span>, <span style="color: #800080;">&quot;1.0&quot;</span>, <span style="color: #800080;">&quot;[ --{-@ ]&quot;</span><span style="color: #000000;">)</span>;
&nbsp; &nbsp;
&nbsp; &nbsp; UpdatePlugin<span style="color: #000000;">(</span><span style="color: #000000;">)</span>;
&nbsp; &nbsp;
<span style="color: #000000;">}</span>

UpdatePlugin<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
&nbsp; &nbsp; <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;">&quot;AutoupdatePlugin&quot;</span>, <span style="color: #800080;">&quot;httpx.amxx&quot;</span><span style="color: #000000;">)</span> == <span style="color: #0000dd;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
&nbsp; &nbsp; &nbsp; &nbsp; <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>;
&nbsp; &nbsp; &nbsp; &nbsp; <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>;
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00c0c0;">callfunc_push_int</span><span style="color: #000000;">(</span>AUTOUPDATE_HOW_OFTEN<span style="color: #000000;">)</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00c0c0;">callfunc_end</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>;
&nbsp; &nbsp; <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 &lt;amxmodx&gt;</span>

<span style="color: #007700;">enum</span> <span style="color: #000000;">{</span>
&nbsp; &nbsp; REQUEST_GET,
&nbsp; &nbsp; 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;">&quot;&quot;</span>, <span style="color: #ff0000;">const</span> CompleteHandler<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">&quot;&quot;</span>, <span style="color: #ff0000;">const</span> ProgressHandler<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">&quot;&quot;</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;">&quot;&quot;</span>, <span style="color: #ff0000;">const</span> Password<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">&quot;&quot;</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 &quot;76775&quot;</span>
<span style="color: #339900;">#define AUTOUPDATE_HOW_OFTEN 0</span>

<span style="color: #007700;">new</span> <span style="color: #ff0000;">const</span> VersionNum =&nbsp; &nbsp;&nbsp; &nbsp;<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;">&quot;1.00&quot;</span>;

<span style="color: #ff0000;">public</span> plugin_init<span style="color: #000000;">(</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
&nbsp; &nbsp; <span style="color: #00c0c0;">register_plugin</span><span style="color: #000000;">(</span><span style="color: #800080;">&quot;HTTP:X Autoupdate example 2&quot;</span>, VersionString, <span style="color: #800080;">&quot;[ --{-@ ]&quot;</span><span style="color: #000000;">)</span>;

&nbsp; &nbsp; HTTPX_Download<span style="color: #000000;">(</span><span style="color: #800080;">&quot;[url="http://your.website.com/your_plugin/version.txt""]http://your.website.com/your_plugin/version.txt&quot;</span>,[/url]<span style="color: #800080;">&quot;&quot;</span>, <span style="color: #800080;">&quot;Complete&quot;</span>, <span style="color: #800080;">&quot;&quot;</span>, <span style="color: #0000dd;">80</span>, REQUEST_GET, <span style="color: #800080;">&quot;&quot;</span>, <span style="color: #800080;">&quot;&quot;</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>
&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">(</span> Error <span style="color: #000000;">)</span>
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span>;

&nbsp; &nbsp; <span style="color: #007700;">new</span> temp<span style="color: #000000;">[</span><span style="color: #0000dd;">16</span><span style="color: #000000;">]</span>;
&nbsp; &nbsp; 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>;

&nbsp; &nbsp; <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> &gt; VersionNum <span style="color: #000000;">)</span>
&nbsp; &nbsp; &nbsp; &nbsp; 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>
&nbsp; &nbsp; <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;">&quot;AutoupdatePlugin&quot;</span>, <span style="color: #800080;">&quot;httpx.amxx&quot;</span><span style="color: #000000;">)</span> == <span style="color: #0000dd;">1</span> <span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
&nbsp; &nbsp; &nbsp; &nbsp; <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>;
&nbsp; &nbsp; &nbsp; &nbsp; <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>;
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00c0c0;">callfunc_push_int</span><span style="color: #000000;">(</span>AUTOUPDATE_HOW_OFTEN<span style="color: #000000;">)</span>;
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00c0c0;">callfunc_end</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>;
&nbsp; &nbsp; <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>
&nbsp; &nbsp; <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>
&nbsp; &nbsp; REQUEST_GET,
&nbsp; &nbsp; REQUEST_POST
<span style="color: #000000;">}</span>

<span style="color: #ff0000; font-style: italic;">/**
&nbsp;* HTTPX_IsFilesizeLarge(DownloadID)
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* HTTPX_GetBytesReceived(DownloadID)
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* HTTPX_GetBytesReceivedLarge(DownloadID, string[], len)
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* HTTPX_GetNewBytesReceived()
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* HTTPX_GetFilesize(DownloadID)
&nbsp;*
&nbsp;* Returns the filesize of DownloadID.
&nbsp;* 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;">/**
&nbsp;* HTTPX_GetFilesizeLarge(DownloadID, string[], len)
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* HTTPX_GetFilename(DownloadID)
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* HTTPX_GetData(data[], len)
&nbsp;*
&nbsp;* Fills variable data[] with the last chunk downloaded.
&nbsp;*
&nbsp;* len decides maxlen for the data[] variable.
&nbsp;* Remember, this is raw data.
&nbsp;* No need to make room for null at the end unless you're passing it to any function that is
&nbsp;* trying to automatically find the end by searching for null (any string function).
&nbsp;*
&nbsp;* The function will return the ammount of bytes that was written to the data[] variable.
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* Automatic updating
&nbsp;* Updates current plugin automatically (from AlliedModders webpage only to prevent spreading of malicious code).
&nbsp;*
&nbsp;*
&nbsp;* file_id[] has to be the same as it is on the forum webpage. (Check the link of the .amxx file (&quot;Get Plugin&quot; link))
&nbsp;*
&nbsp;*
&nbsp;* If frequency is supplied you can set how often to update the file. If none is provided it will update as soon as possible.
&nbsp;* Please use this respectfully. Don't overload the AM forums.
&nbsp;*
&nbsp;* You can however provide your own method of determining whether the file needs to be updated or not before calling this function.
&nbsp;* That way you don't stress AM servers when not required. An example of this is in the HTTPX source which uses this method.
&nbsp;*
&nbsp;* Examples:
&nbsp;*&nbsp; &nbsp; 1d = 86400
&nbsp;*&nbsp; &nbsp; 1w = 604800
&nbsp;*&nbsp; &nbsp;30d = 2592000
&nbsp;*
&nbsp;*
&nbsp;* IMPORTANT!
&nbsp;* 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.
&nbsp;* 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.
&nbsp;* For example:
&nbsp;*&nbsp; &nbsp; &nbsp;The plugin Name Replacer by anakin_cstrike, @http://forums.allied...hlight=replacer
&nbsp;*&nbsp; &nbsp; &nbsp;Scroll down and hover the &quot;Get Plugin&quot;, there you see the file ID. Just replace the placeholder with that value.
&nbsp;*&nbsp; &nbsp; &nbsp;#define AUTOUPDATE_FILE_ID &quot;76775&quot;
&nbsp;*&nbsp; &nbsp; &nbsp;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 &quot;REPLACE_THIS_WITH_YOUR_FILE_ID&quot;
#define AUTOUPDATE_HOW_OFTEN REPLACE_THIS_WITH_DESIRED_FREQUENCY // 1d = 86400, 1w = 604800, 30d = 2592000

UpdatePlugin() {
&nbsp; &nbsp; if ( callfunc_begin(&quot;AutoupdatePlugin&quot;, &quot;httpx.amxx&quot;) == 1 ) { // Don't touch.
&nbsp; &nbsp; &nbsp; &nbsp; callfunc_push_int(get_plugin(-1))&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// Plugin ID (to get the filename). Don't touch.
&nbsp; &nbsp; &nbsp; &nbsp; callfunc_push_str(AUTOUPDATE_FILE_ID, false)&nbsp; &nbsp; // The file_id in string format. Touch above.
&nbsp; &nbsp; &nbsp; &nbsp; callfunc_push_int(AUTOUPDATE_HOW_OFTEN)&nbsp;&nbsp;// Frequency of the automatic updates. Touch above.
&nbsp; &nbsp; &nbsp; &nbsp; callfunc_end()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Don't touch.
&nbsp; &nbsp; }
}

**/</span>

<span style="color: #ff0000; font-style: italic;">/**
&nbsp;* bool:HTTPX_IsPaused(DownloadID)
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* HTTPX_Paused(DownloadID)
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* HTTPX_Unpause(DownloadID)
&nbsp;*
&nbsp;* 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;">/**
&nbsp;* HTTPX_Abort(DownloadID, bool:DeleteFile = true)
&nbsp;*
&nbsp;* Aborts the transfer of selected download DownloadID.
&nbsp;* 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;">/**
&nbsp;* HTTPX_AddPostVar(const variable[], const value[])
&nbsp;*
&nbsp;* Adds a POST variable to the request.
&nbsp;* This function is used before HTTPX_Download() or HTTP_AddToQue(), similar to set/show hudmessage.
&nbsp;* 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;">/**
&nbsp;* HTTPX_AddPostRaw(const data[])
&nbsp;*
&nbsp;* Adds raw POST data to the request.
&nbsp;* This function is used before HTTPX_Download() or HTTP_AddToQue(), similar to set/show hudmessage.
&nbsp;* 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;">/**
&nbsp;* Number of parameters for the callbacks are 1 (DownloadID) for the progress event and 2 (DownloadID, Error) for the complete event.
&nbsp;* Error codes:
&nbsp;*&nbsp; &nbsp; &nbsp;0&nbsp; &nbsp;Download done. No problems encountered.
&nbsp;* Positive returns is unhandled HTTP return codes. For example 404.
&nbsp;* Negative is internal errors.
&nbsp;*&nbsp; &nbsp; -1&nbsp; &nbsp;No response code was found in the HTTP response header or it was outside the accepted range (200-307).
&nbsp;*&nbsp; &nbsp; -2&nbsp; &nbsp;Server is sending bad data or sizes for a chunked transfer or HTTPX has problems reading them.
&nbsp;*&nbsp; &nbsp; -3&nbsp; &nbsp;Nothing received in last packet. Most likely due to an error.
&nbsp;*&nbsp; &nbsp; -4&nbsp; &nbsp;HTTPX was redirected but could not follow due to a socket error.
&nbsp;*&nbsp; &nbsp; -5&nbsp; &nbsp;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;">/**
&nbsp;* HTTPX_Download(const URL[], const Filename[] = &quot;&quot;, const CompleteHandler[] = &quot;&quot;, const ProgressHandler[] = &quot;&quot;, Port = (80&lt;&lt;443), RequestType = REQUEST_GET, const Username[] = &quot;&quot;, const Password[] = &quot;&quot;, ...)
&nbsp;*
&nbsp;* Begins download of a URL. Read parameters for information.
&nbsp;*
&nbsp;*
&nbsp;* Parameters:
&nbsp;*
&nbsp;*&nbsp; &nbsp;const URL[]
&nbsp;*&nbsp; &nbsp; &nbsp; URL that you want to download.
&nbsp;*
&nbsp;*&nbsp; &nbsp;(Optional) const Filename[]
&nbsp;*&nbsp; &nbsp; &nbsp; Where should the information be stored? If no filename is entered it will download as a &quot;stream&quot;.
&nbsp;*&nbsp; &nbsp; &nbsp; This means the data will be thrown away after it passes the buffer.
&nbsp;*&nbsp; &nbsp; &nbsp; You can read the data on progress forward and make use of it there.
&nbsp;*
&nbsp;*&nbsp; &nbsp;(Optional) const CompleteHandler[] = &quot;&quot;
&nbsp;*&nbsp; &nbsp; &nbsp; The function you want called when the download is complete.
&nbsp;*
&nbsp;*&nbsp; &nbsp;(Optional) const ProgressHandler[] = &quot;&quot;
&nbsp;*&nbsp; &nbsp; &nbsp; The function you want called when the download is in progress.
&nbsp;*&nbsp; &nbsp; &nbsp; This will be called every time data is downloaded.
&nbsp;*
&nbsp;*&nbsp; &nbsp;(Optional) Port = 0
&nbsp;*&nbsp; &nbsp; &nbsp; The port that should be used.
&nbsp;*&nbsp; &nbsp; &nbsp; If this is left at default it will use 80 for http and 443 for https (when supported).
&nbsp;*
&nbsp;*&nbsp; &nbsp;(Optional) RequestType = REQUEST_GET
&nbsp;*&nbsp; &nbsp; &nbsp; What type of request should be used.
&nbsp;*&nbsp; &nbsp; &nbsp; If this is left at default it will use GET.
&nbsp;*&nbsp; &nbsp; &nbsp; Possible values so far are REQUEST_GET and REQUEST_POST.
&nbsp;*
&nbsp;*&nbsp; &nbsp;(Optional) const Username[] = &quot;&quot;
&nbsp;*&nbsp; &nbsp;(Optional) const Password[] = &quot;&quot;
&nbsp;*&nbsp; &nbsp; &nbsp; These are used to login to sites that require you to.
&nbsp;*&nbsp; &nbsp; &nbsp; It's only used for Basic authentication, not POST for example.
&nbsp;*
&nbsp;* 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;">&quot;&quot;</span>, <span style="color: #ff0000;">const</span> CompleteHandler<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">&quot;&quot;</span>, <span style="color: #ff0000;">const</span> ProgressHandler<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">&quot;&quot;</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;">&quot;&quot;</span>, <span style="color: #ff0000;">const</span> Password<span style="color: #000000;">[</span><span style="color: #000000;">]</span> = <span style="color: #800080;">&quot;&quot;</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ł




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych