Fixed adding of links without http

This commit is contained in:
ivan 2017-10-01 10:47:08 +03:00
parent 04107d6628
commit 8ebd1c6396
2 changed files with 17 additions and 9 deletions

View File

@ -24,7 +24,7 @@ function SaveEntries() {
global $AdminEntries; global $AdminEntries;
$fhandle=fopen($GBdata,"w"); $fhandle=fopen($GBdata,"w");
foreach($AdminEntries as $e=>$Entry) { foreach($AdminEntries as $e=>$Entry) {
unset($Entry[10]); $Entry[10]="";
fputcsv($fhandle,$Entry); fputcsv($fhandle,$Entry);
} }
fclose($fhandle); fclose($fhandle);
@ -246,7 +246,7 @@ if ($_SESSION["SessionStatus"]==(md5($GBadmin.$GBpassword))) {
SaveEntries(); SaveEntries();
Unset($_SESSION["EditStatus"]); Unset($_SESSION["EditStatus"]);
$AdminEntries=ReadEntries(); $AdminEntries=ReadEntries();
} if ($_SESSION["DeleteStatus"]) { } if (isset($_SESSION["DeleteStatus"])) if ($_SESSION["DeleteStatus"]) {
foreach($_SESSION["DeleteEntries"] as $e=>$DelEnt) Unset($AdminEntries[$DelEnt]); foreach($_SESSION["DeleteEntries"] as $e=>$DelEnt) Unset($AdminEntries[$DelEnt]);
SaveEntries(); SaveEntries();
Unset($_SESSION["DeleteEntries"]); Unset($_SESSION["DeleteEntries"]);

View File

@ -61,6 +61,13 @@ function CheckFile() {
} else return false; } else return false;
} }
function AddHttp($Link) {
if (!preg_match("~^(?:f|ht)tps?://~i",$Link)) {
$Link = "http://".$Link;
}
return $Link;
}
function AddEntry() { function AddEntry() {
global $GBdata; global $GBdata;
global $Titles; global $Titles;
@ -78,8 +85,8 @@ function AddEntry() {
else $NewEntry["from"]=strip_tags($_POST["from"]); else $NewEntry["from"]=strip_tags($_POST["from"]);
} else $NewEntry["from"]=""; } else $NewEntry["from"]="";
if ($GBlinkfield) { if ($GBlinkfield) {
if (!$GBstriptags) $NewEntry["link"]=$_POST["link"]; if (!$GBstriptags) $NewEntry["link"]=AddHttp($_POST["link"]);
else $NewEntry["link"]=strip_tags($_POST["link"]); else $NewEntry["link"]=AddHttp(strip_tags($_POST["link"]));
} else $NewEntry["link"]=""; } else $NewEntry["link"]="";
$NewEntry["email"]=$_POST["email"]; $NewEntry["email"]=$_POST["email"];
if (!$GBstriptags) $NewEntry["text"]=$_POST["text"]; if (!$GBstriptags) $NewEntry["text"]=$_POST["text"];
@ -96,7 +103,10 @@ function AddEntry() {
if (isset($_SESSION["reply"])) { if (isset($_SESSION["reply"])) {
$NewEntry["reply"]=$_SESSION["reply"][5]; $NewEntry["reply"]=$_SESSION["reply"][5];
unset($_SESSION["reply"]); unset($_SESSION["reply"]);
} } else $NewEntry["reply"]="";
$NewEntry["number"]="";
$NewEntry["lock"]="";
$NewEntry["sticky"]="";
$fhandle=fopen($GBdata,"a"); $fhandle=fopen($GBdata,"a");
fputcsv($fhandle,$NewEntry); fputcsv($fhandle,$NewEntry);
fclose($fhandle); fclose($fhandle);
@ -248,11 +258,9 @@ function EntriesView() {
} }
if ($GBreplies) { if ($GBreplies) {
$EntriesReplySorted=$Entries; $EntriesReplySorted=$Entries;
foreach($Entries as $Entry) { if (isset($Entries)) foreach($Entries as $Entry) {
if (isset($Entry[9])) { if (isset($Entry[9])) {
foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[5]) { foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[5]) $a=$n;
$a=$n;
}
foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[9]) $b=$n; foreach($EntriesReplySorted as $n=>$EntrySort) if ($EntrySort[5]==$Entry[9]) $b=$n;
if (isset($b)) { if (isset($b)) {
$out=array_splice($EntriesReplySorted, $a, 1); $out=array_splice($EntriesReplySorted, $a, 1);