Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?php
set_time_limit(0);
$file = "http://сайт/forum/index.php?act=rssout&id=1"; //път към RSS
$maxchar = "100"; //колко символа да показва
$broi = "5"; //колко теми да извежда
$rss_channel = array();
$currently_writing = "";
$main = "";
$item_counter = 0;
function startElement($parser, $name, $attrs) {
global $rss_channel, $currently_writing, $main;
switch($name) {
case "RSS":
case "RDF:RDF":
case "ITEMS":
$currently_writing = "";
break;
case "CHANNEL":
$main = "CHANNEL"; break;
case "IMAGE":
$main = "IMAGE";
$rss_channel["IMAGE"] = array();
break;
case "ITEM":
$main = "ITEMS";
break;
default:
$currently_writing = $name;
break;
}
}
function endElement($parser, $name) {
global $rss_channel, $currently_writing, $item_counter;
$currently_writing = "";
if ($name == "ITEM") {
$item_counter++;
}
}
function characterData($parser, $data) {
global $rss_channel, $currently_writing, $main, $item_counter;
if ($currently_writing != "") {
switch($main) {
case "CHANNEL":
if (isset($rss_channel[$currently_writing])) {
$rss_channel[$currently_writing] .= $data;
} else {
$rss_channel[$currently_writing] = $data;
}
break;
case "IMAGE":
if (isset($rss_channel[$main][$currently_writing])) {
$rss_channel[$main][$currently_writing] .= $data;
} else {
$rss_channel[$main][$currently_writing] = $data;
}
break;
case "ITEMS":
if (isset($rss_channel[$main][$item_counter][$currently_writing])) {
$rss_channel[$main][$item_counter][$currently_writing] .= $data;
} else {
$rss_channel[$main][$item_counter][$currently_writing] = $data;
}
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
if (isset($rss_channel["ITEMS"])) {
if (count($rss_channel["ITEMS"]) > 0) {
echo "<table width='100%' height='50' cellpadding='0' cellspacing='0' border='1' bgcolor='e6e6e6'>";
for($i = 0;$i < $broi;$i++) {
if (strlen($rss_channel["ITEMS"][$i]["TITLE"]) > $maxchar) {
$rssname = $rss_channel["ITEMS"][$i]["TITLE"];
$rssname = substr($rssname, 0, $maxchar);
$rssname .= "...";
}
else $rssname = $rss_channel["ITEMS"][$i]["TITLE"];
echo "<tr><td align='left' style='padding: 2px; font-size: 9px; color: yellow; font-family: Verdana;'><a href=\"" . $rss_channel["ITEMS"][$i]["LINK"] . "\" target=\"_blank\">" . $rssname . "</a></b></td></tr>";
}
echo "</table>";
}
}
?>
Pussycat каза:http://web-tourist.net/login/login/view.php?st=1089 :?:
... global $DB, $mklib ...
<?php
$host="localhost";
$user="root";
$pass="";
$db="базата";
$table_topics="ibf_topics";
$table_forums="ibf_forums";
$table_category="ibf_categories";
$laforums="10";
$link=mysql_connect($host, $user, $pass);
$db=mysql_select_db($db);
$query="select * from $table_topics order by start_date desc limit 0,$laforums";
$result=mysql_query($query, $link);
while ($row=mysql_fetch_array($result)) {
$query1="select * from $table_forums where id='$row[forum_id]'";
$result1=mysql_query($query1, $link);
$row1=mysql_fetch_array($result1);
$forum_name=$row1[name];
$category_id=$row1[category];
$cat=$row2[name];
if ( $row[posts]==0 ){
echo "<a xhref='форум/index.php?showtopic=$row[0]'>$cat: $row[title]</a><br>";
}
else {
echo "<a xhref='форум/index.php?showtopic=$row[0]'>$cat: $row[title]</a> ($row[posts])<br>";
}
}
?>