Diğer sitelere parametreleri gönderme

3 Cevap

look here first http://stackoverflow.com/questions/2883338/how-can-i-send-a-date-from-one-site-to-other-sites let me change the question a bit, i didnt really explain myself properly. What i intend to do is get z.php to read a text file called 'sites.txt' which has a list of sites:

site1.com/a.php
site2.com/b.php
site3.com/c.php

'sites.txt' in sitelerinde adresler yürütmek i geçmek istiyorum siteA.com / z.php? ip = xxx.xxx.xx.xxx & location = UK (z.php sonra 'siteleri okuyacak. sites.txt 'dosyası txt' in) tüm siteler 'olarak idam edilecek

site1.com/a.php?ip=xxx.xxx.xx.xxx&location=UK
site2.com/b.php?ip=xxx.xxx.xx.xxx&location=UK

I hope that makes more sense, i have tried looking around but couldnt find what i was looking for. Thanks for your help so far everyone. site3.com/c.php?ip=xxx.xxx.xx.xxx&location=UK

3 Cevap

Böyle bir şey (test değil)?

$handle = fopen("sites.txt", "r");
while (!feof($handle)) {
  $site = fgets($handle);
  $sitestats = fopen(trim($site) . "?ip={$_GET['ip']}&location={$_GET['UK']}", 'r');
}
fclose($handle);

Muhtemelen de GET değişkenleri doğrulamak istiyor

HTTP Requests

Z.php gelen diğer sitelere vurmak için cURL kitaplığı kullanın.

cURL Eğer bir PHP komut dosyası içinde başka bir web sunucusuna HTTP isteklerini vermesine olanak sağlar.

IP Address

Sen $_SERVER['REMOTE_ADDR'] ile istemci IP adresi alabilirsiniz. Eğer kullanıcı girişi IP adresi alırsanız, o zaman filtre gerekir.

Reading the Text File

Muhtemelen dosyasını okumak için en kolay yolu bir dizinin bir elemanı içine her satırı okur file() fonksiyonu ile. Kod aşağıdaki satırı satırsonlarını dışarı şeritler ve boş satırları yok sayar.

$lines = file('sites.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

Sonra sadece çizgiler yineleme ve yapmanız gerekenleri yapın:

foreach($lines as $line) {
  echo $line;
}

Eğer ortam değişkeni sorgu dizesi ile birlikte file_get_contents kullanarak yapabilirsiniz:

<?php
 // read your site urls into an array, each line as an array element
 $sites = file('sites.txt');

 // walk thru all sites, one at a time
 foreach ($sites as $site) {
   // combine your incoming query string (?ip=...&location=...) with your site, by appending it to $site
   $site .= '?' . getenv('QUERY_STRING');

   // prepend $site with http:// if it is not in your text file
   if ( substr($site, 0, 4) != 'http' ) {
     $site = 'http://' . $site;
   }

   // open the url in $site
   $return = file_get_contents ($site);
 }

Eğer z.php bu kullanırsanız, sizin URL'ler için tüm gelen get url parametreleri iletecek.