File: /var/www/web37/htdocs/topsex/inc/functions.php
<?php
############################################
### Top-XL - Topsite Language File English lang/en.php
############################################
/// 1. You are NOT entiteld to rent, lease, transfer, reproduce or distribute this Software.
/// 2. You are entiteld to adapt, and modify the Software to your need.
/// 3. You can use this Script on all of YOUR Domains.
/// 4. Any modification or removal to the links in the footer and member area shall terminate this license immediately .
/// 5. The Script has been tested on different Servers and found free of any notable errors by the author. The Author shall not in any case be liable for any special, incidental indirect or other similar damages arising from the use of this Script.
/// 6. Author: Simon Zehender - Contact: https://www.paddelberg.de
////////////////////////////////////////////
////////////////////////////////////////////
if ($scriptpath!=$_SERVER['DOCUMENT_ROOT'])
{
echo "Are you looking for something?";
exit;
}
function safety($var)
{return strip_tags (addslashes($var));}
function safe_subject($subject)//// für subject, email, alles was nur eine zeile hat
{
$subject=preg_replace("/(%0A|%0D|\\n+|\\r+)/i"," ",$subject);
$subject=preg_replace( "/[^a-z0-9 !?:;,.\/_\-=+@#$&\*\(\)]/im"," ",$subject);
$subject=preg_replace( "/(content-type:|bcc:|cc:|to:|from:)/im"," ",$subject);
return $subject;
}
function safe_body($body) /// nur für Body und alles, was mehrere Zeilen hat
{return preg_replace("/(content-type:|bcc:|cc:|to:|from:)/im"," ",$body);}
function get_lang($stanlang)
{
$lang = !empty ($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ? substr (safety ($_SERVER["HTTP_ACCEPT_LANGUAGE"]), 0, 2) : '';
return empty ($lang) ? $stanlang : $lang;
}
function get_lang_file($language,$stanlang,$langarray,$langdetect)
{
if ($langdetect=="no")
{return $stanlang;}
$langarray=explode(",",$langarray);
$max=count($langarray);
for($i=0;$i<$max;$i++)
{
if ($langarray[$i]==$language)
{return $langarray[$i];}
}
return $stanlang;
}
function bannerhtmlgen($id,$topxl_admin_table,$topsiteurl,$topbannerurl,$linktitle,$filename,$text_banner,$htmlcodescript,$text_preview,$recipcodebanner,$db)
{
$recicodebanner = recipcodebanner($id,$topxl_admin_table,$topsiteurl,$topbannerurl,$linktitle,$filename,$recipcodebanner,$db);
$recicodebannerhtml = htmlentities($recicodebanner);
$recicodebanner1 = recipcodebanner("none",$topxl_admin_table,$topsiteurl,$topbannerurl,$linktitle,$filename,$recipcodebanner,$db);
$main_content = "<br><strong>".$text_banner."</strong><br>
<textarea name=\"textarea\" style=\"width:95%;height:100px;\">".$htmlcodescript."\n".$recicodebannerhtml."</textarea>
<br><br>".$text_preview.":<br>".$recicodebanner1."<br>";
return $main_content;
}
function texthtmlgen($id,$topxl_admin_table,$topsiteurl,$linktitle,$filename,$text_textlink,$htmlcodescript,$text_preview,$recicodetext,$db) # ,$recicodetext
{
$recicodetexthtml = htmlentities(recipcodetext($id,$topxl_admin_table,$topsiteurl,$linktitle,$filename,$recicodetext,$db));
$recicodetext1 = recipcodetext("none",$topxl_admin_table,$topsiteurl,$linktitle,$filename,$recicodetext,$db);
$main_content = "
<br><strong>".$text_textlink."</strong><br>
<textarea name=\"textarea\" style=\"width:95%;height:100px;\">".$htmlcodescript."\n".$recicodetexthtml."</textarea>
<br><br>".$text_preview.":<br>".$recicodetext1."<br>";
return $main_content;
}
function get_dom($url)
{
$url=parse_url($url);
$url=$url["host"];
$check=explode(".",$url);
$max=count($check);
if($max>2)
{$url=substr(strstr($url,"."),1);}
return $url;
}
function check_multiaccount($email, $topxl_user_table, $db)
{
$db -> query ("SELECT id FROM ".$topxl_user_table." WHERE email='".$email."'");
if ($db -> numRows () > "1")
{return 1;}
else
{return 0;}
}
function count_hits($topxl_user_table, $db)
{
$db -> query ("SELECT sum(hitintotal) AS tisumme,sum(hitouttotal) AS tosumme, sum(hitin) AS insumme,sum(hitout) AS outsumme FROM ".$topxl_user_table." WHERE active='yes'");
$counthitsrow = $db -> fetch ();
return $counthitsrow;
}
function recipcodetext($id,$topxl_admin_table,$topsiteurl,$linktitle,$filename,$recipcodetext,$db)
{
if ($filename == "index.php")
{$filename = "";}
$clickevent = $id != "none" ? "onmousedown=\"return hit('".$topsiteurl."/in.php?id=".$id."')\"" : '';
$recicodetext = str_replace("{topsiteurl}", $topsiteurl."/".$filename, $recipcodetext);
$recicodetext = str_replace("{linktitle}", $linktitle, $recicodetext);
$recicodetext = str_replace("{clickevent}", $clickevent, $recicodetext);
return $recicodetext;
}
function recipcodebanner($id,$topxl_admin_table,$topsiteurl,$topbannerurl,$linktitle,$filename,$recipcodebanner,$db)
{
if ($filename == "index.php")
{$filename = "";}
$clickevent = $id != "none" ? "onmousedown=\"return hit('".$topsiteurl."/in.php?id=".$id."')\"" : '';
$recicodebanner = str_replace("{topsiteurl}", $topsiteurl."/".$filename, $recipcodebanner);
$recicodebanner = str_replace("{linktitle}", $linktitle, $recicodebanner);
$recicodebanner = str_replace("{topsitebannerurl}", $topbannerurl, $recicodebanner);
$recicodebanner = str_replace("{clickevent}", $clickevent, $recicodebanner);
return $recicodebanner;
}
function slashcheck($url)
{
$result = 1; /// Dateiname vorhanden
if (!preg_match("@\.htm|\.html|\.php|\.asp|\.swf|\.cgi|\.shtml@i",$url))
{
$url_info = parse_url($url);
$result = 2; /// kein Dateiname und slash am ende
if (empty ($url_info['query']))
{
$urlcheck = substr (strrchr ($url, "/"), 1 );
if ($urlcheck and $urlcheck != '/')
{$result = 3;} /// kein Dateiname und kein slash am ende
}
}
return $result;
}
function validateEmail ($email)
{
if (function_exists ('filter_var'))
{return (filter_var ($email, FILTER_VALIDATE_EMAIL) === false) ? false : true;}
else # reEx from http://hexillion.com/samples/#Regex
{return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $email);}
}
function html_special_chars ($var)
{return htmlspecialchars ($var, ENT_COMPAT, 'UTF-8', false);}
?>