function writeDbLogSql($sql, $type = 's') { if (getUserConfig("dblog") != "") { if ($type == 's') { if (substr($sql, 0, 24) == "insert into pdfarchiving") { return; } } $f = fopen(getUserConfig("dblog"), "a"); if ($f) { fwrite($f, $type . ":" . serialize($sql) . "\r\n"); fclose($f); } else { session_addvalue("error", "unable to write db log"); } } }
function process_series(&$series) { $ret = true; $_checks = array(); $_checkssameday = array(); $_finals = array(); $failfor = false; $failfor_up = false; if (isset($GLOBALS['process_series_failfor'])) { $failfor_up = $failfor = $GLOBALS['process_series_failfor']; } if (isset($GLOBALS['process_series_failfor_up'])) { $failfor_up = $GLOBALS['process_series_failfor_up']; } foreach ($series as $info => $value) { if (!isset($_checks[$info])) { $_checks[$info] = array(); } if (!isset($_finals[$info])) { $_finals[$info] = array(); } if (!isset($_checkssameday[$info])) { $_checkssameday[$info] = array(); } $lasterrors = 0; while (count($_checkssameday[$info]) || count($value)) { $fromerrors = false; if ($itemch = array_shift($_checkssameday[$info])) { $fromerrors = true; } else { $itemch = array_shift($value); } //check direction if ($itemch['dir'] == 1) { //check for allready in finals $found = false; foreach ($_finals[$info] as $finals_key => $finals_val) { if (bccomp($finals_val['to'], $itemch['from']) < 0 || bccomp($finals_val['from'], $itemch['to']) > 0) { //ok } else { $found = true; array_push($_checkssameday[$info], $itemch); //error if ($fromerrors) { $lasterrors--; if ($lasterrors <= 0) { if ($ret) { session_addvalue("error", getLT("serieserror") . ": " . $itemch['from'] . "-" . $itemch['to'] . "."); } $ret = false; $_checkssameday[$info] = array(); } } else { //get all next for this date.. and try again.. if none good dump error while ($getone = array_shift($value)) { if ($getone['date'] == $itemch['date']) { array_unshift($_checkssameday[$info], $getone); } else { array_unshift($value, $getone); break; } } $lasterrors = count($_checkssameday[$info]); if ($lasterrors <= 1) { //error if ($ret) { session_addvalue("error", getLT("serieserror") . ": " . $itemch['from'] . "-" . $itemch['to'] . "."); } $ret = false; $_checkssameday[$info] = array(); } } break; } } if (!$found) { array_push($_finals[$info], $itemch); if ($fromerrors) { $lasterrors = count($_checkssameday[$info]); } } } else { array_push($_checks[$info], $itemch); //process $count1 = sizeof($_checks[$info]); while ($count1 && ($itemch = array_shift($_checks[$info]))) { $count1--; $count = sizeof($_finals[$info]); $found = false; while ($count && ($item = array_shift($_finals[$info]))) { $count--; if (bccomp($itemch['to'], $item['from']) < 0 || bccomp($itemch['from'], $item['to']) > 0) { //no impact array_push($_finals[$info], $item); } else { $found = true; if (bccomp($item['from'], $itemch['from']) < 0) { if (bccomp($item['from'], bcsub($itemch['from'], "1")) <= 0) { $items = $item; $items["from"] = $item['from']; $items["to"] = bcsub($itemch['from'], "1"); $items["date"] = $item["date"]; $items["dir"] = $item["dir"]; $items["utils"] = $item["utils"]; array_push($_finals[$info], $items); $count++; } } else { if (bccomp($itemch['from'], bcsub($item['from'], "1")) <= 0) { $itemc = array(); $itemc["from"] = $itemch['from']; $itemc["to"] = bcsub($item['from'], "1"); $itemc["date"] = $itemch["date"]; $itemc["dir"] = $itemch["dir"]; $itemc["utils"] = $itemch["utils"]; array_push($_checks[$info], $itemc); $count1++; } } if (bccomp($item['to'], $itemch['to']) > 0) { if (bccomp(bcadd($itemch['to'], "1"), $item['to']) <= 0) { $items = $item; $items["from"] = bcadd($itemch['to'], "1"); $items["to"] = $item['to']; $items["date"] = $item["date"]; $items["dir"] = $item["dir"]; $items["utils"] = $item["utils"]; array_push($_finals[$info], $items); $count++; } } else { if (bccomp(bcadd($item['to'], "1"), $itemch['to']) <= 0) { $itemc = array(); $itemc["from"] = bcadd($item['to'], "1"); $itemc["to"] = $itemch['to']; $itemc["date"] = $itemch["date"]; $itemc["dir"] = $itemch["dir"]; $itemc["utils"] = $itemch["utils"]; array_push($_checks[$info], $itemc); $count1++; } } break; } } if ($found) { //ok if ($fromerrors) { $lasterrors = count($_checkssameday[$info]); } } else { if (isset($itemch['ignore']) && $itemch['ignore']) { //just ignore continue; } array_push($_checkssameday[$info], $itemch); //get all for that day if ($fromerrors) { $lasterrors--; if ($lasterrors <= 0) { $_checkssameday[$info] = array(); if ($failfor !== false) { if (bccomp($failfor, $itemch['from']) >= 0 && bccomp($failfor, $itemch['to']) <= 0) { //we have an error if ($ret) { session_addvalue("error", getLT("serieserror") . ": " . $itemch['from'] . "-" . $itemch['to'] . "."); } $ret = false; break; } } else { if ($ret) { session_addvalue("error", getLT("serieserror") . ": " . $itemch['from'] . "-" . $itemch['to'] . "."); } $ret = false; break; } } } else { //add all on that day while ($getone = array_shift($value)) { if ($getone['date'] == $itemch['date']) { array_unshift($_checkssameday[$info], $getone); } else { array_unshift($value, $getone); break; } } $lasterrors = count($_checkssameday[$info]); if ($lasterrors == 1) { $_checkssameday[$info] = array(); if ($failfor !== false) { if (bccomp($failfor, $itemch['from']) >= 0 && bccomp($failfor, $itemch['to']) <= 0) { //we have an error if ($ret) { session_addvalue("error", getLT("serieserror") . ": " . $itemch['from'] . "-" . $itemch['to'] . "."); } $ret = false; break; } } else { if ($ret) { session_addvalue("error", getLT("serieserror") . ": " . $itemch['from'] . "-" . $itemch['to'] . "."); } $ret = false; break; } } } } } } } } $series = $_finals; if (isset($GLOBALS['process_series_failfor'])) { unset($GLOBALS['process_series_failfor']); } if (isset($GLOBALS['process_series_failfor_up'])) { unset($GLOBALS['process_series_failfor_up']); } return $ret; }
function lookup_execute($action, $slot) { global $_POST; global $_GET; global $_CONFIG; require_once "config/db.php"; global $conn; global $_local_error; $_local_error = ""; global $_local_reloadform; $_local_reloadform = ""; global $render_current_slot; global $current_slots; //mark slot on execution stack $render_current_slot++; $current_slots[$render_current_slot] = $slot; if (getUserConfig("pageprotection") == "yes") { if (isset($_POST['fprotection']) && $_POST['fprotection'] != "") { if (isset($_GET['ajax']) && $_GET['ajax'] == 1) { if (intval(session_getvalue("protection_page")) != intval($_POST['fprotection'])) { $_local_error = getLT("protectionerror"); } } else { if (intval(session_getvalue("protection_page")) != intval($_POST['fprotection']) + 1) { $_local_error = getLT("protectionerror"); } } } } //set default filter $control_filter = ""; $control_name = "lookup"; $control_table = "issues"; $control_id = "id"; //check for rights if (getUserConfig('dinsec_lookup_cando', $action) == 'no') { $_local_error = getLT('nopermissions'); } if (getUserConfig('dinsec_lookup_canpost', $action) == 'no') { $_local_error = getLT('nopermissions'); } if (session_getvalue("blockaccess_lookup") == "yes") { $_local_error = getLT('nopermissions'); } if (session_getvalue("blockaccess_issues") == "yes") { $_local_error = getLT('nopermissions'); } if ($_local_error == "") { switch ($action) { case 'info': if (isset($_POST['cancel_button']) && $_POST['cancel_button'] == getLT('cancel')) { $_local_error = 'usercanceled'; break; } if ($_local_error == "") { require_once "config/utils.php"; $_control_replace_sql = "parseAndReplaceAll"; if (file_exists("extensions/process_lookup.php")) { include "extensions/process_lookup.php"; } } break; case 'siteoffer': if (isset($_POST['cancel_button']) && $_POST['cancel_button'] == getLT('cancel')) { $_local_error = 'usercanceled'; break; } if ($_local_error == "") { require_once "config/utils.php"; $_control_replace_sql = "parseAndReplaceAll"; if (file_exists("extensions/process_siteoffer.php")) { include "extensions/process_siteoffer.php"; } } break; default: //$_local_error="slot:".$slot." unknown post action: ".$action; setSlotView($slot, ""); break; } } if (isset($_POST['cancel_button']) && $_POST['cancel_button'] == getLT('cancel')) { //if($_local_error!="") session_addvalue($slot.'_error',getLT($_local_error)); $_local_error = ''; } else { if ($_local_reloadform != "" || $_local_error != "" || $action == "justreloadform") { //save post for later use foreach ($_POST as $key => $val) { if (is_array($val)) { session_setvalue('savedpost_lookup_' . $key, correctPostValue(implode(",", str_replace(',', ' ', $_POST[$key])))); } else { session_setvalue('savedpost_lookup_' . $key, correctPostValue($val)); } } if ($_local_error != "") { session_addvalue($slot . '_error', $_local_error); } } } $render_current_slot--; return $_local_error; }
function makecontact_execute($action, $slot) { global $_POST; global $_GET; global $_CONFIG; require_once "config/db.php"; global $conn; global $_local_error; $_local_error = ""; global $_local_reloadform; $_local_reloadform = ""; global $render_current_slot; global $current_slots; //mark slot on execution stack $render_current_slot++; $current_slots[$render_current_slot] = $slot; if (getUserConfig("pageprotection") == "yes") { if (isset($_POST['fprotection']) && $_POST['fprotection'] != "") { if (isset($_GET['ajax']) && $_GET['ajax'] == 1) { if (intval(session_getvalue("protection_page")) != intval($_POST['fprotection'])) { $_local_error = getLT("protectionerror"); } } else { if (intval(session_getvalue("protection_page")) != intval($_POST['fprotection']) + 1) { $_local_error = getLT("protectionerror"); } } } } //set default filter $control_filter = ""; $control_name = "makecontact"; $control_table = "projectissues"; $control_id = "id"; //check for rights if (getUserConfig('dinsec_makecontact_cando', $action) == 'no') { $_local_error = getLT('nopermissions'); } if (getUserConfig('dinsec_makecontact_canpost', $action) == 'no') { $_local_error = getLT('nopermissions'); } if (session_getvalue("blockaccess_makecontact") == "yes") { $_local_error = getLT('nopermissions'); } if (session_getvalue("blockaccess_projectissues") == "yes") { $_local_error = getLT('nopermissions'); } if ($_local_error == "") { switch ($action) { case 'add': if (isset($_POST['cancel_button']) && $_POST['cancel_button'] == getLT('cancel')) { $_local_error = 'usercanceled'; setSlotView($slot, "add"); break; } if ($_local_error == '') { if (!isset($_POST['iname']) || $_POST['iname'] == '' || strip_tags($_POST['iname']) == '') { $_local_error .= getLT('iname') . ' ' . getLT('shouldbefilled'); } } if ($_local_error == '') { if (!isset($_POST['iemail']) || $_POST['iemail'] == '' || strip_tags($_POST['iemail']) == '') { $_local_error .= getLT('iemail') . ' ' . getLT('shouldbefilled'); } } if ($_local_error == '') { if (!isset($_POST['icontactname']) || $_POST['icontactname'] == '' || strip_tags($_POST['icontactname']) == '') { $_local_error .= getLT('icontactname') . ' ' . getLT('shouldbefilled'); } } if ($_local_error == '') { if (!isset($_POST['useraddress'])) { $_local_error .= getLT('javascript?'); } else { $ab_def = strtok($_POST['useraddress'], "-"); $ab_test = $ab_def . '-' . number_format(floatVal($ab_def . '.12') * 0.34, 4, '.', ''); if ($ab_test !== $_POST['useraddress']) { $_local_error .= getLT('antiboterror?'); } } } if ($_local_error == "") { $conn->addnew($control_table); $conn->setvalue('iname', correctPostValue($_POST['iname'])); $conn->setvalue('iemail', correctPostValue($_POST['iemail'])); $conn->setvalue('icontactname', correctPostValue($_POST['icontactname'])); $html = correctPostValue($_POST['idesc']); $html = str_ireplace("<script", "[script", $html); $html = str_ireplace("<link", "[link", $html); $html = str_ireplace("<style", "[style", $html); $conn->setvalue('idesc', $html); $conn->setvalue('projectid', $_CONFIG['projectid']); $conn->setvalue('idate', date("Y-m-d H:i:s")); $id = $conn->update(); if ($id != "") { session_addvalue($slot . '_info', getLT('wblank')); session_setvalue($slot . "_viewid", $id); setSlotView($slot, "add"); } else { $_local_error = getLT('unableadd'); break; } } case 'sendemail': if (isset($_POST['cancel_button']) && $_POST['cancel_button'] == getLT('cancel')) { $_local_error = 'usercanceled'; break; } if ($_local_error == "") { ob_start(); require_once "config/htmlreport.php"; require_once "config/templates.php"; require_once "config/mail.php"; global $_templates; require_once "config/utils.php"; $_control_replace_sql = "parseAndReplaceAll"; $pdf = new HtmlReport(""); $emailbody = ob_get_contents(); ob_end_clean(); $emailbody = html_entity_decode($emailbody); $emailsubject = getLT('emailcontact'); global $mails_sql_conn; $mails_sql_conn = create_db_connection(); $mails_sql_conn->openselect($_control_replace_sql("select pemails as email from projects where id=0[config.projectid]")); $noemail = false; if ($mails_sql_conn->eof()) { $noemail = true; } while (!$mails_sql_conn->eof()) { $mailman = createMailObject(); $mailman->IsHTML(true); $emailto = $mails_sql_conn->getvalue("email"); $emailreply = ""; $emailbcc = ""; $emailcc = ""; $emailfrom = ""; $emailbody = getFileContent(getFilePathFor('html', 'makecontact')); require_once "config/utils.php"; $emailbody = parseAndReplaceAll($emailbody); $emailreply = correctPostValue($_POST["iemail"]); $mailman->Body = $emailbody; $mailman->Subject = $emailsubject; $mailman->ClearAddresses(); $mailman->AddAddress($emailto); if ($emailbcc != "") { $mailman->AddBCC($emailbcc); } if ($emailcc != "") { $mailman->AddCC($emailcc); } if ($emailfrom != "") { $mailman->FromName = ""; $mailman->From = $emailfrom; } if ($emailreply != '') { $mailman->AddReplyTo($emailreply); } $mailman->send(); $mails_sql_conn->movenext(); } $mails_sql_conn->close(); if ($noemail) { session_addvalue($slot . '_error', getLT('noemailfound')); } else { session_addvalue($slot . '_info', getLT('yourmessageissent')); } } break; default: //$_local_error="slot:".$slot." unknown post action: ".$action; setSlotView($slot, ""); break; } } if (isset($_POST['cancel_button']) && $_POST['cancel_button'] == getLT('cancel')) { //if($_local_error!="") session_addvalue($slot.'_error',getLT($_local_error)); $_local_error = ''; } else { if ($_local_reloadform != "" || $_local_error != "" || $action == "justreloadform") { //save post for later use foreach ($_POST as $key => $val) { if (is_array($val)) { session_setvalue('savedpost_makecontact_' . $key, correctPostValue(implode(",", str_replace(',', ' ', $_POST[$key])))); } else { session_setvalue('savedpost_makecontact_' . $key, correctPostValue($val)); } } if ($_local_error != "") { session_addvalue($slot . '_error', $_local_error); } } } $render_current_slot--; return $_local_error; }
function getDateForMysql($date, $format) { $date = trim($date); if ('' . $date != '') { switch ($format) { case '%e/%m/%Y': case 'au': case 'dd/MM/yyyy': $ta = explode("/", $date); if (intval(trim($ta[2])) < 100) { $ta[2] = "" . (2000 + trim($ta[2])); } return str_pad(trim(substr($ta[2], 0, 4)), 4, "0", STR_PAD_LEFT) . "-" . str_pad(trim($ta[1]), 2, "0", STR_PAD_LEFT) . "-" . str_pad(trim($ta[0]), 2, "0", STR_PAD_LEFT); break; case '%m/%e/%Y': case 'MM/dd/yyyy': $ta = explode("/", $date); if (intval(trim($ta[2])) < 100) { $ta[2] = "" . (2000 + trim($ta[2])); } return str_pad(trim(substr($ta[2], 0, 4)), 4, "0", STR_PAD_LEFT) . "-" . str_pad(trim($ta[0]), 2, "0", STR_PAD_LEFT) . "-" . str_pad(trim($ta[1]), 2, "0", STR_PAD_LEFT); break; case '%e.%m.%Y': case 'dd.MM.yyyy': $ta = explode(".", $date); if (intval(trim($ta[2])) < 100) { $ta[2] = "" . (2000 + trim($ta[2])); } return str_pad(trim(substr($ta[2], 0, 4)), 4, "0", STR_PAD_LEFT) . "-" . str_pad(trim($ta[1]), 2, "0", STR_PAD_LEFT) . "-" . str_pad(trim($ta[0]), 2, "0", STR_PAD_LEFT); break; case 'time': return adodb_date("Y-m-d", $date); break; default: session_addvalue("error", "Unknown date format: " . $format); break; } } return ''; }