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

View File

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