Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sitemap update #15

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/Config/Database.php
Original file line number Diff line number Diff line change
@@ -27,9 +27,9 @@ class Database extends Config
public array $default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => '',
'username' => 'database_user01',
'password' => 'xyz1245',
'database' => 'bbf',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
3 changes: 3 additions & 0 deletions app/Config/Routes.php
Original file line number Diff line number Diff line change
@@ -6,3 +6,6 @@
* @var RouteCollection $routes
*/
$routes->get('/', 'Home::index');
$routes->get('articles', 'Articles::index');
$routes->get('sitemap', 'Sitemap::index');
$routes->get('web-service/get-social-media-info', 'WebService::get_social_media_info');
21 changes: 21 additions & 0 deletions app/Controllers/Articles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Controllers;

class Articles extends BaseController
{
public function index()
{

// $db = db_connect();

$data = [
["Title" => "One", "content" => "The first"],
["Title" => "Two", "content" => "Some content"]
];

return view("Articles/index", [
"articles" => $data
]);
}
}
11 changes: 11 additions & 0 deletions app/Controllers/Header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php


namespace App\Controllers;

class Header extends BaseController
{
public function index(){
return "Header/index";
}
}
2 changes: 1 addition & 1 deletion app/Controllers/Home.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ class Home extends BaseController
{
public function index(): string
{
return view('welcome_message');
return view("Home/index");
}
}
44 changes: 44 additions & 0 deletions app/Controllers/Sitemap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace App\Controllers;

class Sitemap extends BaseController
{
public function index()
{
$db = db_connect();

$sqlQueries = array(
"SELECT CONCAT('https://bestbizfinder.com/broker/', broker_id, '/', company, '/', address) AS url, 'monthly' AS changefreq, 0.8 AS priority FROM broker_details",
);

$xmlContent = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
$xmlContent .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;

foreach ($sqlQueries as $sqlQuery) {
$result = $db->query($sqlQuery);

if ($result->getResult()) {
$rows = $result->getResultArray();

if (count($rows) > 0) {
foreach ($rows as $row) {
$xmlContent .= '<url>' . PHP_EOL;
$xmlContent .= '<loc>' . htmlspecialchars($row['url']) . '</loc>' . PHP_EOL;
$xmlContent .= '<changefreq>' . htmlspecialchars($row['changefreq']) . '</changefreq>' . PHP_EOL;
$xmlContent .= '<priority>' . htmlspecialchars($row['priority']) . '</priority>' . PHP_EOL;
$xmlContent .= '</url>' . PHP_EOL;
}
}
} else {
echo "No results found";
}
}

$xmlContent .= '</urlset>' . PHP_EOL;

header('Content-Type: application/xml');

echo $xmlContent;
}
}
29 changes: 29 additions & 0 deletions app/Controllers/WebService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Controllers;

use CodeIgniter\Controller;

class WebService extends Controller {

protected $config;
public function __construct() {

try {
$this->config = config('Env');
} catch (Exception $e) {
log_message('error', 'Failed to load environment variables: ' . $e->getMessage());
die('An error occurred while retrieving configuration.');
}
}

public function get_social_media_info() {

$facebookUrl = env('FACEBOOK_PAGE_URL', '');
$twitterUrl = env('TWITTER_PAGE_URL', '');

if (empty($facebookUrl) || empty($twitterUrl)) {
die('Social media URLs are not configured.');
}
}
}
14 changes: 14 additions & 0 deletions app/Views/Articles/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?= $this->extend("layouts/defaults") ?>
<?= $this->section("title") ?>Article<?= $this->endSection() ?>

<?= $this->section("content") ?>

<h1>Articles</h1>

<?php foreach ($articles as $article): ?>
<article>
<h2><?= $article["Title"] ?></h2>
<p><?= $article["content"] ?></p>
</article>
<?php endforeach; ?>
<?= $this->endSection() ?>
7 changes: 7 additions & 0 deletions app/Views/Home/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?= $this->extend("layouts/defaults") ?>
<?= $this->section("title") ?>Home<?= $this->endSection() ?>

<?= $this->section("content") ?>
<h1>Welcome</h1>

<?= $this->endSection() ?>
16 changes: 16 additions & 0 deletions app/Views/Sitemap/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?= $this->extend("layouts/defaults") ?>
<?= $this->section("title") ?>Sitemap<?= $this->endSection() ?>

<?= $this->section("content") ?>
<?= '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($urls as $url): ?>
<url>
<loc><?= htmlspecialchars($url['url']) ?></loc>
<changefreq><?= htmlspecialchars($url['changefreq']) ?></changefreq>
<priority><?= htmlspecialchars($url['priority']) ?></priority>
</url>
<?php endforeach; ?>
</urlset>
</pre>
<?= $this->endSection() ?>
7 changes: 7 additions & 0 deletions app/Views/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?= $title ?></title>
</head>
<body>
12 changes: 12 additions & 0 deletions app/Views/layouts/defaults.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?= $this->renderSection("title") ?></title>
</head>
<body>

<?= $this->renderSection("content") ?>

</body>
</html>
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,8 @@
},
"require": {
"php": "^8.1",
"codeigniter4/framework": "^4.0"
"codeigniter4/framework": "^4.0",
"vlucas/phpdotenv": "^5.6"
},
"require-dev": {
"fakerphp/faker": "^1.9",
2,525 changes: 2,525 additions & 0 deletions composer.lock

Large diffs are not rendered by default.

69 changes: 0 additions & 69 deletions env

This file was deleted.

9 changes: 7 additions & 2 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -43,10 +43,15 @@
* and fires up an environment-specific bootstrapping.
*/

// LOAD DotEnv LIBRARY
require_once __DIR__ . '/../vendor/autoload.php';

// LOAD .ENV FILE
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();

// LOAD OUR PATHS CONFIG FILE
// This is the line that might need to be changed, depending on your folder structure.
require FCPATH . '../app/Config/Paths.php';
// ^^^ Change this line if you move your application folder

$paths = new Config\Paths();