" . $eval_string . "\n";
break;
case "smalltext_cn_1":
echo "
".$label."
" . $eval_string . "\n";
break;
case "smalltext_cn_2_error":
echo "
" . $eval_string . "\n";
break;
case "smalltext_cn_2":
echo "
" . $eval_string . "\n";
break;
case "file":
echo "
".$label."
\n";
break;
case "checkbox":
$checked_text = ($value == "on") ? "checked=\"checked\"" : "";
echo "
".$name."
\n";
break;
case "checkbox_action":
$checked_text = ($value == "on") ? "checked=\"checked\"" : "";
echo "
".$name."
\n";
break;
case "checkbox_shop":
$checked_text = ($value == "on") ? "checked=\"checked\"" : "";
echo "
".$name."
\n";
break;
case "checkbox_with_formreload":
$checked_text = ($value) ? "checked=\"checked\"" : "";
echo "
".$name."
\n";
break;
case "checkbox_with_formreload_checked":
$checked_text = ($value) ? "checked=\"checked\"" : "";
echo "
".$name."
\n";
break;
case "password":
echo "
".$label."
\n";
break;
case "date":
echo "
".$label."
\n";
break;
case "input_pref_delivery_date":
echo "
".$label."
\n";
break;
default:
echo "
".$label." " . $eval_string . "
\n";
break;
}
}
function text( $name, $value ) {
echo "
" . $name . "
";
echo "
\n";
}
function input_select( $name, $inputname, $values, $value_names, $preselect = "", $disabled = FALSE, $auto_update = FALSE, $onchange = "" ) {
$disabled_text = ($disabled) ? " disabled=\"disabled\"" : "";
$autoupdate_text = ($auto_update) ? " onchange=\"this.form.submit();\"" : "";
echo "
" . $name . "
";
echo "
\n\t\n";
FOR ($i = 0; $i < count($values); $i++) {
echo "\t\t" . $value_names[$i] . " \n";
}
echo "\t \n
\n";
}
function input_select_from_sql($name, $inputname, $query, $preselect = "", $disabled = FALSE, $auto_update = FALSE, $onchange = "", $withEmpty = FALSE ) {
$disabled_text = ($disabled) ? " disabled=\"disabled\"" : "";
$autoupdate_text = ($auto_update) ? " onchange=\"this.form.submit();\"" : "";
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
echo "
" . $name . "
";
echo "
\n\t\n";
if($withEmpty){
echo "--- ";
}
while($res = @mysqli_fetch_array($result)) {
echo "\t\t" . $res['name'] . " \n";
}
echo "\t \n
\n";
}
function input_select_from_sql_bereich($name, $inputname, $query, $preselect = "", $disabled = FALSE, $auto_update = FALSE, $onchange = "", $withEmpty = FALSE ) {
$disabled_text = ($disabled) ? " disabled=\"disabled\"" : "";
$autoupdate_text = ($auto_update) ? " onchange=\"this.form.submit();\"" : "";
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
echo "
" . $name . "
";
echo "
\n\t\n";
if($withEmpty){
echo "--- ";
}
while($res = @mysqli_fetch_array($result)) {
echo "\t\t" . $res['description'] . " \n";
}
echo "\t \n
\n";
}
function input_select_from_sql_mandant($name, $inputname, $query, $preselect = "", $disabled = FALSE, $auto_update = FALSE, $onchange = "", $withEmpty = FALSE ) {
$disabled_text = ($disabled) ? " disabled=\"disabled\"" : "";
$autoupdate_text = ($auto_update) ? " onchange=\"this.form.submit();\"" : "";
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
echo "
" . $name . "
";
echo "
\n\t\n";
if($withEmpty){
echo "--- ";
}
while($res = @mysqli_fetch_array($result)) {
echo "\t\t" . $res['description'] . " \n";
}
echo "\t \n
\n";
}
function input_select_from_sql_ein($name, $inputname, $query, $preselect = "", $disabled = FALSE, $auto_update = FALSE, $onchange = "", $withEmpty = FALSE ) {
$disabled_text = ($disabled) ? " disabled=\"disabled\"" : "";
$autoupdate_text = ($auto_update) ? " onchange=\"this.form.submit();\"" : "";
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
echo "
" . $name . "
";
echo "
\n\t\n";
if($withEmpty){
echo "--- ";
}
while($res = @mysqli_fetch_array($result)) {
echo "\t\t" . $res['description'] . " \n";
}
echo "\t \n
\n";
}
// Gibt die Meta-Tags der aktuellen Navigation als DIV-Boxen zurück
function get_search_tags( $navigation = '' ) {
if ($navigation == '') {
$navigation = $GLOBALS["navigation"];
}
if ($navigation["search_tags"] <> '') {
echo "
\n";
$search_tags = explode(",", $navigation["meta_keywords"]);
foreach ($search_tags as $value) {
echo "" . $value . " \n";
}
echo "
\n";
}
}
// Prüft ob das Projekt lokal oder auf dem Webserver läuft
function local_environment() {
return ((strtoupper(substr(php_uname('s'), 0, 3)) === 'WIN'));
}
function show_ck_editor( $content, $style, $css_path, $style_path, $name = "textcontent" ) {
$path = realpath(__DIR__ . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'Registry.php');
if (file_exists($path)) {
require_once($path);
}
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
if ($style == "dc") {
echo("
");
} elseif ($style == "minimal") {
echo("
");
} else {
echo("
");
}
}
//Gibt Längen- und Breitengrad als Array für als String mitgelieferte Adresse aus
function geoencode( $adress ) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://maps.google.com/maps/api/geocode/json?address=" . urlencode($adress) . "&sensor=false");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$json_data = curl_exec($ch);
$json_array = json_decode($json_data, TRUE);
$latlng_array = $json_array['results'][0]['geometry']['location'];
return $latlng_array;
}
//Value von Checkboxen in 1 oder 0 umwandeln
function change_checkboxval_to_bool( $var ) {
if ($var == "on") {
return 1;
} else {
return 0;
}
}
function create_meta_tags() {
$pageData = $GLOBALS["page"];
// Meta-Daten aus Sprache füllen
$site_title = $GLOBALS["navigation"]['menu_name'];
$meta_description = $GLOBALS["language"]["meta_description"];
$meta_keywords = $GLOBALS["language"]["meta_keywords"];
if(isset($_GET['collection_id']) && (int)$_GET['collection_id'] > 0) {
$query = "SELECT description FROM main_collection where id = '" . $_GET['collection_id']."'";
$result = @mysqli_query($GLOBALS['mysql_con'],$query);
$row = @mysqli_fetch_array($result);
$pageData['subtitle'] = $row['description'];
$GLOBALS["page"]["subtitle"] = $row['description'];
}
// Meta-Daten aus Navigation füllen
if ($pageData['subtitle'] != "") {
$site_title = $pageData['subtitle'];
if ($GLOBALS["language"]["site_title_name"] <> '') {
$site_title .= ' - ' . $GLOBALS["language"]["site_title_name"];
}
}
if ($pageData["meta_description"] <> '') {
$meta_description = $pageData["meta_description"];
}
if ($pageData["meta_keywords"] <> '') {
$meta_keywords = $pageData["meta_keywords"];
}
// Meta-Daten für News füllen
/*
$query = "SELECT * FROM main_navigation_has_sitepart WHERE main_navigation_id = ". $navigation["id"] . " AND main_sitepart_id = 2 LIMIT 1";
$result = @mysqli_query($GLOBALS['mysql_con'],$query);
if (@mysqli_num_rows($result) == 1) {
$navigation_has_sitepart = @mysqli_fetch_array($result);
if ($_GET["news" . $navigation_has_sitepart["id"]] <> '') {
$query = "SELECT * FROM news_entry WHERE id = ". $_GET["news" . $navigation_has_sitepart["id"]] . " LIMIT 1";
$result = @mysqli_query($GLOBALS['mysql_con'],$query);
if (@mysqli_num_rows($result) == 1) {
$news = @mysqli_fetch_array($result);
if ($news["headline"] <> '') {
$site_title = $news["headline"];
if ($GLOBALS["language"]["site_title_name"] <> '') {
$site_title .= ' - ' . $GLOBALS["language"]["site_title_name"];
}
}
if ($news["summary"] <> '') {
$news["summary"] = str_replace("\n", "", $news["summary"]);
$news["summary"] = str_replace("\r", "", $news["summary"]);
$meta_description = $news["summary"];
}
if ($news["meta_keywords"] <> '') {
$meta_keywords = $news["meta_keywords"];
}
}
}
}
*/
//Metadaten nur für Shop
if (is_array($GLOBALS['shop'])) {
set_global_metadata_shop();
if(strlen($GLOBALS['site_title']) > 0) {
$site_title = $GLOBALS['site_title'];
}
if(strlen($GLOBALS['meta_description']) > 0) {
$meta_description = $GLOBALS['meta_description'];
$meta_description = html_entity_decode($meta_description);
$meta_description = preg_replace("!\s+!",' ',$meta_description);
$meta_description = htmlentities($meta_description);
}
if(strlen($GLOBALS['meta_keywords']) > 0) {
$meta_keywords = $GLOBALS['meta_keywords'];
}
}
if ($site_title <> '') {
echo "
" . $site_title . " \n";
}
if($GLOBALS["page"]['no_index']){
echo '
';
}
if ($meta_keywords <> '') {
$GLOBALS["meta_keywords"] = $meta_keywords;
echo "
\n";
}
if ($meta_description <> '') {
echo "
\n";
}
}
function documents_insert(){
$name_value = array(
"II Führung und Organisation Teil 1" => "Teil II (Führung und Organisation)",
"II Führung und Organisation Teil 2" => "Teil II (Führung und Organisation)",
"III Ganztag" => "Teil III (Ganztag)",
"III HzE" => "Teil III (HZE)",
"III Kita" => "III Kita",
"III Landesgeschäftsstelle" => "Teil III (Landesgeschäftsstelle)",
"III OKJA Beratung" => "Teil III (OKJA/Beratung)",
"Index" => "Index Übersicht",
);
$dir = "../../userdata/03_Module/01_Firmenwiki/AWO Wiki";
$directories = scandir($dir);
foreach($directories as $file) {
if ($file != "." && $file != ".." && $name_value[$file] !== null) {
$file_dir = "../../userdata/03_Module/01_Firmenwiki/AWO Wiki/".$file."/".$file;
$file_directory = scandir($file_dir);
foreach ($file_directory as $file_name) {
if ($file_name != "." && $file_name != "..") {
// echo $file_name . "
";
$file_info = pathinfo($file_dir."/".$file_name);
$desc_collection = $file_name;
$time = time();
$extension = $file_info['extension'];
$file_sql_name = "03_Module/01_Firmenwiki/AWO Wiki/".$file."/".$file."/".$file_name;
$category = $name_value[$file];
@mysqli_query($GLOBALS['mysql_con'], "CALL documentsInsert('".$desc_collection."', '".$time."', '".$extension."', '".$file_sql_name."', '".$file_sql_name."', '".$category."');");
// echo $desc_collection."".$time."".$extension."".$file_sql_name."".$category."===========";
}
}
}
}
}
function set_global_meta_tag_content_site() {
$pageData = $GLOBALS["page"];
// Meta-Daten aus Sprache füllen
$site_title = $GLOBALS["navigation"]['menu_name'];
$meta_description = $GLOBALS["language"]["meta_description"];
$meta_keywords = $GLOBALS["language"]["meta_keywords"];
if(isset($_GET['collection_id']) && (int)$_GET['collection_id'] > 0) {
$query = "SELECT description FROM main_collection where id = '" . $_GET['collection_id']."'";
$result = @mysqli_query($GLOBALS['mysql_con'],$query);
$row = @mysqli_fetch_array($result);
$pageData['subtitle'] = $row['description'];
$GLOBALS["page"]["subtitle"] = $row['description'];
}
// Meta-Daten aus Navigation füllen
if ($pageData['subtitle'] != "") {
$site_title = $pageData['subtitle'];
if ($GLOBALS["language"]["site_title_name"] <> '') {
$site_title .= ' - ' . $GLOBALS["language"]["site_title_name"];
}
}
if ($pageData["meta_description"] <> '') {
$meta_description = $pageData["meta_description"];
}
if ($pageData["meta_keywords"] <> '') {
$meta_keywords = $pageData["meta_keywords"];
}
// Meta-Daten für News füllen
/*
$query = "SELECT * FROM main_navigation_has_sitepart WHERE main_navigation_id = ". $navigation["id"] . " AND main_sitepart_id = 2 LIMIT 1";
$result = @mysqli_query($GLOBALS['mysql_con'],$query);
if (@mysqli_num_rows($result) == 1) {
$navigation_has_sitepart = @mysqli_fetch_array($result);
if ($_GET["news" . $navigation_has_sitepart["id"]] <> '') {
$query = "SELECT * FROM news_entry WHERE id = ". $_GET["news" . $navigation_has_sitepart["id"]] . " LIMIT 1";
$result = @mysqli_query($GLOBALS['mysql_con'],$query);
if (@mysqli_num_rows($result) == 1) {
$news = @mysqli_fetch_array($result);
if ($news["headline"] <> '') {
$site_title = $news["headline"];
if ($GLOBALS["language"]["site_title_name"] <> '') {
$site_title .= ' - ' . $GLOBALS["language"]["site_title_name"];
}
}
if ($news["summary"] <> '') {
$news["summary"] = str_replace("\n", "", $news["summary"]);
$news["summary"] = str_replace("\r", "", $news["summary"]);
$meta_description = $news["summary"];
}
if ($news["meta_keywords"] <> '') {
$meta_keywords = $news["meta_keywords"];
}
}
}
}
*/
if ($site_title <> '') {
$GLOBALS['site_title'] = $site_title;
} else {
$GLOBALS['site_title'] = NULL;
}
if ($meta_keywords <> '') {
$GLOBALS["meta_keywords"] = $meta_keywords;
} else {
$GLOBALS["meta_keywords"] = NULL;
}
if ($meta_description <> '') {
$GLOBALS['meta_description'] = $meta_description;
} else {
$GLOBALS['meta_description'] = NULL;
}
}
//warenkorb zwischenseite "Lightbox"
function get_shadow_queue() {
$body = "";
if ($_GET["action"] == "shop_add_item_to_basket_card" || $_GET["action"] == "shop_add_item_to_basket_list" || $_GET["action"] == "shop_add_item_to_basket") {
$body = "
";
}
return $body;
}
function is_item_no( $string ) {
$pattern = '/^[0-9]+-?[0-9]*$/';
$result = preg_match($pattern, $string);
if ($result === 1) {
return TRUE;
} else {
return FALSE;
}
}
function cologne_phon( $word ) {
$query = 'SELECT cologne_phon(\'' . mysqli_real_escape_string($GLOBALS['mysql_con'],trim($word)) . '\')';
$result = @mysqli_query($GLOBALS['mysql_con'],$query);
$cologne_phon = @mysqli_result($result);
if(strlen($cologne_phon) > 0) {
$return_value = preg_replace('!\s+!', ' ', $cologne_phon);
return $return_value;
}
/**
* @param string $word string to be analyzed
*
* @return string $value represents the Kölner Phonetik value
* @access public
*/
// prepare for processing
$value = array();
$value_2 = array();
$value_3 = array();
$word = strtolower($word);
$substitution = array(
"ä" => "a",
"ö" => "o",
"ü" => "u",
"ß" => "ss",
"ph" => "f",
" " => "|"
);
foreach ($substitution as $letter => $subst) {
$word = str_replace($letter, $subst, $word);
}
$len = strlen($word);
// Rule for exeptions
$exceptionsLeading1 = array(
4 => array("ca", "ch", "ck", "cl", "co", "cq", "cu", "cx")
);
$exl1 = array("ca", "ch", "ck", "cl", "co", "cq", "cu", "cx");
$exceptionsLeading2 = array(
8 => array("dc", "ds", "dz", "tc", "ts", "tz")
);
$exl2 = array("dc", "ds", "dz", "tc", "ts", "tz");
$exceptionsLeading3 = array(
4 => array("ac,ak,ec,ek,ic,ik,oc,ok,uc,uk")
);
$exl3 = array("ac,ak,ec,ek,ic,ik,oc,ok,uc,uk");
$exceptionsFollowing = array("sc", "zc", "cx", "kx", "qx");
//Table for coding
$codingTable = array(
0 => array("a", "e", "i", "j", "o", "u", "y"),
1 => array("b", "p"),
2 => array("d", "t"),
3 => array("f", "v", "w"),
4 => array("c", "g", "k", "q"),
48 => array("x"),
5 => array("l"),
6 => array("m", "n"),
7 => array("r"),
8 => array(),
9 => Array("h")
);
for ($i = 0; $i < $len; $i++) {
$rank = "";
$sl = $word[$i];
if (isset($word[$i + 1])) {
$dl = $word[$i] . $word[$i + 1];
} else {
$dl = $word[$i];
}
//DL-Handling
if (strlen($dl) == 2) {
//Leading
if (($i == 0 && $dl == 'cr') || (in_array($dl, $exl1))) {
$value[$i] = 4;
}
if (in_array($dl, $exl2)) {
$value[$i] = 8;
}
if ($i > 0 && (in_array($dl, $exl3))) {
$value[$i] = 4;
}
//Following
if ($i > 0 && (in_array($word[$i - 1] . $word[$i], $exceptionsFollowing))) {
$value[$i] = 8;
}
}
// normal encoding
if (empty($value[$i])) {
foreach ($codingTable as $code => $letters) {
if (in_array($word[$i], $letters)) {
$value[$i] = $code;
}
}
}
if (in_array($sl, array('c', 's', 'z')) && ((isset($word[$i - 1])) && !(in_array($word[$i - 1], array('a', 'e', 'i', 'o', 'u'))))) {
$value[$i] = 8;
}
//Space
if ($word[$i] == '|') {
$value[$i] = '|';
}
}
// delete double values
$len = count($value);
for ($i = 1; $i < $len; $i++) {
if ($i > 1 && isset($value[$i - 1]) && $value[$i] == $value[$i - 1]) {
$value[$i] = "";
}
}
foreach ($value as $key => $value1) {
if (isset($value1) && ($value1 == 0 || $value1 != '')) {
$value_2[] = $value1;
}
}
$len = count($value_2);
// delete vocals
for ($i = 1; $i < $len; $i++) {
// omitting first characer code and h
if (($value_2[$i] === 0 || $value_2[$i] === 9) && ($i !== 0) && ($value_2[$i - 1] !== '|')) {
$value_2[$i] = "";
}
}
$res_arr = array();
$z = 0;
$value_3 = array();
foreach ($value_2 as $key => $value) {
if (isset($value) && $value == 0 || $value != '') {
$value_3[] = $value;
}
}
for ($i = 0; $i < count($value_3); $i++) {
if ($value_3[$i] === '|') {
$res_arr[$z] = ' ';
$z++;
} elseif (preg_match('/[0-9]/', $value_3[$i])) {
$res_arr[$z] = $value_3[$i];
if ($res_arr[$z] == 0 && $z === 0) {
$res_arr[$z] = 9;
}
$z++;
}
}
foreach ($res_arr as $key => &$value) {
if ($value == 0) {
$value = '';
}
}
unset($value);
$res_arr2 = array();
foreach ($res_arr as $key => &$value2) {
if ((int)$value > 0) {
$res_arr2[] = $value2;
}
}
unset($value2);
$res_arr2 = array_filter($res_arr2);
for ($i = 0; $i < count($res_arr2); $i++) {
if ($res_arr2[$i] == 9) {
$res_arr2[$i] = 0;
}
if ($i > 0 && $res_arr2[$i] === $res_arr2[$i - 1]) {
$res_arr2[$i] = '';
}
}
$res_arr2 = implode("", $res_arr2);
return $res_arr2;
}
function get_number_matches( $search_term ) {
$add_query_num = '';
$query = "SELECT *
FROM shop_item_cross_reference
WHERE item_reference_no like '%" . $search_term . "%'
AND (customer_no = '" . $GLOBALS["shop_customer"]["customer_no"] . "' OR customer_no='')
AND company ='" . $GLOBALS['shop']['company'] . "'
";
$result = mysqli_query($GLOBALS['mysql_con'], $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_assoc($result)) {
$add_query_num .= " OR shop_view_active_item.item_no LIKE '%" . $row['item_no'] . "%'";
}
}
$number_query = "
SELECT shop_view_active_item.*
FROM shop_view_active_item
WHERE
shop_view_active_item.company = '" . $GLOBALS["shop"]["company"] . "'
AND
shop_view_active_item.shop_code = '" . $GLOBALS["shop"]["code"] . "'
AND
shop_view_active_item.language_code = '" . $GLOBALS["shop_language"]["code"] . "'
AND
shop_view_active_item.item_no LIKE '%" . $search_term . "%'
OR
shop_view_active_item.ean_no LIKE '%" . $search_term . "%'
" . $add_query_num . "
GROUP BY shop_view_active_item.item_no";
$result = @mysqli_query($GLOBALS['mysql_con'], $number_query);
$search_string = "";
$sort_string = "";
if (@mysqli_num_rows($result) > 0) {
$search_string = "(";
$z = 0;
while ($item = @mysqli_fetch_assoc($result)) {
if ($z === 0) {
$search_string .= " shop_item.id=" . $item["id"];
} else {
$search_string .= " OR shop_item.id=" . $item["id"];
}
$z++;
}
$search_string .= ")";
$sort_string .= " CASE WHEN shop_item.item_no='" . $search_term . "' THEN 1 ELSE 0 END DESC, CASE WHEN shop_item.ean_no='" . $search_term . "' THEN 1 ELSE 0 END DESC,CASE WHEN shop_item_cross_reference.item_reference_no='" . $search_term . "' THEN 1 ELSE 0 END DESC,
CASE WHEN shop_item.item_no LIKE '%" . $search_term . "%' THEN 1 ELSE 0 END DESC, CASE WHEN shop_item.ean_no='%" . $search_term . "%' THEN 1 ELSE 0 END DESC,CASE WHEN shop_item_cross_reference.item_reference_no='%" . $search_term . "%' THEN 1 ELSE 0 END DESC";
}
$return["search_string"] = $search_string;
$return["sort_string"] = $sort_string;
return $return;
}
function getSpaceOrganigramm($key){
echo var_dump($GLOBALS['mysql_con']);
$sql_query_space = "SELECT main_department.description as 'desc', organigramm_einrichtungen.*, main_contact.*, main_role.* FROM `organigramm_einrichtungen` INNER JOIN main_contact ON organigramm_einrichtungen.contact_id=main_contact.id INNER JOIN main_contact_department ON main_contact.id=main_contact_department.main_contact_id INNER JOIN main_department ON organigramm_einrichtungen.department_id=main_department.id INNER JOIN main_role ON main_contact_department.main_role_id=main_role.id WHERE organigramm_einrichtungen.space='".$key."' AND main_role.id=3 ORDER BY main_department.id ASC;";
$sql_space = @mysqli_query($GLOBALS['mysql_con'], $sql_query_space);
// echo var_dump($sql_space);
while ($row = @mysqli_fetch_array($sql_space)) {
// echo "
".$row['desc']."
".$row['name']."".$row['description']."
";
}
}
function getToken($code){
$array = array();
$headers = [
'Content-Type: application/x-www-form-urlencoded'
];
$fcmUrl = 'https://login.microsoftonline.com/organizations/oauth2/v2.0/token';
$cRequest = curl_init();
curl_setopt($cRequest, CURLOPT_URL, $fcmUrl);
curl_setopt($cRequest, CURLOPT_POST, true);
curl_setopt($cRequest, CURLOPT_HTTPHEADER, $headers);
curl_setopt($cRequest, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cRequest, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cRequest, CURLOPT_POSTFIELDS, http_build_query(array(
'client_id' => '93d2326e-40da-4938-a4d4-1df743ebd29a',
'scope' => 'openid User.ReadWrite User.ReadBasic.All Calendars.ReadWrite Presence.ReadWrite Mail.Read Mail.Read.Shared Mail.ReadBasic Mail.ReadBasic.Shared Mail.ReadWrite Mail.ReadWrite.Shared Mail.Send Mail.Send.Shared',
'code' => $code,
'redirect_uri' => 'https://intranet.awo-hamburg.de/',
'grant_type' => 'authorization_code',
'client_secret' => 'nlI8Q~XnsFkO~8T0U8hFgqb5c.mji5jjz5zV.dbV'
)));
$result = curl_exec($cRequest);;
$obj_token = json_decode($result);
$token_get = $obj_token->access_token;
$refresh_token = $obj_token->refresh_token;
array_push($array, $token_get);
array_push($array, $refresh_token);
curl_close($cRequest);
return $array;
}
function img_size_mm( $img, $dpi ) {
function px_to_mm( $px, $dpi ) {
return in_to_mm($px / $dpi);
}
function mm_to_px( $mm, $dpi ) {
return mm_to_in($mm) * $dpi;
}
function mm_to_in( $mm ) {
return $mm * $GLOBALS["mm_per_in"];
}
function in_to_mm( $in ) {
return $in * $GLOBALS["in_per_mm"];
}
$dimensions = getimagesize($img);
$width = $dimensions[0];
$height = $dimensions[1];
if ($width > 0 && $height > 0) {
$return[0] = px_to_mm($width, $dpi);
$return[1] = px_to_mm($height, $dpi);
return $return;
} else {
return FALSE;
}
}
function log_text( $newtext ) {
$file = $GLOBALS["curr_logfile"];
$current = file_get_contents($file);
$current .= "\r\n\r\n" . $newtext;
file_put_contents($file, $current);
}
function get_text_module_attachment( $company, $text_module_code, $attachment_no = 1 ) {
$query = 'SELECT attachment_' . $attachment_no . ' FROM shop_text_module WHERE company=\'' . $company . '\' AND code=\'' . $text_module_code . '\'';
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
$filename = @mysqli_result($result, 0, 0);
if (strlen($filename) > 0) {
return "/userdata/dcshop/documents/" . $filename;
} else {
return '';
}
}
function get_visitor_small( $sid, $from_session = 0, $from_cookie = 0 ) {
$query = "DELETE FROM
main_visitor
WHERE
(
session_date != '0000-00-00 00:00:00'
AND
session_date IS NOT NULL
AND
valid_until != '0000-00-00 00:00:00'
AND
valid_until IS NOT NULL
AND
valid_until <= NOW()
AND
nav_login != 1
)
OR
(
session_date != '0000-00-00 00:00:00'
AND
session_date IS NOT NULL
AND
(main_user_id IS NULL OR main_user_id = 0)
AND
(main_admin_user_id IS NULL OR main_admin_user_id = 0)
AND
session_date <= DATE_SUB(NOW(),INTERVAL 90 MINUTE)
AND
nav_login != 1
)
OR
(
session_date != '0000-00-00 00:00:00'
AND
session_date IS NOT NULL
AND
(
remember_token IS NULL
OR
remember_token = ''
)
AND
session_date <= DATE_SUB(NOW(),INTERVAL 90 MINUTE)
AND
nav_login != 1
)
OR
(
nav_login = 1
AND
(session_date <= DATE_SUB(NOW(),INTERVAL 90 MINUTE) OR session_date IS NULL OR session_date = '0000-00-00 00:00:00')
)";
@mysqli_query($GLOBALS['mysql_con'], $query);
$query = 'SELECT * FROM main_visitor WHERE session_id = ?';
$stmt = mysqli_prepare($GLOBALS["mysql_con"],$query);
$stmt->bind_param("s",$sid);
$stmt->execute();
$stmt->store_result();
$assoc_array = fetchAssocStatement($stmt);
if ($stmt->num_rows == 1) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
/* foreach($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
$value = trim($parts[1]);
$_SESSION[$name] = $value;
} */
if ($from_session == 1) {
$_SESSION['session_login'] = 1;
$_SESSION['cookie_login'] = 0;
} elseif ($from_cookie == 1) {
$_SESSION['session_login'] = 0;
$_SESSION['cookie_login'] = 1;
}
return $assoc_array;
}
}
function cookie_login_postprocessing( $visitor, $cookies ) {
$old_sid = $cookies['sid' . $GLOBALS['site']['code']];
$old_token = trim($cookies[$GLOBALS['site']['code'] . '_remember_login']);
$GLOBALS['test']['old_sid'] = $old_sid;
if (session_regenerate_id()) {
$newSid = session_id();
\DynCom\mysyde\common\classes\Hook::update('session_id_changed',['old_sid' => $old_sid, 'new_sid' => $newSid]);
$_SESSION['sid' . $GLOBALS['site']['code']] = $newSid;
$cookie_login = FALSE;
$cookie_removed = '';
foreach ($cookies as $name => $value) {
if (
(isset($visitor['remember_token']))
&&
(strlen($visitor['remember_token']) > 0)
&&
($name == $GLOBALS['site']['code'] . '_remember_login')
) {
$cookie_login = TRUE;
setcookie($name, '', time() - 1000);
setcookie($name, '', time() - 1000, '/');
}
}
$cookie_timeout = COOKIE_DAYS_VALID * 24 * 60 * 60;
if ((!empty($visitor['remember_token'])) && (strlen($visitor['remember_token']) > 0) && $cookie_login) {
$query = 'SELECT password FROM shop_user WHERE id=' . $visitor['main_user_id'];
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
$password = @mysqli_result($result);
$remember_token_unique = md5(uniqid(session_id(), TRUE) . $password . $GLOBALS['visitor']['main_user_id']);
$query = 'UPDATE main_visitor SET session_id=\'' . session_id() . '\', cookie_only=1, frontend_login=1, remember_token=\'' . $remember_token_unique . '\' WHERE id=' . $visitor['id'];
@mysqli_query($GLOBALS['mysql_con'], $query);
$visitor_query = "SELECT * FROM main_visitor WHERE id=" . $visitor['id'];
$visitor_result = @mysqli_query($GLOBALS['mysql_con'], $visitor_query);
$visitor = @mysqli_fetch_assoc($visitor_result);
if ($visitor['frontend_login']) {
$GLOBALS['visitor']['frontend_login'] = 1;
}
setcookie($GLOBALS['site']['code'] . '_remember_login', $remember_token_unique, time() + $cookie_timeout, '/');
setcookie('sid' . $GLOBALS['site']['code'], session_id(), time() + $cookie_timeout, '/');
}
}
}
function nav_login_postprocessing( &$visitor ) {
$old_sid = $visitor['session_id'];
if (session_regenerate_id()) {
$new_sid = session_id();
$_SESSION['sid' . $GLOBALS['site']['code']] = $new_sid;
$query = 'UPDATE main_visitor SET session_id = \'' . $new_sid . '\' WHERE session_id = \'' . $old_sid . '\'';
if (@mysqli_query($GLOBALS['mysql_con'], $query)) {
$delete_query = 'DELETE FROM main_visitor WHERE main_user_id = ' . $visitor['main_user_id'] . ' AND nav_login=1 AND session_id != \'' . $new_sid . '\'';
@mysqli_query($GLOBALS['mysql_con'], $delete_query);
$select_query = 'SELECT * FROM main_visitor WHERE session_id = \'' . $new_sid . '\'';
$result = @mysqli_query($GLOBALS['mysql_con'], $select_query);
if (@mysqli_num_rows($result) > 0) {
$visitor = @mysqli_fetch_assoc($result);
}
} else {
throw new Exception('NOT UPDATED: ' . $query);
}
}
}
// function scanDirectory($directory, &$filesArrays, $maxFiles = 30) {
// try {
// //code...
// static $processedFiles = []; // Статическая переменная для хранения уже обработанных файлов
// // Проверяем, является ли переданный путь директорией
// if (!is_dir($directory)) {
// return;
// }
// // Открываем директорию для чтения
// if ($handle = opendir($directory)) {
// // Проходим по содержимому директории
// while (false !== ($file = readdir($handle))) {
// if ($file != "." && $file != "..") {
// $path = $directory . DIRECTORY_SEPARATOR . $file;
// // Если это файл, добавляем его путь в массив текущего блока, только если он еще не был обработан
// if (is_file($path) && pathinfo($path)['extension'] == "pdf") {
// $lastKey = count($filesArrays) - 1;
// if (!isset($filesArrays[$lastKey]) || count($filesArrays[$lastKey]) >= $maxFiles) {
// $filesArrays[] = [];
// $lastKey++;
// }
// $filesArrays[$lastKey][] = $path;
// $processedFiles[] = $path; // Записываем обработанный файл в список
// }
// // Если это директория, вызываем функцию scanDirectory рекурсивно
// elseif (is_dir($path)) {
// scanDirectory($path, $filesArrays, $maxFiles);
// }
// }else {
// continue;
// }
// }
// // Закрываем дескриптор директории
// closedir($handle);
// }
// } catch (\Throwable $th) {
// echo $th;
// }
// }
// function s_p_a($search_text, $filesArray){
// try {
// //code...
// $exist = false;
// $loop = Factory::create();
// $count = 0;
// $links = array();
// foreach ($filesArray as $array) {
// ${'search_in_pdf_async_'.$count} = function($array, $searchText, $links, $exist) {
// $prefix = '/var/www/web4/htdocs/intranet/';
// $prefix_name = '/var/www/web4/htdocs/intranet/userdata/03_Module/01_Firmenwiki/AWO Wiki/';
// foreach ($array as $path) {
// $parser = new Parser();
// $pdf = $parser->parseFile($path);
// $text = $pdf->getText();
// if (strpos($text, $searchText)) {
// $exist = true;
// $cleaned_path = str_replace($prefix, '', $path);
// $cleaned_path_name = str_replace($prefix_name, '', $path);
// echo "
".$cleaned_path_name." ";
// continue;
// }else {
// continue;
// }
// }
// };
// $dyncFunction = ${'search_in_pdf_async_'.($count)}($array, $search_text, $links, $exist);
// ${'promise_'.$count} = new Promise(function ($resolve, $reject) use ($dyncFunction) {
// $resolve($dyncFunction);
// });
// }
// if ($count > 0) {
// for ($i = 1; $i < $count; $i++) {
// $promise = ${'promise_'.$i};
// if ($promise !== null) {
// $promise->then(function ($result) {
// echo $result."";
// })->catch(function (Throwable $error) { // Здесь ожидается Throwable, а не просто string
// echo "Error: " . $error->getMessage();
// });
// }else {
// continue;
// }
// }
// }
// $loop->run();
// if ($exist == false) {
// echo "
Datei nicht gefunden
";
// }
// } catch (\Throwable $th) {
// echo $th;
// }
// }
function just_search($searchText, $filesArray){
$exist = false;
$prefix = '/var/www/web4/htdocs/intranet/';
$prefix_name = '/var/www/web4/htdocs/intranet/userdata/03_Module/01_Firmenwiki/AWO Wiki/';
foreach ($filesArray as $array) {
foreach ($array as $path) {
$parser = new Parser();
$pdf = $parser->parseFile($path);
$text = $pdf->getText();
if (strpos($text, $searchText)) {
$exist = true;
$cleaned_path = str_replace($prefix, '', $path);
$cleaned_path_name = str_replace($prefix_name, '', $path);
echo "
".$cleaned_path_name." ";
continue;
}else {
continue;
}
}
}
if ($exist == false) {
echo "
Datei nicht gefunden
";
}
}
function logQuery( $datetime, $query, $file, $line, $toGlobal = NULL, $toFile = FALSE, $toHTML = TRUE, $msg = '', $includeSession = FALSE, $includeCookie = FALSE, $includePost = FALSE, $includeGet = FALSE, $includeArray = NULL ) {
$logtext = PHP_EOL . $datetime . ' - ' . $msg . PHP_EOL;
$logtext .= ' QUERY: ' . $query . PHP_EOL;
$logtext .= ' FILE: ' . $file . PHP_EOL;
$logtext .= ' LINE: ' . $line . PHP_EOL;
if ($includeSession) {
$sessiontext = print_r($_SESSION, 1);
$sessiontext = str_replace('\n(\n', '\n (\n', $sessiontext);
$logtext .= ' SESSION: ' . $sessiontext . PHP_EOL;
}
if ($includeCookie) {
$cookietext = print_r($_COOKIE, 1);
$cookietext = str_replace('\n(\n', '\n (\n', $cookietext);
$logtext .= ' COOKIE: ' . $cookietext . PHP_EOL;
}
if ($includePost) {
$posttext = print_r($_POST, 1);
$posttext = str_replace('\n(\n', '\n (\n', $posttext);
$logtext .= ' POST: ' . $posttext . PHP_EOL;
}
if ($includeGet) {
$gettext = print_r($_GET, 1);
$gettext = str_replace('\n(\n', '\n (\n', $gettext);
$logtext .= ' GET: ' . $gettext . PHP_EOL;
}
if (is_array($includeArray)) {
$arrtext = print_r($includeArray, 1);
$arrtext = str_replace('\n(\n', '\n (\n', $arrtext);
$logtext .= ' CUST-ARRAY: ' . $arrtext . PHP_EOL;
}
if (isset($toGlobals)) {
$toGlobals .= $logtext;
$GLOBALS['querylog'] .= $logtext;
} elseif ($toFile) {
}
if ($toHTML) {
echo '';
}
if ($toFile) {
$querylog = fopen(rtrim($_SERVER['DOCUMENT_ROOT'],'/') . "/userdata/logfile-visitor.txt", "a+");
fwrite($querylog, $logtext . PHP_EOL);
fclose($querylog);
}
}
function check_sid_for_login( $sid, $nav_login = FALSE ) {
$nav_login_insert = ($nav_login ? ' AND nav_login=1 ' : '');
$query = 'SELECT EXISTS(SELECT id FROM main_visitor WHERE session_id = \'' . mysqli_real_escape_string($GLOBALS['mysql_con'], $sid) . '\' AND main_user_id > 0 AND frontend_login=1 ' . $nav_login_insert . ')';
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
return (@mysqli_result($result, 0, 0) == TRUE ? TRUE : FALSE);
}
function renew_session_dates( $visitor ) {
if ((int)$visitor['id'] > 0) {
$query = '
UPDATE main_visitor SET session_date = NOW(), valid_until = DATE_ADD(NOW(),INTERVAL 30 DAY) WHERE id = ' . (int)$visitor['id'];
@mysqli_query($GLOBALS['mysql_con'], $query);
}
}
function set_shop_globals_from_site() {
if (!empty($GLOBALS['language']['company']) && !empty($GLOBALS['language']['shop_code']) && !empty($GLOBALS['language']['shop_language_code'])) {
$company = $GLOBALS['language']['company'];
$shop_code = $GLOBALS['language']['shop_code'];
$shop_language_code = $GLOBALS['language']['shop_language_code'];
if (empty($GLOBALS['shop'])) {
$shop_query = "SELECT * FROM shop_shop WHERE company = '" . $company . "' AND code = '" . $shop_code . "'";
$shop_result = @mysqli_query($GLOBALS['mysql_con'], $shop_query);
$shop = @mysqli_fetch_assoc($shop_result);
if (!empty($shop['id']) && (int)$shop['id'] > 0) {
$GLOBALS['shop'] = $shop;
}
}
if (empty($GLOBALS['shop_language'])) {
$shop_language_query = "SELECT * FROM shop_language WHERE company = '" . $company . "' AND shop_code = '" . $shop_code . "' AND code = '" . $shop_language_code . "'";
$shop_language_result = @mysqli_query($GLOBALS['mysql_con'], $shop_language_query);
$shop_language = @mysqli_fetch_assoc($shop_language_result);
if (!empty($shop_language['id']) && (int)$shop_language['id'] > 0) {
$GLOBALS['shop_language'] = $shop_language;
}
}
} else {
set_shop_globals_from_login();
}
}
function set_shop_globals_from_login() {
$query = "SELECT target_site_code, target_language_code FROM main_shop_login WHERE main_language_id = " . (int)$GLOBALS['language']['id'];
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
if ((int)@mysqli_num_rows($result) === 1) {
$row = mysqli_fetch_assoc($result);
$site_code = $row['target_site_code'];
$language_code = $row['target_language_code'];
if (!empty($site_code) && !empty($language_code)) {
//Shop holen
$query = "
SELECT
shop_shop.*
FROM
main_language,
main_site,
shop_shop
WHERE
main_site.code = '" . $site_code . "'
AND
main_language.main_site_id = main_site.id
AND
main_language.code = '" . $language_code . "'
AND
shop_shop.company = main_language.company
AND
shop_shop.code = main_language.shop_code
";
$shop_result = @mysqli_query($GLOBALS['mysql_con'], $query);
$shop = @mysqli_fetch_assoc($shop_result);
if (!empty($shop['id']) && (int)$shop['id'] > 0) {
$GLOBALS['shop'] = $shop;
if ($language_code == 'de' || $language_code == 'DE' || $language_code == 'DEU' || $language_code == 'deu') {
$lang_snippet = " AND code IN('de','DE','DEU','deu','dea','DEA') ";
} elseif ($language_code == 'dea' || $language_code == 'DEA') {
$lang_snippet = " AND code IN('dea','DEA') ";
} elseif ($language_code == 'en' || $language_code == 'EN' || $language_code == 'ENU' || $language_code == 'enu') {
$lang_snippet = " AND code IN('en','EN','ENU','enu') ";
}
$query = "SELECT * FROM shop_language WHERE company = '" . $shop['company'] . "' AND shop_code = '" . $shop['code'] . "' " . $lang_snippet;
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
if ((int)@mysqli_num_rows($result) == 1) {
$shop_language = mysqli_fetch_assoc($result);
if (!empty($shop_language['id']) && (int)$shop_language['id'] > 0) {
$GLOBALS['shop_language'] = $shop_language;
}
} else {
//echo $query;
}
} else {
//echo $query;
}
}
}
}
function get_login_fields_html( $shop ) {
$email_field = (
$show_labels_in_fields ?
"
"
:
"
"
);
$login_field = (
$show_labels_in_fields ?
"
"
:
"
"
);
$customer_no_field = (
$show_labels_in_fields ?
"
"
:
"
"
);
$password_field = (
$show_labels_in_fields ?
"
"
:
"
"
);
$field_1_html = '';
$field_2_html = '';
switch ($shop['login_type']) {
case 0: //E-Mail & Passwort
$field_1_html = $email_field;
break;
case 1: //Login & Passwort
$field_1_html = $login_field;
break;
case 2: //Kunden-Nr., Login & Passwort
$field_1_html = $customer_no_field;
$field_2_html = $login_field;
break;
case 3: //Kunden-Nr., E-Mail & Passwort
$field_1_html = $customer_no_field;
$field_2_html = $email_field;
break;
case 4: //Kunden-Nr. & Passwort
$field_1_html = $customer_no_field;
break;
default:
break;
}
$pre_check_remember_login = (!empty($GLOBALS['visitor']['remember_token']) ? 'checked ' : '');
$fields = '
' . $field_1_html . $field_2_html . $password_field .
'
';
return $fields;
}
function split_name( $name ) {
$results = array();
$r = explode(' ', $name);
$size = count($r);
//check first for period, assume salutation if so
if (mb_strpos($r[0], '.') === FALSE) {
$results['salutation'] = '';
$results['first'] = $r[0];
} else {
$results['salutation'] = $r[0];
$results['first'] = $r[1];
}
//check last for period, assume suffix if so
if (mb_strpos($r[$size - 1], '.') === FALSE) {
$results['suffix'] = '';
} else {
$results['suffix'] = $r[$size - 1];
}
//combine remains into last
$start = ($results['salutation']) ? 2 : 1;
$end = ($results['suffix']) ? $size - 2 : $size - 1;
$last = '';
for ($i = $start; $i <= $end; $i++) {
$last .= ' ' . $r[$i];
}
$results['last'] = trim($last);
return $results;
}
function validateDate( $date, $format = 'Y-m-d H:i:s' ) {
$d = DateTime::createFromFormat($format, $date);
return ($d && $d->format($format) == $date);
}
function stringEndsWith( $string, $endsWith ) {
$strlen = strlen($string);
$testlen = strlen($endsWith);
if ($testlen > $strlen) {
return FALSE;
}
return substr_compare(strtolower($string), strtolower($endsWith), $strlen - $testlen, $testlen) === 0;
}
function MySQLTypeIsText( $typestring ) {
$typestring = (string)$typestring;
return (
stringEndsWith($typestring, 'CHAR')
||
stringEndsWith($typestring, 'TEXT')
);
}
function MySQLTypeIsNumeric( $typestring ) {
$typestring = strtoupper($typestring);
return (
stringEndsWith($typestring, 'INT')
||
stringEndsWith($typestring, 'FLOAT')
||
stringEndsWith($typestring, 'DECIMAL')
);
}
function MySQLTypeIsDate( $typestring ) {
$typestring = strtoupper($typestring);
return (
$typestring == 'DATETIME'
||
$typestring == 'DATE'
||
$typestring == 'TIMESTAMP'
);
}
function array_depth( array $array ) {
$max_indentation = 1;
$array_str = print_r($array, TRUE);
$lines = explode("\n", $array_str);
foreach ($lines as $line) {
$indentation = (strlen($line) - strlen(ltrim($line))) / 4;
if ($indentation > $max_indentation) {
$max_indentation = $indentation;
}
}
return ceil(($max_indentation - 1) / 2) + 1;
}
function mysqli_fetch_all_from_executed_stmt(mysqli_stmt $stmt) {
try {
// Get metadata for field names
$meta = $stmt->result_metadata();
// initialise some empty arrays
$fields = $results = $fieldNames = array();
// This is the tricky bit dynamically creating an array of variables to use
// to bind the results
while ($field = $meta->fetch_field()) {
$fieldNames[] = $field->name;
$var = $field->name;
$$var = NULL;
$fields[$var] = &$$var;
}
$fieldCount = count($fieldNames);
// Bind Results
call_user_func_array(array($stmt,'bind_result'),$fields);
$i=0;
while ($stmt->fetch()){
for($l=0;$l<$fieldCount;$l++) {
$results[$i][$fieldNames[$l]] = $fields[$fieldNames[$l]];
}
$i++;
}
$stmt->close();
return $results;
} catch(Exception $e) {
return array();
}
}
/**
* @param $id
*
* @return bool
*/
function setMailSent( $id ) {
$query = 'UPDATE main_mail_log SET send_date = now() WHERE id = ' . (int)$id;
$result = @mysqli_query($GLOBALS['mysql_con'],$query);
return (bool)$result;
}
function get_all_whitespace_collapsed_variants($string) {
$string = str_replace(array(' AND ',' OR '),' ',$string);
$tokens = explode(' ',$string);
$urlencodedTokens = array_map(function($str){return urlencode($str);},$tokens);
$noOfTokens = count($tokens);
if($noOfTokens === 1) { return array(); }
//$whitespaceCollapsedStrings = $tokens;
$whitespaceCollapsedStrings = array();
for($i = 0;$i <= ($noOfTokens - 1);++$i) {
$newString = '';
$newStringWildCard = '';
for($j = 1;$j <= ($noOfTokens - $i);++$j) {
$newSuffix = $tokens[(($i + $j)-1)];
if($newSuffix !== 'AND' && $newSuffix !== 'OR') {
$arrSearchStr = $newString . $newSuffix;
$newString .= urlencode($newSuffix);
$newStringWildCard .= (($newStringWildCard)?'*':'');
$newStringWildCard .= $newSuffix;
//$newString .= $newSuffix;
if(!in_array($arrSearchStr,$tokens) && !in_array($newString,$urlencodedTokens)) {
if(!in_array($newString,$whitespaceCollapsedStrings) && mb_strlen($newString,'UTF-8')>0) {
$whitespaceCollapsedStrings[] = $newString;
//$whitespaceCollapsedStrings[] = $newStringWildCard;
}
}
}
}
}
return $whitespaceCollapsedStrings;
}
function string_starts_with($haystack, $needle) {
// search backwards starting from haystack length characters from the end
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
}
function string_ends_with($haystack, $needle) {
// search forward starting from end minus needle length characters
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
}
if (!function_exists("array_column")) {
function array_column($array,$column_name)
{
return array_map(function($element) use($column_name){return $element[$column_name];}, $array);
}
}
function pad_string_to_mb_length($string,$to_length,$padChar = ' ')
{
$padChar = (string)$padChar;
$padChar = $padChar[0];
$to_length = (int)$to_length;
$currLength = mb_strlen($string);
if ($currLength < $to_length) {
while (mb_strlen($string) < $to_length) {
$string = $string . $padChar;
}
}
return $string;
}
function escapeChars($charsToEscape, $escapeSeq, &$string)
{
$charsToEscape = preg_quote($charsToEscape, '/');
$regexSafeEscapeSeq = preg_quote($escapeSeq, '/');
$escapeSeq = preg_replace('/([$\\\\])/', '\\\$1', $escapeSeq);
$stringCopy = $string;
$correctedStringCopy = (preg_replace('/(? 0) {
$stepMultiplier = ceil($stepMultiplier);
} else {
$stepMultiplier = floor($stepMultiplier);
}
$newQty = $step * $stepMultiplier;
}
if ($newQty > $max) {
$newQty = $max;
} elseif($newQty < $min) {
$newQty = $min;
}
}
function normalize_search_string($string) {
$string = trim(strip_tags($string));
$string = preg_replace('/\s+/',' ',$string);
escapeChars('+-&|!(){}[]^~*?:\\/','\\',$string);
//$string = preg_replace('/\-/','*',$string);
//$string = preg_replace('/[^[:alnum:]]/','',$string);
//$string = preg_replace('/[^a-zA-Z0-9\s+\-_°&*?"]/','',$string);
$subTerms = explode(' ',$string);
$subtermCount = count($subTerms);
//if(strpos($string,' ') === FALSE) return '"' . $string . '"';
/*
$termArr = array();
$initTerm = $string;
$initPhraseTerm = '"' . $initTerm . '"';
$termArr[] = '(' . $initTerm . ')';
$itemNoIntactTerm = "(item_no_intact:($initTerm))";
$termArr[] = $itemNoIntactTerm;
$vendorItemNoIntactTerm = "(vender_item_no_intact:($initTerm))";
$termArr[] = $vendorItemNoIntactTerm;
$referenceNosTerm = "(reference_nos:($initTerm))";
$termArr[] = $referenceNosTerm;
if($subtermCount > 1) {
$fuzzyTerm = preg_replace('/(?<=^\b|\s\b)([\w]+)/','$1~2',$string);
$descriptionIntactPhraseTerm = "(description_intact:\"$initTerm\"~2)";
$termArr[] = $descriptionIntactPhraseTerm;
$mainCombinedPhraseTerm = "(main_item_desc_combined:\"$initTerm\"~2)";
$termArr[] = $mainCombinedPhraseTerm;
$descriptionPhraseTerm = "(description:\"$initTerm\"~2)";
$termArr[] = $descriptionPhraseTerm;
$didYouMeanPhraseTerm = "(did_you_mean:\"$initTerm\"~2)";
$termArr[] = $didYouMeanPhraseTerm;
} else {
$fuzzyTerm = $initTerm . '~2';
}
$descriptionIntactTerm = "(description_intact:($fuzzyTerm))";
$termArr[] = $descriptionIntactTerm;
$mainCombinedExactTerm = "(main_item_desc_combined_exact:($fuzzyTerm))";
$termArr[] = $mainCombinedExactTerm;
$didYouMeanTerm = "(did_you_mean:($fuzzyTerm))";
$termArr[] = $didYouMeanTerm;
$descriptionTerm = "(description:($initTerm))";
$termArr[] = $descriptionTerm;
$mainCombinedTerm = "(main_item_desc_combined:($initTerm))";
$termArr[] = $mainCombinedTerm;
$mainCombinedEdgeTerm = "(main_item_desc_combined_edge:($initTerm))";
$termArr[] = $mainCombinedEdgeTerm;
$mainCombinedNGramTerm = "(main_item_desc_combined_ngram:($initTerm))";
$termArr[] = $mainCombinedNGramTerm;
$termStr = implode(' AND ',$termArr);
$string = ltrim($string,' AND ');
$string = preg_replace('/\s+/',' ',$string);
*/
if($subtermCount > 1) {
$origString = $string;
}
//$string = preg_replace("/(?<=^|\"|\s)([^\s\"]+)(?=\s|\"|$)/",'$1~1',$string); $string =
//$string = preg_replace('/(?:\b\sAND\s\b)|(?:(? 1) {
//$string = '("' . $origString . '" AND ' . $string . ')';
//$string = '("' . $origString . '")';
$string = "$string";
}
return '(' . urlencode($string) . ')';
}
function formatBytes($bytes, $precision = 2) {
$kilobyte = 1024;
$megabyte = 1024 * 1024;
if ($bytes >= 0 && $bytes < $kilobyte) {
return $bytes . " b";
}
if ($bytes >= $kilobyte && $bytes < $megabyte) {
return round($bytes / $kilobyte, $precision) . " kb";
}
return round($bytes / $megabyte, $precision) . " mb";
}
/**
* This file is part of the array_column library
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Copyright (c) Ben Ramsey (http://benramsey.com)
* @license http://opensource.org/licenses/MIT MIT
*/
if (!function_exists('array_column')) {
/**
* Returns the values from a single column of the input array, identified by
* the $columnKey.
*
* Optionally, you may provide an $indexKey to index the values in the returned
* array by the values from the $indexKey column in the input array.
*
* @param array $input A multi-dimensional array (record set) from which to pull
* a column of values.
* @param mixed $columnKey The column of values to return. This value may be the
* integer key of the column you wish to retrieve, or it
* may be the string key name for an associative array.
* @param mixed $indexKey (Optional.) The column to use as the index/keys for
* the returned array. This value may be the integer key
* of the column, or it may be the string key name.
* @return array
*/
function array_column($input = null, $columnKey = null, $indexKey = null)
{
// Using func_get_args() in order to check for proper number of
// parameters and trigger errors exactly as the built-in array_column()
// does in PHP 5.5.
$argc = func_num_args();
$params = func_get_args();
if ($argc < 2) {
trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
return null;
}
if (!is_array($params[0])) {
trigger_error(
'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
E_USER_WARNING
);
return null;
}
if (!is_int($params[1])
&& !is_float($params[1])
&& !is_string($params[1])
&& $params[1] !== null
&& !(is_object($params[1]) && method_exists($params[1], '__toString'))
) {
trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
return false;
}
if (isset($params[2])
&& !is_int($params[2])
&& !is_float($params[2])
&& !is_string($params[2])
&& !(is_object($params[2]) && method_exists($params[2], '__toString'))
) {
trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
return false;
}
$paramsInput = $params[0];
$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
$paramsIndexKey = null;
if (isset($params[2])) {
if (is_float($params[2]) || is_int($params[2])) {
$paramsIndexKey = (int) $params[2];
} else {
$paramsIndexKey = (string) $params[2];
}
}
$resultArray = array();
foreach ($paramsInput as $row) {
$key = $value = null;
$keySet = $valueSet = false;
if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
$keySet = true;
$key = (string) $row[$paramsIndexKey];
}
if ($paramsColumnKey === null) {
$valueSet = true;
$value = $row;
} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
$valueSet = true;
$value = $row[$paramsColumnKey];
}
if ($valueSet) {
if ($keySet) {
$resultArray[$key] = $value;
} else {
$resultArray[] = $value;
}
}
}
return $resultArray;
}
}
function safe_array_dot_access(array $arr, $dotKey, $defaultValue = null) {
$keyParts = explode('.',$dotKey,100);
$lastPartIndex = count($keyParts) - 1;
$i = 0;
$currPart = $keyParts[$i];
foreach ($keyParts as $keyPart) {
$keyPartDigit = $keyPart;
if (ctype_digit($keyPart)) {
$keyPartDigit = (int)$keyPart;
}
if ($i === $lastPartIndex) {
if (isset($currPart[$keyPart])) {
return $currPart[$keyPart];
} elseif (isset($currPart[$keyPartDigit])) {
return $currPart[$keyPartDigit];
} else {
return $defaultValue;
}
}
if (array_key_exists($keyPart,$currPart)) {
$currPart = $currPart[$keyPart];
$i++;
} elseif (array_key_exists($keyPartDigit,$currPart)) {
$currPart = $currPart[$keyPartDigit];
$i++;
} else {
return $defaultValue;
}
}
return $defaultValue;
}
function universal_redirect($absoluteRedirectPath,$redirectCode = 302)
{
if (!headers_sent()) {
header('Location: ' . $absoluteRedirectPath,true,$redirectCode);
} else {
echo "
";
}
}
function getSessionErrorMessages()
{
if (isset($_SESSION['msgBag']['errors'])) {
return $_SESSION['msgBag']['errors'];
}
return [];
}
function getSessionNotifications()
{
if (isset($_SESSION['msgBag']['notifications'])) {
return $_SESSION['msgBag']['notifications'];
}
return [];
}
function getSessionSuccessMessages()
{
if (isset($_SESSION['msgBag']['successes'])) {
return $_SESSION['msgBag']['successes'];
}
return [];
}
function printFlashMessages()
{
$wrapper = '
%s
';
$inner = '
%s
';
$allInner = '';
if (array_key_exists('msgBag',$_SESSION)) {
if (array_key_exists('successes',$_SESSION['msgBag'])) {
foreach ($_SESSION['msgBag']['successes'] as $successMsg) {
$allInner .= sprintf($inner,'success',$successMsg);
}
}
if (array_key_exists('errors',$_SESSION['msgBag'])) {
foreach ($_SESSION['msgBag']['errors'] as $errorMsg) {
$allInner .= sprintf($inner,'error',$errorMsg);
}
}
if (array_key_exists('notifications',$_SESSION['msgBag'])) {
foreach ($_SESSION['msgBag']['notifications'] as $notification) {
$allInner .= sprintf($inner,'notification',$notification);
}
}
}
$html = sprintf($wrapper,$allInner);
$javascript = '
';
echo $html;
echo $javascript;
$_SESSION['msgBag'] = null;
unset($_SESSION['msgBag']);
}
function generateCallTrace()
{
$e = new Exception();
$trace = explode("\n", $e->getTraceAsString());
// reverse array to make steps line up chronologically
$trace = array_reverse($trace);
array_shift($trace); // remove {main}
array_pop($trace); // remove call to this method
$length = count($trace);
$result = array();
for ($i = 0; $i < $length; $i++)
{
$result[] = ($i + 1) . ')' . substr($trace[$i], strpos($trace[$i], ' ')); // replace '#someNum' with '$i)', set the right ordering
}
return "\t" . implode("\n\t", $result);
}
function get_requestbox($text, $title = "", $typ = "error", $instantLoad = true, $id = "requestbox"){
if($title == ""){
switch ($typ) {
case "success":
$title = $GLOBALS['tc']['success'];
break;
case "warning":
$title = $GLOBALS['tc']['warning'];
break;
default:
$title = $GLOBALS['tc']['error'];
break;
}
}
if ($instantLoad) {
?>
} ?>
}
function get_password_options() {
$random_byte_length = 22;
$salt = '';
if (function_exists('random_bytes')) {
return [
'cost' => 11,
];
} else {
$salt = mcrypt_create_iv($random_byte_length,MCRYPT_DEV_URANDOM);
return [
'cost' => 11,
'salt' => $salt,
];
}
}
function fetchAssocStatement($stmt)
{
if($stmt->num_rows>0)
{
$result = array();
$md = $stmt->result_metadata();
$params = array();
while($field = $md->fetch_field()) {
$params[] = &$result[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $params);
if($stmt->fetch())
return $result;
}
return null;
}
function get_nl_coupon($sales_header = "") { //changed
$dc_code = "";
if ($sales_header != "") {
$query = "SELECT * FROM shop_language WHERE company = '".$sales_header["company"]."' AND shop_code = '".$sales_header["shop_code"]."' AND code = '".$sales_header["language_code"]."'";
$result = mysqli_query($GLOBALS['mysql_con'], $query);
$language = mysqli_fetch_array($result);
if (is_null($GLOBALS["shop_language"])) {
$GLOBALS["shop_language"] = $language;
}
$query = "SELECT * FROM shop_shop WHERE company = '".$sales_header["company"]."' AND code = '".$sales_header["shop_code"]."'";
$result = mysqli_query($GLOBALS['mysql_con'], $query);
$shop = mysqli_fetch_array($result);
if (is_null($GLOBALS["shop"])) {
$GLOBALS["shop"] = $shop;
}
}
if ($GLOBALS["shop_language"]["nl_coupon_active"] && $GLOBALS["shop_language"]["nl_coupon_header"] != "") {
$dc_code = random_str(7);
$counter_line = 1;
$new_code = true;
while ($dc_code <> '' && $counter_line < 10 && $new_code == true)
{
$query_line = "SELECT id FROM shop_coupon_line
WHERE company = '" . $GLOBALS["shop"]["company"] . "'
AND shop_code = '" . $GLOBALS['shop']["code"] . "'
AND language_code = '" . $GLOBALS['shop_language']["code"] . "'
AND coupon_code = '" . $dc_code . "'";
$result_line = mysqli_query($GLOBALS['mysql_con'], $query_line);
if (mysqli_num_rows($result_line) > 0) {
$dc_code = random_str(7);
$new_code = true;
$counter_line++;
}
else
{
$new_code = false;
}
}
$header_code = $GLOBALS["shop_language"]["nl_coupon_header"];
$query = "SELECT * FROM shop_coupon_header
WHERE company = '".$GLOBALS["shop"]["company"]."'
AND shop_code = '".$GLOBALS["shop"]["code"]."'
AND language_code = '".$GLOBALS["shop_language"]["code"]."'
AND code = '".$header_code."'
";
$result = mysqli_query($GLOBALS['mysql_con'], $query);
if (mysqli_num_rows($result) == 1) {
$coupon_header = mysqli_fetch_array($result);
$query = "INSERT INTO shop_coupon_line
SET company = '" . $GLOBALS["shop"]["company"] . "',
shop_code = '" . $GLOBALS['shop']["code"] . "',
language_code = '" . $GLOBALS['shop_language']["code"] . "',
code = '" . $coupon_header["code"] . "',
coupon_code = '" . $dc_code . "',
times_used = 0,
max_no_of_usage = 1,
amount = '" . $coupon_header["amount"] . "',
amount_left = '" . $coupon_header["amount"] . "',
update_insert = 1,
last_date_used=CURDATE()";
mysqli_query($GLOBALS['mysql_con'], $query);
}
}
return $dc_code;
}
function random_str($length, $keyspace = '0123456789ABCDEFGHJKLMNPQRSTUVWXYZ')
{
$str = '';
$max = mb_strlen($keyspace, '8bit') - 1;
for ($i = 0; $i < $length; ++$i) {
$str .= $keyspace[random_int(0, $max)];
}
return $str;
}
function get_client_ip_address() {
$ipAddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipAddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipAddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipAddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED']))
$ipAddress = $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR']))
$ipAddress = $_SERVER['REMOTE_ADDR'];
else
$ipAddress = 'UNKNOWN';
return $ipAddress;
}
function cartesian_product(array $input) {
// filter out empty values
$input = array_filter($input);
$result = [[]];
foreach ($input as $key => $values) {
$append = array();
foreach($result as $product) {
foreach($values as $item) {
$product[$key] = $item;
$append[] = $product;
}
}
$result = $append;
}
return $result;
}
function cartesian_product_generator(array $input)
{
if ($input) {
if ($u = array_pop($input)) {
foreach (cartesian_product_generator($input) as $p) {
foreach ($u as $v) {
yield $p + [count($p) => $v];
}
}
}
} else {
yield[];
}
}
function dropAllActionItemsOnUrlQuery():string{
$actualURL = (isset($_SERVER['HTTPS']) ? "https" : "http") . '://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$actualURLParts = parse_url($actualURL);
$actualURLPartsQuery = explode('&',$actualURLParts["query"]);
$i = 0;
foreach ($actualURLPartsQuery as $actualUrlPartQuery){
$actualUrlPartQuery = explode('=',$actualUrlPartQuery);
if ($actualUrlPartQuery[0] === 'action' || $actualUrlPartQuery[0] === 'action_id') {
unset($actualURLPartsQuery[$i]);
}
$i++;
}
return implode('&',$actualURLPartsQuery);
}
function get_false_password_login_counter($ipHash,$loginHash)
{
$pdoHost = getenv('MAIN_MYSQL_DB_HOST');
$pdoPort = getenv('MAIN_MYSQL_DB_PORT');
$pdoUser = getenv('MAIN_MYSQL_DB_USER');
$pdoPass = getenv('MAIN_MYSQL_DB_PASS');
$pdoSchema = getenv('MAIN_MYSQL_DB_SCHEMA');
$pdo = new \DynCom\mysyde\common\classes\PDOQueryWrapper($pdoHost, $pdoPort, $pdoSchema, $pdoUser, $pdoPass);
$prepStatement = "
SELECT
false_login.*
FROM
false_login
WHERE
( false_login.ip_hash = :ip_hash OR false_login.login_hash = :login_hash )
";
$params = [
[':ip_hash', $ipHash, PDO::PARAM_STR],
[':login_hash', $loginHash, PDO::PARAM_STR],
];
$pdo->setQuery($prepStatement);
$pdo->prepareQuery();
$pdo->bindParameters($params);
$pdo->executePreparedStatement();
$result = $pdo->getResultArray();
return $result;
}
function add_false_password_loign_counter($ipHash,$loginHash, $counter = 1, $nextLoginTime, $blockCounter = 0 )
{
$pdoHost = getenv('MAIN_MYSQL_DB_HOST');
$pdoPort = getenv('MAIN_MYSQL_DB_PORT');
$pdoUser = getenv('MAIN_MYSQL_DB_USER');
$pdoPass = getenv('MAIN_MYSQL_DB_PASS');
$pdoSchema = getenv('MAIN_MYSQL_DB_SCHEMA');
$pdo = new \DynCom\mysyde\common\classes\PDOQueryWrapper($pdoHost, $pdoPort, $pdoSchema, $pdoUser, $pdoPass);
$prepStatement = "
INSERT INTO `false_login`
(`ip_hash`, `login_hash`, `total_counter`, `next_login_time`, block_counter)
VALUES
(:ip_hash ,:login_hash, :counter, :next_login_time, 0)
ON DUPLICATE KEY UPDATE block_counter = :block_counter , next_login_time = :next_login_time
";
if($counter == 1)
{
$prepStatement = "
INSERT INTO `false_login`
(`ip_hash`, `login_hash`, `total_counter`, `next_login_time`, block_counter)
VALUES
(:ip_hash ,:login_hash, :counter, :next_login_time, :block_counter)
ON DUPLICATE KEY UPDATE total_counter = total_counter + 1 , next_login_time = :next_login_time
";
}
$params = [
[':ip_hash', $ipHash, PDO::PARAM_STR],
[':login_hash', $loginHash, PDO::PARAM_STR],
[':counter', $counter, PDO::PARAM_STR],
[':next_login_time', $nextLoginTime, PDO::PARAM_STR],
[':block_counter', $blockCounter, PDO::PARAM_STR],
];
$pdo->setQuery($prepStatement);
$pdo->prepareQuery();
$pdo->bindParameters($params);
$pdo->executePreparedStatement();
}
function delete_false_password_loign_counter($ipHash,$loginhash)
{
$pdoHost = getenv('MAIN_MYSQL_DB_HOST');
$pdoPort = getenv('MAIN_MYSQL_DB_PORT');
$pdoUser = getenv('MAIN_MYSQL_DB_USER');
$pdoPass = getenv('MAIN_MYSQL_DB_PASS');
$pdoSchema = getenv('MAIN_MYSQL_DB_SCHEMA');
$pdo = new \DynCom\mysyde\common\classes\PDOQueryWrapper($pdoHost, $pdoPort, $pdoSchema, $pdoUser, $pdoPass);
$prepStatement = "
Delete From `false_login` where ip_hash = :ip_hash or login_hash = :login_hash
";
$params = [
[':ip_hash', $ipHash, PDO::PARAM_STR],
[':login_hash', $loginhash, PDO::PARAM_STR],
];
$pdo->setQuery($prepStatement);
$pdo->prepareQuery();
$pdo->bindParameters($params);
$pdo->executePreparedStatement();
}
function getUserIP()
{
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
return $ip;
}
function recaptcha() {
$query = 'SELECT * FROM google_recaptcha';
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
$recaptcha = @mysqli_fetch_array($result);
$secret = $recaptcha["secretkey"];
$key = $recaptcha["websitekey"];
$GLOBALS["secret"] = $secret;
$GLOBALS["key"] = $key;
}
// FAQ MODULE
function replace_umlaut ($txt) {
//Replace String to Entities
if (strpos($txt,'Ö') !== false) {
$txt = str_replace('Ö', 'Ö', $txt);
}
if (strpos($txt,'ö') !== false) {
$txt = str_replace('ö', 'ö', $txt);
}
if (strpos($txt,'Ü') !== false) {
$txt = str_replace('Ü', 'Ü', $txt);
}
if (strpos($txt,'ü') !== false) {
$txt = str_replace('ü', 'ü', $txt);
}
if (strpos($txt,'Ä') !== false) {
$txt = str_replace('Ä', 'Ä', $txt);
}
if (strpos($txt,'ä') !== false) {
$txt = str_replace('ä', 'ä', $txt);
}
return $txt;
}
// Funktion zum Laden des benutzerdefinierten Selektor-Aktionsumschalters
function loadAction($formname, $deleteAction, $dblclick_action, $counter){
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
?>
= '
';?>
= '
';?>
//
}