• About
  • Contact
  • Skype
  • Browse

    Latest Coding

    Latest Daily

    Latest Health

    Featured Story

Forum 2020

| Home | File Bank |  Register | Reply | Search | Statistics | Manual |
Coding Forum Home / Coding /  
 

Minibb forum sitemap creator and Google ping code

 
Author Admin
Admin


#1 | Posted: 4 Sep 2020 08:28 | Edited by: Admin 
I am now using the code below to create a sitemap of this forum. Once it has been created the rest of the code pings Google and Bing so as to notify them of changes. I shall probably run the file manually at the moment (end of the day, maybe). I might well consider setting up a cron job for it instead though to automate the process. I don't really want to ping Google too often.

The code below creates a text file called 'sitemap-full.txt' which is populated with the links to topic messages, including the very first. The second part of the code then pings Google and Bing. I run the code by opening the page in my browser. I have also mentioned the location of the sitemap file in the robots.txt file, like so ...

SITEMAP: http://brainwaving.co.uk/sitemap-full.txt

and added 2 links in the admin panel by editing the admin_panel.html file found in the templates directory. I added 2 new lines like this ...

<li><a href="{$main_url}/{$indexphp}action=pmail&amp;step=massmail" class="mnblnk">PM Mailing List</a></li>
<li><a href="/location of my sitemap" class="mnblnk" target="_blank">Update Sitemap</a></li>
<li><a href="/sitemap-full.txt" class="mnblnk" target="_blank">View Sitemap</a></li>

If you want to use the code below then create a php file of your own in the root of your domain. Match the minibb tables with your own setup. You might have to create the sitemap.txt file beforehand and give it write permissions depending on your server setup.

<?php

// Turn off all error reporting

error_reporting(0);

$servername = "localhost";

$username = "";

$password = "";

$dbname = "";

// beginning of sitemap

$filename0 = 'sitemap-full.txt';

$filehandle0 = fopen($filename0, 'w') or die('error opening file');

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT minibbfull_topics.topic_title, minibbfull_topics.topic_id, minibbfull_topics.forum_id, minibbfull_topics.topic_time, minibbfull_posts.post_id, minibbfull_posts.post_text, minibbfull_posts.topic_id

FROM minibbfull_topics

JOIN minibbfull_posts ON minibbfull_topics.topic_id = minibbfull_posts.topic_id

ORDER BY topic_time DESC

LIMIT 45000";

$result = $conn->query($sql);

if ($result->num_rows > 0) {

// output data of each row

while($row = $result->fetch_assoc()) {

$forum_id = $row['forum_id'];

$topic_title = $row['topic_title'];

$topic_time = $row['topic_time'];

$topic_title = str_replace(' ', '-', $topic_title);

$topic_title = str_replace('!', '', $topic_title);

$topic_title = str_replace('?', '', $topic_title);

$topic_title = str_replace(':', '', $topic_title);

$topic_title = strip_tags($row['topic_title']);

if (strlen($topic_title) > 40) {

$topic_title = substr($topic_title, 0, 40)."...";

}

$topic_id = $row['topic_id'];

$post_id = $row['post_id'];

$post_text = $row['post_text'];

$post_text = strip_tags($row['post_text']);

if (strlen($post_text) > 170) {

$post_text = substr($post_text, 0, 170)."...";

}

$results0 .= "http://brainwaving.co.uk/forum/index.php?action=vthread&forum=$forum_id&topic=$topic_id#msg$post_id\r\n";
}

fwrite($filehandle0, $results0);

fclose($filehandle0);

}

// end of sitemap

echo "Sitemap Created";

$conn->close();

// Ping Google

// ini_set('display_errors', 1);

// ini_set('display_startup_errors', 1);

// error_reporting(E_ALL);


$array[] = "http://www.google.com/webmasters/sitemaps/ping?sitemap=http://brainwaving.co.uk/sitemap-full.txt";

// cUrl handler to ping the Sitemap submission URLs for Search EnginesÖ

function myCurl($url){

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

return $httpCode;

}

// Ping Above URLs

foreach($array as $val) {

$url = "$val";

$returnCode = myCurl($url);

echo "<br>";

echo "<br>";

echo $url;

echo "<br>";

echo "<br>";

sleep(1);

}

echo 'Google Pinged';

echo "<br>";

echo 'Bing Pinged';

echo "<br>";

?>
0
0

Your Reply Click this icon to move up to the quoted message


 ?
Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.

 

 
Forum Home Powered by Bulletin Board Script miniBB ®
Online now: Guests - 1
Members - 0
Max. ever online: 406 [6 Feb 2020 07:33]
Guests - 406 / Members - 0
No Of Posts

  • Latest Daily Post ...

  • Latest Health Post ...

CONTACT

Phone: +01 0775 8107 427

sport4u2018@gmail.com

WEBMASTER

email icon Mark Jones

Latest Story

RANDOM CODING

  • Copyright © 2018 MKJ Brainwaving
↑ TOP