Forum Webscript.Ru

Программирование => PHP => Тема начата: alesh от 23 Сентября 2002, 13:45:14

Название: Экспорт
Отправлено: alesh от 23 Сентября 2002, 13:45:14
Всем привет.
У меня есть некий php файл который экспортирует заголовки с моего сайта.
Код его такой:

$file = "http://www.alesh.ru/rss/export.xml?enc=$enc";
@$fp = fopen($file,"r");
if (!$fp) {
print "File $file doesn\'t exist
\\n";
} else {
$fileok = "ok";
while (!feof($fp)) {
$check = eregi_replace("\\n","",fgets($fp, 4096));
if (strpos($check,"num")) {
$num[] = trim(eregi_replace("","",eregi_replace("","",$check)));
}
if (strpos($check,"description")) {
$description[] = trim(eregi_replace("","",eregi_replace("","",$check)));
}
if (strpos($check,"link")) {
$link[] = trim(eregi_replace("","",eregi_replace("","",$check)));
}
if (strpos($check,"title")) {
$title[] = trim(eregi_replace("","",eregi_replace("","",$check)))); <br />} <br />} <br />} <br />@fclose($fp); <br /><br />if ($fileok == "ok") { <br />for ($i=0;$i<sizeof($title);$i++) { <br />print "<a href=\\"".$link[$i]."\\">[#".$num[$i]."]".$title[$i]."<br />".$description[$i]."</a><br />\\n"; <br />} <br />} <br />?><br />Как сделать, что бы он експортился в js файл, который любой мог бы всунуть к себе на сайт? </dd> <dt class="postheader"> Название: <strong>Экспорт</strong><br /> Отправлено: <strong>Ленивый гость</strong> от <strong>23 Сентября 2002, 14:29:09</strong> </dt> <dd class="postbody"> fwrite(\'куда пишем\',\'что пишем\'); </dd> <dt class="postheader"> Название: <strong>Экспорт</strong><br /> Отправлено: <strong>xnx</strong> от <strong>23 Сентября 2002, 16:09:35</strong> </dt> <dd class="postbody"> Засунь весь вывод в document.write() и включай в страниці типа <script src="путь к скрипту"></script> </dd> <dt class="postheader"> Название: <strong>Экспорт</strong><br /> Отправлено: <strong>alesh</strong> от <strong>23 Сентября 2002, 20:00:33</strong> </dt> <dd class="postbody"> 2 <strong>xnx</strong>: не понял тебя.<br />Можешь код написать? </dd> <dt class="postheader"> Название: <strong>Экспорт</strong><br /> Отправлено: <strong>PilotV</strong> от <strong>24 Сентября 2002, 22:44:50</strong> </dt> <dd class="postbody"> <?<br />function to_js($str) {<br />  return addcslashes(addslashes($str),"\\n\\r");<br />  }<br />?><br /><script>document.write("<?= to_js($output) ?>")</script> </dd> </dl> <div id="footer" class="smalltext"> <span class="smalltext" style="display: inline; visibility: visible; font-family: Verdana, Arial, sans-serif;"><a href="https://forums.webscript.ru/index.php?action=credits" title="Simple Machines Forum" target="_blank" class="new_win">SMF 2.0.19</a> | <a href="http://www.simplemachines.org/about/smf/license.php" title="License" target="_blank" class="new_win">SMF © 2016</a>, <a href="http://www.simplemachines.org" title="Simple Machines" target="_blank" class="new_win">Simple Machines</a> </span> </div> </body> </html>