-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from berkanumutlu/basic-sitemap
Basic Sitemap
- Loading branch information
Showing
62 changed files
with
60,773 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# IDE stuff | ||
**/.idea/ | ||
**/.settings/ | ||
**/.vscode/ | ||
**/.idea_modules/ | ||
**/.buildpath | ||
**/.project | ||
vendor/ | ||
|
||
# Other paths | ||
**/.vagrant/ | ||
**/vagrantfile | ||
|
||
#*.env | ||
*.log | ||
*.vs* | ||
._* | ||
/src/nbproject/private/ | ||
src/sftp-config.json | ||
**/composer.lock | ||
|
||
### Node template | ||
# Logs | ||
/src/logs | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
/src/lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
/src/coverage | ||
|
||
# nyc test coverage | ||
/src/.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
/src/.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
/src/bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
/src/build/Release | ||
|
||
# Dependency directories | ||
/src/node_modules/ | ||
/src/jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
/src/typings/ | ||
|
||
# Optional npm cache directory | ||
/src/.npm | ||
|
||
# Optional eslint cache | ||
/src/.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
/src/.cache | ||
|
||
# vuepress build output | ||
/src/.vuepress/dist | ||
|
||
# Serverless directories | ||
/src/.serverless | ||
|
||
# Service worker | ||
sw.* | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
# Vim swap files | ||
*.swp | ||
yarn.lock | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,25 @@ | ||
# php-sitemap-generator | ||
PHP Sitemap Generator | ||
<div align="center" dir="auto"> | ||
<a href="https://php.net"> | ||
<img alt="PHP" src="https://www.php.net/images/logos/new-php-logo.svg" width="150"> | ||
</a> | ||
</div> | ||
<br> | ||
<p align="center"> | ||
<a href="https://www.php.net/releases/5_6_0.php" target="_blank" rel="nofollow"><img src="https://img.shields.io/badge/PHP->=v5.6-777BB4?logo=php&logoColor=white&labelColor=777BB4" alt="PHP Version"></a> | ||
<a href="https://getbootstrap.com/docs/5.3/getting-started/introduction/" target="_blank" rel="nofollow"><img src="https://img.shields.io/badge/Bootstrap-v5.3.3-7952B3?logo=bootstrap&logoColor=white&labelColor=7952B3" alt="Bootstrap Version"></a> | ||
<a href="https://blog.jquery.com/2023/08/28/jquery-3-7-1-released-reliable-table-row-dimensions/" target="_blank" rel="nofollow"><img src="https://img.shields.io/badge/jQuery-v3.7.1-0769AD?logo=jquery&logoColor=white&labelColor=0769AD" alt="jQuery Version"></a> | ||
<a href="https://github.com/berkanumutlu/php-sitemap-generator/blob/master/LICENSE" target="_blank" rel="nofollow"><img src="https://img.shields.io/github/license/berkanumutlu/laravel-example-app" alt="License"></a> | ||
</p> | ||
|
||
# PHP Sitemap Generator | ||
|
||
This project can be used to generate sitemaps. It can build a sitemap file from a list of URLs. The URLs may have attached the last modification date, a change frequency and a priority. | ||
|
||
## Screenshots | ||
|
||
 | ||
 | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
define('BASE_PATH', __DIR__.'/'); | ||
require_once '../vendor/autoload.php'; | ||
require_once 'config/db.php'; | ||
|
||
use App\Library\SitemapGenerator; | ||
|
||
if (!empty($_POST['sitemap'])) { | ||
$response = new \App\Library\Response(); | ||
$sitemap_generator = new SitemapGenerator(); | ||
try { | ||
$sitemap_generator->getSitemap()->setHttpSecure(!empty($_POST['http_secure'])); | ||
if (!empty($_POST['domain'])) { | ||
$sitemap_generator->getSitemap()->setDomain(trim($_POST['domain'])); | ||
} | ||
if (!empty($_POST['last_mod'])) { | ||
$sitemap_generator->setLastMod(trim($_POST['last_mod'])); | ||
} | ||
if (!empty($_POST['change_freq'])) { | ||
$sitemap_generator->setChangeFreq(trim($_POST['change_freq'])); | ||
} | ||
if (!empty($_POST['priority'])) { | ||
$sitemap_generator->setPriority(trim($_POST['priority'])); | ||
} | ||
if (!empty($_POST['file_path'])) { | ||
$sitemap_generator->getSitemap()->setFilePath(BASE_PATH.trim($_POST['file_path'])); | ||
} | ||
if (!empty($_POST['file_name'])) { | ||
$sitemap_generator->getSitemap()->setFileName(trim($_POST['file_name'])); | ||
} | ||
if (!empty($_POST['file_ext'])) { | ||
$sitemap_generator->getSitemap()->setFileExt(trim($_POST['file_ext'])); | ||
} | ||
if (!empty($_POST['file_header'])) { | ||
$sitemap_generator->getSitemap()->setHeader(trim($_POST['file_header'])); | ||
} | ||
if (!empty($_POST['file_urlset_header'])) { | ||
$sitemap_generator->getSitemap()->setUrlsetHeader(trim($_POST['file_urlset_header'])); | ||
} | ||
if (!empty($_POST['file_urlset_footer'])) { | ||
$sitemap_generator->getSitemap()->setUrlsetFooter(trim($_POST['file_urlset_footer'])); | ||
} | ||
$query_pages = $db->query("SELECT * from tbl_pages", PDO::FETCH_ASSOC); | ||
if ($query_pages && $query_pages->rowCount()) { | ||
$pages = $query_pages->fetchAll(PDO::FETCH_ASSOC); | ||
foreach ($pages as $page) { | ||
$sitemap_generator->set_url_loc($page['slug']); | ||
$sitemap_generator->set_url_last_mod(!empty($page['updated_at']) ? $page['updated_at'] : $page['created_at']); | ||
$sitemap_generator->set_url_priority(0.8); | ||
$sitemap_generator->add_url_to_list(); | ||
} | ||
} | ||
$query_products = $db->query("SELECT * from tbl_products", PDO::FETCH_ASSOC); | ||
if ($query_products && $query_products->rowCount()) { | ||
$products = $query_products->fetchAll(PDO::FETCH_ASSOC); | ||
foreach ($products as $product) { | ||
$sitemap_generator->set_url_loc('product-detail/'.$product['slug']); | ||
$sitemap_generator->set_url_last_mod(!empty($product['updated_at']) ? $product['updated_at'] : $product['created_at']); | ||
$sitemap_generator->set_url_priority(1); | ||
$sitemap_generator->add_url_to_list(); | ||
} | ||
} | ||
$response = $sitemap_generator->generate(); | ||
} catch (\Exception $e) { | ||
$response->setStatus(false); | ||
$response->setStatusCode(500); | ||
$response->setStatusText($e->getMessage()); | ||
$response->setMessage('The sitemap could not be created.'); | ||
} | ||
echo $response->toJson(); | ||
return true; | ||
} |
Oops, something went wrong.