From the panel site
This commit is contained in:
parent
d684ca74fb
commit
2fc04bcfac
1194 changed files with 154606 additions and 13040 deletions
|
|
@ -34,34 +34,116 @@ function exec_ogp_module()
|
|||
echo '<div class="maincategory"><img class="headerimage" src="modules/faq/faq.png">Categories<div style="float:right" >'.
|
||||
'<input class=search name=search id=search type=text placeholder="Search"/></div><br></div>';
|
||||
|
||||
// Load FAQ data from new HTML structure
|
||||
require_once 'modules/faq/faq_data.php';
|
||||
$entries = getFaqData();
|
||||
require 'modules/faq/rss_php.php';
|
||||
$url = 'https://opengamepanel.org/faq/rss.php';
|
||||
$local_copy = 'modules/faq/faq.rss'; ## Relative path
|
||||
$save_as = realpath('modules' . DIRECTORY_SEPARATOR . 'faq') . DIRECTORY_SEPARATOR . 'faq.rss';
|
||||
## Full path (adding the filename to realpath would fail if the file does not exists yet)
|
||||
$online = false;
|
||||
$local = true;
|
||||
$updated = false;
|
||||
$s = (isset($_SERVER['HTTPS'])) ? "s" : "";
|
||||
$p = (isset($_SERVER['SERVER_PORT']) and $_SERVER['SERVER_PORT'] != "80") ? ":".$_SERVER['SERVER_PORT'] : "";
|
||||
$localServerURL = $_SERVER['SERVER_NAME'];
|
||||
if($localServerURL == "_"){
|
||||
$localServerURL = "localhost";
|
||||
}
|
||||
$local_url = 'http'.$s.'://'.$localServerURL.$p.$_SERVER['SCRIPT_NAME'];
|
||||
$local_url = str_replace('home.php', $local_copy, $local_url);
|
||||
if(file_exists($save_as))
|
||||
{
|
||||
$rss = new rss_php;
|
||||
$rss->load($local_url);
|
||||
$items = $rss->getItems(); #returns all rss items
|
||||
$local = true;
|
||||
}
|
||||
/*
|
||||
echo "<script>console.log('Last Update : ".date("r", filemtime($save_as))."\\nCurrent Time: ".date('r',time())."\\nNext Update : ".date('r', strtotime("+1 day", filemtime($save_as)))."');</script>";
|
||||
if( ($local AND ( strtotime("+1 day", filemtime($save_as)) <= strtotime("now") )) OR !$local) # Check the file is older than 1 day to avoid spamming the server
|
||||
{
|
||||
stream_context_set_default(array('ssl' => array(
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false
|
||||
)
|
||||
));
|
||||
|
||||
$headers = get_headers( $url, 1 );
|
||||
touch( $save_as ); # Connection done, so we reset the file modification time even if the server is down (avoid server spamming)
|
||||
echo "<script>console.log('Trying to connect to ".$url."');</script>";
|
||||
if( $headers[0] == 'HTTP/1.1 200 OK')
|
||||
{
|
||||
$online = false;
|
||||
$rss_online = new rss_php;
|
||||
$rss_online->load($url); # SERVER USAGE WARNING : using 32kb of server bandwidth each time each person loads this function
|
||||
$items_online = $rss_online->getItems();
|
||||
echo "<script>console.log('Connected successfully to ".$url.", checking...');</script>";
|
||||
if(($local and $items_online != $items ) OR !$local)
|
||||
{
|
||||
$contents = file_get_contents($url);
|
||||
if(preg_match('#^<\?xml version="1.0" encoding="utf-8" \?>#', $contents, $match))
|
||||
{
|
||||
if( file_put_contents($save_as, $contents) === false )
|
||||
{
|
||||
print_failure("Imposible write " . $save_as);
|
||||
return;
|
||||
}
|
||||
touch( $save_as );
|
||||
echo "<script>console.log('Entries updated successfully.');</script>";
|
||||
$updated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
print_failure("Imposible fetch " . $url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<script>console.log('No changes found...');</script>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($updated)
|
||||
{
|
||||
$rss = new rss_php;
|
||||
$rss->load($local_url);
|
||||
$items = $rss->getItems(); #returns all rss items
|
||||
}
|
||||
*/
|
||||
|
||||
if(!file_exists($save_as))
|
||||
{
|
||||
print_failure('Unable to load entries.');
|
||||
return; # Stop loading page
|
||||
}
|
||||
|
||||
|
||||
$entries = array();
|
||||
foreach($items as $index => $item)
|
||||
{
|
||||
$category = $item['category'][0];
|
||||
$entries[$category][$index]['title'] = $item['title'][0];
|
||||
$entries[$category][$index]['content'] = $item['content:encoded'][0];
|
||||
}
|
||||
$categories = "";
|
||||
$accordion_entries = "<div id=\"accordion\">\n";
|
||||
|
||||
foreach($entries as $category_name => $category_entries)
|
||||
{
|
||||
// Create category navigation link with clean ID
|
||||
$category_id = preg_replace('/[^a-z0-9_]/', '_', strtolower($category_name));
|
||||
$categories .= "<li class='faqblock'><a class='faqcategory' href=\"#$category_id\">$category_name</a></li>";
|
||||
|
||||
// Create category section
|
||||
$accordion_entries .= "<div class=\"category\" id=\"$category_id\"><img class='headerimage' src='modules/faq/faqlower.png'>$category_name</div>";
|
||||
|
||||
// Add items for this category
|
||||
foreach($category_entries as $item)
|
||||
$categories .= "<li class='faqblock'><a class='faqcategory' href=\"#$category_name\">$category_name</a></li>";
|
||||
$accordion_entries .= "<div class=\"category\" id=\"$category_name\"><img class='headerimage' src='modules/faq/faqlower.png'>$category_name</div>";
|
||||
foreach($category_entries as $index => $item)
|
||||
{
|
||||
$accordion_entries .= "\t<div class=\"accordion-toggle\">".
|
||||
htmlspecialchars($item['title']) . "</div>\n".
|
||||
"\t<div class=\"accordion-content\">\n\t\t<div class=\"faqanswer\">" . $item['content'] . "</div>\n\t</div>\n";
|
||||
$accordion_entries .= "\t<div class=\"accordion-toggle\">".
|
||||
"$item[title]</div>\n".
|
||||
"\t<div class=\"accordion-content\">\n\t\t<div class=\"faqanswer\">$item[content]</div>\n\t</div>\n";
|
||||
}
|
||||
}
|
||||
$categories .= "</ul>";
|
||||
$accordion_entries .= "</div>";
|
||||
|
||||
echo $categories . $accordion_entries;
|
||||
echo $categories.$accordion_entries;
|
||||
|
||||
echo "<div class='footer' >".
|
||||
"<div style='display:block;float:left' >".
|
||||
|
|
@ -69,7 +151,7 @@ function exec_ogp_module()
|
|||
"</div>".
|
||||
"<div class='credits' style='display:block;float:right' >".
|
||||
"<b>Credits:</b><br>".
|
||||
"<div class='credittext'>Open Game Panel - Enhanced HTML FAQ System<br>".
|
||||
"<div class='credittext'><br>".
|
||||
"</div>".
|
||||
"</div>";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue