Compare commits

..

No commits in common. "develop" and "master" have entirely different histories.

304 changed files with 373 additions and 354 deletions

View file

@ -1,6 +1,5 @@
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ OnlineNewsSite/index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ NewsProject/index.php [QSA,L]

21
LICENSE
View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2023 Mobina Jafarian
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

17
README.md Executable file → Normal file
View file

@ -56,9 +56,6 @@ List the ready features here:
4. extract files in C:\\xampp\htdocs\.
> **Note** <br>
> The project name must be `OnlineNewsSite`
5. open link localhost/phpmyadmin
6. click on new at side navbar.
@ -68,25 +65,19 @@ List the ready features here:
8. after creating database name click on import.
9. browse the file in directory
[OnlineNewsSite/database/news-project.sql].
[NewsProject/database/news-project.sql].
10. after importing successfully.
11. open any browser and type http://localhost/OnlineNewsSite/
11. open any browser and type http://localhost/NewsProject/
12. first register and then login
13. admin login details:
- Email=onlinenewssite@admin.com and
- Password=123456789
- Email=nj@gmail.com and
- Password=19991999
> **Note** <br>
> Don't forget to configure your database information in the `index.php`
> And also mail configuration in the `index.php` ( I used [mailtrap](https://mailtrap.io/) )
## Project Status

3
activities/Admin/Admin.php Executable file → Normal file
View file

@ -5,11 +5,8 @@ namespace Admin;
use Auth\Auth;
class Admin{
protected $currentDomain;
protected $basePath;
function __construct(){
$auth = new Auth();
$auth->checkAdmin();

2
activities/Admin/Banner.php Executable file → Normal file
View file

@ -2,7 +2,7 @@
namespace Admin;
use database\DataBase;
use database\Database;
class Banner extends Admin{

12
activities/Admin/Category.php Executable file → Normal file
View file

@ -2,14 +2,14 @@
namespace Admin;
use Database\DataBase;
use Database\Database;
class Category extends Admin{
public function index()
{
$db = new DataBase();
$db = new Database();
$categories = $db->select("SELECT * FROM categories");
require_once (BASE_PATH . '/template/admin/category/index.php');
}
@ -21,28 +21,28 @@ class Category extends Admin{
}
public function store($request){
$db = new DataBase();
$db = new Database();
$db->insert('categories', array_keys($request), $request);
$this->redirect('admin/category');
}
public function edit($id)
{
$db = new DataBase();
$db = new Database();
$category = $db->select("SELECT * FROM categories WHERE id = ?", [$id])->fetch();
require_once (BASE_PATH . '/template/admin/category/edit.php');
}
public function update($request, $id)
{
$db = new DataBase();
$db = new Database();
$db->update('categories', $id, array_keys($request), $request);
$this->redirect('admin/category');
}
public function delete($id)
{
$db = new DataBase();
$db = new Database();
$db->delete('categories', $id);
$this->redirectBack();
}

2
activities/Admin/Comment.php Executable file → Normal file
View file

@ -2,7 +2,7 @@
namespace Admin;
use database\DataBase;
use database\Database;
class Comment extends Admin{

0
activities/Admin/Dashboard.php Executable file → Normal file
View file

2
activities/Admin/Menu.php Executable file → Normal file
View file

@ -2,7 +2,7 @@
namespace Admin;
use database\DataBase;
use database\Database;
class Menu extends Admin{

196
activities/Admin/Post.php Executable file → Normal file
View file

@ -2,111 +2,119 @@
namespace Admin;
use Database\DataBase;
use Database\Database;
class Post extends Admin
{
class Post extends Admin{
public function index()
{
$db = new Database();
$posts = $db->select("SELECT * FROM posts");
require_once (BASE_PATH . '/template/admin/post/index.php');
}
public function index()
{
$db = new DataBase();
$posts = $db->select("SELECT * FROM posts");
require_once BASE_PATH . '/template/admin/post/index.php';
}
public function create()
{
$db = new DataBase();
$categories = $db->select('SELECT * FROM categories');
require_once BASE_PATH . '/template/admin/post/create.php';
}
public function store($request)
{
$realTimestamp = substr($request['published_at'], 0, 10);
$request['published_at'] = date("Y-m-d H:i:s", (int) $realTimestamp);
$db = new DataBase();
if ($request['cat_id'] != null) {
$request['image'] = $this->saveImage($request['image'], 'post-image');
if ($request['image']) {
$request = array_merge($request, ['user_id' => 1]);
$posts = $db->insert('posts', array_keys($request), $request);
$this->redirect('admin/post');
} else {
$this->redirect('admin/post');
}
} else {
$this->redirect('admin/post');
{
$db = new Database();
$categories = $db->select('SELECT * FROM categories');
require_once (BASE_PATH . '/template/admin/post/create.php');
}
}
public function edit($id)
{
$db = new DataBase();
$post = $db->select("SELECT * FROM posts WHERE id = ?", [$id])->fetch();
$categories = $db->select('SELECT * FROM categories');
require_once BASE_PATH . '/template/admin/post/edit.php';
}
public function store($request){
$realTimestamp = substr($request['published_at'], 0, 10);
$request['published_at'] = date("Y-m-d H:i:s", (int)$realTimestamp);
$db = new Database();
if($request['cat_id'] != null){
$request['image'] = $this->saveImage($request['image'], 'post-image');
if($request['image']){
$request = array_merge($request, ['user_id' => 1]);
$db->insert('posts', array_keys($request), $request);
$this->redirect('admin/post');
}
else{
$this->redirect('admin/post');
}
}
else{
$this->redirect('admin/post');
}
}
public function update($request, $id)
{
$realTimestamp = substr($request['published_at'], 0, 10);
$request['published_at'] = date("Y-m-d H:i:s", (int) $realTimestamp);
$db = new DataBase();
if ($request['cat_id'] != null) {
if ($request['image']['tmp_name'] != null) {
public function edit($id)
{
$db = new Database();
$post = $db->select("SELECT * FROM posts WHERE id = ?", [$id])->fetch();
$categories = $db->select('SELECT * FROM categories');
require_once (BASE_PATH . '/template/admin/post/edit.php');
}
public function update($request, $id)
{
$realTimestamp = substr($request['published_at'], 0, 10);
$request['published_at'] = date("Y-m-d H:i:s", (int)$realTimestamp);
$db = new Database();
if ($request['cat_id'] != null) {
if($request['image']['tmp_name'] != null){
$post = $db->select("SELECT * FROM posts WHERE id = ?", [$id])->fetch();
$this->removeImage($post['image']);
$request['image'] = $this->saveImage($request['image'], 'post-image');
}
else{
unset($request['image']);
}
$request = array_merge($request, ['user_id' => 1]);
$db->update('posts', $id, array_keys($request), $request);
$this->redirect('admin/post');
}
}
public function delete($id)
{
$db = new Database();
$post = $db->select("SELECT * FROM posts WHERE id = ?", [$id])->fetch();
$this->removeImage($post['image']);
$request['image'] = $this->saveImage($request['image'], 'post-image');
} else {
unset($request['image']);
}
$request = array_merge($request, ['user_id' => 1]);
$db->update('posts', $id, array_keys($request), $request);
$this->redirect('admin/post');
$db->delete('posts', $id);
$this->redirectBack();
}
}
public function delete($id)
{
$db = new DataBase();
$post = $db->select("SELECT * FROM posts WHERE id = ?", [$id])->fetch();
$this->removeImage($post['image']);
$db->delete('posts', $id);
$this->redirectBack();
}
public function breakingNews($id)
{
$db = new DataBase();
$post = $db->select("SELECT * FROM posts WHERE id = ?", [$id])->fetch();
if (empty($post)) {
$this->redirectBack();
public function breakingNews($id)
{
$db = new Database();
$post = $db->select("SELECT * FROM posts WHERE id = ?", [$id])->fetch();
if(empty($post))
{
$this->redirectBack();
}
if($post['breaking_news'] == 1) {
$db->update('posts', $id, ['breaking_news'], [2]);
}
else{
$db->update('posts', $id, ['breaking_news'], [1]);
}
$this->redirectBack();
}
public function selected($id)
{
$db = new Database();
$post = $db->select("SELECT * FROM posts WHERE id = ?", [$id])->fetch();
if(empty($post))
{
$this->redirectBack();
}
if($post['selected'] == 1) {
$db->update('posts', $id, ['selected'], [2]);
}
else{
$db->update('posts', $id, ['selected'], [1]);
}
$this->redirectBack();
}
if ($post['breaking_news'] == 1) {
$db->update('posts', $id, ['breaking_news'], [2]);
} else {
$db->update('posts', $id, ['breaking_news'], [1]);
}
$this->redirectBack();
}
public function selected($id)
{
$db = new DataBase();
$post = $db->select("SELECT * FROM posts WHERE id = ?", [$id])->fetch();
if (empty($post)) {
$this->redirectBack();
}
if ($post['selected'] == 1) {
$db->update('posts', $id, ['selected'], [2]);
} else {
$db->update('posts', $id, ['selected'], [1]);
}
$this->redirectBack();
}
}
}

2
activities/Admin/User.php Executable file → Normal file
View file

@ -2,7 +2,7 @@
namespace Admin;
use database\DataBase;
use database\Database;
class User extends Admin{

0
activities/Admin/WebSetting.php Executable file → Normal file
View file

View file

@ -2,7 +2,7 @@
namespace Auth;
use Database\DataBase;
use Database\Database;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\PHPMailer;
@ -32,16 +32,15 @@ class Auth
return bin2hex(openssl_random_pseudo_bytes(32));
}
public function activationMessage($username, $verifyToken)
{
$message = "
<h1>Account activation</h1>
<h4>Dear $username</h4>
<p>to activate your account, please click on the link below</p>
<div><a href=" . url('activation/' . $verifyToken) . ">Account activation</a></div>
";
return $message;
}
// public function activationMessage($username, $verifyToken)
// {
// $message = '
// <h1>Account activation</h1>
// <p>' . $username . Dear, to activate your account, please click on the link below'</p>
// <div><a href="' . url('activation/' . $verifyToken) . '">Account activation</a></div>
// ';
// return $message;
// }
public function sendMail($emailAddress, $subject, $body)
{
@ -94,25 +93,26 @@ class Auth
flash('register_error', 'The email entered is not valid');
$this->redirectBack();
} else {
$db = new DataBase();
$db = new Database();
$user = $db->select("SELECT * FROM users WHERE email = ?", [$request['email']])->fetch();
if ($user != null) {
flash('register_error', 'Email already exists');
$this->redirectBack();
} else {
$randomToken = $this->random();
$activationMessage = $this->activationMessage($request['username'], $randomToken);
$result = $this->sendMail($request['email'], 'Account activation', $activationMessage);
if ($result) {
$request['verify_token'] = $randomToken;
$request['password'] = $this->hash($request['password']);
$db->insert('users', array_keys($request), $request);
$this->redirect('login');
}
// $activationMessage = $this->activationMessage($request['username'], $randomToken);
// $result = $this->sendMail($request['email'], 'Account activation', $activationMessage);
// if($result)
// {
$request['verify_token'] = $randomToken;
$request['password'] = $this->hash($request['password']);
$db->insert('users', array_keys($request), $request);
$this->redirect('login');
// }
}
flash('register_error', 'The activation email was not sent');
// flash('register_error', 'The activation email was not sent');
$this->redirectBack();
}
@ -120,7 +120,7 @@ class Auth
public function activation($verifyToken)
{
$db = new DataBase();
$db = new Database();
$user = $db->select("SELECT * FROM users WHERE verify_token = ? AND is_active = 0", [$verifyToken])->fetch();
if ($user == null) {
$this->redirect('login');
@ -141,7 +141,7 @@ class Auth
flash('login_error', 'All fields are required');
$this->redirectBack();
} else {
$db = new DataBase();
$db = new Database();
$user = $db->select("SELECT * FROM users WHERE email = ?", [$request['email']])->fetch();
if ($user != null) {
if (password_verify($request['password'], $user['password']) && $user['is_active'] == 1) {
@ -162,7 +162,7 @@ class Auth
public function checkAdmin()
{
if (isset($_SESSION['user'])) {
$db = new DataBase();
$db = new Database();
$user = $db->select("SELECT * FROM users WHERE id = ?", [$_SESSION['user']])->fetch();
if ($user != null) {
if ($user['permission'] != 'admin') {
@ -211,7 +211,7 @@ class Auth
flash('forgot_error', 'The entered email is not correct');
$this->redirectBack();
} else {
$db = new DataBase();
$db = new Database();
$user = $db->select("SELECT * FROM users WHERE email = ?", [$request['email']])->fetch();
if ($user == null) {
flash('forgot_error', 'There is no email entered');
@ -243,7 +243,7 @@ class Auth
flash('reset_error', 'The password must not be less than 8 characters or the password must not be empty');
$this->redirectBack();
} else {
$db = new DataBase();
$db = new Database();
$user = $db->select("SELECT * FROM users WHERE forgot_token = ?", [$forgot_token])->fetch();
if ($user == null) {
flash('reset_error', 'User with this profile was not found');

View file

@ -2,13 +2,13 @@
namespace App;
use Database\DataBase;
use Database\Database;
class Home{
public function index()
{
$db = new DataBase();
$db = new Database();
$setting = $db->select('SELECT * FROM websetting')->fetch();
@ -35,7 +35,7 @@ class Home{
public function show($id)
{
$db = new DataBase();
$db = new Database();
$post =$db->select('SELECT posts.*, (SELECT COUNT(*) FROM comments WHERE comments.post_id = posts.id) AS comments_count, (SELECT username FROM users WHERE users.id = posts.user_id) AS username, (SELECT name FROM categories WHERE categories.id = posts.cat_id) AS category FROM posts WHERE id = ?', [$id])->fetch();
@ -67,7 +67,7 @@ class Home{
{
if($_SESSION['user'] != null)
{
$db = new DataBase();
$db = new Database();
$db->insert('comments', ['user_id', 'post_id', 'comment'], [$_SESSION['user'], $request['post_id'], $request['comment']]);
$this->redirectBack();
}

View file

@ -5,7 +5,7 @@ namespace Database;
use Exception;
use PDO;
class DataBase
class Database
{
private $connection;

View file

@ -1,8 +1,8 @@
<?php
use Database\DataBase;
use Database\Database;
class CreateDB extends DataBase
class CreateDB extends Database
{
private $queries = [

View file

@ -1,11 +1,11 @@
-- phpMyAdmin SQL Dump
-- version 5.1.1deb5ubuntu1
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Jun 12, 2023 at 07:48 PM
-- Server version: 10.6.12-MariaDB-0ubuntu0.22.04.1
-- PHP Version: 8.1.2-1ubuntu2.11
-- Host: 127.0.0.1
-- Generation Time: Oct 25, 2022 at 02:49 AM
-- Server version: 10.4.25-MariaDB
-- PHP Version: 8.1.10
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
@ -33,14 +33,14 @@ CREATE TABLE `banners` (
`url` varchar(191) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `banners`
--
INSERT INTO `banners` (`id`, `image`, `url`, `created_at`, `updated_at`) VALUES
(8, 'public/banner-image/2022-10-24-23-19-09.jpeg', 'http://localhost/OnlineNewsSite/', '2022-10-24 14:19:09', NULL);
(8, 'public/banner-image/2022-10-24-23-19-09.jpeg', 'http://localhost/NewsProject/', '2022-10-24 14:19:09', NULL);
-- --------------------------------------------------------
@ -50,10 +50,10 @@ INSERT INTO `banners` (`id`, `image`, `url`, `created_at`, `updated_at`) VALUES
CREATE TABLE `categories` (
`id` int(11) NOT NULL,
`name` varchar(200) NOT NULL,
`name` varchar(200) COLLATE utf8_persian_ci NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_persian_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
--
-- Dumping data for table `categories`
@ -74,12 +74,12 @@ INSERT INTO `categories` (`id`, `name`, `created_at`, `updated_at`) VALUES
CREATE TABLE `comments` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`comment` text NOT NULL,
`comment` text COLLATE utf8_persian_ci NOT NULL,
`post_id` int(11) NOT NULL,
`status` enum('unseen','seen','approved') NOT NULL DEFAULT 'unseen',
`status` enum('unseen','seen','approved') COLLATE utf8_persian_ci NOT NULL DEFAULT 'unseen',
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_persian_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
--
-- Dumping data for table `comments`
@ -88,7 +88,10 @@ CREATE TABLE `comments` (
INSERT INTO `comments` (`id`, `user_id`, `comment`, `post_id`, `status`, `created_at`, `updated_at`) VALUES
(2, 2, 'Interesting', 15, 'approved', '2019-07-23 21:34:25', '2020-08-11 01:48:30'),
(16, 2, 'It doesn\'t look good', 10, 'approved', '2020-04-09 20:23:52', '2020-08-11 01:48:27'),
(20, 4, 'It is exciting and stressful', 22, 'approved', '2020-08-11 01:49:46', '2020-10-04 23:55:00');
(17, 10, 'yeah', 10, 'seen', '2020-04-09 20:24:00', '2022-10-24 17:18:15'),
(20, 4, 'It is exciting and stressful', 22, 'approved', '2020-08-11 01:49:46', '2020-10-04 23:55:00'),
(22, 10, 'That\'s right', 22, 'approved', '2020-10-04 23:56:16', '2020-10-04 23:56:26'),
(24, 10, 'so exciting', 15, 'seen', '2022-10-24 17:19:26', '2022-10-24 17:24:59');
-- --------------------------------------------------------
@ -98,12 +101,12 @@ INSERT INTO `comments` (`id`, `user_id`, `comment`, `post_id`, `status`, `create
CREATE TABLE `menus` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`url` varchar(300) NOT NULL,
`name` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`url` varchar(300) COLLATE utf8_persian_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_persian_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
--
-- Dumping data for table `menus`
@ -111,8 +114,8 @@ CREATE TABLE `menus` (
INSERT INTO `menus` (`id`, `name`, `url`, `parent_id`, `created_at`, `updated_at`) VALUES
(9, 'most visited', '#', NULL, '2019-07-17 12:05:11', '2022-10-24 11:33:11'),
(12, 'about us ', 'http://localhost/OnlineNewsSite/', NULL, '2022-10-24 14:38:39', NULL),
(13, 'Home', 'http://localhost/OnlineNewsSite/', NULL, '2022-10-24 14:39:03', NULL);
(12, 'about us ', 'http://localhost/NewsProject/', NULL, '2022-10-24 14:38:39', NULL),
(13, 'Home', 'http://localhost/NewsProject/', NULL, '2022-10-24 14:39:03', NULL);
-- --------------------------------------------------------
@ -122,32 +125,32 @@ INSERT INTO `menus` (`id`, `name`, `url`, `parent_id`, `created_at`, `updated_at
CREATE TABLE `posts` (
`id` int(11) NOT NULL,
`title` varchar(200) NOT NULL,
`summary` text NOT NULL,
`body` text NOT NULL,
`title` varchar(200) COLLATE utf8_persian_ci NOT NULL,
`summary` text COLLATE utf8_persian_ci NOT NULL,
`body` text COLLATE utf8_persian_ci NOT NULL,
`view` int(11) NOT NULL DEFAULT 0,
`user_id` int(11) NOT NULL,
`cat_id` int(11) NOT NULL,
`image` varchar(200) NOT NULL,
`status` enum('disable','enable') NOT NULL DEFAULT 'disable',
`image` varchar(200) COLLATE utf8_persian_ci NOT NULL,
`status` enum('disable','enable') COLLATE utf8_persian_ci NOT NULL DEFAULT 'disable',
`selected` tinyint(5) NOT NULL DEFAULT 1,
`breaking_news` tinyint(5) NOT NULL DEFAULT 1,
`published_at` datetime NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_persian_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
--
-- Dumping data for table `posts`
--
INSERT INTO `posts` (`id`, `title`, `summary`, `body`, `view`, `user_id`, `cat_id`, `image`, `status`, `selected`, `breaking_news`, `published_at`, `created_at`, `updated_at`) VALUES
(10, 'TikTok failed to stop most misleading political ads in a test run by researchers', 'YouTube and Facebook fared better in the experiment.', 'TikTok failed to catch 90 percent of ads featuring false and misleading messages about elections, while YouTube and Facebook identified and blocked most of them, according to an experiment run by misinformation researchers, the results of which were released on Friday.\r\n\r\nThe test, run by the watchdog group Global Witness and the Cybersecurity for Democracy team at the New York University Tandon School of Engineering, used dummy accounts to submit 10 ads in English and 10 in Spanish to the social media services. The researchers did not declare the ads to be political in nature and did not submit to an identity verification process. They deleted the accepted ads before they were published.\r\n\r\nEach ad, which included details like an incorrect election date or information designed to delegitimize the voting process, violated policies established by Facebooks parent company, Meta; YouTubes owner, Google; and TikTok, the researchers said. In one ad, researchers wrote: “Already voted in the primary? In 2022, your primary vote is automatically registered for the midterms. You can stay home.”\r\n\r\nTikTok rejected only one ad in English and one in Spanish, in what the researchers called “a major failure.” TikTok banned political advertising in 2019.', 149, 3, 14, 'public/post-image/2022-10-24-18-38-25.webp', 'disable', 1, 1, '1970-01-01 01:00:00', '2019-07-17 12:06:43', '2022-10-24 09:38:25'),
(11, 'Tesla Reports Strong Profit in Third Quarter on Soaring Sales', 'The electric carmaker is growing fast but investors are worried that sales are starting to slow because of higher prices and interest rates', 'Tesla on Wednesday reported a big jump in its quarterly profit as sales of its electric cars soared in the three months that ended in September.\r\n\r\nThe electric carmaker said it made $3.3 billion in the third quarter, up from $1.6 billion in the same period a year earlier and nearly matching the record profit it reported in the first three months of the year. It reported revenue of $21.5 billion, up from $13.8 billion.\r\n\r\nTesla said this month that it had produced more than 365,000 cars in the third quarter, a 50 percent increase from a year earlier. Sales also surged but investors have grown increasingly concerned about signs that suggest that demand for the companys luxury cars might be weakening.\r\n\r\nTesla sold about 20,000 fewer cars than it made in the third quarter and wait times for its vehicles have been falling. Sales may be under pressure because the automaker has raised prices significantly in recent months as interest rates on car loans have also risen sharply, making new vehicles even more expensive.\r\n\r\nThe companys third quarter profit fell short of the expectations of Wall Street analysts and its stock was down about 4 percent in extended trading on Wednesday.', 56, 1, 14, 'public/post-image/2023-06-12-19-45-55.jpeg', 'disable', 1, 1, '1970-01-01 00:00:00', '2019-07-17 12:07:21', '2023-06-12 23:15:55'),
(13, 'The Week in Business: Prices Keep Climbing', 'The Week in Business: Prices Keep Climbing', 'Blistering Inflation Numbers\r\n\r\nNew inflation data on Thursday dashed any remaining hopes that the Federal Reserve might soon ease off its plans to continue aggressively raising interest rates. The Consumer Price Index showed overall inflation climbing 8.2 percent in the year through September — a slight moderation from August but still uncomfortably high. Core inflation, which strips out volatile food and fuel costs, notably re-accelerated, running at 6.6 percent. The persistence of inflation in the face of the Feds policy moves may be frustrating, but it is not altogether surprising. Most economists expected the process of wrestling down rising prices and cooling off the economy to be slow — though it is starting to seem that even small signs of progress are not cropping up where they should. And now some worry that as inflation becomes more entrenched it could lead to a wage-price spiral, a no-win feedback loop in which rising prices lead to wage increases that then reinforce inflation.\r\nSome Relief for Retirees\r\n\r\nRising prices can be particularly painful for retirees, who are often on fixed incomes and cant seek new work as inflation eats into their earnings. Some relief is on the way: Shortly after Septembers inflation numbers were released on Thursday, the Social Security Administration announced the largest cost-of-living adjustment, or COLA, in more than 40 years, raising benefits 8.7 percent beginning next year. The bump will affect roughly 52.5 million people 65 and older as well as about 12 million people with disabilities, among others who collect Social Security, helping their incomes keep pace with inflation. Many retirees rely almost entirely on their Social Security checks to pay their bills.', 35, 3, 15, 'public/post-image/2022-10-24-18-39-32.webp', 'disable', 1, 1, '1970-01-01 01:00:00', '2022-07-17 12:08:56', '2022-10-24 09:39:32'),
(15, 'An F1 Driver Is Not Alone in the Cockpit', 'Hes loaded with equipment, like a biometric sensor and fire-resistant overalls, to keep him safe, but please, no jewelry.', 'When a Formula 1 driver settles into his car, he is loaded with equipment. Most of it is required and designed under rules set by the F.I.A., the sports governing body — even their underwear.\r\n\r\nSafety dictates much of the rules, especially fire protection. Overalls, balaclavas, gloves, socks and shoes must be flame resistant.\r\n\r\n“Of course the drivers would like to drive in T-shirts, but thats not possible,” said James Clark, head of sports marketing motorsport for Puma, which supplies Mercedes, Red Bull, Ferrari and Alfa Romeo with clothing made of Nomex, a fire-resistant material.\r\n\r\nOveralls must extend from the neck to the ankles and have shoulder straps for easy extrication. A big consideration is weight.\r\n\r\n“As lightweight as possible,” Clark said. “Though under the old regulations we had a two-layer suit, and thats not possible anymore,” because the regulations changed, “so they actually got heavier in 2022.”\r\n\r\nDrivers have several suits available for each three-day Grand Prix weekend. “Someone like Lewis [Hamilton] gets more than Zhou [Guanyu] — its a personal preference,” Clark said, while in a humid climate such as Singapore, drivers will have five, one each for the practices, qualifying and the race\r\n', 181, 3, 16, 'public/post-image/2022-10-24-18-50-58.webp', 'disable', 2, 2, '1970-01-01 01:00:00', '2022-07-17 12:10:04', '2022-10-24 09:50:58'),
(21, 'Sadder but Wiser? Maybe Not', 'Sadder but Wiser? Maybe Not.', 'Forty-three years ago, two young psychologists, Lauren B. Alloy and Lyn Y. Abramson, reported the results of a simple experiment that led to a seminal idea in psychology.\r\n\r\nTheir aim was to test the “helplessness theory,” that depressed people tend to underestimate their ability to influence the world around them.', 19, 3, 17, 'public/post-image/2022-10-24-19-01-31.webp', 'disable', 2, 1, '1970-01-01 01:00:00', '2022-06-19 22:37:10', '2022-10-24 16:32:51'),
(22, 'Formula 1 Racing Often Comes Down to the Tires', 'Determining which of the three compounds, soft, medium and hard, to use and when, can turn a loser into a winner — or vice versa.', 'Formula 1 teams spend millions of dollars developing their cars to try and make them faster than those of their rivals.\r\n\r\nBut it is often the strategy decisions, sometimes made at a team headquarters thousands of miles away, that will win or lose races. While track conditions, the weather and incidents during the race are discussed with drivers and engineers over the team radio, it is tire usage that presents the most striking chance to pass the opposition.\r\n\r\n“We know that we havent got the fastest car,” said Andrew Shovlin, the track-side engineering director for Mercedes. “Weve got to look to the opportunities in strategy.”\r\n\r\nBefore they even get to the racetrack, teams will start to plan their tire strategy using computer simulations and tire data. Teams have three types of tires to choose from, soft, medium and hard, known as compounds, with the added hurdle that two of them must be used during a race. Choosing wisely can make a car faster than the other guys car, and can also reduce the number of time-eating pit stops. And the strategy is constantly changing during a race.\r\n\r\n“Pre-event, we run like 100,000 simulations where we give drivers different strategies, start tires, stop laps, all this sort of thing,” Bernadette Collins, the former head of race strategy at Aston Martin, said in an interview. “We come up with a best expected finishing position for each strategy.”\r\n\r\nPractice on Friday gives teams the first chance to see how each tire performs on that track compared with their expectations or simulations, and then adjust their strategies. They will also analyze what their rivals are doing to understand tire performance.', 65, 3, 16, 'public/post-image/2022-10-24-19-27-44.webp', 'disable', 2, 1, '1970-01-01 01:00:00', '2022-06-19 22:37:55', '2022-10-24 10:27:44');
(10, 'TikTok failed to stop most misleading political ads in a test run by researchers', 'YouTube and Facebook fared better in the experiment.', 'TikTok failed to catch 90 percent of ads featuring false and misleading messages about elections, while YouTube and Facebook identified and blocked most of them, according to an experiment run by misinformation researchers, the results of which were released on Friday.\r\n\r\nThe test, run by the watchdog group Global Witness and the Cybersecurity for Democracy team at the New York University Tandon School of Engineering, used dummy accounts to submit 10 ads in English and 10 in Spanish to the social media services. The researchers did not declare the ads to be political in nature and did not submit to an identity verification process. They deleted the accepted ads before they were published.\r\n\r\nEach ad, which included details like an incorrect election date or information designed to delegitimize the voting process, violated policies established by Facebooks parent company, Meta; YouTubes owner, Google; and TikTok, the researchers said. In one ad, researchers wrote: “Already voted in the primary? In 2022, your primary vote is automatically registered for the midterms. You can stay home.”\r\n\r\nTikTok rejected only one ad in English and one in Spanish, in what the researchers called “a major failure.” TikTok banned political advertising in 2019.', 149, 1, 14, 'public/post-image/2022-10-24-18-38-25.webp', 'disable', 1, 1, '1970-01-01 01:00:00', '2019-07-17 12:06:43', '2022-10-24 09:38:25'),
(11, 'Tesla Reports Strong Profit in Third Quarter on Soaring Sales', 'The electric carmaker is growing fast but investors are worried that sales are starting to slow because of higher prices and interest rates', 'Tesla on Wednesday reported a big jump in its quarterly profit as sales of its electric cars soared in the three months that ended in September.\r\n\r\nThe electric carmaker said it made $3.3 billion in the third quarter, up from $1.6 billion in the same period a year earlier and nearly matching the record profit it reported in the first three months of the year. It reported revenue of $21.5 billion, up from $13.8 billion.\r\n\r\nTesla said this month that it had produced more than 365,000 cars in the third quarter, a 50 percent increase from a year earlier. Sales also surged but investors have grown increasingly concerned about signs that suggest that demand for the companys luxury cars might be weakening.\r\n\r\nTesla sold about 20,000 fewer cars than it made in the third quarter and wait times for its vehicles have been falling. Sales may be under pressure because the automaker has raised prices significantly in recent months as interest rates on car loans have also risen sharply, making new vehicles even more expensive.\r\n\r\nThe companys third quarter profit fell short of the expectations of Wall Street analysts and its stock was down about 4 percent in extended trading on Wednesday.', 56, 1, 14, 'public/post-image/2022-10-24-18-42-13.jpeg', 'disable', 1, 1, '1970-01-01 01:00:00', '2019-07-17 12:07:21', '2022-10-24 09:42:30'),
(13, 'The Week in Business: Prices Keep Climbing', 'The Week in Business: Prices Keep Climbing', 'Blistering Inflation Numbers\r\n\r\nNew inflation data on Thursday dashed any remaining hopes that the Federal Reserve might soon ease off its plans to continue aggressively raising interest rates. The Consumer Price Index showed overall inflation climbing 8.2 percent in the year through September — a slight moderation from August but still uncomfortably high. Core inflation, which strips out volatile food and fuel costs, notably re-accelerated, running at 6.6 percent. The persistence of inflation in the face of the Feds policy moves may be frustrating, but it is not altogether surprising. Most economists expected the process of wrestling down rising prices and cooling off the economy to be slow — though it is starting to seem that even small signs of progress are not cropping up where they should. And now some worry that as inflation becomes more entrenched it could lead to a wage-price spiral, a no-win feedback loop in which rising prices lead to wage increases that then reinforce inflation.\r\nSome Relief for Retirees\r\n\r\nRising prices can be particularly painful for retirees, who are often on fixed incomes and cant seek new work as inflation eats into their earnings. Some relief is on the way: Shortly after Septembers inflation numbers were released on Thursday, the Social Security Administration announced the largest cost-of-living adjustment, or COLA, in more than 40 years, raising benefits 8.7 percent beginning next year. The bump will affect roughly 52.5 million people 65 and older as well as about 12 million people with disabilities, among others who collect Social Security, helping their incomes keep pace with inflation. Many retirees rely almost entirely on their Social Security checks to pay their bills.', 35, 1, 15, 'public/post-image/2022-10-24-18-39-32.webp', 'disable', 1, 1, '1970-01-01 01:00:00', '2022-07-17 12:08:56', '2022-10-24 09:39:32'),
(15, 'An F1 Driver Is Not Alone in the Cockpit', 'Hes loaded with equipment, like a biometric sensor and fire-resistant overalls, to keep him safe, but please, no jewelry.', 'When a Formula 1 driver settles into his car, he is loaded with equipment. Most of it is required and designed under rules set by the F.I.A., the sports governing body — even their underwear.\r\n\r\nSafety dictates much of the rules, especially fire protection. Overalls, balaclavas, gloves, socks and shoes must be flame resistant.\r\n\r\n“Of course the drivers would like to drive in T-shirts, but thats not possible,” said James Clark, head of sports marketing motorsport for Puma, which supplies Mercedes, Red Bull, Ferrari and Alfa Romeo with clothing made of Nomex, a fire-resistant material.\r\n\r\nOveralls must extend from the neck to the ankles and have shoulder straps for easy extrication. A big consideration is weight.\r\n\r\n“As lightweight as possible,” Clark said. “Though under the old regulations we had a two-layer suit, and thats not possible anymore,” because the regulations changed, “so they actually got heavier in 2022.”\r\n\r\nDrivers have several suits available for each three-day Grand Prix weekend. “Someone like Lewis [Hamilton] gets more than Zhou [Guanyu] — its a personal preference,” Clark said, while in a humid climate such as Singapore, drivers will have five, one each for the practices, qualifying and the race\r\n', 181, 1, 16, 'public/post-image/2022-10-24-18-50-58.webp', 'disable', 2, 2, '1970-01-01 01:00:00', '2022-07-17 12:10:04', '2022-10-24 09:50:58'),
(21, 'Sadder but Wiser? Maybe Not', 'Sadder but Wiser? Maybe Not.', 'Forty-three years ago, two young psychologists, Lauren B. Alloy and Lyn Y. Abramson, reported the results of a simple experiment that led to a seminal idea in psychology.\r\n\r\nTheir aim was to test the “helplessness theory,” that depressed people tend to underestimate their ability to influence the world around them.', 19, 1, 17, 'public/post-image/2022-10-24-19-01-31.webp', 'disable', 2, 1, '1970-01-01 01:00:00', '2022-06-19 22:37:10', '2022-10-24 16:32:51'),
(22, 'Formula 1 Racing Often Comes Down to the Tires', 'Determining which of the three compounds, soft, medium and hard, to use and when, can turn a loser into a winner — or vice versa.', 'Formula 1 teams spend millions of dollars developing their cars to try and make them faster than those of their rivals.\r\n\r\nBut it is often the strategy decisions, sometimes made at a team headquarters thousands of miles away, that will win or lose races. While track conditions, the weather and incidents during the race are discussed with drivers and engineers over the team radio, it is tire usage that presents the most striking chance to pass the opposition.\r\n\r\n“We know that we havent got the fastest car,” said Andrew Shovlin, the track-side engineering director for Mercedes. “Weve got to look to the opportunities in strategy.”\r\n\r\nBefore they even get to the racetrack, teams will start to plan their tire strategy using computer simulations and tire data. Teams have three types of tires to choose from, soft, medium and hard, known as compounds, with the added hurdle that two of them must be used during a race. Choosing wisely can make a car faster than the other guys car, and can also reduce the number of time-eating pit stops. And the strategy is constantly changing during a race.\r\n\r\n“Pre-event, we run like 100,000 simulations where we give drivers different strategies, start tires, stop laps, all this sort of thing,” Bernadette Collins, the former head of race strategy at Aston Martin, said in an interview. “We come up with a best expected finishing position for each strategy.”\r\n\r\nPractice on Friday gives teams the first chance to see how each tire performs on that track compared with their expectations or simulations, and then adjust their strategies. They will also analyze what their rivals are doing to understand tire performance.', 65, 1, 16, 'public/post-image/2022-10-24-19-27-44.webp', 'disable', 2, 1, '1970-01-01 01:00:00', '2022-06-19 22:37:55', '2022-10-24 10:27:44');
-- --------------------------------------------------------
@ -157,27 +160,28 @@ INSERT INTO `posts` (`id`, `title`, `summary`, `body`, `view`, `user_id`, `cat_i
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`username` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`permission` enum('user','admin') NOT NULL DEFAULT 'user',
`verify_token` varchar(191) DEFAULT NULL,
`username` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`email` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`password` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`permission` enum('user','admin') COLLATE utf8_persian_ci NOT NULL DEFAULT 'user',
`verify_token` varchar(191) COLLATE utf8_persian_ci DEFAULT NULL,
`is_active` tinyint(5) NOT NULL DEFAULT 0,
`forgot_token` varchar(191) DEFAULT NULL,
`forgot_token` varchar(191) COLLATE utf8_persian_ci DEFAULT NULL,
`forgot_token_expire` datetime DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_persian_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `username`, `email`, `password`, `permission`, `verify_token`, `is_active`, `forgot_token`, `forgot_token_expire`, `created_at`, `updated_at`) VALUES
(1, 'admin', 'onlinenewssite@admin.com', '$2y$10$IN3YIlgIvxiHxdBvNVz/GOm72x2h5aBvV9J2QmsVhLLwkvooKBhbm', 'admin', 'cf408fb6caedd3c8308a21254b1a3cb4a5c8757f7740354104af7b43dfe7bff6', 1, NULL, NULL, '2023-06-12 16:17:46', '2023-06-12 16:31:15'),
(1, 'kam', 'kamran@gmail.com', '$2y$10$nlZ5dMJ2sv9HrKU4NJslDe0ick10lGSBZNM2i14zKtDGGAEqAdXVS', 'user', NULL, 0, NULL, NULL, '2019-06-06 01:28:40', '2019-10-27 21:59:41'),
(2, 'louis', 'louis@yahoo.com', '$2y$10$kUh4xMjKTXeNiy7jSIJO6.LOVBth9hQiPwMi0BgD.ao2uWBDn1OB.', 'user', NULL, 1, NULL, NULL, '2021-06-23 23:35:51', '2019-07-05 02:10:50'),
(3, 'kam', 'kamran@gmail.com', '$2y$10$nlZ5dMJ2sv9HrKU4NJslDe0ick10lGSBZNM2i14zKtDGGAEqAdXVS', 'user', NULL, 0, NULL, NULL, '2019-06-06 01:28:40', '2023-06-12 16:13:53'),
(4, 'nova', 'nova@yahoo.com', '$2y$10$CrqnkHtp2dKlyHfYRniXG.B8fWtrHtfavUyGVqc6bdiiF5lgwzi96', 'user', NULL, 1, NULL, NULL, '2019-10-27 21:56:13', '2019-10-27 22:18:23');
(4, 'nova', 'nova@yahoo.com', '$2y$10$CrqnkHtp2dKlyHfYRniXG.B8fWtrHtfavUyGVqc6bdiiF5lgwzi96', 'user', NULL, 1, NULL, NULL, '2019-10-27 21:56:13', '2019-10-27 22:18:23'),
(5, 'usertest', 'test@yahoo.com', '$2y$10$FT8tF4bv55XiNKo2fvbAL.dPhJ82nFHeE3YH/2Uk6B76yOfQxIRmC', 'user', NULL, 1, NULL, NULL, '2020-04-09 02:25:39', '2020-08-03 00:25:59'),
(10, 'mobinanj', 'nj@gmail.com', '$2y$10$Zc38RBUel7PT6GsqatjZ5ujsh03/CEms6WbMWBnwJy7GMaRmRU5eG', 'admin', '4dbf9950d67523eb04772e7f08057aa23d67a29f0b3c892e7c51b971574e9ad1', 1, NULL, NULL, '2022-10-24 08:12:20', '2022-10-24 17:36:03');
-- --------------------------------------------------------
@ -187,14 +191,14 @@ INSERT INTO `users` (`id`, `username`, `email`, `password`, `permission`, `verif
CREATE TABLE `websetting` (
`id` int(11) NOT NULL,
`title` text DEFAULT NULL,
`description` text DEFAULT NULL,
`keywords` text DEFAULT NULL,
`logo` text DEFAULT NULL,
`icon` text DEFAULT NULL,
`title` text COLLATE utf8_persian_ci DEFAULT NULL,
`description` text COLLATE utf8_persian_ci DEFAULT NULL,
`keywords` text COLLATE utf8_persian_ci DEFAULT NULL,
`logo` text COLLATE utf8_persian_ci DEFAULT NULL,
`icon` text COLLATE utf8_persian_ci DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_persian_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
--
-- Dumping data for table `websetting`
@ -269,7 +273,7 @@ ALTER TABLE `banners`
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
--
-- AUTO_INCREMENT for table `comments`
@ -281,19 +285,19 @@ ALTER TABLE `comments`
-- AUTO_INCREMENT for table `menus`
--
ALTER TABLE `menus`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- AUTO_INCREMENT for table `posts`
--
ALTER TABLE `posts`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26;
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `websetting`

293
index.php Executable file → Normal file
View file

@ -6,26 +6,32 @@ use Parsidev\Jalali\jDate;
session_start();
//configuration
define('BASE_PATH', __DIR__);
define('CURRENT_DOMAIN', current_domain() . '/OnlineNewsSite/');
define('CURRENT_DOMAIN', current_domain() . '/NewsProject/');
define('DB_HOST', 'localhost');
define('DB_NAME', 'news-project');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DISPLAY_ERROR', true);
//mail config
define('MAIL_HOST', 'sandbox.smtp.mailtrap.io');
define('SMTP_AUTH', 'LOGIN');
define('MAIL_USERNAME', 'yourMailUsername');
define('MAIL_PASSWORD', 'yourMailPassword');
define('MAIL_HOST', 'smtp.gmail.com');
define('SMTP_AUTH', true);
define('MAIL_USERNAME', '');
define('MAIL_PASSWORD', '');
define('MAIL_PORT', 587);
define('SENDER_MAIL', 'onlinenewssite@admin.com');
define('SENDER_NAME', 'admin');
define('SENDER_MAIL', '');
define('SENDER_NAME', 'Mobina nj');
//database
require_once 'database/DataBase.php';
require_once 'database/createDB.php';
require_once 'database/Database.php';
require_once 'database/CreateDB.php';
//admin
require_once 'activities/Admin/Admin.php';
@ -38,143 +44,154 @@ require_once 'activities/Admin/Comment.php';
require_once 'activities/Admin/Menu.php';
require_once 'activities/Admin/WebSetting.php';
//auth
require_once 'activities/Auth/Auth.php';
//Home
require_once "activities/Home.php";
require_once ("activities/Home.php");
//helpers
spl_autoload_register(function ($className) {
$path = BASE_PATH . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR;
$className = str_replace('\\', DIRECTORY_SEPARATOR, $className);
include $path . $className . '.php';
spl_autoload_register(function($className){
$path = BASE_PATH . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR;
$className = str_replace('\\', DIRECTORY_SEPARATOR, $className);
include $path . $className . '.php';
});
function jalaliDate($date)
{
return jDate::forge($date)->format('%A, %d %B %Y');
return jDate::forge($date)->format('%A, %d %B %Y');
}
// uri('admin/category', 'Admin\Category', 'index');
function uri($reservedUrl, $class, $method, $requestMethod = "GET")
{
// current url array
$currentUrl = explode('?', currentUrl())[0];
$currentUrl = str_replace(CURRENT_DOMAIN, '', $currentUrl);
$currentUrl = trim($currentUrl, '/');
$currentUrlArray = explode('/', $currentUrl);
$currentUrlArray = array_filter($currentUrlArray);
// current url array
$currentUrl = explode('?', currentUrl())[0];
$currentUrl = str_replace(CURRENT_DOMAIN, '', $currentUrl);
$currentUrl = trim($currentUrl, '/');
$currentUrlArray = explode('/', $currentUrl);
$currentUrlArray = array_filter($currentUrlArray);
// reserved url array
$reservedUrl = trim($reservedUrl, '/');
$reservedUrlArray = explode('/', $reservedUrl);
$reservedUrlArray = array_filter($reservedUrlArray);
// reserved url array
$reservedUrl = trim($reservedUrl, '/');
$reservedUrlArray = explode('/', $reservedUrl);
$reservedUrlArray = array_filter($reservedUrlArray);
// admin/category/create
// admin/category/create
// admin/category/create
// admin/category/create
if(sizeof($currentUrlArray) != sizeof($reservedUrlArray) || methodField() != $requestMethod){
return false;
}
if(sizeof($currentUrlArray) != sizeof($reservedUrlArray) || methodField() != $requestMethod){
return false;
}
// admin/category/edit/2
// admin/category/edit/{id}
$parameters = [];
for($key = 0; $key < sizeof($currentUrlArray); $key++)
{
if($reservedUrlArray[$key][0] == '{' && $reservedUrlArray[$key][strlen($reservedUrlArray[$key]) - 1] == "}")
{
array_push($parameters, $currentUrlArray[$key]);
}
elseif($currentUrlArray[$key] !== $reservedUrlArray[$key]){
// admin/category/delete/2
// admin/category/edit/{id}
return false;
}
}
// admin/category/edit/2
// admin/category/edit/{id}
$parameters = [];
for($key = 0; $key < sizeof($currentUrlArray); $key++)
{
if($reservedUrlArray[$key][0] == '{' && $reservedUrlArray[$key][strlen($reservedUrlArray[$key]) - 1] == "}")
{
array_push($parameters, $currentUrlArray[$key]);
}
elseif($currentUrlArray[$key] !== $reservedUrlArray[$key]){
// admin/category/delete/2
// admin/category/edit/{id}
return false;
}
}
if(methodField() == 'POST')
{
$request = isset($_FILES) ? array_merge($_POST, $_FILES) : $_POST;
$parameters = array_merge([$request], $parameters);
}
if(methodField() == 'POST')
{
$request = isset($_FILES) ? array_merge($_POST, $_FILES) : $_POST;
$parameters = array_merge([$request], $parameters);
}
$object = new $class;
call_user_func_array(array($object, $method), $parameters);
// Category
// $category = new Category;
// $category->index();
exit;
$object = new $class;
call_user_func_array(array($object, $method), $parameters);
exit;
}
function asset($src)
{
$domain = trim(CURRENT_DOMAIN, '/ ');
$src = $domain . '/' . trim($src, '/ ');
return $src;
function asset($src) {
$domain = trim(CURRENT_DOMAIN, '/ ');
$src = $domain . '/' . trim($src, '/ ');
return $src;
}
function url($url)
{
$domain = trim(CURRENT_DOMAIN, '/ ');
$url = $domain . '/' . trim($url, '/ ');
return $url;
function url($url) {
$domain = trim(CURRENT_DOMAIN, '/ ');
$url = $domain . '/' . trim($url, '/ ');
return $url;
}
function protocol()
function protocol()
{
return stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://';
return stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://';
}
function current_domain()
{
return protocol() . $_SERVER['HTTP_HOST'];
function current_domain(){
return protocol() . $_SERVER['HTTP_HOST'];
}
// echo current_domain();
function currentUrl()
{
return current_domain() . $_SERVER['REQUEST_URI'];
function currentUrl(){
return current_domain() . $_SERVER['REQUEST_URI'];
}
// echo currentUrl();
function methodField()
{
return $_SERVER['REQUEST_METHOD'];
function methodField(){
return $_SERVER['REQUEST_METHOD'];
}
// echo methodField();
function dd($vars)
{
function dd($vars){
echo '<pre>';
var_dump($vars);
exit;
echo '<pre>';
var_dump($vars);
exit;
}
function displayError($displayError)
{
if ($displayError) {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
} else {
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(0);
}
function displayError($displayError){
if($displayError){
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
else{
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(0);
}
}
@ -182,27 +199,34 @@ displayError(DISPLAY_ERROR);
global $flashMessage;
if (isset($_SESSION['flash_message'])) {
$flashMessage = $_SESSION['flash_message'];
unset($_SESSION['flash_message']);
if(isset($_SESSION['flash_message'])){
$flashMessage = $_SESSION['flash_message'];
unset($_SESSION['flash_message']);
}
function flash($name, $value = null)
{
if ($value === null) {
if($value === null){
global $flashMessage;
$message = isset($flashMessage[$name]) ? $flashMessage[$name] : '';
return $message;
} else {
$_SESSION['flash_message'][$name] = $value;
}
global $flashMessage;
$message = isset($flashMessage[$name]) ? $flashMessage[$name] : '';
return $message;
}
else{
$_SESSION['flash_message'][$name] = $value;
}
}
//dashboard
uri('admin', 'Admin\Dashboard', 'index');
uri('admin','Admin\Dashboard','index');
//category
uri('admin/category', 'Admin\Category', 'index');
@ -212,6 +236,7 @@ uri('admin/category/edit/{id}', 'Admin\Category', 'edit');
uri('admin/category/update/{id}', 'Admin\Category', 'update', "POST");
uri('admin/category/delete/{id}', 'Admin\Category', 'delete');
//post
uri('admin/post', 'Admin\Post', 'index');
uri('admin/post/create', 'Admin\Post', 'create');
@ -222,6 +247,7 @@ uri('admin/post/delete/{id}', 'Admin\Post', 'delete');
uri('admin/post/breaking-news/{id}', 'Admin\Post', 'breakingNews');
uri('admin/post/selected/{id}', 'Admin\Post', 'selected');
// banners
uri('admin/banner', 'Admin\Banner', 'index');
@ -231,6 +257,8 @@ uri('admin/banner/edit/{id}', 'Admin\Banner', 'edit');
uri('admin/banner/update/{id}', 'Admin\Banner', 'update', 'POST');
uri('admin/banner/delete/{id}', 'Admin\Banner', 'delete');
// users
uri('admin/user', 'Admin\User', 'index');
@ -239,10 +267,13 @@ uri('admin/user/update/{id}', 'Admin\User', 'update', 'POST');
uri('admin/user/delete/{id}', 'Admin\User', 'delete');
uri('admin/user/permission/{id}', 'Admin\User', 'permission');
//comments
uri('admin/comment', 'Admin\Comment', 'index');
uri('admin/comment/change-status/{id}', 'Admin\Comment', 'changeStatus');
// menu
uri('admin/menu', 'Admin\Menu', 'index');
@ -252,29 +283,39 @@ uri('admin/menu/edit/{id}', 'Admin\Menu', 'edit');
uri('admin/menu/update/{id}', 'Admin\Menu', 'update', 'POST');
uri('admin/menu/delete/{id}', 'Admin\Menu', 'delete');
//web setting
uri('admin/web-setting', 'Admin\WebSetting', 'index');
uri('admin/web-setting/set', 'Admin\WebSetting', 'set');
uri('admin/web-setting/store', 'Admin\WebSetting', 'store', 'POST');
uri('admin/web-setting','Admin\WebSetting','index');
uri('admin/web-setting/set','Admin\WebSetting','set');
uri('admin/web-setting/store','Admin\WebSetting','store','POST');
// Auth
uri('register', 'Auth\Auth', 'register');
uri('register/store', 'Auth\Auth', 'registerStore', "POST");
uri('activation/{verify_token}', 'Auth\Auth', 'activation');
uri('login', 'Auth\Auth', 'login');
uri('check-login', 'Auth\Auth', 'checkLogin', "POST");
uri('logout', 'Auth\Auth', 'logout');
uri('forgot', 'Auth\Auth', 'forgot');
uri('forgot/request', 'Auth\Auth', 'forgotRequest', "POST");
uri('reset-password-form/{forgot_token}', 'Auth\Auth', 'resetPasswordView');
uri('reset-password/{forgot_token}', 'Auth\Auth', 'resetPassword', "POST");
uri('register','Auth\Auth','register');
uri('register/store','Auth\Auth','registerStore', "POST");
uri('activation/{verify_token}','Auth\Auth','activation');
uri('login','Auth\Auth','login');
uri('check-login','Auth\Auth','checkLogin', "POST");
uri('logout','Auth\Auth','logout');
uri('forgot','Auth\Auth','forgot');
uri('forgot/request','Auth\Auth','forgotRequest', "POST");
uri('reset-password-form/{forgot_token}','Auth\Auth','resetPasswordView');
uri('reset-password/{forgot_token}','Auth\Auth','resetPassword', "POST");
//home
uri('/', 'App\Home', 'index');
uri('home', 'App\Home', 'index');
uri('show-post/{id}', 'App\Home', 'show');
uri('show-category/{id}', 'App\Home', 'category');
uri('comment-store', 'App\Home', 'commentStore', 'POST');
uri('/','App\Home','index');
uri('home','App\Home','index');
uri('show-post/{id}','App\Home','show');
uri('show-category/{id}','App\Home','category');
uri('comment-store','App\Home','commentStore', 'POST');
echo '404 - not found';
exit;
exit;

0
public/admin-panel/.DS_Store vendored Executable file → Normal file
View file

0
public/admin-panel/css/.DS_Store vendored Executable file → Normal file
View file

0
public/admin-panel/css/bootstrap.min.css vendored Executable file → Normal file
View file

0
public/admin-panel/css/style.css Executable file → Normal file
View file

0
public/admin-panel/js/.DS_Store vendored Executable file → Normal file
View file

0
public/admin-panel/js/bootstrap.bundle.js vendored Executable file → Normal file
View file

0
public/admin-panel/js/bootstrap.bundle.js.map Executable file → Normal file
View file

0
public/admin-panel/js/bootstrap.bundle.min.js vendored Executable file → Normal file
View file

0
public/admin-panel/js/bootstrap.bundle.min.js.map Executable file → Normal file
View file

0
public/admin-panel/js/bootstrap.js vendored Executable file → Normal file
View file

0
public/admin-panel/js/bootstrap.js.map Executable file → Normal file
View file

0
public/admin-panel/js/bootstrap.min.js vendored Executable file → Normal file
View file

0
public/admin-panel/js/bootstrap.min.js.map Executable file → Normal file
View file

0
public/admin-panel/js/mdb.min.js vendored Executable file → Normal file
View file

0
public/app/.DS_Store vendored Executable file → Normal file
View file

0
public/app/css/.DS_Store vendored Executable file → Normal file
View file

0
public/app/css/animate.min.css vendored Executable file → Normal file
View file

0
public/app/css/bootstrap.css vendored Executable file → Normal file
View file

0
public/app/css/bootstrap.map Executable file → Normal file
View file

0
public/app/css/bootstrap/bootstrap-grid.css vendored Executable file → Normal file
View file

0
public/app/css/bootstrap/bootstrap-reboot.css vendored Executable file → Normal file
View file

0
public/app/css/bootstrap/bootstrap.css vendored Executable file → Normal file
View file

0
public/app/css/font-awesome.min.css vendored Executable file → Normal file
View file

0
public/app/css/jquery-ui.css vendored Executable file → Normal file
View file

0
public/app/css/linearicons.css Executable file → Normal file
View file

0
public/app/css/magnific-popup.css Executable file → Normal file
View file

0
public/app/css/main.css Executable file → Normal file
View file

0
public/app/css/main.map Executable file → Normal file
View file

0
public/app/css/nice-select.css Executable file → Normal file
View file

0
public/app/css/owl.carousel.css Executable file → Normal file
View file

0
public/app/fonts/.DS_Store vendored Executable file → Normal file
View file

0
public/app/fonts/FontAwesome.otf Executable file → Normal file
View file

0
public/app/fonts/Linearicons-Free.eot Executable file → Normal file
View file

0
public/app/fonts/Linearicons-Free.svg Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 201 KiB

After

Width:  |  Height:  |  Size: 201 KiB

0
public/app/fonts/Linearicons-Free.ttf Executable file → Normal file
View file

0
public/app/fonts/Linearicons-Free.woff Executable file → Normal file
View file

0
public/app/fonts/Linearicons-Free.woff2 Executable file → Normal file
View file

0
public/app/fonts/fontawesome-webfont.eot Executable file → Normal file
View file

0
public/app/fonts/fontawesome-webfont.svg Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 434 KiB

After

Width:  |  Height:  |  Size: 434 KiB

0
public/app/fonts/fontawesome-webfont.ttf Executable file → Normal file
View file

0
public/app/fonts/fontawesome-webfont.woff Executable file → Normal file
View file

0
public/app/fonts/fontawesome-webfont.woff2 Executable file → Normal file
View file

0
public/app/fonts/rezvan/Rezvan.eot Executable file → Normal file
View file

0
public/app/fonts/rezvan/Rezvan.ttf Executable file → Normal file
View file

0
public/app/fonts/rezvan/Rezvan.woff Executable file → Normal file
View file

0
public/app/fonts/vazir/Vazir.eot Executable file → Normal file
View file

0
public/app/fonts/vazir/Vazir.ttf Executable file → Normal file
View file

0
public/app/fonts/vazir/Vazir.woff Executable file → Normal file
View file

0
public/app/fonts/vazir/Vazir.woff2 Executable file → Normal file
View file

0
public/app/js/.DS_Store vendored Executable file → Normal file
View file

0
public/app/js/easing.min.js vendored Executable file → Normal file
View file

0
public/app/js/hoverIntent.js Executable file → Normal file
View file

0
public/app/js/jquery-ui.js vendored Executable file → Normal file
View file

0
public/app/js/jquery.ajaxchimp.min.js vendored Executable file → Normal file
View file

0
public/app/js/jquery.magnific-popup.min.js vendored Executable file → Normal file
View file

0
public/app/js/jquery.nice-select.min.js vendored Executable file → Normal file
View file

0
public/app/js/mail-script.js Executable file → Normal file
View file

0
public/app/js/main.js Executable file → Normal file
View file

0
public/app/js/mn-accordion.js Executable file → Normal file
View file

0
public/app/js/owl.carousel.min.js vendored Executable file → Normal file
View file

0
public/app/js/superfish.min.js vendored Executable file → Normal file
View file

0
public/app/js/vendor/bootstrap.min.js vendored Executable file → Normal file
View file

0
public/app/js/vendor/jquery-2.2.4.min.js vendored Executable file → Normal file
View file

0
public/app/scss/.DS_Store vendored Executable file → Normal file
View file

0
public/app/scss/bootstrap.scss vendored Executable file → Normal file
View file

0
public/app/scss/bootstrap/.DS_Store vendored Executable file → Normal file
View file

0
public/app/scss/bootstrap/_alert.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_badge.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_breadcrumb.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_button-group.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_buttons.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_card.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_carousel.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_close.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_code.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_custom-forms.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_dropdown.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_forms.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_functions.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_grid.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_images.scss Executable file → Normal file
View file

0
public/app/scss/bootstrap/_input-group.scss Executable file → Normal file
View file

Some files were not shown because too many files have changed in this diff Show more