mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 06:30:07 +01:00
More cleanup
This commit is contained in:
parent
a1025a514e
commit
a88feadd29
7 changed files with 98 additions and 46688 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
||||||
tmp/temp.tdata
|
tmp/temp.tdata
|
||||||
|
sitemap.xml
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('config.php');
|
require_once('../config.php');
|
||||||
// DB table to use
|
// DB table to use
|
||||||
$table = 'pastes';
|
$table = 'pastes';
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ $columns2 = array(
|
||||||
|
|
||||||
// SQL server connection information
|
// SQL server connection information
|
||||||
$sql_details = array(
|
$sql_details = array(
|
||||||
'user' => $dbuser,
|
'user' => $db_user,
|
||||||
'pass' => $dbpassword,
|
'pass' => $db_pass,
|
||||||
'db' => $dbname,
|
'db' => $db_schema,
|
||||||
'host' => $dbhost
|
'host' => $db_host
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
32
archive.php
32
archive.php
|
@ -27,37 +27,7 @@ $data_ip = file_get_contents('tmp/temp.tdata');
|
||||||
// Temp count for untagged pastes
|
// Temp count for untagged pastes
|
||||||
$total_untagged = intval($conn->query("SELECT COUNT(*) from pastes WHERE tagsys IS NULL")->fetch(PDO::FETCH_NUM)[0]);
|
$total_untagged = intval($conn->query("SELECT COUNT(*) from pastes WHERE tagsys IS NULL")->fetch(PDO::FETCH_NUM)[0]);
|
||||||
|
|
||||||
// Page views
|
updatePageViews($conn);
|
||||||
$last_page_view = $conn->query('SELECT * FROM page_view ORDER BY id DESC LIMIT 1')->fetch();
|
|
||||||
$last_date = $last_page_view['date'];
|
|
||||||
|
|
||||||
if ($last_date == $date) {
|
|
||||||
if (str_contains($data_ip, $ip)) {
|
|
||||||
$last_tpage = intval($last_page_view['tpage']) + 1;
|
|
||||||
|
|
||||||
// IP already exists, Update view count
|
|
||||||
$statement = $conn->prepare("UPDATE page_view SET tpage = ? WHERE id = ?");
|
|
||||||
$statement->execute([$last_tpage, $last_page_view['id']]);
|
|
||||||
} else {
|
|
||||||
$last_tpage = intval($last_page_view['tpage']) + 1;
|
|
||||||
$last_tvisit = intval($last_page_view['tvisit']) + 1;
|
|
||||||
|
|
||||||
// Update both tpage and tvisit.
|
|
||||||
$statement = $conn->prepare("UPDATE page_view SET tpage = ?,tvisit = ? WHERE id = ?");
|
|
||||||
$statement->execute([$last_tpage, $last_tvisit, $last_page_view['id']]);
|
|
||||||
file_put_contents('tmp/temp.tdata', $data_ip . "\r\n" . $ip);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Delete the file and clear data_ip
|
|
||||||
unlink("tmp/temp.tdata");
|
|
||||||
|
|
||||||
// New date is created
|
|
||||||
$statement = $conn->prepare("INSERT INTO page_view (date, tpage, tvisit) VALUES (?, '1', '1')");
|
|
||||||
$statement->execute([$date]);
|
|
||||||
|
|
||||||
// Update the IP
|
|
||||||
file_put_contents('tmp/temp.tdata', $ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ads
|
// Ads
|
||||||
$site_ads_rows = $conn->query('SELECT * FROM ads WHERE id = 1');
|
$site_ads_rows = $conn->query('SELECT * FROM ads WHERE id = 1');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
if (!defined('IN_PONEPASTE')) {
|
if (!defined('IN_PONEPASTE')) {
|
||||||
die();
|
die('This file may not be accessed directly.');
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once('config.php');
|
require_once('config.php');
|
||||||
|
@ -15,6 +15,43 @@ function getSiteLangAndTheme($conn) {
|
||||||
return $conn->query('SELECT lang, theme FROM interface LIMIT 1')->fetch();
|
return $conn->query('SELECT lang, theme FROM interface LIMIT 1')->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updatePageViews($conn) {
|
||||||
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
$date = date('jS F Y');
|
||||||
|
$data_ip = file_get_contents('tmp/temp.tdata');
|
||||||
|
|
||||||
|
$last_page_view = $conn->query('SELECT * FROM page_view ORDER BY id DESC LIMIT 1')->fetch();
|
||||||
|
$last_date = $last_page_view['date'];
|
||||||
|
|
||||||
|
if ($last_date == $date) {
|
||||||
|
if (str_contains($data_ip, $ip)) {
|
||||||
|
$last_tpage = intval($last_page_view['tpage']) + 1;
|
||||||
|
|
||||||
|
// IP already exists, Update view count
|
||||||
|
$statement = $conn->prepare("UPDATE page_view SET tpage = ? WHERE id = ?");
|
||||||
|
$statement->execute([$last_tpage, $last_page_view['id']]);
|
||||||
|
} else {
|
||||||
|
$last_tpage = intval($last_page_view['tpage']) + 1;
|
||||||
|
$last_tvisit = intval($last_page_view['tvisit']) + 1;
|
||||||
|
|
||||||
|
// Update both tpage and tvisit.
|
||||||
|
$statement = $conn->prepare("UPDATE page_view SET tpage = ?,tvisit = ? WHERE id = ?");
|
||||||
|
$statement->execute([$last_tpage, $last_tvisit, $last_page_view['id']]);
|
||||||
|
file_put_contents('tmp/temp.tdata', $data_ip . "\r\n" . $ip);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Delete the file and clear data_ip
|
||||||
|
unlink("tmp/temp.tdata");
|
||||||
|
|
||||||
|
// New date is created
|
||||||
|
$statement = $conn->prepare("INSERT INTO page_view (date, tpage, tvisit) VALUES (?, '1', '1')");
|
||||||
|
$statement->execute([$date]);
|
||||||
|
|
||||||
|
// Update the IP
|
||||||
|
file_put_contents('tmp/temp.tdata', $ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$conn = new PDO(
|
$conn = new PDO(
|
||||||
"mysql:host=$db_host;dbname=$db_schema;charset=utf8",
|
"mysql:host=$db_host;dbname=$db_schema;charset=utf8",
|
||||||
$db_user,
|
$db_user,
|
||||||
|
@ -64,5 +101,6 @@ if (isset($_GET['logout'])) {
|
||||||
unset($_SESSION['token']);
|
unset($_SESSION['token']);
|
||||||
unset($_SESSION['oauth_uid']);
|
unset($_SESSION['oauth_uid']);
|
||||||
unset($_SESSION['username']);
|
unset($_SESSION['username']);
|
||||||
|
unset($_SESSION['pic']);
|
||||||
session_destroy();
|
session_destroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -529,7 +529,7 @@ function embedView( $paste_id, $p_title, $p_conntent, $p_code, $title, $baseurl,
|
||||||
function addToSitemap($paste_id, $priority, $changefreq, $mod_rewrite)
|
function addToSitemap($paste_id, $priority, $changefreq, $mod_rewrite)
|
||||||
{
|
{
|
||||||
$c_date = date('Y-m-d');
|
$c_date = date('Y-m-d');
|
||||||
$site_data = file_get_conntents("sitemap.xml");
|
$site_data = file_get_contents("sitemap.xml");
|
||||||
$site_data = str_replace("</urlset>", "", $site_data);
|
$site_data = str_replace("</urlset>", "", $site_data);
|
||||||
// which protocol are we on
|
// which protocol are we on
|
||||||
$protocol = paste_protocol();
|
$protocol = paste_protocol();
|
||||||
|
@ -550,7 +550,7 @@ function addToSitemap($paste_id, $priority, $changefreq, $mod_rewrite)
|
||||||
</urlset>';
|
</urlset>';
|
||||||
|
|
||||||
$full_map = $site_data . $c_sitemap;
|
$full_map = $site_data . $c_sitemap;
|
||||||
file_put_conntents("sitemap.xml", $full_map);
|
file_put_contents("sitemap.xml", $full_map);
|
||||||
}
|
}
|
||||||
function paste_protocol() {
|
function paste_protocol() {
|
||||||
|
|
||||||
|
|
203
index.php
203
index.php
|
@ -24,53 +24,50 @@ if (file_exists($directory)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required functions
|
// Required functions
|
||||||
require_once('config.php');
|
|
||||||
require_once('includes/captcha.php');
|
require_once('includes/captcha.php');
|
||||||
require_once('includes/functions.php');
|
require_once('includes/functions.php');
|
||||||
|
define('IN_PONEPASTE', 1);
|
||||||
|
require_once('includes/common.php');
|
||||||
|
|
||||||
// PHP <5.5 compatibility
|
// PHP <5.5 compatibility
|
||||||
require_once('includes/password.php');
|
require_once('includes/password.php');
|
||||||
|
|
||||||
|
function calculatePasteExpiry($p_expiry) {
|
||||||
|
switch ($p_expiry) {
|
||||||
|
case '10M':
|
||||||
|
$expires = mktime(date("H"), date("i") + "10", date("s"), date("n"), date("j"), date("Y"));
|
||||||
|
break;
|
||||||
|
case '1H':
|
||||||
|
$expires = mktime(date("H") + "1", date("i"), date("s"), date("n"), date("j"), date("Y"));
|
||||||
|
case '1D':
|
||||||
|
$expires = mktime(date("H"), date("i"), date("s"), date("n"), date("j") + "1", date("Y"));
|
||||||
|
break;
|
||||||
|
case '1W':
|
||||||
|
$expires = mktime(date("H"), date("i"), date("s"), date("n"), date("j") + "7", date("Y"));
|
||||||
|
break;
|
||||||
|
case '2W':
|
||||||
|
$expires = mktime(date("H"), date("i"), date("s"), date("n"), date("j") + "14", date("Y"));
|
||||||
|
break;
|
||||||
|
case '1M':
|
||||||
|
$expires = mktime(date("H"), date("i"), date("s"), date("n") + "1", date("j"), date("Y"));
|
||||||
|
break;
|
||||||
|
case 'self':
|
||||||
|
$expires = "SELF";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$expires = "NULL";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $expires;
|
||||||
|
}
|
||||||
|
|
||||||
// UTF-8
|
// UTF-8
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
|
||||||
// Database Connection
|
|
||||||
$conn = new PDO(
|
|
||||||
"mysql:host=$db_host;dbname=$db_schema;charset=utf8",
|
|
||||||
$db_user,
|
|
||||||
$db_pass,
|
|
||||||
$db_opts
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Get site info
|
|
||||||
$site_info_rows = $conn->query('SELECT * FROM site_info');
|
|
||||||
while ($row = $site_info_rows->fetch()) {
|
|
||||||
$title = Trim($row['title']);
|
|
||||||
$des = Trim($row['des']);
|
|
||||||
$baseurl = Trim($row['baseurl']);
|
|
||||||
$keyword = Trim($row['keyword']);
|
|
||||||
$site_name = Trim($row['site_name']);
|
|
||||||
$email = Trim($row['email']);
|
|
||||||
$twit = Trim($row['twit']);
|
|
||||||
$face = Trim($row['face']);
|
|
||||||
$gplus = Trim($row['gplus']);
|
|
||||||
$ga = Trim($row['ga']);
|
|
||||||
$additional_scripts = Trim($row['additional_scripts']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set theme and language
|
|
||||||
$site_theme_rows = $conn->query('SELECT * FROM interface WHERE id="1"');
|
|
||||||
while ($row = $site_theme_rows->fetch()) {
|
|
||||||
$default_lang = Trim($row['lang']);
|
|
||||||
$default_theme = Trim($row['theme']);
|
|
||||||
}
|
|
||||||
require_once("langs/$default_lang");
|
|
||||||
|
|
||||||
// Current date & user IP
|
// Current date & user IP
|
||||||
$date = date('jS F Y');
|
$date = date('jS F Y');
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
$data_ip = file_get_contents('tmp/temp.tdata');
|
|
||||||
|
|
||||||
// Ads
|
// Ads
|
||||||
$site_ads_rows = $conn->query('SELECT * FROM ads WHERE id="1"');
|
$site_ads_rows = $conn->query('SELECT * FROM ads WHERE id="1"');
|
||||||
|
@ -113,16 +110,6 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if IP is banned
|
|
||||||
if ( is_banned($conn, $ip) ) die($lang['banned']); // "You have been banned from ".$site_name;
|
|
||||||
|
|
||||||
// Site permissions
|
|
||||||
|
|
||||||
$site_perms_rows = $conn->query("SELECT * FROM site_permissions where id='1'");
|
|
||||||
while ($row = $site_perms_rows->fetch()) {
|
|
||||||
$disableguest = Trim($row['disableguest']);
|
|
||||||
$siteprivate = Trim($row['siteprivate']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,92 +124,29 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logout
|
updatePageViews($conn);
|
||||||
if (isset($_GET['logout'])) {
|
|
||||||
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
|
||||||
unset($_SESSION['token']);
|
|
||||||
unset($_SESSION['oauth_uid']);
|
|
||||||
unset($_SESSION['username']);
|
|
||||||
unset($_SESSION['pic']);
|
|
||||||
session_destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Page views
|
|
||||||
$site_view_rows = $conn->query("SELECT @last_id := MAX(id) FROM page_view");
|
|
||||||
while ($row = $site_view_rows->fetch()) {
|
|
||||||
$last_id = $row['@last_id := MAX(id)'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$site_view_last = $conn->prepare("SELECT * FROM page_view WHERE id = ?");
|
|
||||||
$site_view_last->execute([$last_id]);
|
|
||||||
while ($row = $site_view_last->fetch()) {
|
|
||||||
$last_date = $row['date'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($last_date == $date) {
|
|
||||||
if (str_contains($data_ip, $ip)) {
|
|
||||||
$statement = $conn->prepare("SELECT * FROM page_view WHERE id = ?");
|
|
||||||
$statement->execute([$last_id]);
|
|
||||||
while ($row = $statement->fetch()) {
|
|
||||||
$last_tpage = Trim($row['tpage']);
|
|
||||||
}
|
|
||||||
$last_tpage = $last_tpage + 1;
|
|
||||||
|
|
||||||
// IP already exists, Update view count
|
|
||||||
$statement = $conn->prepare("UPDATE page_view SET tpage=? WHERE id = ?");
|
|
||||||
$statement->execute([$last_tpage,$last_id]);
|
|
||||||
} else {
|
|
||||||
$statement = $conn->prepare("SELECT * FROM page_view WHERE id = ?");
|
|
||||||
$statement->execute([$last_id]);
|
|
||||||
while ($row = $statement->fetch()) {
|
|
||||||
$last_tpage = Trim($row['tpage']);
|
|
||||||
$last_tvisit = Trim($row['tvisit']);
|
|
||||||
}
|
|
||||||
$last_tpage = $last_tpage + 1;
|
|
||||||
$last_tvisit = $last_tvisit + 1;
|
|
||||||
|
|
||||||
// Update both tpage and tvisit.
|
|
||||||
$statement = $conn->prepare("UPDATE page_view SET tpage = ?, tvisit = ? WHERE id = ?");
|
|
||||||
$statement->execute([$last_tpage,$last_tvisit,$last_id]);
|
|
||||||
file_put_contents('tmp/temp.tdata', $data_ip . "\r\n" . $ip);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Delete the file and clear data_ip
|
|
||||||
unlink("tmp/temp.tdata");
|
|
||||||
$data_ip = "";
|
|
||||||
|
|
||||||
// New date is created
|
|
||||||
$statement = $conn->prepare("INSERT INTO page_view (date,tpage,tvisit) VALUES (?,'1','1')");
|
|
||||||
$statement->execute([$date]);
|
|
||||||
// Update the IP
|
|
||||||
file_put_contents('tmp/temp.tdata', $data_ip . "\r\n" . $ip);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST Handler
|
// POST Handler
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
// Check if fields are empty
|
// Check if fields are empty
|
||||||
if (empty($_POST["paste_data"])) {
|
if (empty($_POST["paste_data"]) || trim($_POST['paste_data'] === '')) {
|
||||||
$error = $lang['empty_paste'];
|
$error = $lang['empty_paste'];
|
||||||
goto OutPut;
|
goto OutPut;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($_POST["tags"])) {
|
if (empty($_POST["tags"])) {
|
||||||
$error = $lang['notags'];
|
$error = $lang['notags'];
|
||||||
goto OutPut;
|
goto OutPut;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($_POST["title"]) > 70) {
|
if (strlen($_POST["title"]) > 70) {
|
||||||
$error = $lang['titlelen'];
|
$error = $lang['titlelen'];
|
||||||
goto OutPut;
|
goto OutPut;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// Check if fields are only white space
|
|
||||||
if (trim($_POST["paste_data"]) == '') {
|
|
||||||
$error = $lang['empty_paste'];
|
|
||||||
goto OutPut;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set our limits
|
// Set our limits
|
||||||
if (mb_strlen($_POST["paste_data"], '8bit') > 1024 * 1024 * $pastelimit) {
|
if (mb_strlen($_POST["paste_data"], '8bit') > 1024 * 1024 * $pastelimit) {
|
||||||
|
@ -232,7 +156,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check POST data status
|
// Check POST data status
|
||||||
if (isset($_POST['title']) And isset($_POST['paste_data'])) {
|
if (isset($_POST['title']) && isset($_POST['paste_data'])) {
|
||||||
if ($cap_e == "on" && !isset($_SESSION['username'])) {
|
if ($cap_e == "on" && !isset($_SESSION['username'])) {
|
||||||
if ($mode == "reCAPTCHA") {
|
if ($mode == "reCAPTCHA") {
|
||||||
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secretkey."&response=".$_POST['g-recaptcha-response']);
|
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secretkey."&response=".$_POST['g-recaptcha-response']);
|
||||||
|
@ -282,7 +206,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
}
|
}
|
||||||
$p_encrypt = Trim(htmlspecialchars($_POST['encrypted']));
|
$p_encrypt = Trim(htmlspecialchars($_POST['encrypted']));
|
||||||
|
|
||||||
if ($p_encrypt == "" || $p_encrypt == null) {
|
if (empty($p_encrypt)) {
|
||||||
$p_encrypt = "0";
|
$p_encrypt = "0";
|
||||||
} else {
|
} else {
|
||||||
// Encrypt option
|
// Encrypt option
|
||||||
|
@ -296,49 +220,22 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$p_member = "Guest";
|
$p_member = "Guest";
|
||||||
}
|
}
|
||||||
// Set expiry time
|
// Set expiry time
|
||||||
switch ($p_expiry) {
|
$expires = calculatePasteExpiry($p_expiry);
|
||||||
case '10M':
|
|
||||||
$expires = mktime(date("H"), date("i") + "10", date("s"), date("n"), date("j"), date("Y"));
|
|
||||||
break;
|
|
||||||
case '1H':
|
|
||||||
$expires = mktime(date("H") + "1", date("i"), date("s"), date("n"), date("j"), date("Y"));
|
|
||||||
case '1D':
|
|
||||||
$expires = mktime(date("H"), date("i"), date("s"), date("n"), date("j") + "1", date("Y"));
|
|
||||||
break;
|
|
||||||
case '1W':
|
|
||||||
$expires = mktime(date("H"), date("i"), date("s"), date("n"), date("j") + "7", date("Y"));
|
|
||||||
break;
|
|
||||||
case '2W':
|
|
||||||
$expires = mktime(date("H"), date("i"), date("s"), date("n"), date("j") + "14", date("Y"));
|
|
||||||
break;
|
|
||||||
case '1M':
|
|
||||||
$expires = mktime(date("H"), date("i"), date("s"), date("n") + "1", date("j"), date("Y"));
|
|
||||||
break;
|
|
||||||
case 'self':
|
|
||||||
$expires = "SELF";
|
|
||||||
break;
|
|
||||||
case 'N':
|
|
||||||
$expires = "NULL";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$expires = "NULL";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$p_title = mysqli_real_escape_string($con, $p_title);
|
|
||||||
$p_content = mysqli_real_escape_string($con, $p_content);
|
|
||||||
$p_date = date('jS F Y h:i:s A');
|
$p_date = date('jS F Y h:i:s A');
|
||||||
$date = date('jS F Y');
|
$date = date('jS F Y');
|
||||||
$now_time = mktime(date("H"), date("i"), date("s"), date("n"), date("j"), date("Y"));
|
$now_time = mktime(date("H"), date("i"), date("s"), date("n"), date("j"), date("Y"));
|
||||||
$timeedit = gmmktime(date("H"), date("i"), date("s"), date("n"), date("j"), date("Y"));
|
$timeedit = gmmktime(date("H"), date("i"), date("s"), date("n"), date("j"), date("Y"));
|
||||||
$p_tagsys = mysqli_real_escape_string($con, $p_tagsys);
|
|
||||||
$p_code = mysqli_real_escape_string($con, $p_code);
|
|
||||||
$p_visible = mysqli_real_escape_string($con, $p_visible);
|
|
||||||
// Edit existing paste or create new?
|
// Edit existing paste or create new?
|
||||||
if ( isset($_POST['edit'] ) ) {
|
if ( isset($_POST['edit'] ) ) {
|
||||||
if (isset($_SESSION['username'])) {
|
if (isset($_SESSION['username'])) {
|
||||||
$edit_paste_id = $_POST['paste_id'];
|
$edit_paste_id = $_POST['paste_id'];
|
||||||
$statement = $conn->prepare("UPDATE pastes SET title=?,content=?,visible=?,code=?,expiry=?,password=?,encrypt=?,member=?,ip=?,tagsys=?,now_time=? ,timeedit=? WHERE id = '?'");
|
$statement = $conn->prepare(
|
||||||
$statement->execute([$p_title,$p_content,$p_visible,$p_code,$expires,$p_password,$p_encrypt,$p_member,$ip,$p_tagsys,$now_time,$timeedit,$edit_paste_id]);
|
"UPDATE pastes SET title = ?,content = ?,visible = ?,code=?,expiry=?,password=?,encrypt=?,member=?,ip=?,tagsys=?,now_time=? ,timeedit=? WHERE id = '?'"
|
||||||
|
);
|
||||||
|
|
||||||
|
$statement->execute([$p_title,$p_content,$p_visible,$p_code,$expires,$p_password,$p_encrypt,$p_member,$ip,$p_tagsys,$now_time,$timeedit,$edit_paste_id]);
|
||||||
}}
|
}}
|
||||||
else {
|
else {
|
||||||
$statement = $conn->prepare("INSERT INTO pastes (title,content,visible,code,expiry,password,encrypt,member,date,ip,now_time,views,s_date,tagsys) VALUES
|
$statement = $conn->prepare("INSERT INTO pastes (title,content,visible,code,expiry,password,encrypt,member,date,ip,now_time,views,s_date,tagsys) VALUES
|
||||||
|
@ -346,11 +243,9 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$statement->execute([$p_title,$p_content,$p_visible,$p_code,$expires,$p_password,$p_encrypt,$p_member,$p_date,$ip,$now_time,$date,$p_tagsys]);
|
$statement->execute([$p_title,$p_content,$p_visible,$p_code,$expires,$p_password,$p_encrypt,$p_member,$p_date,$ip,$now_time,$date,$p_tagsys]);
|
||||||
|
|
||||||
}
|
}
|
||||||
$get_last = $conn->prepare( "SELECT @last_id := MAX(id) FROM pastes");
|
$paste_id = $conn->query('SELECT MAX(id) FROM pastes')->fetch(PDO::FETCH_NUM)[0];
|
||||||
while ($row = $get_last->fetch()) {
|
|
||||||
$paste_id = $row['@last_id := MAX(id)'];
|
|
||||||
}
|
|
||||||
$success = $paste_id;
|
$success = $paste_id;
|
||||||
|
|
||||||
if ($p_visible == '0') {
|
if ($p_visible == '0') {
|
||||||
addToSitemap($paste_id, $priority, $changefreq, $mod_rewrite);
|
addToSitemap($paste_id, $priority, $changefreq, $mod_rewrite);
|
||||||
}
|
}
|
||||||
|
|
46495
sitemap.xml
46495
sitemap.xml
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue