20000000) { return TRUE; } return FALSE; } function isMobile() { // return TRUE; static $isMobile = 0; if($isMobile == 0) { $useragent=$_SERVER['HTTP_USER_AGENT']; //if(preg_match('/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) if(preg_match('/android.|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) { $isMobile = 1; } else { $isMobile = -1; } } return (($isMobile == 1) ? TRUE : FALSE); } function logWrite($msg, $logLevel = "debug") { $ts = date("Y-m-d H:i:s"); switch ($logLevel) { case "sql": case "debug": case "cache": case "session": case "mail": case "main": case "ws": case "sms": case "merchant": case "transactions": case "giftcard": case "app": $logFile = LOG_DIR . "/" .$logLevel . "_" . date("Y-m-d") . ".log"; break; default: echo "wrong logLevel: '$logLevel' $msg"; exit; } $msg = str_replace("\n\n", "\n", $msg); $logText = ""; $logText = "[$ts] [" . $_SERVER["REMOTE_ADDR"] . "] [" . $_SERVER["REQUEST_URI"] . "] $msg \n"; if ($fd = fopen ($logFile, "a+")) { if (flock($fd, LOCK_EX)) { // do an exclusive lock fwrite($fd, $logText); flock($fd, LOCK_UN); // release the lock } else { echo "Couldn't lock the file !"; exit; } fclose($fd); } } // function debug($text) { if(DEBUG_ENABLE) { if(is_array($text)) { echo "
";
			print_r($text);
			echo "
"; } else { echo "** $text **
\n"; } } } // /* function doError($errorCode, $errorData = "") { global $json; global $errorTable; static $disableDoError = FALSE; $ajaxError = intval($_REQUEST["isAjax"]); $err = array(); $err[] = array("errorCode" => $errorCode); if($errorData) { $err[] = array("errorData " => $errorData); } if (function_exists("debug_backtrace")) { $err[] = array("errorBacktrace " => debug_backtrace()); } if($json) { $response["error"]["id"] = $errorCode; $response["error"]["user_message"] = $errorTable[$errorCode]; $response["error"]["debug_message"] = $errorData; echo json_encode($response); exit; } else{ if(DEBUG_ENABLE) { debug($err); exit; } else { logWrite(print_r($err,TRUE), "main"); if($disableDoError) { logWrite("doError disabled to prevent recursion", "debug"); exit; } else { $disableDoError = TRUE; if (!headers_sent($filename, $linenum)) { if($ajaxError) { echo $errorTable[$errorCode]; } else { include("../page/error.php"); } //header("location: " . ERROR_PAGE . "?errorcode=" . $errorCode . "&errormsg=" . urlencode($errorMessage)); exit; } else { logWrite(" headers already sent $filename $linenum", "debug"); include("../include/error-box.php"); } } } } }*/ function doError($errorCode, $errorData = "") { header("location: ../main/?page=errore&e=$errorCode&c=$errorData"); exit; } // function doNoAccess($errorData = "") { $err[] = array("errorCode" => "doNoAccess UNAUTORHIZED TO FL_BACKEND"); $err[] = array("errorData " => $errorData); if(DEBUG_ENABLE) { debug($err); exit; } else { logWrite(print_r($err, TRUE), "main"); logWrite(print_r($err, TRUE), "debug"); header('HTTP/1.0 404 Not Found'); include("../errorpage/404.php"); exit; } } // function openDbConnection($dbUser = "", $dbPass = "", $dbName = "") { if($dbUser == "") { $dbUser = DB_USER; } if($dbPass == "") { $dbPass = DB_PWD; } if($dbName == "") { $dbName = DB_NAME; } $cnn = @ociLogon($dbUser, $dbPass, $dbName, 'AL32UTF8') or doError("sql", "login");// 'AL32UTF8'); $stmt = ociParse($cnn, "ALTER SESSION SET NLS_DATE_LANGUAGE=American"); ociExecute($stmt) or doError("sql", "login"); $stmt = ociParse($cnn, "ALTER SESSION SET NLS_LANGUAGE=American"); ociExecute($stmt) or doError("sql", "login"); $stmt = ociParse($cnn, "ALTER SESSION SET NLS_TERRITORY=America"); ociExecute($stmt) or doError("sql", "login"); $stmt = ociParse($cnn, "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); ociExecute($stmt) or doError("sql", "login"); $stmt = ociParse($cnn, "ALTER SESSION SET NLS_TIME_FORMAT = 'HH24:MI:SS'"); ociExecute($stmt) or doError("sql", "login"); $stmt = ociParse($cnn, "ALTER SESSION SET NLS_COMP='LINGUISTIC'"); ociExecute($stmt) or doError("sql", "login"); $stmt = ociParse($cnn, "ALTER SESSION SET NLS_SORT='BINARY_AI'"); ociExecute($stmt) or doError("sql", "login"); ociFreeStatement($stmt) or doError("sql", "login"); return $cnn; } // function closeDbConnection(&$cnn) { if($cnn) { ociLogoff($cnn); $cnn = NULL; } } // function getHumanDate($isoDate, $enableZero = TRUE) { $humanDate = "00-00-0000"; $tmp = explode(" ", $isoDate); $tmp = explode("-", $tmp[0]); if(count($tmp)== 3) { if(checkdate ($tmp[1], $tmp[2], $tmp[0])) { $humanDate = $tmp[2] . "-" . $tmp[1] . "-" . $tmp[0]; } } if(!$enableZero && $humanDate == "00-00-0000") { $humanDate = ""; } return $humanDate; } // function getEngDate($isoDate, $enableZero = TRUE) { // iso date = YYYY-MM-DD // eng date = MM-DD-YYYY $engDate = "00-00-0000"; $tmp = explode(" ", $isoDate); $tmp = explode("-", $tmp[0]); if(count($tmp)== 3) { if(checkdate ($tmp[1], $tmp[2], $tmp[0])) { $humanDate = $tmp[1] . "/" . $tmp[2] . "/" . $tmp[0]; } } if(!$enableZero && $engDate == "00-00-0000") { $humanDate = ""; } return $humanDate; } // function getIsoDate($humanDate) { $humanDate = str_replace("/","-", $humanDate); $isoDate = "0000-00-00"; $tmp = explode("-", $humanDate); for($i = 0; $i < count($tmp); $i++) { $tmp[$i] = intval($tmp[$i]); } if(count($tmp) == 3) { if(checkdate ($tmp[1], $tmp[0], $tmp[2])) { if($tmp[0] < 10) { $tmp[0] = "0" . $tmp[0]; } if($tmp[1] < 10) { $tmp[1] = "0" . $tmp[1]; } $isoDate = $tmp[2] . "-" . $tmp[1] . "-" . $tmp[0]; } } return $isoDate; } // function getIsoTime($humanTime) { $humanTime = str_replace(".",":", $humanTime); $isoTime = "00:00:00"; $tmp = explode(":", $humanTime); for($i = 0; $i < count($tmp); $i++) { $tmp[$i] = intval($tmp[$i]); } if(count($tmp) == 3) { if($tmp[0] < 10) { $tmp[0] = "0" . $tmp[0]; } if($tmp[1] < 10) { $tmp[1] = "0" . $tmp[1]; } if($tmp[2] < 10) { $tmp[2] = "0" . $tmp[2]; } if(($tmp[0] >= 0) && ($tmp[0] < 24) && ($tmp[1] >= 0) && ($tmp[1] < 60) && ($tmp[2] >= 0) && ($tmp[2] < 60)) { $isoTime = $humanTime; } } if(count($tmp) == 2) { if($tmp[0] < 10) { $tmp[0] = "0" . $tmp[0]; } if($tmp[1] < 10) { $tmp[1] = "0" . $tmp[1]; } if(($tmp[0] >= 0) && ($tmp[0] < 24) && ($tmp[1] >= 0) && ($tmp[1] < 60)) { $isoTime = $humanTime . ":00"; } } return $isoTime; } // gethumaddatetime function getHumanDateTime($humanDateTime, $enableZero = TRUE) { $isoDateTime = "00-00-0000 00:00:00"; $tmp = explode(" ", $humanDateTime); if(count($tmp) == 2) { $humanDate = getHumanDate($tmp[0]); $humanDateTime = $humanDate . " " . $tmp[1]; } if(!$enableZero && $humanDateTime == "00-00-0000 00:00:00") { $humanDateTime = ""; } return $humanDateTime; } // function getEngDateTime($engDateTime, $enableZero = TRUE) { $isoDateTime = "00-00-0000 00:00:00"; $tmp = explode(" ", $engDateTime); if(count($tmp) == 2) { $humanDate = getEngDate($tmp[0]); $humanDateTime = $humanDate . " " . $tmp[1]; } if(!$enableZero && $engDateTime == "00-00-0000 00:00:00") { $humanDateTime = ""; } return $humanDateTime; } // function getIsoDateTime($humanDateTime) { $isoDateTime = "0000-00-00 00:00:00"; $tmp = explode(" ", $humanDateTime); if(count($tmp) == 2) { $isoDate = getIsoDate($tmp[0]); $isoTime = getIsoTime($tmp[1]); $isoDateTime = $isoDate . " " . $isoTime; } else { $isoDate = getIsoDate($humanDateTime); $isoDateTime = $isoDate . " 00:00:00"; } return $isoDateTime; } // function br2nl($text) { return eregi_replace("<[ ]*br[ ]*[/]{0,1}[ ]*>", "\n", $text); } // function br2space($text) { return eregi_replace("<[ ]*br[ ]*[/]{0,1}[ ]*>", " ", $text); } // function nl2space($text) { $t = str_replace("\n"," ", $text); $t = str_replace("\r"," ", $t); $t = str_replace("\l"," ", $t); return $t; } // function cutText($text, $limit) { if(strlen($text) > $limit * 1.2) { $text = substr($text, 0, $limit); $pos1 = strrpos($text, " "); if($pos1 !== FALSE) { $text = substr($text, 0, $pos1+1); } $pos1aperto = strrpos($text, "<"); $pos1chiuso = strrpos($text, ">"); if ($pos1aperto > $pos1chiuso) { $text = substr($text, 0, $pos1chiuso+1); } $text .= "..."; } return $text; } // function adjustWordQuote($text) { $text = str_replace("“", "\"", $text); $text = str_replace("”", "\"", $text); $text = str_replace("‘", "'", $text); $text = str_replace("’", "'", $text); return $text; } // function getFormatDescriptor($item) { $text = ""; if($item["macrotype"] == "calendar") { switch ($item["datatype"]) { case "date": $text = "gg-mm-aaaa"; break; case "datetime": $text = "gg-mm-aaaa hh:mm:ss"; break; case "time": $text = "hh:mm:ss"; break; } } return $text; } // function countRowsFromTable(&$cnn, $tableName, $whereCriteria = "") { $blocksCount = 0; $sql = "SELECT count(*) as C FROM $tableName"; if(strlen($whereCriteria) > 0) { $sql .= " WHERE $whereCriteria"; } if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $blocksCount = $row["C"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $blocksCount; } // function getRowsFromTable(&$cnn, $tableName, $whereCriteria = "", $orderCriteria = "", $pageSize = 0, $absPage = 0) { $outData = array(); $base = "SELECT * FROM $tableName";// ORDER BY POSITION"; if(strlen($whereCriteria) > 0) { $base .= " WHERE $whereCriteria"; } $order = ""; $limit = ""; if(strlen($orderCriteria) > 0) { $order .= " ORDER BY $orderCriteria"; } $sql = $base . $order; if(($absPage > 0) && ($pageSize > 0)) { $sql = addSqlLimit($sql, $absPage * $pageSize, ($absPage - 1) * $pageSize); } //debug($sql); if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $outData[] = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $outData; } // function getCurrUrl($exclude = array ()) { reset ($_GET); $tmp = ""; while(list($key, $val) = each ($_GET)) { if (!in_array($key, $exclude) && ($val != "")) { $tmp = $tmp . "&" . urlencode($key) . "=" . urlencode($val); } } if (strlen($tmp)> 0) { $tmp = substr($tmp, 1); } $theurl = $_SERVER["SCRIPT_NAME"]; if (strlen($tmp)> 0) { $theurl .= "?" . $tmp; } return $theurl; } // function getCurrParam($exclude = array ()) { reset ($_GET); $tmp = ""; while(list($key, $val) = each ($_GET)) { if (!in_array($key, $exclude) && ($val != "")) { $tmp = $tmp . "&" . urlencode($key) . "=" . urlencode($val); } } if (strlen($tmp)> 0) { $tmp = substr($tmp, 1); } return $tmp; } // function generatePassword($len) { $char = array("2","3","4","6","7","8","9","a","b","c","d","e","f","g","h","j","m","n","p","q","r","t","u","v","w","x","y","z"); $pass = ""; for($i = 0; $i < $len; $i++) { $pass .= $char[rand(0, count($char) - 1)]; } return $pass; } // function my_file_get_contents($filename) { if(!function_exists('file_get_contents')) { $text = ""; $lines = file($filename); for($i = 0; $i < count($lines); $i++) { $text .= $lines[$i]; } return $text; } else { return file_get_contents($filename); } } // function lighten($colore, $alias = FALSE) { if ($alias) { return "#FFFFFF"; } // $out = $colore; if(strlen($colore) == 7) { $r = base_convert(substr($colore, 1, 2), 16, 10); $g = base_convert(substr($colore, 3, 2), 16, 10); $b = base_convert(substr($colore, 5, 2), 16, 10); if($r == 0) { $r += 10; } if($g == 0) { $g += 10; } if($b == 0) { $b += 10; } $r = round(min(($r * 3), 255)); $g = round(min(($g * 3), 255)); $b = round(min(($b * 3), 255)); $r = base_convert($r, 10, 16); if(strlen($r) < 2) { $r = "0" . $r; } $g = base_convert($g, 10, 16); if(strlen($g) < 2) { $g = "0" . $g; } $b = base_convert($b, 10, 16); if(strlen($b) < 2) { $b = "0" . $b; } $out = "#" . $r . $g . $b; } return $out; } // function checkBasicChar($txt) { $ok = TRUE; for($i = 0; $i < strlen($txt); $i++) { $c = substr($txt, $i, 1); if((ord($c) >= ord("0") && ord($c) <= ord("9")) || (ord($c) >= ord("a") && ord($c) <= ord("z"))) { continue; } else { $ok = FALSE; break; } } return $ok; } // function checkCleanChar($txt) { $reschar=array("#","/","*",";","\\","'","\""); foreach ($reschar as $c) { if(ord($c) > 125) { return FALSE; } if(strstr($txt, $c)!= FALSE) { return FALSE; } } return TRUE; } // function getPagesBar($recordCount, $pageSize, $absPage = 1, $extra = "") { if($pageSize > 0) { $exclude = array ("absPage"); $theurl = getCurrUrl($exclude); $offset = 3; $start = 1; $mod = $recordCount % $pageSize; $pageCount = ($recordCount - $mod) / $pageSize; if ($mod != 0) { $pageCount++; } $end = $pageCount; $navText = ""; $tmpText = ""; if(($absPage == "") || ($absPage == "0")) { $absPage = 1; } else { //$absPage = parseInt($absPage,10); } if ($recordCount > $pageSize) { if ($absPage - $offset > $start) { $start = $absPage - $offset; } if ($absPage + $offset < $pageCount) { $end = $absPage + $offset; } $navText = ""; for ($i = $start; $i <= $end; $i++) { $tmpText = ""; //$tmpText = ($i-1) * $pageSize + 1; //$tmpText = $tmpText . "-"; /*if ($recordCount < $i * $pageSize) { $tmpText = $tmpText . $recordCount; } else { $tmpText = $tmpText . ($i * $pageSize); }*/ $tmpText = $tmpText . $i; if ($i != $absPage) { $tmpText = "" . $tmpText . ""; } else { $tmpText = "$tmpText"; } $navText = $navText . "    " . $tmpText; } if ($start > 1) { $navText = "«" . $navText; } if ($pageCount > $end) { $navText = $navText . "    " . "»"; } $navText = "
" . $navText . "
"; return $navText; } else { return "1"; } } return ""; } // function getHumanPagesBar($recordCount, $pageSize, $absPage, $extra) { if($absPage < 1) { $absPage = 1; } $exclude = array ("absPage"); $theurl = getCurrUrl($exclude); $start = 1; $mod = $recordCount % $pageSize; $pageCount = ($recordCount - $mod) / $pageSize; if ($mod != 0) { $pageCount++; } $end = $pageCount; $navText = ""; $navText = "
"; for ($i=$start; $i<=$end; $i++) { if ($i != $absPage) { $navText .= "" . $i . ""; } else { $navText .= "$i"; } if (($i % 20) != 0) { $navText .= "   "; } else { $navText .= "
"; } } $navText .= "
"; return $navText; } function getHumanPagesBar2($recordCount, $pageSize, $absPage, $extra = "",$appendUrl = "" ) { if($absPage < 1) { $absPage = 1; } $exclude = array ("ap"); $theurl = getCurrUrl($exclude); $theurl .= $appendUrl; $start = 1; $mod = $recordCount % $pageSize; $pageCount = ($recordCount - $mod) / $pageSize; if ($mod != 0) { $pageCount++; } $end = $pageCount; $navText = ""; $navText = "
"; for ($i=$start; $i<=$end; $i++) { if ($i != $absPage) { $navText .= "" . $i . ""; } else { $navText .= "$i"; } if (($i % 20) != 0) { $navText .= "   "; } else { $navText .= "
"; } } $navText .= "
"; return $navText; } // function mhtml_entity_decode($string) { $string = str_replace("<","<",$string); $string = str_replace(">",">",$string); $string = str_replace("&","&",$string); return $string; } // function getArrayFromList(&$input, $name) { $dataArray = array(); foreach($input as $k => $v) { if (substr($k, 0, strlen($name)) . "_" == $name . "_") { //$index = intval(substr($k, strlen($postName) + 1)); $dataArray[] = $v; } } return $dataArray; } // function quoteForDb($text) { $text = str_replace("'", "''", $text); return $text; } // function addSqlLimit($sql, $max, $min = 0) { $sql = "select ROWNUM as RNUM, T1.* from ($sql) T1 where ROWNUM <= $max"; if($min > 0) { $sql = "select * from ($sql) T2 where RNUM > $min"; } return $sql; } // function getSqlTs(&$cnn) { static $ts = 0; if($ts == 0) { $sql = "SELECT ((SYSDATE - TO_DATE('01-01-1970','DD-MM-YYYY')) * 86400) AS TS FROM DUAL"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt,OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $ts = intval($row["TS"]); } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return $ts; } // function getSqlDate(&$cnn) { static $date = ""; if($date == "") { $sql = "SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD') AS \"DATE\" FROM DUAL"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt,OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $date = $row["DATE"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return $date; } // function getSqlDateTime(&$cnn) { static $dateTime = ""; if($dateTime == "") { $sql = "SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS') AS \"DT\" FROM DUAL"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt,OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $dateTime = $row["DT"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return $dateTime; } // function readCacheData(&$cnn, $userId, $key, &$data) { global $disableCache; $userId = intval($userId); $out = FALSE; if(!$disableCache) { $sql = "SELECT * FROM CM_CACHE WHERE USERID = $userId AND KEY = '$key'"; if(LOG_CACHE) { logWrite($sql, "cache"); } if(LOG_SQL) { logWrite($sql, "sql"); } $sql = "SELECT * FROM CM_CACHE WHERE USERID = :user_id AND KEY = :key"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":user_id", $userId, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":key", $key, strlen($key)) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { //$data = unserialize(gzuncompress($row["VALUE"] -> load())); $data = unserialize($row["VALUE"] -> load()); $out = TRUE; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return $out; } // function writeCacheData(&$cnn, $userId, $key, $path, &$data) { global $disableCache; if(!$disableCache) { $userId = intval($userId); //$value = gzcompress(serialize($data)); $value = serialize($data); if(LOG_CACHE) { logWrite("write cache => [user: '$userId', path: '$path', size ". strlen($ser) . "/" . strlen($value) . " bytes, key: '$key']", "cache"); } if(LOG_CACHE) { $sql = "INSERT INTO CM_CACHE (USERID, \"KEY\", \"PATH\", \"VALUE\") VALUES ($userId, '$key', '$path', EMPTY_BLOB()) RETURNING \"VALUE\" INTO :mylob "; logWrite($sql, "cache"); } $sql = "INSERT INTO CM_CACHE (USERID, \"KEY\", \"PATH\", \"VALUE\") VALUES ($userId, '$key', '$path', EMPTY_BLOB()) RETURNING \"VALUE\" INTO :mylob "; //$sql = "INSERT INTO CM_CACHE (USERID, \"KEY\", \"PATH\", \"VALUE\") VALUES (:user_id, :key, :path, '$value')"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); $mylob = ociNewDescriptor($cnn, OCI_D_LOB) or doError("sql", ociError($stmt)); ociBindByName($stmt,':mylob',$mylob, -1, OCI_B_BLOB) or doError("sql", ociError($stmt)); //ociBindByName($stmt, ":user_id", $userId, 4); //ociBindByName($stmt, ":key", $key, strlen($key)); //ociBindByName($stmt, ":path", $path, strlen($path)); //ociBindByName($stmt, ":value", $value, strlen($value)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); $mylob->save($value); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); $mylob->free(); ociCommit($cnn); } return $out; } // function clearCacheOldData(&$cnn) { $sql = "DELETE FROM CM_CACHE WHERE SYSDATE - DT_INS > 10"; if(LOG_SQL) { logWrite($sql, "sql"); } if(LOG_CACHE) { logWrite($sql, "cache"); } $stmt = ociParse($cnn, $sql) or doError("sql",$sql); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } // function clearCacheData(&$cnn) { $sql = "DELETE FROM CM_CACHE"; if(LOG_SQL) { logWrite($sql, "sql"); } if(LOG_CACHE) { logWrite($sql, "cache"); } $stmt = ociParse($cnn, $sql) or doError("sql",$sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } // function invalidateCacheDataByUser(&$cnn, $userId) { $userId = intval($userId); $sql = "DELETE FROM CM_CACHE WHERE USERID = $userId"; if(LOG_CACHE) { logWrite($sql, "cache"); } if(LOG_SQL) { logWrite($sql, "sql"); } $sql = "DELETE FROM CM_CACHE WHERE USERID = :user_id"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":user_id", $userId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } // function invalidateCacheDataByGroup(&$cnn, $groupId) { $groupId = intval($groupId); $sql = "DELETE FROM CM_CACHE WHERE USERID IN (SELECT USERID FROM USR_USER_GROUP WHERE GROUPID = $groupId) "; if(LOG_CACHE) { logWrite($sql, "cache"); } if(LOG_SQL) { logWrite($sql, "sql"); } $sql = "DELETE FROM CM_CACHE WHERE USERID IN (SELECT USERID FROM USR_USER_GROUP WHERE GROUPID = :group_id) "; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":group_id", $groupId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } // function invalidateCacheDataByPath(&$cnn, $path) { $sql = "DELETE FROM CM_CACHE WHERE \"PATH\" LIKE '" . $path . ".%'"; if(LOG_CACHE) { logWrite($sql, "cache"); } if(LOG_SQL) { logWrite($sql, "sql"); } $sql = "DELETE FROM CM_CACHE WHERE \"PATH\" LIKE :path"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); $path = $path . ".%"; ociBindByName($stmt, ":path", $path, strlen($path)) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } //************************************** // // Name: MEL :: Better Check Email Funct // ion // Description:**UPDATED** This function // will double check and validate an E-mail // address by checking the sintaxis first a // nd the domain's MX, A and CNAME records // to be valid and active. It will return T // RUE if the email is valid or FALSE if no // t, very simple. The best approach I've m // ade to validate an Email. Let me know th // is has been useful, your comments and su // ggestions are very much appreciate it. * // *Please Vote** // By: Melvin D. Nava // // Assumes:Relies on the checkdnsrr PHP // Function to do the DNS work. Not availab // le for Windows. I've included a replacem // ent (ONLY WIN32) // //This code is copyrighted and has // limited warranties.Please see http:// // www.Planet-Source-Code.com/vb/scripts/Sh // owCode.asp?txtCodeId=1316&lngWId=8 //for details. //************************************** // // // CHECK EMAIL FUNCTION //*********************** function check_email_mx($email) { if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) || (preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) { $host = explode('@', $email); if(checkdnsrr($host[1].'.', 'MX') ) return true; if(checkdnsrr($host[1].'.', 'A') ) return true; if(checkdnsrr($host[1].'.', 'CNAME') ) return true; } return false; } // // FIX FOR WINDOWS // PROGRAMMERS //*********************** // checkdnsrr is not available // under windows I so included // the next replacement. You // may remove this if you are // gonna publish later over // any Linux/Unix OS // // thanx Jon Kriek for next snippet // and Rickard SjŲquist for notice // Melvin D. Nava. // if (!function_exists('checkdnsrr')) { function checkdnsrr($host, $type = '') { if(!empty($host)) { if($type == '') { $type = "MX"; } @exec("nslookup -type=$type $host", $output); while(list($k, $line) = each($output)) { if(eregi("^$host", $line)) { return true; } } return false; } } } function existFileCacheData($key) { return is_file(CHACHE_DIR . "/" . $key . ".html"); } function writeFileCacheData($key, &$data) { if ($fd = fopen (CHACHE_DIR . "/" . $key . ".html", "w+")) { if (flock($fd, LOCK_EX)) { // do an exclusive lock fwrite($fd, $data); flock($fd, LOCK_UN); // release the lock } fclose($fd); } } function importFileCacheData($key) { include(CHACHE_DIR . "/" . $key . ".html"); } function deleteFileCacheData($prefix = "") { $filelist = array(); if (is_dir(CHACHE_DIR)) { if ($dh = opendir(CHACHE_DIR)) { while (($file = readdir($dh)) !== false) { if(is_file(CHACHE_DIR . "/" . $file)) { if(substr($file, 0 , strlen($prefix)) == $prefix) { $filelist[] = $file; } } } closedir($dh); } foreach($filelist as $file) { unlink(CHACHE_DIR . "/" . $file); } } } function recordSort($records, $field, $reverse, $defaultSortField = 0) { $hash = array(); foreach($records as $k => $record) { $hash[$k] = $record[$field]; // $hash[$record[$field]] = $record; } ($reverse)? arsort($hash) : asort($hash); $sortedRecords = array(); foreach($hash as $k => $record) { $sortedRecords[]= $records[$k]; } return $sortedRecords; } function createCSVrow($titles, $filename) { $openMode = "a"; if (!$handle = fopen($filename, $openMode)) { debug("Cannot open file ($filename)"); $err = 1; } if($err == 0) { $txt = ""; foreach($titles as $field) { $field = br2space(ns2space($field)); if (strstr ($field, ";")) { $field = str_replace("\"", "\"\"", $field); } $txt .= "\"" . $field . "\";"; } $txt = substr($txt, 0, -1); $txt .= "\r\n"; if (fwrite($handle, $txt) === FALSE) { debug("Cannot write to file ($filename)"); $err = 1; break; } } fclose($handle); return $err; } // function createCSVfromQuery(&$cnn, $sql, $filename, $writeHeader = TRUE, $append = FALSE) { $err = 0; $openMode = "w"; if ($append) { $openMode = "a"; } if (!$handle = fopen($filename, $openMode)) { debug("Cannot open file ($filename)"); $err = 1; } if($err == 0) { //debug($sql); $stmt = ociParse($cnn, $sql) or doError("sql", array($sql, ociError($stmt))); ociExecute($stmt) or doError("sql", array($sql, ociError($stmt))); $i = 0; $txt = ""; while (ociFetchInto($stmt, $row, OCI_RETURN_NULLS + OCI_ASSOC)) { if (($i == 0) && $writeHeader) { $fields = array_keys ($row); foreach($fields as $field) { //if (strstr ($field, ";")) { $field = str_replace("\"", "\"\"", $field); } $txt .= "\"" . $field . "\";"; } $i++; $txt = substr($txt, 0, -1); $txt .= "\r\n"; if (fwrite($handle, $txt) === FALSE) { debug("Cannot write to file ($filename)"); $err = 1; break; } } $txt = ""; foreach($row as $item) { //if (strstr ($item, ";")) { $item = str_replace("\"", "\"\"", $item); } $txt .= "\"" . $item . "\";"; } $txt = substr($txt, 0, -1); $txt .= "\r\n"; if (fwrite($handle, $txt) === FALSE) { debug("Cannot write to file ($filename)"); $err = 1; break; } } ociFreeStatement($stmt) or doError("sql", array($sql, ociError($stmt))); } fclose($handle); return $err; } if (!function_exists('mime_content_type')) { function mime_content_type($file, $method = 0) { if ($method == 0) { ob_start(); system('/usr/bin/file -i -b ' . realpath($file)); $type = ob_get_clean(); $parts = explode(';', $type); return trim($parts[0]); } else if ($method == 1) { // another method here } } } function get_mime_type($filename, $mimePath = '/etc') { $fileext = substr(strrchr($filename, '.'), 1); if (empty($fileext)) return (false); $regex = "/^([\w\+\-\.\/]+)\s+(\w+\s)*($fileext\s)/i"; $lines = file("$mimePath/mime.types"); foreach($lines as $line) { if (substr($line, 0, 1) == '#') continue; // skip comments $line = rtrim($line) . " "; if (!preg_match($regex, $line, $matches)) continue; // no match to the extension return ($matches[1]); } return (false); // no match at all } function getParentFolder($file) { $file = str_replace("//", "/", $file . "/"); $parent = ""; $tmp = explode("/", $file); unset($tmp[count($tmp) -2]); $parent = implode("/", $tmp); return $parent; } function autoindex($url, $downloadUrl, $basedir, $requestfile) { $requestfile = str_replace("/./", "/", $requestfile); $requestfile = str_replace("//", "/", $requestfile); if(substr($requestfile, -1 ) == "/") { $requestfile = substr($requestfile, 0, -1 ); } if(($requestfile == ".") || ($requestfile == "")) { $requestfil = "/"; } $basedir = realpath($basedir); $basedir = str_replace("/./", "/", $basedir); $basedir = str_replace("//", "/", $basedir); $dirname = realpath($basedir ."/" . $requestfile); $dirname = str_replace("/./", "/", $dirname); $dirname = str_replace("//", "/", $dirname); if($basedir != substr($dirname,0, strlen($basedir))) { doError("filenotfound"); } $parent = getParentFolder($requestfile); if($parent) { echo "
 
"; } $handle = opendir($dirname); if($handle) { $items = array(); while (FALSE !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && is_readable($dirname . '/' . $file)) { //$items[] = $file; $dimensione=filemtime($dirname . "/" . $file);//stat($dirname . "/" . $file); $items[$file]=$dimensione;//$date("d-m-Y",$dimensione);//$dimensione['mtime']); //echo "
";print_r($dimensione);echo "
"; } } closedir($handle); //asort($items); arsort($items); echo ""; //foreach($items as $file) foreach ($items as $file => $date) { if (is_dir($dirname . '/' . $file)) { //$percorso="$dirname.$requestfile . "/" . $file;print_r($percorso); exit; //$dimensione=stat($dirname . "/" . $file); //echo ""; echo ""; } else { //$percorso=$dirname. "/" . $file;print_r($percorso); exit; // $dimensione=stat($dirname . "/" . $file); //echo ""; echo ""; } } echo "
  ". date("d-m-Y",$dimensione['mtime'])."
  ". date("d-m-Y",$date)."
  ".date("d-m-Y",$dimensione['mtime'])."
  ".date("d-m-Y",$date)."
"; } } function send_file($file) { $fileName = basename($file); if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) { $fileName = preg_replace('/\./', '%2e', $fileName, substr_count($fileName, '.') - 1); } $mime = FALSE; $finfo = finfo_open(FILEINFO_MIME); if ($finfo) { $mime = finfo_file($finfo, $file); } finfo_close($finfo); if($mime === FALSE) { $mime = "application/download"; } set_time_limit(0); header("Content-Type: $mime"); header("Content-Disposition:attachment; filename=\"" . htmlentities($fileName, ENT_COMPAT | ENT_HTML401, 'UTF-8') . "\""); header("Content-Description: " . htmlentities($fileName, ENT_COMPAT | ENT_HTML401, 'UTF-8'));; header("Content-Length: ". (string)(filesize($file))); header("Connection: close"); if($fp = fopen($file, 'rb')) { while( (!feof($fp)) && (connection_status()==0) ) { print(fread($fp, 1024 * 8)); flush(); } fclose($fp); } return ((connection_status()==0) and !connection_aborted()); } function makeXlsFromData(&$cnn, $definition, $data, $filename, $printHeader = true) { $xlsDoc = new Spreadsheet_Excel_Writer($filename); $xlsDoc->setVersion(8); $worksheet = & $xlsDoc->addWorksheet("sheet1"); // Creating the format $format = & $xlsDoc->addFormat(array('Size' => 12, 'Color' => 'black', 'Border' => 1, 'BorderColor' => 'black')); $format_titles = & $xlsDoc->addFormat(array('Size' => 13, 'Align' => 'center', 'Color' => 'white', 'Bold' => 1, 'FgColor' => 'blue', 'Border' => 1, 'BorderColor' => 'black')); $xlsRow = 0; $xlsCol = 0; if($printHeader) { foreach($definition["fields"] as $f) { if($definition[$f]["type"] == "password") { continue; } $worksheet->write($xlsRow, $xlsCol, $definition[$f]["label"], $format_titles); $xlsCol++; } $xlsCol = 0; $xlsRow++; } foreach($data as $row) { foreach($definition["fields"] as $f) { $value = utf8_decode($row[$f]); switch($definition[$f]["type"]) { case "password": continue 2; break; case "combo": switch($definition[$f]["combo_source"]) { case "table": $selectdValue = $value; $value = getValsFromDB($cnn, $definition[$f]["combo_lookup"], "", $definition[$f]["combo_key"], $definition[$f]["combo_value"], $selectdValue, $definition[$f]["combo_multiple"], 1); $worksheet->writeString($xlsRow, $xlsCol, $value, $format); break; } break; default: switch($definition[$f]["macrotype"]) { case "text": $worksheet->writeString($xlsRow, $xlsCol, $value, $format); break; case "int": case "float": $worksheet->writeNumber($xlsRow, $xlsCol, $value, $format); break; case "calendar": switch($definition[$f]["forcecast"]) { case "date": $value = getHumanDate($value); $value = str_replace("-", "/", $value); break; case "datetime": $value = getHumanDateTime($value); $value = str_replace("-", "/", $value); break; default: } $worksheet->write($xlsRow, $xlsCol, $value, $format); break; default: $worksheet->write($xlsRow, $xlsCol, $value, $format); break; } } $xlsCol++; } $xlsCol = 0; $xlsRow++; } $xlsDoc->close(); return FALSE; } // function check_cellulare($cellulare) { //if( (preg_match('/^(([+][0-9]{2})?([ ])?[0-9]{3}([ ,.\\\/-])?[0-9]{7})?$/',$cellulare)) ) if(ereg("^(\+{0,1}[0-9]{2,3}|[0-9]{3,5})[-\/ ]?[0-9]{2,4}[-\/ ]?[0-9]{5,8}$",$cellulare)) { return true; } else { return false; } } // function check_email($email) { if( (preg_match('/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/',$email)) ) { return true; } else { return false; } } ?> 0) { $data["table"] = $tableName; } else { $data["table"] = $section["table"]; } $data["fields"] = $fields; $data["key"] = $section["key"]; //$data["owner"] = $section["owner"]; $data["order"] = $section["orderby"]; $data["filter"] = $section["filter"]; for($i=0 ; $i < count($fields) ; $i++) { $field = $fields[$i]; $data[$field] = Array(); $data[$field]["label"] = $section[$field . "_label"]; if(strlen($data[$field]["label"]) == 0) { $data[$field]["label"] = $field; } $data[$field]["type"] = strtolower($section[$field . "_type"]); if(strlen($data[$field]["type"]) == 0) { $data[$field]["type"] = "text"; } $data[$field]["ro"] = FALSE; $data[$field]["insertvalue"] = ""; $data[$field]["defaultvalue"] = ""; $data[$field]["size"] = 0; //$data[$field]["optional"] = FALSE; $data[$field]["required"] = FALSE; $data[$field]["validation"] = ""; $data[$field]["skipempty"] = FALSE; $data[$field]["minlen"] = 0; if(array_key_exists($field . "_source", $section)) { $data[$field]["source"] = trim($section[$field . "_source"]); } if(array_key_exists($field . "_ro", $section)) { $data[$field]["ro"] = ($section[$field . "_ro"] == TRUE ) ? TRUE : FALSE; } if(array_key_exists($field . "_insertvalue", $section)) { $data[$field]["insertvalue"] = $section[$field . "_insertvalue"]; //$data[$field]["ro"] = TRUE; } if(array_key_exists($field . "_defaultvalue", $section)) { $data[$field]["defaultvalue"] = $section[$field . "_defaultvalue"]; } if(array_key_exists($field . "_size", $section)) { $data[$field]["size"] = intval($section[$field . "_size"]); } if(array_key_exists($field . "_minlen", $section)) { $data[$field]["minlen"] = intval($section[$field . "_minlen"]); } //if(array_key_exists($field . "_optional", $section)) //{ // $data[$field]["optional"] = ($section[$field . "_optional"] == TRUE ) ? TRUE : FALSE; //} if(array_key_exists($field . "_required", $section)) { $data[$field]["required"] = ($section[$field . "_required"] == TRUE ) ? TRUE : FALSE; } if(array_key_exists($field . "_validation", $section)) { $data[$field]["validation"] = strtolower($section[$field . "_validation"]); } if(array_key_exists($field . "_skipempty", $section)) { $data[$field]["skipempty"] = ($section[$field . "_skipempty"] == TRUE ) ? TRUE : FALSE; } if(array_key_exists($field . "_forcecast", $section)) { $data[$field]["forcecast"] = $section[$field . "_forcecast"]; } switch($section[$field . "_type"]) { case "menulink": break; case "combo": $data[$field]["combo_source"] = $section[$field . "_combo_source"]; switch($data[$field]["combo_source"]) { case "file": $data[$field]["combo_lookup"] = $section[$field . "_combo_lookup"]; $data[$field]["combo_filter"] = $section[$field . "_combo_filter"]; break; case "table": $data[$field]["combo_lookup"] = $section[$field . "_combo_lookup"]; $data[$field]["combo_key"] = $section[$field . "_combo_key"]; $data[$field]["combo_value"] = $section[$field . "_combo_value"]; $data[$field]["combo_filter"] = $section[$field . "_combo_filter"]; $data[$field]["combo_order"] = $section[$field . "_combo_order"]; break; case "sql": $data[$field]["combo_sql"] = $section[$field . "_combo_sql"]; $data[$field]["combo_key"] = $section[$field . "_combo_key"]; $data[$field]["combo_value"] = $section[$field . "_combo_value"]; break; case "values": $data[$field]["combo_key_val"] = $section[$field . "combo_key_val"]; break; case "array": $data[$field]["combo_lookup"] = $section[$field . "_combo_lookup"]; $data[$field]["combo_lookup_key"] = $section[$field . "_combo_lookup_key"]; $data[$field]["combo_key"] = $section[$field . "_combo_key"]; $data[$field]["combo_value"] = $section[$field . "_combo_value"]; break; case "variable": //todo break; } $data[$field]["combo_widget"] = "list"; if (strtolower($section[$field . "_combo_widget"]) == "group" ) { $data[$field]["combo_widget"] = "group"; } $data[$field]["combo_emptyline"] = ($section[$field . "_combo_emptyline"] == TRUE ) ? TRUE : FALSE; $data[$field]["combo_multiple"] = ($section[$field . "_combo_multiple"] == TRUE ) ? TRUE : FALSE; break; case "file": $data[$field]["enable_delete"] = ($section[$field . "_disable_delete"] == TRUE ) ? FALSE : TRUE; break; case "img": $data[$field]["enable_delete"] = ($section[$field . "_disable_delete"] == TRUE ) ? FALSE : TRUE; break; case "text": case "password": $data[$field]["width"] = intval($section[$field . "_cols"]); break; case "textarea": $data[$field]["include"] = trim($section[$field . "_include"]); $data[$field]["width"] = intval($section[$field . "_cols"]); $data[$field]["height"] = intval($section[$field . "_rows"]); break; case "htmlarea": $data[$field]["width"] = intval($section[$field . "_cols"]); $data[$field]["height"] = intval($section[$field . "_rows"]); $data[$field]["config"] = $section[$field . "_config"]; break; case "checkbox": break; case "radio": $data[$field]["radio_source"] = $section[$field . "_radio_source"]; switch($data[$field]["radio_source"]) { case "table": $data[$field]["radio_lookup"] = $section[$field . "_radio_lookup"]; $data[$field]["radio_key"] = $section[$field . "_radio_key"]; $data[$field]["radio_value"] = $section[$field . "_radio_value"]; $data[$field]["radio_filter"] = $section[$field . "_radio_filter"]; $data[$field]["radio_order"] = $section[$field . "_radio_order"]; break; case "sql": $data[$field]["radio_sql"] = $section[$field . "_radio_sql"]; $data[$field]["radio_key"] = $section[$field . "_radio_key"]; $data[$field]["radio_value"] = $section[$field . "_radio_value"]; break; case "values": $data[$field]["radio_value"] = explode(",", $section[$field . "_radio_value"]); if($section[$field . "_radio_label"]) { $data[$field]["radio_label"] = explode(",", $section[$field . "_radio_label"]); } else { $data[$field]["radio_label"] = $data[$field]["radio_value"]; } break; case "variable": //todo break; } break; } } if(strlen($data["table"]) > 0) { $sql = "select TABLE_TYPE from USER_CATALOG WHERE TABLE_NAME = '" . $data["table"] . "' and table_type = 'SYNONYM'"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql); ociExecute($stmt, OCI_DEFAULT); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { switch($row["TABLE_TYPE"]) { case "SYNONYM": $sql = "select TABLE_OWNER from USER_SYNONYMS WHERE SYNONYM_NAME='" . $data["table"] . "'"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt1 = ociParse($cnn, $sql); ociExecute($stmt1, OCI_DEFAULT); while (ociFetchInto($stmt1, $row, OCI_ASSOC)) { $data["owner"] = $row["TABLE_OWNER"]; } break; case "TABLE": $data["owner"] = DB_USER; break; } } ociFreeStatement($stmt); if(strlen($data["owner"]) != DB_USER) { $sql = "SELECT COLUMN_NAME AS FIELD, DATA_PRECISION, DATA_SCALE, DATA_TYPE, NULLABLE, DATA_LENGTH, CHAR_LENGTH from ALL_TAB_COLUMNS WHERE TABLE_NAME = '" . $data["table"] . "' AND OWNER = '" . $data["owner"] . "'"; } else { $sql = "SELECT COLUMN_NAME AS FIELD, DATA_PRECISION, DATA_SCALE, DATA_TYPE, NULLABLE, DATA_LENGTH, CHAR_LENGTH from USER_TAB_COLUMNS WHERE TABLE_NAME = '" . $data["table"] . "'"; } if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql); ociExecute($stmt, OCI_DEFAULT); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { if(in_array($row["FIELD"], $fields)) { $dataType = $row["DATA_TYPE"]; $size = $row["DATA_LENGTH"]; $type = $dataType . "($size)"; /*$x = strpos($type, "("); if($x > 0) { $y = strpos($type, ")"); $size = substr($type, ++$x, $y - $x); $type = $dataType; }*/ $data[$row["FIELD"]]["datatype"] = strtolower($type); $data[$row["FIELD"]]["macrotype"] = "text";//(text, int, calendar, float) $data[$row["FIELD"]]["datasize"] = 10; switch(strtoupper($dataType)) { case "FLOAT": case "RAW": case "LONG RAW": case "MLSLABEL"; case "TIMESTAMP": break; case "BFILE": $data[$row["FIELD"]]["datasize"] = 16777216; break; case "BLOB": $data[$row["FIELD"]]["datatype"] = strtolower($row["DATA_TYPE"]); $data[$row["FIELD"]]["macrotype"] = "binary"; $data[$row["FIELD"]]["datasize"] = $row["DATA_LENGTH"]; break; case "CLOB": case "NBLOB": $data[$row["FIELD"]]["datatype"] = strtolower($row["DATA_TYPE"]); $data[$row["FIELD"]]["macrotype"] = "text"; $data[$row["FIELD"]]["datasize"] = 1000000; break; case "CHAR": case "NCHAR": case "VARCHAR2": case "NVARCHAR2": $data[$row["FIELD"]]["macrotype"] = "text"; $data[$row["FIELD"]]["datasize"] = $row["CHAR_LENGTH"]; break; case "LONG": $data[$row["FIELD"]]["macrotype"] = "text"; $data[$row["FIELD"]]["datasize"] = 16777216; break; case "NUMBER": $data[$row["FIELD"]]["macrotype"] = "int"; if($row["DATA_SCALE"] > 0) { $data[$row["FIELD"]]["macrotype"] = "float"; } $data[$row["FIELD"]]["datasize"] = 38; if(strlen($row["DATA_PRECISION"]) > 0) { $data[$row["FIELD"]]["datasize"] = intval($row["DATA_PRECISION"]); } break; case "ROWID": $data[$row["FIELD"]]["macrotype"] = "text"; $data[$row["FIELD"]]["datasize"] = 32; break; case "UROWID": $data[$row["FIELD"]]["macrotype"] = "text"; $data[$row["FIELD"]]["datasize"] = 4000; break; case "DATE": $data[$row["FIELD"]]["macrotype"] = "calendar"; $data[$row["FIELD"]]["datatype"] = "datetime"; $data[$row["FIELD"]]["datasize"] = "20"; switch ($data[$row["FIELD"]]["forcecast"]) { case "date": $data[$row["FIELD"]]["datatype"] = "date"; $data[$row["FIELD"]]["datasize"] = "10"; break; case "time": $data[$row["FIELD"]]["datatype"] = "time"; $data[$row["FIELD"]]["datasize"] = "8"; break; case "datetime": $data[$row["FIELD"]]["datatype"] = "date"; $data[$row["FIELD"]]["datasize"] = "19"; break; } break; } /*if($data[$row["FIELD"]]["datasize"] == 0) { $data[$row["FIELD"]]["datasize"] = 10; }*/ if($data[$row["FIELD"]]["size"] > 0) { $data[$row["FIELD"]]["datasize"] = min($data[$row["FIELD"]]["size"], $data[$row["FIELD"]]["datasize"]); } } } ociFreeStatement($stmt); } for($i=0 ; $i < count($fields) ; $i++) { if($data[$fields[$i]]["datasize"] == 0) { $data[$fields[$i]]["datasize"] = $data[$fields[$i]]["size"]; } $data[$fields[$i]]["maxlen"] = $data[$fields[$i]]["datasize"]; } } $ini = $iniFile; $sec = $iniSection; $tab = $tableName; } } return $data; } function getTableInfo(&$cnn, $tableName) { $sql = "select TABLE_TYPE from USER_CATALOG WHERE TABLE_NAME = '" . $tableName . "' and table_type = 'SYNONYM'"; debug($sql); if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql); ociExecute($stmt, OCI_DEFAULT); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { switch($row["TABLE_TYPE"]) { case "SYNONYM": $sql = "select TABLE_OWNER from USER_SYNONYMS WHERE SYNONYM_NAME='" . $tableName . "'"; debug($sql); if(LOG_SQL) { logWrite($sql, "sql"); } $stmt1 = ociParse($cnn, $sql); ociExecute($stmt1, OCI_DEFAULT); while (ociFetchInto($stmt1, $row, OCI_ASSOC)) { $owner = $row["TABLE_OWNER"]; } break; case "TABLE": $owner = DB_USER; break; } } ociFreeStatement($stmt); if(strlen($owner) != DB_USER) { $sql = "SELECT COLUMN_NAME AS FIELD, DATA_PRECISION, DATA_SCALE, DATA_TYPE, NULLABLE, DATA_LENGTH, CHAR_LENGTH from ALL_TAB_COLUMNS WHERE TABLE_NAME = '" . $tableName . "' AND OWNER = '" . $owner . "'"; } else { $sql = "SELECT COLUMN_NAME AS FIELD, DATA_PRECISION, DATA_SCALE, DATA_TYPE, NULLABLE, DATA_LENGTH, CHAR_LENGTH from USER_TAB_COLUMNS WHERE TABLE_NAME = '" . $tableName . "'"; } debug($sql); if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql); ociExecute($stmt, OCI_DEFAULT); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { switch(strtoupper($row["DATA_TYPE"])) { case "RAW": case "LONG RAW": case "MLSLABEL"; case "TIMESTAMP": case "BFILE": case "LONG": break; case "BLOB": case "CLOB": case "NBLOB": $items[$row["FIELD"]]["type"] = "blob"; $items[$row["FIELD"]]["empty"] = "EMPTY_CLOB()"; break; case "CHAR": case "NCHAR": case "VARCHAR2": case "NVARCHAR2": $items[$row["FIELD"]]["type"] = "text"; if($row["NULLABLE"] == "Y") { $items[$row["FIELD"]]["empty"] = "NULL"; } else { $items[$row["FIELD"]]["empty"] = "''"; } break; case "NUMBER": $items[$row["FIELD"]]["type"] = "number"; if($row["NULLABLE"] == "Y") { $items[$row["FIELD"]]["empty"] = "NULL"; } else { $items[$row["FIELD"]]["empty"] = "0"; } break; case "DATE": if($row["NULLABLE"] == "Y") { $items[$row["FIELD"]]["type"] = "date"; $items[$row["FIELD"]]["empty"] = "NULL"; } break; } } ociFreeStatement($stmt); return($items); } //popola l'array outDefinition con le definizioni lette da formDefinition ed i valori letti da values //facendo caso ai valori di default function readValues($formDefinition, $values, $escape = FALSE, $forInsert = FALSE) { $outDefinition = array(); $outDefinition = $formDefinition; for($i=0; $i < count($formDefinition["fields"]); $i++) { $fieldName = $formDefinition["fields"][$i]; $val = ""; if(($formDefinition[$fieldName]["insertvalue"] == "") || ($forInsert == FALSE)) { if($formDefinition[$fieldName]["defaultvalue"] != "") { $val = $formDefinition[$fieldName]["defaultvalue"]; } if(is_array($values) && array_key_exists($fieldName, $values)) { if(is_array($values[$fieldName])) { $val = implode(",", $values[$fieldName]); } else { switch($formDefinition[$fieldName]["datatype"]) { case "date": $val = getHumanDate($values[$fieldName]); break; case "datetime"; $val = getHumanDateTime($values[$fieldName]); break; default: $val = $values[$fieldName]; } } } } else { $val = $formDefinition[$fieldName]["insertvalue"]; } if($escape) { //$outDefinition[$fieldName]["value"] = addslashes($val); $outDefinition[$fieldName]["value"] = $val; } else { $outDefinition[$fieldName]["value"] = $val; } } return $outDefinition; } //imposta i valori di outDefinition con i dati inviati dall'utente function setValues($formDefinition, $nameAppend, $values, $forInsert = FALSE) { $outDefinition = array(); $outDefinition = $formDefinition; foreach($values as $k => $v) { $values[$k] = adjustWordQuote($v); if(ini_get("magic_quotes_gpc")) { if(is_array($v)) { /*foreach($v as $kk => $kk) { $values[$k][$kk] = stripslashes($values[$k][$kk]); }*/ foreach($v as $kk => $vv) { $values[$k][$kk] = stripslashes($values[$k][$kk]); } } else { $values[$k] = stripslashes($values[$k]); } } } for($i=0; $i < count($formDefinition["fields"]); $i++) { $fieldName = $formDefinition["fields"][$i]; if(($formDefinition[$fieldName]["insertvalue"] == "") || ($forInsert == FALSE)) { //debug($formDefinition[$fieldName]); $val = ""; $t = $formDefinition[$fieldName]["type"]; if(($t != "file") && ($t != "obj") && ($t != "img") && ($t != "video")) { //if(($t != "file")) if(array_key_exists($fieldName . $nameAppend, $values)) { if(is_array($values[$fieldName . $nameAppend])) { $val = implode(",", $values[$fieldName . $nameAppend]); } else { switch($formDefinition[$fieldName]["type"]) { case "password": if($values[$fieldName . $nameAppend . "_confirm"] == $values[$fieldName . $nameAppend]) { $val = ($values[$fieldName]); } break; case "hidden": case "text": $val = trim($values[$fieldName . $nameAppend]); break; case "textarea": $val = str_replace("\r\n", "", nl2br(htmlspecialchars($values[$fieldName . $nameAppend]))); $val = trim(eregi_replace("[\n]*[\r]*", "", $val)); break; case "htmlarea": $val = trim(eregi_replace("[\n]*[\r]*", "", $values[$fieldName . $nameAppend])); break; default: $val = $values[$fieldName . $nameAppend]; } if(!ini_get("magic_quotes_gpc")) { //$val = addslashes($val); } } } else { if($formDefinition[$fieldName]["type"] == "combo") { if($formDefinition[$fieldName]["combo_widget"]) { $val = implode(",", getArrayFromList( $values, $fieldName . $nameAppend)); } } } } else { $val["file"] = ""; $val["file_ext"] = ""; $val["file_size"] = ""; $val["file_name"] = ""; $val["file_delete"] = 0; if(array_key_exists($fieldName . $nameAppend . "_delete", $values)) { $val["file_delete"] = $values[$fieldName . $nameAppend . "_delete"]; } if(!$val["file_delete"]) { if(array_key_exists($fieldName . $nameAppend, $_FILES)) { if(($_FILES[$fieldName . $nameAppend]["error"] == 0) && ($_FILES[$fieldName . $nameAppend]["size"] > 0)) { $path_parts = pathinfo($_FILES[$fieldName . $nameAppend]["name"]); $val["file_ext"] = $path_parts["extension"]; $val["file_size"] = $_FILES[$fieldName . $nameAppend]["size"]; $val["file_name"] = $_FILES[$fieldName . $nameAppend]["name"]; $val["file"] = $_FILES[$fieldName . $nameAppend]["tmp_name"]; } } } } if(($t != "file") && ($t != "obj") && ($t != "img") && ($t != "video") && (strlen($val) == 0 ) && ($formDefinition[$fieldName]["skipempty"] == FALSE)) { //if(($t != "file") && (strlen($val) == 0 ) && ($formDefinition[$fieldName]["skipempty"] == FALSE)) //{ switch($formDefinition[$fieldName]["macrotype"]) { //(text, int, calendar, float) case "text": $val = ""; break; case "int": case "float": $val = 0; break; case "calendar": switch($formDefinition[$fieldName]["datatype"]) { case "date": $val = "00-00-0000"; break; case "time": $val = "00:00:00"; break; case "datetime"; $val = "00-00-0000 00:00:00"; break; case "timestamp": $val = "0"; break; case "year": $val = "0"; break; } break; } } } else { if(($t != "file") && ($t != "obj") && ($t != "img") && ($t != "video")) { $val = $formDefinition[$fieldName]["insertvalue"]; } } $outDefinition[$fieldName]["value"] = $val; } return $outDefinition; } // function getParsedValues($itemDefinition, $enableEscape = FALSE) { switch($itemDefinition["macrotype"]) { //(text, int, calendar, float) case "text": if($enableEscape) { //$value = "'" . quoteForDb(substr($itemDefinition["value"], 0, $itemDefinition["datasize"] - 2)) . "'"; $value = "'" . quoteForDb(substr($itemDefinition["value"], 0, $itemDefinition["datasize"])) . "'"; } else { //$value = "'" . substr($itemDefinition["value"], 0, $itemDefinition["datasize"] - 2) . "'"; $value = "'" . substr($itemDefinition["value"], 0, $itemDefinition["datasize"]) . "'"; } break; case "int": $value = intval($itemDefinition["value"]); break; case "float": $value = $itemDefinition["value"]; break; case "calendar": switch($itemDefinition["datatype"]) { case "date": if(getIsoDate($itemDefinition["value"]) == "0000-00-00") { $value = "NULL"; } else { $value = "to_date('" . getIsoDate($itemDefinition["value"]) . "','YYYY-MM-DD')"; } break; case "time": if(getIsoTime($itemDefinition["value"]) == "00:00:00") { $value = "NULL"; } else { $value = "to_date('" . getIsoTime($itemDefinition["value"]) . "','HH24:MI:SS')"; } break; case "datetime": if(getIsoDateTime($itemDefinition["value"]) == "0000-00-00 00:00:00") { $value = "NULL"; } else { $value = "to_date('" . getIsoDateTime($itemDefinition["value"]) . "','YYYY-MM-DD HH24:MI:SS')"; } break; case "year": $value = "'" . intval($itemDefinition["value"]) . "'"; break; case "timestamp": //$value = "'" . intval($itemDefinition["value"]) . "'"; $value = intval($itemDefinition["value"]); } break; } return $value; } // function getUpdateQuery($tableName, $formDefinition, $otherValues = 0, $excludeFields = 0) { for($i = 0; $i < count($formDefinition["fields"]); $i++) { $fieldName = $formDefinition["fields"][$i]; if(is_array($excludeFields)) { if (in_array($fieldName, $excludeFields)) { continue; } } if($formDefinition[$formDefinition["fields"][$i]]["ro"]) { continue; } switch ($formDefinition[$formDefinition["fields"][$i]]["datatype"]) { case "blob": case "clob": case "nclob": $sql .= "\"" . $fieldName . "\" = EMPTY_CLOB(), "; break; default: if((strlen($formDefinition[$fieldName]["value"]) > 0 ) || ($formDefinition[$fieldName]["skipempty"] == FALSE)) { $sql .= "\"" . $fieldName . "\" = "; $sql .= getParsedValues($formDefinition[$fieldName], TRUE) . ", "; } } } if(is_array($otherValues)) { foreach($otherValues as $k => $v) { $sql .= "\"$k\" = $v, "; } } if(strlen($sql) > 0) { $sql = substr($sql, 0, -2); } $sql = "UPDATE \"$tableName\" SET " . $sql; return $sql; } // function getInsertQuery($tableName, $formDefinition, $otherValues = 0, $excludeFields = 0, $sqlPart = "all") { $fields = ""; $values = ""; for($i = 0; $i < count($formDefinition["fields"]); $i++) { $fieldName = $formDefinition["fields"][$i]; if(is_array($excludeFields)) { if (in_array($fieldName, $excludeFields)) { continue; } } if($formDefinition[$formDefinition["fields"][$i]]["ro"]) { continue; } $doAppend = FALSE; if($sqlPart != "all") { $doAppend = TRUE; } else { if((strlen($formDefinition[$fieldName]["value"]) > 0 ) || ($formDefinition[$fieldName]["skipempty"] == FALSE)) { $doAppend = TRUE; } } if($doAppend) { $fields .= "\"" . $fieldName . "\", "; switch ($formDefinition[$formDefinition["fields"][$i]]["datatype"]) { case "blob": case "clob": case "nclob": $values .= "EMPTY_CLOB(), "; break; default: $values .= getParsedValues($formDefinition[$fieldName], TRUE) . ", "; } } } if(is_array($otherValues)) { foreach($otherValues as $k => $v) { $fields .= "\"$k\", "; $values .= "$v, "; } } if(strlen($fields) > 0) { $fields = substr($fields, 0, -2); $values = substr($values, 0, -2); } switch($sqlPart) { case "all": $sql = "INSERT INTO \"$tableName\" ($fields) VALUES ($values)"; break; case "values": $sql = "($values)"; break; case "fields": $sql = "($fields)"; break; } return $sql; } // function getOrderByParam($from) { $orderCrit = array(); if (array_key_exists("ord", $from)) { if(checkCleanChar($from["ord"])) { $orderCrit["order"] = $from["ord"]; } } if (array_key_exists("dir", $from)) { $orderCrit["direction"] = "asc"; if($from["dir"] == "desc") { $orderCrit["direction"] = "desc"; } } return $orderCrit; } // function getOrderByCriteria(&$from, &$definition, &$orderCrit) { $orderBy = ""; $orderCrit = getOrderByParam($from); if(strlen($orderCrit["order"]) == 0) { $orderBy = $definition["order"]; } else { $orderBy = "lower(" . $orderCrit["order"] . ") " . $orderCrit["direction"]; } return $orderBy; } // function getWhereCriteria(&$from, &$definition, &$filterValues) { $filter = ""; $filterValues = array(); if(array_key_exists("submit_x", $from) || array_key_exists("submit", $from)) { $tmpFilter = array(); foreach($definition["fields"] as $f) { if (array_key_exists($f, $from)) { $from[$f] = trim($from[$f]); if(strlen($from[$f]) > 0) { if(checkCleanChar($from[$f])) { $filterValues[$f] = $from[$f]; if($definition[$f]["datatype"] == "datetime") { $tmpDate = getIsoDate($from[$f]); if($tmpDate == "0000-00-00") { $filterValues[$f] = ""; } else { $tmpFilter[] = $f . " = to_date( '" . $tmpDate . "', 'YYYY-MM-DD')"; } } else { switch ($definition[$f]["type"]) { case "obj": $tmpFilter[] = " lower(" . $f . "_NAME) LIKE '%" . strtolower($from[$f]) . "%'"; break; case "text": $tmpFilter[] = " lower(" .$f . ") LIKE '%" . strtolower($from[$f]) . "%'"; break; case "combo": if($from[$f] != "0") { $tmpFilter[] = " $f = '" . $from[$f] . "'"; } break; case "checkbox": if($from[$f] > 0) { $tmpFilter[] = " $f = '" . $from[$f] . "'"; } break; } } } } } } if(count($tmpFilter) > 0) { if(strlen($filter) > 0) { $filter .= " AND " . implode(" AND ", $tmpFilter); } else { $filter .= implode(" AND ", $tmpFilter); } } } return $filter; } ?> 0) { if($multiple) { $items = explode(",", $selected); if($isText) { for($i = 0; $i < count($items); $i++) { $items[$i] = "'" . $items[$i] . "'"; } } //$items = explode(",", $selected); } else { $selected = "'" . $selected . "'"; $items[] = $selected; } } $selected = implode(",", $items); if(count($items) > 0) { $sql = "SELECT * FROM " . $table . " WHERE $itemId IN ($selected)"; if(trim($order) != "" ) { $sql .= " order by " . $order; } if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", array($sql, ociError($stmt))); ociExecute($stmt, OCI_DEFAULT) or doError("sql", array($sql, ociError($stmt))); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { for($i = 0; $i < count($lista); $i++) { //$combo .= substr(($row[$lista[$i]]),0,50) . " "; $combo .= $row[$lista[$i]] . " "; } if($isText) { $combo .= "
"; } } ociFreeStatement($stmt) or doError("sql", array($sql, ociError($stmt))); } return $combo; } // function getComboFromDB($name, &$cnn, $table, $order, $itemId, $itemName, $selected, $filter, $multiple, $emptyrow, $attrib = "" ) { $sql = ""; $combo = ""; $items = array(); $lista = array(); $lista = explode(",", $itemName); if($multiple) { $items = explode(",", $selected); $name = $name . "[]"; } else { $items[] = $selected; } $combo = "\n"; } // function GetHTMLArea($name, $value, $rows, $cols, $attrib = "") { //return ""; return ""; } // function GetTextArea($name, $value, $cols, $rows, $attrib = "") { if(($rows == "") || ($rows <= 0)) { $rows = 3; } if(($cols == "") || ($cols <= 0)) { $cols = 10; } //return "\n"; return "\n"; } // function GetCheckBox($name, $value, $checked, $attrib = "") { $status = ""; if($value != "") { if(($checked == TRUE) || ($checked == 1)) { $status = "checked"; } } return "\n"; } // function GetRadio($name, $value, $checked, $attrib = "") { $status = ""; if($value != "") { if(($checked == TRUE) || ($checked == 1)) { $status = "checked"; } } return "\n"; } function drawWidget(&$cnn, $formReadOnly, $field, $definition, $value, $extra="") { $iniItem = $definition[$field]; $type = $iniItem["type"]; switch ($type) { case "text": if(!$formReadOnly && !$iniItem["ro"]) { echo GetInput($field, $type, htmlspecialchars($value), $iniItem["datasize"], $iniItem["width"], $extra); } else { echo $value; } break; case "hidden": if(!$formReadOnly && !$iniItem["ro"]) { echo GetInput($field, $type, $value, $iniItem["datasize"], $extra); } break; case "password": if(!$formReadOnly && !$iniItem["ro"]) { echo GetInput($field, $type, $value, $iniItem["datasize"], $iniItem["width"], $extra); //echo " "; echo GetInput($field . "_confirm", $type, $value, $iniItem["datasize"], $iniItem["width"], $extra); //echo "
"; } else { echo "**********"; } break; case "textarea": if((!$formReadOnly && !$iniItem["ro"]) || ($iniItem["include"])) { if($iniItem["include"]) { echo "\n"; } else { echo GetTextArea($field, br2nl($value), $iniItem["width"], $iniItem["height"], $extra); } } else { echo $iniItem["value"]; } break; case "combo": switch($iniItem["combo_source"]) { case "table": if(!$formReadOnly && !$iniItem["ro"]) { $sql = "SELECT * FROM " . $iniItem["combo_lookup"]; if(strlen($iniItem["combo_filter"]) > 0) { $sql .= " WHERE " . $iniItem["combo_filter"]; } if(strlen($iniItem["combo_order"]) > 0) { $sql .= " ORDER BY " . $iniItem["combo_order"]; } if($iniItem["combo_widget"] == "list") { echo GetComboFromSql($field, $cnn, $sql, $iniItem["combo_key"], $iniItem["combo_value"], $value, $iniItem["combo_multiple"], $iniItem["combo_emptyline"], $extra); } else { echo getCheckboxGroupFromSql($field, $cnn, $sql, $iniItem["combo_key"], $iniItem["combo_value"], $value, $iniItem["combo_multiple"], $iniItem["combo_emptyline"], $extra); } //echo getComboFromDB($field, $cnn, $iniItem["combo_lookup"], $iniItem["combo_order"], $iniItem["combo_key"], $iniItem["combo_value"], $value, $iniItem["combo_multiple"], $iniItem["combo_emptyline"] ); } else { echo getValsFromDB($cnn, $iniItem["combo_lookup"], $iniItem["combo_order"], $iniItem["combo_key"], $iniItem["combo_value"], $value, $iniItem["combo_multiple"], $iniItem["combo_emptyline"], "disabled"); } break; // case "sql": // break; // case "values": // break; case "array": if(strlen($iniItem["combo_lookup_key"]) > 0) { $tmp = $$iniItem["combo_lookup"]; $data = $tmp[$iniItem["combo_lookup_key"]]; } else { $data = $$iniItem["combo_lookup"]; } if(!$formReadOnly && !$iniItem["ro"]) { echo getComboFromArray($field, $data, $iniItem["combo_key"], $iniItem["combo_value"], $value, $iniItem["combo_multiple"], $iniItem["combo_emptyline"], $extra); } else { echo getValsFromArray($data, $iniItem["combo_key"], $iniItem["combo_value"], $value, $iniItem["combo_multiple"], $iniItem["combo_emptyline"]); } break; } break; case "checkbox": if(!$formReadOnly && !$iniItem["ro"]) { echo GetCheckBox($field, 1, $value, $extra); } else { echo GetCheckBox($field, 1, $value, "$extra disabled"); } break; case "radio": switch($iniItem["radio_source"]) { case "values": for($i = 0; $i < count($iniItem["radio_value"]); $i++) { $r = $iniItem["radio_value"][$i]; $l = $iniItem["radio_label"][$i]; echo GetRadio($field, $r, ($r == $value), $formReadOnly ? "$extra disabled":"$extra"); echo "$l \n"; } break; } break; } } ?> 0) { $out = 0; $ts = 0; if(LOG_SQL) { $sql = "BEGIN :retcode := PKG_SESSION.REFRESH_SESSION('$sessionId', $timeout, :out_ts); END;"; logWrite($sql, "sql"); logWrite($sql, "session"); } $sql = "BEGIN :retcode := PKG_SESSION.REFRESH_SESSION(:in_ds_session, :in_timeout, :out_ts); END;"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":in_ds_session", $sessionId, strlen( $sessionId)) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":in_timeout", $timeout, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":out_ts", $ts, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":retcode", $out, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if($out == 0) { logWrite("var out = 0", "session"); setSessionId($sessionId, $ts, $timeout); setSessionUserIdAlt(getSessionUserIdAlt($cnn), $ts); } else { logWrite("var out != 0 - session refresh failed", "session"); closeSession($cnn); doError("outoftime", "refreshSession FAILED"); } } } // function closeSession(&$cnn) { $sessionId = getSessionId(); setSessionId(""); setSessionUserIdAlt(0); if(strlen($sessionId) > 0) { $out = 0; $ts = 0; if(LOG_SQL) { $sql = "BEGIN :retcode := PKG_SESSION.CLOSE_SESSION('$sessionId', :out_ts); END;"; logWrite($sql, "sql"); } $sql = "BEGIN :retcode := PKG_SESSION.CLOSE_SESSION(:in_ds_session, :out_ts); END;"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":in_ds_session", $sessionId, strlen( $sessionId)) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":out_ts", $ts, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":retcode", $out, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); getSessionId(TRUE); getSessionUserKey($cnn, TRUE); if($out == 0) { return TRUE; } else { return FALSE; } } return FALSE; } function closeAllUserSessions(&$cnn, $userKey) { if(LOG_SQL) { $sql = "DELETE FROM USR_SESSION WHERE USER_KEY = '$userKey'"; logWrite($sql, "sql"); } $sql = "DELETE FROM USR_SESSION WHERE USER_KEY = :userKey"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userKey", $userKey, strlen($userKey)) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return TRUE; } // function setSessionId($sessionId, $ts = 0, $timeout = 0) { if($timeout) { if(strlen($sessionId) == 0) { if($ts == 0) { $ts = time() - 3600; } } else { if($ts == 0) { $ts = time() + SESSIONTIMEOUT * 86400; } else { $ts += SESSIONTIMEOUT * 86400; } } } else { $ts = 0; } setcookie (SESSION_NAME_USER, $sessionId, $ts, "/"); } // function setSessionUserIdAlt($userIdAlt, $ts = 0) { if(SESSIONTIMEOUT == 0) { $ts = 0; } else { $userIdAlt = intval($userIdAlt); if($userIdAlt == 0) { $ts = time() - 3600; } else { if($ts == 0) { $ts = time() + SESSIONTIMEOUT; } else { $ts += SESSIONTIMEOUT; } } } setcookie (SESSION_NAME_ALT, $userIdAlt, $ts, "/"); } // function getSessionUserIdAlt(&$cnn) { $userIdAlt = 0; if(array_key_exists(SESSION_NAME_ALT, $_COOKIE)) { $userIdAlt = intval($_COOKIE[SESSION_NAME_ALT]); } return $userIdAlt; } // function getSessionUserKey(&$cnn, $erase = FALSE) { static $userKey = ""; static $sessionId = ""; if($erase) { $userKey = ""; $sessionId = ""; return $userKey; } if(strlen($sessionId) == 0) { $sessionId = getSessionId(); } if(strlen($sessionId) > 0) { if(strlen($userKey) == 0) { $userKey = ""; $ts = 0; if(LOG_SQL) { $sql = "BEGIN :retcode := PKG_SESSION.GET_USER_KEY('$sessionId', :out_user_key, :out_timeout, :out_ts); END;"; logWrite($sql, "sql"); logWrite($sql, "session"); } $sql = "BEGIN :retcode := PKG_SESSION.GET_USER_KEY(:in_ds_session, :out_user_key, :out_timeout, :out_ts); END;"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":in_ds_session", $sessionId, strlen( $sessionId)) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":out_user_key", $userKey, 50) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":out_timeout", $timeout, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":out_ts", $ts, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":retcode", $out, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if($out == 0) { logWrite("var out = 0", "session"); if($timeout > 0 ) { $timeout = SESSIONTIMEOUT * 86400; logWrite("var timeout = $timeout", "session"); } else { /*if(!validateFullSid($sessionId)) { logWrite("failed validateFullSid", "session"); closeSession($cnn); return ""; }*/ } logWrite("refresh session", "session"); refreshSession($cnn, $timeout); } else { $userKey = ""; //closeSession($cnn); } } } logWrite("var userKey = $userKey", "session"); return $userKey; } ?> 0) && ($row["NU_LOGIN_FAILED"] >= LOGIN_CRIT_FAILED) && ($loginFailedTime < LOGIN_MAX_FAILED_TIME)) { $userData = ""; } else { $userData = ""; if($found && strlen($row["USR_PASSWORD"]) > 0) { $tmpUserId = $row["ID"]; $tmpUserName = $row["USR_USERNAME"]; $tmpPassword = $row["USR_PASSWORD"]; } } } unset($row["USR_PASSWORD"]); ociFreeStatement($stmt); if($tmpUserId > 0) { if($encrypt) { if(crypt($userPassword, $tmpPassword) == $tmpPassword) { $dataOk = TRUE; } } else { if($userPassword == $tmpPassword) { $dataOk = TRUE; if($caseSensitive) { $tmpUserKey = $userName; } else { $tmpUserKey = strtolower($userName); } } } } } if($dataOk == TRUE) { $tmpSessionID = startSession($cnn, $tmpUserKey, $persistent * 86400); //$tmpSessionID = startSession($cnn, $tmpUserId); if(strlen($tmpSessionID) > 0) { if(LOG_SQL) { $sql = "UPDATE USR_USER SET DT_LOGIN_OK = sysdate, NU_LOGIN_FAILED = 0 WHERE ID = " . $tmpUserId; logWrite($sql, "sql"); } $sql = "UPDATE USR_USER SET DT_LOGIN_OK = sysdate, NU_LOGIN_FAILED = 0 WHERE ID = :userid"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userid", $tmpUserId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); return "ok"; } } else { if($found) { $loginFailed = 1; if($loginFailedTime < LOGIN_MAX_FAILED_TIME) { $loginFailed = $row["NU_LOGIN_FAILED"] + 1; } if(LOG_SQL) { $sql = "UPDATE USR_USER SET DT_LOGIN_FAILED = sysdate, NU_LOGIN_FAILED = " . $loginFailed . " WHERE ID = " . $row["ID"]; logWrite($sql, "sql"); } $sql = "UPDATE USR_USER SET DT_LOGIN_FAILED = sysdate, NU_LOGIN_FAILED = :failed WHERE ID = :userid"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userid", $row["ID"], 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":failed", $loginFailed , 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); $retval = "ko"; if($loginFailed >= LOGIN_WARN_FAILED) { $retval = "warn"; } if($loginFailed >= LOGIN_CRIT_FAILED) { $retval = "crit"; } } } logWrite("login $retval: login attempt " . $loginFailed . " times, last attempt " . $loginFailedTime . " sec ago ", "main"); if($retval == "crit") { logWrite("disabling login for " . LOGIN_MAX_FAILED_TIME . "sec, user $userName","main"); } return $retval; } function forceLogin(&$cnn, $userName, $caseSensitive = FALSE) { // check per caratteri $retval = "ko"; $tmpUserId = 0; $tmpPassword = ""; $tmpUserName = ""; $dataOk = FALSE; if($caseSensitive == FALSE) { $userName = strtolower($userName); } closeSession($cnn); if(checkCleanChar($userName)) { if(LOG_SQL) { $sql = "SELECT ID, USR_USERNAME, ((sysdate - DT_LOGIN_FAILED) * 3600 * 24) AS TIME_FAILED_LOGIN , NU_LOGIN_FAILED FROM USR_USER WHERE USR_USERNAME = '$userName' AND FL_ACTIVE = 1 AND \"FL_CHECKED\" = 1 AND FL_DELETED = 0"; logWrite($sql, "sql"); } $sql = "SELECT ID, USR_USERNAME, ((sysdate - DT_LOGIN_FAILED) * 3600 * 24) AS TIME_FAILED_LOGIN, NU_LOGIN_FAILED FROM USR_USER WHERE USR_USERNAME = :username AND FL_ACTIVE = 1 AND \"FL_CHECKED\" = 1 AND FL_DELETED = 0"; $found = FALSE; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":username", $userName, strlen($userName)) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { if($caseSensitive) { if($row["USR_USERNAME"] == $userName) { $found = TRUE; } } else { if(strtolower($row["USR_USERNAME"]) == strtolower($userName)) { $found = TRUE; } } $loginFailedTime = intval($row["TIME_FAILED_LOGIN"]); $userData = getUserData($cnn, $row["ID"]); if((!$userData["FL_ROOT"]) && (LOGIN_CRIT_FAILED > 0) && ($row["NU_LOGIN_FAILED"] >= LOGIN_CRIT_FAILED) && ($loginFailedTime < LOGIN_MAX_FAILED_TIME)) { $userData = ""; } else { $userData = ""; if($found) { $tmpUserId = $row["ID"]; $tmpUserName = $row["USR_USERNAME"]; } } } ociFreeStatement($stmt); if($tmpUserId > 0) { $dataOk = TRUE; if($caseSensitive) { $tmpUserKey = $userName; } else { $tmpUserKey = strtolower($userName); } } } if($dataOk == TRUE) { $tmpSessionID = startSession($cnn, $tmpUserKey); //$tmpSessionID = startSession($cnn, $tmpUserId); if(strlen($tmpSessionID) > 0) { if(LOG_SQL) { $sql = "UPDATE USR_USER SET DT_LOGIN_OK = sysdate, NU_LOGIN_FAILED = 0 WHERE ID = " . $tmpUserId; logWrite($sql, "sql"); } $sql = "UPDATE USR_USER SET DT_LOGIN_OK = sysdate, NU_LOGIN_FAILED = 0 WHERE ID = :userid"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userid", $tmpUserId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); return "ok"; } } else { if($found) { $loginFailed = 1; if($loginFailedTime < LOGIN_MAX_FAILED_TIME) { $loginFailed = $row["NU_LOGIN_FAILED"] + 1; } if(LOG_SQL) { $sql = "UPDATE USR_USER SET DT_LOGIN_FAILED = sysdate, NU_LOGIN_FAILED = " . $loginFailed . " WHERE ID = " . $row["ID"]; logWrite($sql, "sql"); } $sql = "UPDATE USR_USER SET DT_LOGIN_FAILED = sysdate, NU_LOGIN_FAILED = :failed WHERE ID = :userid"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userid", $row["ID"], 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":failed", $loginFailed , 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); $retval = "ko"; if($loginFailed >= LOGIN_WARN_FAILED) { $retval = "warn"; } if($loginFailed >= LOGIN_CRIT_FAILED) { $retval = "crit"; } } } logWrite("login $retval: login attempt " . $loginFailed . " times, last attempt " . $loginFailedTime . " sec ago ", "main"); if($retval == "crit") { logWrite("disabling login for " . LOGIN_MAX_FAILED_TIME . "sec, user $userName","main"); } return $retval; } // function logout(&$cnn) { setUserIdAlt($cnn, 0); $sessionId = getSessionId(); if(strlen($sessionId) > 0) { closeSession($cnn); return OK; } return ERR_FAIL; } // function logoutUser(&$cnn, $userKey) { setUserIdAlt($cnn, 0); $sessionId = getSessionId(); if(strlen($userKey) > 0) { $status = closeAllUserSessions($cnn, $userKey); if($status) { return TRUE; } else { return FALSE; } } else { return FALSE; } } // function getUserIdAlt(&$cnn) { static $userIdAlt = 0; if($userIdAlt == 0) { if(isLogged($cnn)) { $userIdAlt = getSessionUserIdAlt($cnn); } } return $userIdAlt; } // function setUserIdAlt(&$cnn, $userIdAlt) { setSessionUserIdAlt($userIdAlt); } // function getUserIdFromName(&$cnn, $userName) { $userId = 0; if($userName != "") { if(LOG_SQL) { $sql = "SELECT ID FROM USR_USER WHERE USR_USERNAME = '$userName' AND FL_DELETED = 0"; logWrite($sql, "sql"); } $sql = "SELECT ID FROM USR_USER WHERE USR_USERNAME = :username AND FL_DELETED = 0"; $stmt = ociParse($cnn, $sql) or doError("sql",$sql); ociBindByName($stmt, ":username", $userName, strlen($userName)) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $userId = $row["ID"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return $userId; } // function getUserName(&$cnn, $userId) { $userName = ""; $userId = intval($userId); if($userId > 0) { if(LOG_SQL) { $sql = "SELECT USR_USERNAME FROM USR_USER WHERE ID = $userId AND FL_DELETED = 0"; logWrite($sql, "sql"); } $sql = "SELECT USR_USERNAME FROM USR_USER WHERE ID = :userid AND FL_DELETED = 0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userid", $userId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $userName = $row["USR_USERNAME"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return $userName; } // function userNameExist(&$cnn, $userName) { $exist = FALSE; if(LOG_SQL) { $sql = "SELECT COUNT(*) AS C FROM USR_USER WHERE USR_USERNAME = '$userName' AND FL_DELETED = 0"; logWrite($sql, "sql"); } $sql = "SELECT COUNT(*) AS C FROM USR_USER WHERE USR_USERNAME = :username AND FL_DELETED = 0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":username", $userName, strlen($userName)) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { if($row["C"] > 0) { $exist = TRUE; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $exist; } // function userExist(&$cnn, $userId) { $userId = intval($userId); if($userId > 0) { if(LOG_SQL) { $sql = "SELECT COUNT(*) AS C FROM USR_USER WHERE ID = $userId AND FL_DELETED = 0"; logWrite($sql, "sql"); } $sql = "SELECT COUNT(*) AS C FROM USR_USER WHERE ID = :userid AND FL_DELETED = 0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userid", $userId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { if($row["C"] == 1) { return TRUE; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return FALSE; } // function getAllGroups(&$cnn, $includeBackend = FALSE, $includeEveryone = FALSE) { $userId = intval($userId); $groups = array(); if($includeEveryone) { $groups[] = array("ID" => 0, "NAME" => "Everyone"); $groups[] = array("ID" => "@", "NAME" => "Valid User"); } $sql = "SELECT * FROM USR_GROUP WHERE FL_DELETED = 0"; if(!$includeBackend) { $sql .= " AND FL_BACKEND = 0"; } $sql .= " ORDER BY NAME ASC"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $groups[] = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $groups; } // function getGroup(&$cnn, $groupId) { $groupId = intval($groupId); $group = array(); if(LOG_SQL) { $sql = "SELECT * FROM USR_GROUP WHERE FL_DELETED = 0 AND ID = $groupId ORDER BY NAME ASC"; logWrite($sql, "sql"); } $sql = "SELECT * FROM USR_GROUP WHERE FL_DELETED = 0 AND ID = :groupid ORDER BY NAME ASC"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":groupid", $groupId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $group = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $group; } // function getUsersInGroup(&$cnn, $groupId) { $groupId = intval($groupId); $userGroups = array(); if(LOG_SQL) { $sql = "SELECT USR_USER.ID FROM USR_USER_GROUP LEFT JOIN USR_USER ON USR_USER_GROUP.USERID = USR_USER.ID WHERE USR_USER.FL_DELETED = 0 AND USR_USER_GROUP.GROUPID = $groupId"; logWrite($sql, "sql"); } $sql = "SELECT USR_USER.ID FROM USR_USER_GROUP LEFT JOIN USR_USER ON USR_USER_GROUP.USERID = USR_USER.ID WHERE USR_USER.FL_DELETED = 0 AND USR_USER_GROUP.GROUPID = :groupid"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":groupid", $groupId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $userGroups[] = $row["ID"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $userGroups; } // function getGroupsIdByUserId(&$cnn, $userId, $includeBackend = FALSE) { $userId = intval($userId); $userGroups = array(); if(LOG_SQL) { $sql = "SELECT USR_GROUP.ID FROM USR_USER_GROUP LEFT JOIN USR_GROUP ON USR_USER_GROUP.GROUPID = USR_GROUP.ID WHERE USR_GROUP.FL_DELETED = 0 AND USR_USER_GROUP.USERID = $userId"; if(!$includeBackend) { $sql .= " AND FL_BACKEND = 0"; } logWrite($sql, "sql"); } $sql = "SELECT USR_GROUP.ID FROM USR_USER_GROUP LEFT JOIN USR_GROUP ON USR_USER_GROUP.GROUPID = USR_GROUP.ID WHERE USR_GROUP.FL_DELETED = 0 AND USR_USER_GROUP.USERID = :userid"; if(!$includeBackend) { $sql .= " AND FL_BACKEND = 0"; } $stmt = ociParse($cnn, $sql) or doError("sql", ociError($sql)); ociBindByName($stmt, ":userid", $userId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $userGroups[] = $row["ID"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $userGroups; } // function getAllUsers(&$cnn, $includeBackEndUsers = FALSE, $includeDisactive = FALSE) { $usersData = array(); $usersId = array(); $usersId = getAllUsersId($cnn, $includeBackEndUsers, $includeDisactive); for($i = 0; $i < count($usersId); $i++) { $tmp = getUserData($cnn, $usersId[$i]); $usersData[] = $tmp; } return $usersData; } // function getAllUsersId(&$cnn, $includeBackEndUsers = FALSE, $includeDisactive = FALSE) { $usersId = array(); if(!$includeBackEndUsers) { $sql = "SELECT USR_USER.ID "; $sql .= "FROM USR_USER LEFT JOIN USR_USER_GROUP ON USR_USER.ID = USR_USER_GROUP.USERID "; $sql .= "LEFT JOIN USR_GROUP ON USR_USER_GROUP.GROUPID = USR_GROUP.ID AND USR_GROUP.FL_DELETED = 0 "; $sql .= "WHERE USR_USER.FL_DELETED = 0 "; if(!$includeDisactive) { $sql .= "AND USR_USER.FL_ACTIVE = 1 "; } $sql .= " GROUP BY USR_USER.ID HAVING SUM(USR_GROUP.FL_BACKEND) = 0 "; } else { $sql = "SELECT USR_USER.ID FROM USR_USER WHERE USR_USER.FL_DELETED = 0 "; if(!$includeDisactive) { $sql .= " AND USR_USER.FL_ACTIVE = 1"; } } if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $usersId[] = $row["ID"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $usersId; } // function getUserData(&$cnn, $userId) { //$key = "userData." . $userId; $userData = array(); //if(DISABLE_CACHE || ($userId == 0) || (!readCacheData($cnn, $userId, $key, $userData))) { $userId = intval($userId); $userData["ID"] = $userId; $userData["USR_USERNAME"] = ""; $userData["NOME"] = ""; $userData["COGNOME"] = ""; $userData["EMAIL"] = ""; $userData["DS_TEL"] = ""; $userData["DS_CELL"] = ""; $userData["DT_NASCITA"] = ""; $userData["USR_GROUP"] = array(); $userData["FL_BACKEND"] = 0; $userData["FL_ROOT"] = 0; $userData["FL_IMPERSONATE"] = 0; $userData["FL_GEST_PRIV"] = 0; $userData["FL_GEST_LOCK"] = 0; $userData["FL_GEST_CM"] = 0; $userData["FL_PUBLISH"] = 0; if($userId > 0) { if(LOG_SQL) { $sql = "SELECT * FROM USR_USER WHERE ID = $userId AND FL_DELETED=0"; logWrite($sql, "sql"); } $sql = "SELECT * FROM USR_USER WHERE ID = :userid AND FL_DELETED=0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userid", $userId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $userData = $row; $userData["USR_GROUP"] = getGroupsIdByUserId($cnn, $userId, TRUE); if(count($userData["USR_GROUP"]) > 0) { $groups = implode(",", $userData["USR_GROUP"]); $sql = "SELECT MAX(FL_BACKEND) AS FL_BACKEND, MAX(FL_ROOT) AS FL_ROOT, MAX(FL_IMPERSONATE) AS FL_IMPERSONATE, MAX(FL_GEST_LOCK) AS FL_GEST_LOCK, MAX(FL_GEST_PRIV) AS FL_GEST_PRIV, MAX(FL_PUBLISH) AS FL_PUBLISH, MAX(FL_GEST_CM) FL_GEST_CM "; $sql .= "FROM USR_GROUP WHERE ID IN ($groups) AND FL_DELETED = 0"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmtg = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmtg, OCI_DEFAULT) or doError("sql", ociError($stmtg)); while (ociFetchInto($stmtg, $rowg, OCI_ASSOC)) { $userData["FL_BACKEND"] = $rowg["FL_BACKEND"]; $userData["FL_ROOT"] = $rowg["FL_ROOT"]; $userData["FL_IMPERSONATE"] = $rowg["FL_IMPERSONATE"]; $userData["FL_GEST_PRIV"] = $rowg["FL_GEST_PRIV"]; $userData["FL_GEST_LOCK"] = $rowg["FL_GEST_LOCK"]; $userData["FL_PUBLISH"] = $rowg["FL_PUBLISH"]; $userData["FL_GEST_CM"] = $rowg["FL_GEST_CM"]; } ociFreeStatement($stmtg) or doError("sql", ociError($stmtg)); } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if($userData["FL_SSO"]) { if(LOG_SQL) { $sql = "SELECT ID_CLIENTE, ID_CLIENTE_PADRE FROM USR_USER, CLI_CLIENTE_USER WHERE USR_USER.ID = CLI_CLIENTE_USER.ID_USER AND USR_USER.ID =" . $userData["ID"]; logWrite($sql, "sql"); } $sql = "SELECT ID_CLIENTE, ID_CLIENTE_PADRE FROM USR_USER, CLI_CLIENTE_USER WHERE USR_USER.ID = CLI_CLIENTE_USER.ID_USER AND USR_USER.ID = :userid"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userid", $userData["ID"], 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $userData["ESHOP"] = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } /*if(!DISABLE_CACHE) { writeCacheData($cnn, $userId, $key, "user.", $userData); }*/ } } unset($userData["USR_PASSWORD"]); return $userData; } function deleteUser(&$cnn, &$definition, $userId) { $sql = "UPDATE USR_USER "; $sql .= "SET FL_DELETED = 1, "; $sql .= "USR_USERNAME = SUBSTRC('" . $userId . "_' || USR_USERNAME, 1, 50), "; $sql .= "CD_MEMBER = SUBSTRC('" . $userId . "_' || CD_MEMBER, 1, 50) "; $sql .= "WHERE ID = $userId"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); $sql = "DELETE FROM USR_USER_GROUP WHERE USERID = $userId "; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } function deleteGroup(&$cnn, &$definition, $groupId) { $sql = "UPDATE USR_GROUP "; $sql .= "SET FL_DELETED = 1, "; $sql .= "NAME = SUBSTRC('" . $groupId . "_' || NAME,1, 50) "; $sql .= "WHERE ID = $groupId"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); $sql = "DELETE FROM USR_USER_GROUP WHERE GROUPID = $groupId "; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } function insertUserOrGroup(&$cnn, &$definition, $newValues, $otherValues, $excludeValues, &$nodeId) { $sql = "SELECT SQ_" . $definition["table"] . ".NEXTVAL FROM DUAL"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $nodeId = $row["NEXTVAL"]; $otherValues[$definition["key"]] = $nodeId; $sql = getInsertQuery($definition["table"], $newValues, $otherValues, $excludeValues); if(LOG_SQL) { logWrite($sql, "sql"); } $stmti = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmti, OCI_DEFAULT) or doError("sql", ociError($stmti)); ociFreeStatement($stmti) or doError("sql", ociError($stmti)); } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } function updateUser(&$cnn, &$definition, $newValues, $otherValues, $excludeValues, $nodeId) { $sql = getUpdateQuery($definition["table"], $newValues, $otherValues, $excludeValues); $sql .= " WHERE " . $definition["key"] . " = $nodeId"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } function isNwlChecked($userData) { $userStatus = FALSE; if($userData["FL_ACTIVE"] && $userData["FL_CHECKED"] && $userData["FL_NWL"]) { $userStatus = TRUE; } return $userStatus; } function cambiaPassword(&$cnn, $userID, $newPW) { if(LOG_SQL) { $sql = "UPDATE USR_USER SET USR_PASSWORD = '$newPW' WHERE ID = $userID"; logWrite($sql, "sql"); } $sql = "UPDATE USR_USER SET USR_PASSWORD = :password WHERE ID = :userID"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":password", $newPW, strlen($newPW)) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":userID", $userID, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } function getUserDataFromUserName(&$cnn, $userName) { if(isVicCode($userName) && is_numeric($userName)) { $userName = str_pad($userName, 8, 0, STR_PAD_LEFT); } if(LOG_SQL) { $sql = "SELECT ID, EMAIL, DS_CELL, USR_PASSWORD, NOME, COGNOME FROM USR_USER WHERE USR_USERNAME = '$userName'"; logWrite($sql, "sql"); } $sql = "SELECT ID, EMAIL, DS_CELL, USR_PASSWORD, NOME, COGNOME FROM USR_USER WHERE USR_USERNAME = :userName"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userName", $userName, strlen($userName)) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $result[] = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); $rs = $result[0]; return $rs; } function getUserDataFromCdMember(&$cnn, $cd_member) { if(LOG_SQL) { $sql = "SELECT ID FROM USR_USER WHERE CD_MEMBER = '$cd_member' AND FL_DELETED = 0"; logWrite($sql, "sql"); } $sql = "SELECT ID FROM USR_USER WHERE CD_MEMBER = :cd_member AND FL_DELETED = 0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":cd_member", $cd_member, strlen($cd_member)) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while(ociFetchInto($stmt, $row, OCI_ASSOC)) { $result = getUserData($cnn, $row["ID"]); } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $result; } function generateActivationKey($value) { $timeStamp = time(); $hash = md5($timeStamp . rand(97, 122) . rand(97, 122) . $value . rand(97, 122) . rand(97, 122)); return $hash; } function hashNewUser(&$cnn, $userId, $hash) { $ok = FALSE; if(LOG_SQL) { $sql = "UPDATE USR_USER SET ACTIVATION_KEY='$hash', FL_CHECKED=0 WHERE ID = $userId"; logWrite($sql, "sql"); } $sql = "UPDATE USR_USER SET ACTIVATION_KEY=:hash, FL_CHECKED=0 WHERE ID = :userId"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":hash", $hash, strlen($hash)) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":userId", $userId, 32) or doError("sql", ociError($stmt)); if(ociExecute($stmt, OCI_DEFAULT)) { $ok = TRUE; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if($ok) { return $hash; } return ""; } function getUserDataFromHash(&$cnn, $hash) { $userId = 0; $userData = array(); if(LOG_SQL) { $sql = "select ID FROM USR_USER WHERE ACTIVATION_KEY = '$hash'"; logWrite($sql, "sql"); } $sql = "select ID FROM USR_USER WHERE ACTIVATION_KEY = :hash"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":hash", $hash, strlen($hash)) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $userId = $row["ID"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if($userId > 0) { $userData = getUserData($cnn, $userId); } return $userData; } function activateUser(&$cnn, &$userData) { if(LOG_SQL) { $sql = "UPDATE USR_USER SET FL_CHECKED = 1, ACTIVATION_KEY = NULL, SMS_KEY = NULL, DT_ACTIVATION = SYSDATE WHERE ID = " . $userData["ID"]; logWrite($sql, "sql"); } $sql = "UPDATE USR_USER SET FL_CHECKED = 1, ACTIVATION_KEY = NULL, SMS_KEY = NULL, DT_ACTIVATION = SYSDATE WHERE ID = :userId"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userId", $userData["ID"], 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } function cleanPendigRegistration(&$cnn) { $sql = "DELETE FROM USR_USER WHERE FL_ACTIVE=1 AND FL_CHECKED=0 AND ACTIVATION_KEY <> '' AND (DT_INS + 2) < SYSDATE"; logWrite($sql, "sql"); $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); } function getPwdUser(&$cnn, $userID) { if(LOG_SQL) { $sql = "SELECT USR_PASSWORD FROM USR_USER WHERE ID = " . $userID; logWrite($sql, "sql"); } $sql = "SELECT USR_PASSWORD FROM USR_USER WHERE ID = :userID"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userID", $userID, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while(ociFetchInto($stmt, $row, OCI_ASSOC)) { $clear_pwd = $row["USR_PASSWORD"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); $pwd = md5($clear_pwd); return $pwd; } function verifyMerchantPin(&$cnn, $userID, $insertedPin) { $sql = "SELECT USR_PASSWORD FROM USR_USER WHERE ID = '$userID'"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while(ociFetchInto($stmt, $row, OCI_ASSOC)) { $userPassword = $row["USR_PASSWORD"]; } if($userPassword == $insertedPin) { return TRUE; } else { return FALSE; } } function get_next_prot(&$cnn) { $sql="SELECT max(nu_prot) from usr_user where nu_prot is not null"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFetchInto($stmt, $row, OCI_ASSOC); $last_prot=$row["MAX(NU_PROT)"]; ociFreeStatement($stmt) or doError("sql", ociError($stmt)); $last_prot++; return $last_prot; } function check_card ($card, &$cnn) { $sql="SELECT cd_member FROM V_CLIENTI_OLAP where cd_member=$card"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFetchInto($stmt, $row, OCI_ASSOC); $member=$row["CD_MEMBER"]; ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if ($member) { return false; } else { return true; } } function isGiftCard (&$cnn, $card, $stato = FALSE) { if (!$stato) { $sql="SELECT CD_GIFTCARD AS CD_MEMBER, IM_VALORE_NOMINALE AS NU_VALUE, NU_PUNTI, DT_ATTIVAZIONE, CASE WHEN (DT_ATTIVAZIONE IS NOT NULL) THEN 1 ELSE 0 END AS FL_ACTIVE, CASE WHEN (DT_SCADENZA>=SYSDATE) THEN 1 ELSE 0 END AS FL_VALIDA FROM V_ANA_GIFT_CARD where CD_GIFTCARD='$card' and (CD_CIRCUITO is null or CD_CIRCUITO='". CD_CIRCUITO ."')"; } else { $sql="select 1 FROM V_ANA_GIFT_CARD where CD_GIFTCARD='$card' and (CD_CIRCUITO is null or CD_CIRCUITO='". CD_CIRCUITO ."')"; } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while(ociFetchInto($stmt, $row, OCI_ASSOC)) { if (!$stato) {$giftCard = $row;} else {$giftCard = $row[1];} } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); //$giftCard["FL_ACTIVE"] = 1; return $giftCard; } function insertGiftCard (&$cnn, $card) { $sql="insert into USR_USER (CD_MEMBER, DT_ATTIVAZIONE,DT_SCADENZA, CD_CARD_PREFIX) VALUES ('$card', SYSDATE, (SYSDATE+365), '" . CD_CARD_PREFIX ."')"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); //$giftCard["FL_ACTIVE"] = 1; } function isGiftMerchant (&$cnn, $id) { $sql="select 1 from V_ELENCO_ESERCENTI where ID_ESERCENTE = $id and CD_CIRCUITO = '".CD_CIRCUITO."'"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while(ociFetchInto($stmt, $row, OCI_ASSOC)) {$enable = $row["1"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $enable; } function registra(&$cnn, $dati) { $sqlID = "SELECT SQ_ISCRIZIONI_RAVIGGIOLO.NEXTVAL FROM DUAL"; $stmtID = ociParse($cnn, $sqlID) or doError("sql", $sqlID); ociExecute($stmtID) or doError("sql", ociError($stmtID)); while(ociFetchInto($stmtID, $row, OCI_ASSOC)) { $id = $row["NEXTVAL"]; } ociFreeStatement($stmtID) or doError("sql", ociError($stmt)); for($i = 0; $i < 5; $i++) { $hash = generateActivationKey($dati["email"]); if($hash) { break; } } if (!$hash) { doError("no_activation"); exit; } else { $otherValues["ACTIVATION_KEY"]= "'".$hash."'"; } if ($dati["action"]=="degustazione") { $sql= "INSERT INTO ISCRIZIONI_RAVIGGIOLO (ID, NOME, COGNOME, DS_CELLULARE, DS_EMAIL, DS_EVENTO, ACTIVATION_KEY "; if($dati["firstname_2"]) { $sql .= " , NOME_2 "; } if($dati["lastname_2"]) { $sql .= " , COGNOME_2 "; } $sql .= " ) VALUES ( " . $id . ", '".$dati["firstname"]."','".$dati["lastname"]."','".$dati["phone"]."','".$dati["email"]."','".$dati["action"]."', '".$hash."'"; if($dati["firstname_2"]) { $sql .= " ,'".$dati["firstname_2"] ."' "; } if($dati["lastname_2"]) { $sql .= " ,'".$dati["lastname_2"] ."' "; } $sql .= ")"; print_r($sql); $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } else if ($dati["action"]=="laboratorio") { $sql= "INSERT INTO ISCRIZIONI_RAVIGGIOLO (ID, NOME, COGNOME, DS_CELLULARE, DS_EMAIL, DS_EVENTO, ACTIVATION_KEY, NOME_BAMBINO, NU_ETA_BAMBINO, NOME_BAMBINO_2, NU_ETA_BAMBINO_2, NOME_BAMBINO_3, NU_ETA_BAMBINO_3, NOME_BAMBINO_4, NU_ETA_BAMBINO_4 "; $sql .= " ) VALUES ( " . $id . ", '".$dati["firstname"]."','".$dati["lastname"]."','".$dati["phone"]."','".$dati["email"]."','".$dati["action"]."', '".$hash."','".$dati["bambino_1"]."','".$dati["eta_1"]."','".$dati["bambino_2"]."','".$dati["eta_2"] ."','".$dati["bambino_3"]."','".$dati["eta_3"]."','".$dati["bambino_4"]."','".$dati["eta_4"] ."'"; $sql .= ")"; //print_r($sql); $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return ($hash); } function getUserFromHash(&$cnn, $hash) { $userId = 0; $userData = array(); if(LOG_SQL) { $sql = "select ID FROM ISCRIZIONI_RAVIGGIOLO WHERE ACTIVATION_KEY = '$hash'"; logWrite($sql, "sql"); } //print_r($sql);exit; $sql = "select ID FROM ISCRIZIONI_RAVIGGIOLO WHERE ACTIVATION_KEY = :hash"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":hash", $hash, strlen($hash)) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $userId = $row["ID"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if($userId > 0) { $userData = getUserDataRaviggiolo($cnn, $userId); } return $userData; } function activateUserRaviggiolo(&$cnn, $userData) { if(LOG_SQL) { $sql = "UPDATE ISCRIZIONI_RAVIGGIOLO SET FL_CHECKED = 1, ACTIVATION_KEY = NULL, DT_ATTIVAZIONE = SYSDATE WHERE ID = " . $userData["ID"]; logWrite($sql, "sql"); } $sql = "UPDATE ISCRIZIONI_RAVIGGIOLO SET FL_CHECKED = 1, ACTIVATION_KEY = NULL, DT_ATTIVAZIONE = SYSDATE WHERE ID = " . $userData["ID"]; $sql = "UPDATE ISCRIZIONI_RAVIGGIOLO SET FL_CHECKED = 1, ACTIVATION_KEY = NULL, DT_ATTIVAZIONE = SYSDATE WHERE ID = :userId"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userId", $userData["ID"], 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if (!ociError($stmt)) { ociCommit($cnn); return TRUE; } } function getUserDataRaviggiolo(&$cnn, $userId) { //$key = "userData." . $userId; $userData = array(); //if(DISABLE_CACHE || ($userId == 0) || (!readCacheData($cnn, $userId, $key, $userData))) { if($userId > 0) { if(LOG_SQL) { $sql = "SELECT * FROM ISCRIZIONI_RAVIGGIOLO WHERE ID = $userId AND NVL(FL_DELETED, 0) = 0"; logWrite($sql, "sql"); } $sql = "SELECT * FROM ISCRIZIONI_RAVIGGIOLO WHERE ID = :userid AND NVL(FL_DELETED, 0) = 0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":userid", $userId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $userData = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return $userData; } } function getSignedCount(&$cnn, $event) { //$key = "userData." . $userId; $userData = array(); if ($event == 'laboratorio') { $sql= "SELECT b.PARTECIPANTI_1+c.PARTECIPANTI_2+d.PARTECIPANTI_3+e.PARTECIPANTI_4 AS PARTECIPANTI FROM (select count(*) as PARTECIPANTI_1 FROM ISCRIZIONI_RAVIGGIOLO where DS_EVENTO = '$event' and FL_CHECKED = 1 AND NVL(FL_DELETED, 0)=0 AND (NVL(NOME_BAMBINO, ' ') <> ' ' )) b, (select count(*) as PARTECIPANTI_2 FROM ISCRIZIONI_RAVIGGIOLO where DS_EVENTO = '$event' and FL_CHECKED = 1 AND NVL(FL_DELETED, 0)=0 AND (NVL(NOME_BAMBINO_2, ' ') <> ' ' )) c, (select count(*) as PARTECIPANTI_3 FROM ISCRIZIONI_RAVIGGIOLO where DS_EVENTO = '$event' and FL_CHECKED = 1 AND NVL(FL_DELETED, 0)=0 AND (NVL(NOME_BAMBINO_3, ' ') <> ' ' )) d, (select count(*) as PARTECIPANTI_4 FROM ISCRIZIONI_RAVIGGIOLO where DS_EVENTO = '$event' and FL_CHECKED = 1 AND NVL(FL_DELETED, 0)=0 AND (NVL(NOME_BAMBINO_4, ' ') <> ' ' )) e"; } else if ($event == 'degustazione') { $sql = "SELECT a.PARTECIPANTI_1+b.PARTECIPANTI_2 AS PARTECIPANTI FROM ( select count(*) as PARTECIPANTI_1 FROM ISCRIZIONI_RAVIGGIOLO a where DS_EVENTO = '$event' and FL_CHECKED = 1 AND NVL(FL_DELETED, 0)=0 ) a, (select count(*) as PARTECIPANTI_2 FROM ISCRIZIONI_RAVIGGIOLO where DS_EVENTO = '$event' and FL_CHECKED = 1 AND NVL(FL_DELETED, 0)=0 AND (NVL(NOME_2, ' ') <> ' ' OR NVL(COGNOME_2,' ') <> ' ')) b"; } //if(DISABLE_CACHE || ($userId == 0) || (!readCacheData($cnn, $userId, $key, $userData))) { if(LOG_SQL) { //$sql = "SELECT count(*) as PARTECIPANTI FROM ISCRIZIONI_RAVIGGIOLO WHERE DS_EVENTO = '$event' and FL_CHECKED = 1 AND NVL(FL_DELETED, 0)=0"; logWrite($sql, "sql"); } //$sql = "SELECT count(*) as PARTECIPANTI FROM ISCRIZIONI_RAVIGGIOLO WHERE DS_EVENTO = '$event' and FL_CHECKED = 1 AND NVL(FL_DELETED, 0)=0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $conta = $row["PARTECIPANTI"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $conta; } } function getSignedByEmail(&$cnn, $email, $event) { //if(DISABLE_CACHE || ($userId == 0) || (!readCacheData($cnn, $userId, $key, $userData))) { if(LOG_SQL) { $sql = "SELECT 1 as MAIL_EXISTS FROM ISCRIZIONI_RAVIGGIOLO WHERE upper(DS_EMAIL) like '%" . strtoupper($email) . "%' AND DS_EVENTO = '$event' AND NVL(FL_DELETED, 0)=0"; logWrite($sql, "sql"); } $sql = "SELECT 1 as MAIL_EXISTS FROM ISCRIZIONI_RAVIGGIOLO WHERE upper(DS_EMAIL) like '%" . strtoupper($email) . "%' AND DS_EVENTO = '$event' AND NVL(FL_DELETED, 0)=0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $esiste = $row["MAIL_EXISTS"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $esiste; } } ?> $v) { $out[] = urlencode($k) ."=" . urlencode($v); } return implode("&", $out); } function getLocationPart($location) { $location = trim($location); $tmp = strtolower($location); $part = array(); $part["protocol"] = "http"; $part["serverName"] = $tmp; $part["serverPort"] = "80"; $i = strstr($tmp,"://"); if ($i == true) { $i = strpos($tmp, "://"); $part["protocol"] = substr($tmp, 0, $i); $part["serverName"] = substr($tmp, $i + 3); } $i = strstr($part["serverName"], "/"); if ($i == true) { $i = strpos($part["serverName"], "/"); $part["serverName"] = substr($part["serverName"], 0, $i); } $i = strstr($part["serverName"], ":"); if ($i == true) { $i = strpos($part["serverName"], ":"); $part["port"] = substr($part["serverName"], $i+1); $part["serverName"] = substr($part["serverName"], 0, $i); } $i = strpos(strtolower($location), $part["serverName"]); $part["target"] = substr($location, $i + strlen($part["serverName"])); $i = strstr($part["target"], ":"); if ($i == true) { $i = strpos($part["target"], ":"); $part["target"] = substr($part["target"], $i + 1); $i = strstr($part["target"], "/"); if ($i == true) { $i = strpos($part["target"], "/"); $part["target"] = substr($part["target"], $i ); } else { $part["target"] = "/"; } } return $part; } function httpClient($location, $method, $postValues="", $clientHeader="") { $locationPart = getLocationPart($location); $response = array(); if ($locationPart["protocol"] == "http") { $request = "$method " . $locationPart["target"] . " HTTP/1.0\r\n"; $request .= "Host: " . $locationPart["serverName"] . "\r\n"; if (is_array( $clientHeader)) { foreach($clientHeader as $k => $v) { //if (strcmp(strtolower($k), "host") != 0) $request .= "$k: " . $v . "\r\n"; } } else { if (strlen($clientHeader) > 0) $request .= $clientHeader . "\r\n"; } if ( $method == "POST" ) { $lenght = strlen( $postValues ); $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; $request .= "Content-Length: $lenght\r\n"; $request .= "\r\n"; $request .= $postValues; } else { $request .= "\r\n"; } $timeout = 10; $size = 0; // Bytes will be read (and display). 0 for read all //$locationPart["serverIP"] = gethostbyname($locationPart["serverName"]); $socket = @fsockopen($locationPart["serverName"], $locationPart["serverPort"], $errno, $errstr, $timeout ); if ($socket) { fputs( $socket, $request ); if ( $size > 0 ) { $ret = fgets( $socket, $size ); } else { $ret = ''; while ( !feof( $socket ) ) { $ret .= fgets( $socket, 4096 ); } } fclose( $socket ); if ($errno == 0) { $response["STATUS_CODE"] = "0"; $response["STATUS_MSG"] = "OK"; $response["RAW_DATA"] = $ret; $i = strpos($response["RAW_DATA"], "\r\n\r\n"); $response["RAW_HEADER"] = substr($ret, 0, $i+4); $response["RAW_BODY"] = substr($ret, $i); $lines = explode("\r\n", $response["RAW_HEADER"]); $i = strpos($lines[0], " "); $response["PROTOCOL"] = trim(substr($lines[0], 0, $i)); $lines[0] = substr($lines[0], $i + 1); $i = strpos($lines[0], " "); $response["CODE"] = trim(substr($lines[0], 0, $i)); $lines[0] = substr($lines[0], $i + 1); $response["MSG"] = trim($lines[0]); $response["HEADER"] = array(); for ($i=1; $i < count($lines); $i++) { $j = strpos($lines[$i], ":"); if ($j > 0) { $name = trim(substr($lines[$i], 0, $j)); $response["HEADER"][$name] = trim(substr($lines[$i], $j + 1)); } } } else { $response["STATUS_CODE"] = "2"; $response["STATUS_MSG"] = "$errno - $errstr"; } } else { $response["STATUS_CODE"] = "1"; $response["STATUS_MSG"] = "NO CONNECTION"; } } return $response; } ?> 0) { $packedData = $aclsData[$i]["GROUP"] . "_" . $priv; $item[] = $packedData; } } return implode("|", $item); } // function unpackAcls($aclsText) { static $aclsData = array(); static $oldAclsText = ""; if($oldAclsText != $aclsText) { $aclsData = array(); $oldAclsText = $aclsText; $item = explode("|", $aclsText); for($i = 0; $i < count($item); $i++) { $tmp = explode("_", $item[$i]); $aclsData[$i] = array(); $aclsData[$i]["GROUP"] = $tmp[0]; $aclsData[$i]["NO_ACCESS"] = ($tmp[1] & 8) >> 3 ; $aclsData[$i]["READ"] = ($tmp[1] & 4) >> 2 ; $aclsData[$i]["WRITE"] = ($tmp[1] & 2) >> 1 ; $aclsData[$i]["EXECUTE"] = ($tmp[1] & 1); } } return $aclsData; } // function getAuthorization($aclsText, $userData) { static $oldAclsText = ""; static $oldUserId = ""; static $autorization = array(); if(($oldAclsText != $aclsText) || ($oldUserId != $userData["ID"])) { $oldUserId = $userData["ID"]; $oldAclsText = $aclsText; $autorization = array(); $aclData = unpackAcls($aclsText); $su = -1; $sg = -1; $autorization = array(); $autorization["NO_ACCESS"] = 0; $autorization["READ"] = 0; $autorization["WRITE"] = 0; $autorization["EXECUTE"] = 0; if($userData["FL_ROOT"] ) { $autorization["READ"] = 1; $autorization["WRITE"] = 1; $autorization["EXECUTE"] = 1; } else { for($j = 0; $j < count($aclData); $j++) { if("." . $aclData[$j]["GROUP"] == ".0") { $autorization["NO_ACCESS"] = max($aclData[$j]["NO_ACCESS"], $autorization["NO_ACCESS"]); $autorization["READ"] = max($aclData[$j]["READ"], $autorization["READ"]); $autorization["WRITE"] = max($aclData[$j]["WRITE"], $autorization["WRITE"]); $autorization["EXECUTE"] = max($aclData[$j]["EXECUTE"], $autorization["EXECUTE"]); } else { if("." . $aclData[$j]["GROUP"] == ".@") { if($userData["USR_USERNAME"] != "") { $autorization["NO_ACCESS"] = max($aclData[$j]["NO_ACCESS"], $autorization["NO_ACCESS"]); $autorization["READ"] = max($aclData[$j]["READ"], $autorization["READ"]); $autorization["WRITE"] = max($aclData[$j]["WRITE"], $autorization["WRITE"]); $autorization["EXECUTE"] = max($aclData[$j]["EXECUTE"], $autorization["EXECUTE"]); } } else { if($aclData[$j]["GROUP"] == "su") { $su = $j; } if($aclData[$j]["GROUP"] == "sg") { $sg = $j; } for($i = 0; $i < count($userData["USR_GROUP"]); $i++) { if($userData["USR_GROUP"][$i] == $aclData[$j]["GROUP"]) { $autorization["NO_ACCESS"] = max($aclData[$j]["NO_ACCESS"], $autorization["NO_ACCESS"]); $autorization["READ"] = max($aclData[$j]["READ"], $autorization["READ"]); $autorization["WRITE"] = max($aclData[$j]["WRITE"], $autorization["WRITE"]); $autorization["EXECUTE"] = max($aclData[$j]["EXECUTE"], $autorization["EXECUTE"]); } } } } } if($autorization["NO_ACCESS"]) { $autorization["READ"] = 0; $autorization["WRITE"] = 0; $autorization["EXECUTE"] = 0; } if(is_array($userData) && array_key_exists("REAL", $userData)) { if($su > -1) { $autorization["READ"] = $autorization["READ"] & $aclData[$su]["READ"]; $autorization["WRITE"] = $autorization["WRITE"] & $aclData[$su]["WRITE"]; $autorization["EXECUTE"] = $autorization["EXECUTE"] & $aclData[$su]["EXECUTE"]; } if($sg > -1) { $autorization["READ"] = $autorization["READ"] & $aclData[$sg]["READ"]; $autorization["WRITE"] = $autorization["WRITE"] & $aclData[$sg]["WRITE"]; $autorization["EXECUTE"] = $autorization["EXECUTE"] & $aclData[$sg]["EXECUTE"]; } } } } return $autorization; } // function cloneAcls($oldAclsText, $groupFrom, $groupTo) { $newAclsText = ""; $aclsFrom = array(); $aclsTo = array(); $oldAcls = unpackAcls($oldAclsText); for($i = 0; $i < count($oldAcls); $i++) { if($oldAcls[$i]["GROUP"] == $groupFrom) { $aclsFrom = $oldAcls[$i]; break; } } $newAcls = array(); $operation = ""; $j = 0; for($i = 0; $i < count($oldAcls); $i++) { if($oldAcls[$i]["GROUP"] == $groupTo) { if(count($aclsFrom) > 0) { $newAcls[$j] = $aclsFrom; $newAcls[$j]["GROUP"] = $groupTo; $operation = "update"; $j++; } } else { $newAcls[$j] = $oldAcls[$i]; $j++; } } if($operation == "") { if(count($aclsFrom) > 0) { $newAcls[$j] = $aclsFrom; $newAcls[$j]["GROUP"] = $groupTo; $operation = "insert"; $j++; } } $newAclsText = packAcls($newAcls); return $newAclsText; } ?> 9) { $c += ord("a") - 10; } else { $c += ord("0"); } $rndname .= chr($c); } $tmpname = str_replace("//", "/", $dir . "/" . $rndname); if(!file_exists ($tmpname)) { if($oldPhp) { $ret = fopen($tmpname,'w'); } else { $ret = fopen($tmpname, "x"); } if($ret) { fclose($ret); } } $j++; } } if($ret) { return $tmpname; } else { return FALSE; } } } function getHumanFileSize($bytes) { $unit = ""; $baseUnit = array("bytes", "Kb", "Mb", "Gb"); $hsize = $bytes; for($i = 0; $i < count($baseUnit); $i++) { $unit = $baseUnit[$i]; if($hsize > 1024 * 2) { $hsize = $hsize / 1024; } else { break; } } $hsize = (intval($hsize * 100)) / 100; $hsize .= " " . $unit; return $hsize; } function readObj($cnn, $itemName, $obj_key, $obj_id, $table) { $obj_id = intval($obj_id); $obj = array(); if($obj_id > 0) { $obj["file"] = ""; $obj["file_name"] = ""; $obj["file_mime"] = ""; $obj["file_ext"] = ""; $obj["file_size"] = 0; $obj["file_hsize"] = 0; $obj["file_width"] = ""; $obj["file_height"] = ""; $obj["file_thumb"] = ""; $obj["file_thumb_width"] = 0; $obj["file_thumb_height"] = 0; $obj["file_track"] = 0; $sql = "SELECT * FROM $table WHERE $obj_key = $obj_id"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql); ociExecute($stmt); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $obj["title"] = $row["TITLE"]; $obj["subtitle"] = $row["SUBTITLE"]; $obj["file"] = $row[$itemName]; $obj["file_name"] = $row[$itemName . "_NAME"]; $obj["file_mime"] = $row[$itemName . "_MIME"]; $obj["file_ext"] = $row[$itemName . "_EXT"]; $obj["file_size"] = $row[$itemName . "_SIZE"]; $obj["file_thumb"] = $row[$itemName . "_THUMB"]; $obj["file_width"] = $row[$itemName . "_WIDTH"]; $obj["file_height"] = $row[$itemName . "_HEIGHT"]; $obj["file_thumb_width"] = $row[$itemName . "_THUMB_WIDTH"]; $obj["file_thumb_height"] = $row[$itemName . "_THUMB_HEIGHT"]; $obj["file_hsize"] = getHumanFileSize($row[$itemName . "_SIZE"]); $obj["file_track"] = intval($row["FL_TRK"]); } ociFreeStatement($stmt); } return $obj; } function deleteFile($fullfilename) { //$out = array(); //$ret = 0; if(is_file($fullfilename)) { $fullfilename = realpath($fullfilename); $path_parts = pathinfo($fullfilename); if (strlen($fullfilename) > 0) { unlink($fullfilename); } $fullfilename = substr($fullfilename, 0 , strlen($fullfilename) - strlen($path_parts["extension"]) - 1); if (strlen($fullfilename) > 0) { unlink($fullfilename); } } } function storeFile($srcname, $storepath, $ext, $prefix="") { $srcname = realpath($srcname); //debug("storeFile '$srcname' '$storepath' '$ext'"); for($dstname = $storepath; file_exists($dstname);) { $dstname = mytempnam ($storepath, $prefix); $dstname = realpath($dstname); $oldname = $dstname; $dstname .= $ext; } //$out = array(); //$ret = 0; //exec ("rm -f " . ($oldname), $out, $ret); if($dstname == $storepath) { //debug("tmpfile error"); return ""; } if(is_file($fullfilename)) { unlink($oldname); } //debug("copy $srcname => $dstname"); $ret = copy($srcname, $dstname); //if(copy(realpath($srcfilename), $tmpfname)) if($ret == TRUE) { $path_parts = pathinfo($dstname); $dstname = $path_parts["basename"]; return $dstname; } else { //debug("upload failed"); return ""; } return ""; } // function getMimeType($filename) { //$finfo = finfo_open(FILEINFO_MIME); //$mime = finfo_file($finfo, realpath($filename)); //finfo_close($finfo); return $mime; } // function isImage($mimeType) { $out = FALSE; switch ($mimeType) { case "image/bmp": case "image/gif": case "image/jpeg": case "image/png": // case "image/tiff": $out = TRUE; break; } return $out; } function writeFileIntoDb(&$cnn, &$definition, $newValues, $otherValues, $excludeValues, $nodeId = 0) { if($nodeId > 0) { $sql = getUpdateQuery($definition["table"], $newValues, $otherValues); $sql .= " WHERE ID = $nodeId"; } else { $sql = "SELECT SQ_" . $definition["table"] . ".NEXTVAL FROM DUAL"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $nodeId = $row["NEXTVAL"]; $otherValues[$definition["key"]] = $nodeId; $sql = getInsertQuery($definition["table"], $newValues, $otherValues); } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $nodeId; } function deleteFileFromDb(&$cnn, &$definition, $nodeId) { $sql = "UPDATE " . $definition["table"] . " SET FL_DELETED = 1 WHERE ID = $nodeId"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } function insertDownloadLog($cnn, $branchData, $objId, $objInfo, $tableName, $userId) { $sql = "select sq_log_download.nextval from dual"; $stmt = ociParse($cnn, $sql); ociExecute($stmt); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $dlId = intval($row["NEXTVAL"]); } ociFreeStatement($stmt); $path = array(); if(!empty($branchData)) { foreach($branchData as $bd) { $path[] = $bd["LABEL"]; } } else { $path[] = "Home"; } $downloadLog = array(); $downloadLog["DL_ID"] = $dlId; $downloadLog["OBJ_ID"] = $objId; $downloadLog["OBJ_TABLE"] = $tableName; $downloadLog["OBJ_TITLE"] = $objInfo["title"]; $downloadLog["OBJ_SUBTITLE"] = $objInfo["subtitle"]; $downloadLog["OBJ_MIME"] = $objInfo["file_mime"]; $downloadLog["OBJ_NAME"] = $objInfo["file_name"]; $downloadLog["OBJ_EXT"] = $objInfo["file_ext"]; $downloadLog["OBJ_SIZE"] = $objInfo["file_size"]; $downloadLog["OBJ_HSIZE"] = $objInfo["file_hsize"]; $downloadLog["USR_ID"] = $userId; $downloadLog["DL_DS_SOURCE"] = implode(" -> ", $path); $attrib = array(); $values = array(); foreach($downloadLog as $k => $v) { $v = quoteForDb($v); $attrib[] = $k; $values[] = $v; } if(LOG_SQL) { $sql = "INSERT INTO LOG_DOWNLOAD (" . implode(", ", $attrib) . ") values ('" . implode("', ':",$values) . "')"; logWrite($sql, "sql"); } $sql = "INSERT INTO LOG_DOWNLOAD (" . implode(", ", $attrib) . ") values (:" . implode(", :",$attrib) . ")"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":DL_ID", $dlId, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":OBJ_ID", $objId, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":OBJ_TABLE", $tableName, strlen($tableName)) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":OBJ_TITLE", $downloadLog["OBJ_TITLE"], strlen($downloadLog["OBJ_TITLE"])) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":OBJ_SUBTITLE", $downloadLog["OBJ_SUBTITLE"], strlen($downloadLog["OBJ_SUBTITLE"])) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":OBJ_MIME", $downloadLog["OBJ_MIME"], strlen($downloadLog["OBJ_MIME"])) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":OBJ_NAME", $downloadLog["OBJ_NAME"], strlen($downloadLog["OBJ_NAME"])) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":OBJ_EXT", $downloadLog["OBJ_EXT"], strlen($downloadLog["OBJ_EXT"])) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":OBJ_SIZE", $downloadLog["OBJ_SIZE"], 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":OBJ_HSIZE", $downloadLog["OBJ_HSIZE"], strlen($downloadLog["OBJ_HSIZE"])) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":USR_ID", $downloadLog["USR_ID"], 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":DL_DS_SOURCE", $downloadLog["DL_DS_SOURCE"], strlen($downloadLog["DL_DS_SOURCE"])) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $dlId; } function updateDownloadLog($cnn, $dlId, $byte) { if(LOG_SQL) { $sql = "UPDATE LOG_DOWNLOAD SET DT_DOWNLOAD_END = (SELECT SYSDATE FROM DUAL), BYTE_DOWNLOAD = $byte where DL_ID = $dlId"; logWrite($sql, "sql"); } $sql = "UPDATE LOG_DOWNLOAD SET DT_DOWNLOAD_END = (SELECT SYSDATE FROM DUAL), BYTE_DOWNLOAD = $byte WHERE DL_ID = :dlId"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":dlId", $dlId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } function resizeImage($fileName, $width) { $file = PATH_IMG . $fileName; $image = new SimpleImage(); $image->load(PATH_IMG . $fileName); $image->resizeToWidth($width); $image->save($file); return $file; } // function resizeImage($fileName, $objInfo, $mode, $width = 0, $height = 0) { // $image = new SimpleImage(); // $image->load($fileName); // switch($mode) { // case "max": // //resize to fit into box if image is bigger, preserve aspect ratio // if(!$width && !$height) { doerror("wrongthumb", "missing size to resize image"); } // if(($objInfo["file_width"] > $width) || ($objInfo["file_height"] > $height)) // { // if(($objInfo["file_width"] / $objInfo["file_height"]) >= ($width / $height)) { // $image->resizeToWidth($width); // } else { // $image->resizeToHeight($height); // } // } // break; // case "preserve": // //resize to fit into box, preserve aspect ratio // if(!$width && !$height) { // doerror("wrongthumb", "missing size to resize image"); // } // if(($objInfo["file_width"] / $objInfo["file_height"]) >= ($width / $height)) { // $image->resizeToWidth($width); // } else { // $image->resizeToHeight($height); // } // break; // case "fixed": // //resize to fixed size // if(!$width && !$height) { doerror("wrongthumb", "missing size to resize image"); } // $image->resize($width, $height); // break; // case "width": // //resize into defined width, preserve aspect ratio // if(!$width) { doerror("wrongthumb", "missing size to resize image"); } // $image->resizeToWidth($width); // break; // case "height": // //resize into defined height, preserve aspect ratio // if(!$height) { doerror("wrongthumb", "missing size to resize image"); } // $image->resizeToHeight($height); // break; // default: // doError("param", "wrong mode $mode"); // } // $image->save($thumbName); // return $thumbName; // } ?> 0; $i--) { $acls = unpackAcls($branchData[$i]["ACLS"]); foreach($acls as $a) { if($a["GROUP"] == 0) { if(!$a["READ"] || !$a["EXECUTE"]) { $private = TRUE; } break; } } if($private) { break; } } } $private = FALSE; if((($contentData["DESCRIPTION"] == "") || ($contentData["KEYWORD"] == "")) && !$private) { for($i = count($branchData) - 1; $i--; $i > 0) { $upContentId = $branchData[$i]["ID"]; if(LOG_SQL) { $sql = "SELECT DESCRIPTION, $tableName.KEYWORD FROM $tableName WHERE ID = $upContentId"; logWrite($sql, "sql"); } $sql = "SELECT DESCRIPTION, $tableName.KEYWORD FROM $tableName WHERE ID = :contentId"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":contentId", $upContentId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while(ociFetchInto($stmt, $row, OCI_ASSOC)) { if($contentData["DESCRIPTION"] == "") { $contentData["DESCRIPTION"] = $row["DESCRIPTION"]; } if($contentData["KEYWORD"] == "") { $contentData["KEYWORD"] = $row["KEYWORD"]; } if($contentData["DESCRIPTION"] && $contentData["KEYWORD"]) { break; } } } } return $contentData; } // function getHumanPathUrlPart($nodeData) { if(strlen($nodeData["SHORTNAME"]) > 0) { $humanPath = "menuName=" . $nodeData["CM"] . "." . $nodeData["SHORTNAME"]; } else { $humanPath = "menuId=" . $nodeData["PATH"]; } return $humanPath; } // function getExtensionData($layoutName) { $extension["lib"] = "../ext_" . $layoutName . "/lib_" . $layoutName . ".php"; $extension["common"] = "../ext_" . $layoutName . "/common_" . $layoutName . ".php"; $extension["page"] = "../ext_" . $layoutName . "/page_" . $layoutName . ".php"; $extension["layout"] = "../ext_" . $layoutName . "/layout_" . $layoutName . ".php"; $extension["controller"] = "../ext_" . $layoutName . "/controller_" . $layoutName . ".php"; $extension["ini"] = "../ext_" . $layoutName . "/cfg_" . $layoutName . ".ini.php"; foreach($extension as $k => $ext) { if(!is_file($ext)) { $extension[$k] = ""; } } return $extension; } // function getRootFolder() { return dirname(dirname($_SERVER["PHP_SELF"])); } // function isHome($branchData) { if(count($branchData) == 1) { return TRUE; } return FALSE; } // function setEditMode($mode) { $status = TRUE; switch ($mode) { case "edit": case "preview": setcookie ("COOKIE_MODE", $mode, 0, "/"); break; case "public": default: setcookie ("COOKIE_MODE", "", time() - 3600, "/"); break; } } // function getEditMode() { $mode = "public"; if(array_key_exists("COOKIE_MODE", $_COOKIE)) { switch ($_COOKIE["COOKIE_MODE"]) { case "edit": case "preview": $mode = $_COOKIE["COOKIE_MODE"]; break; default: break; } } return $mode; } // function getBlockName(&$cnn, $blockType) { $blockName = ""; $blockType = intval($blockType); if(LOG_SQL) { $sql = "SELECT NAME FROM CM_BLOCK_TYPE WHERE ID = $blockType"; logWrite($sql, "sql"); } $sql = "SELECT NAME FROM CM_BLOCK_TYPE WHERE ID = :blocktype"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":blocktype", $blockType, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $blockName = $row["NAME"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $blockName; } // function getBlocksTypeFromLayout(&$cnn, $layoutId) { $blocksType = array(); $blocks = ""; if(LOG_SQL) { $sql = "SELECT BLOCK FROM CM_CONTENT_TYPE WHERE FL_DELETED = 0 AND ID = $layoutId"; logWrite($sql, "sql"); } $sql = "SELECT BLOCK FROM CM_CONTENT_TYPE WHERE FL_DELETED = 0 AND ID = :layoutId"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":layoutId", $layoutId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $blocks = $row["BLOCK"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if(strlen($blocks) > 0) { if(LOG_SQL) { $sql = "SELECT * FROM CM_BLOCK_TYPE WHERE ID IN ($blocks) AND FL_DELETED = 0 ORDER BY POSITION"; logWrite($sql, "sql"); } $sql = "SELECT * FROM CM_BLOCK_TYPE WHERE ID IN ($blocks) AND FL_DELETED = 0 ORDER BY POSITION"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); //ociBindByName($stmt, ":blocks", $blocks, strlen($blocks)) // or doError("sql", array($sql, ociError($stmt))); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $blocksType[] = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } return $blocksType; } // function getContentsType(&$cnn, $target = "") { $contentsType = array(); $filter = ""; switch($target) { case"admin": $filter = "AND FL_CM=1"; break; case"public": $filter = "AND FL_CM=0"; break; } $sql = "SELECT * FROM CM_CONTENT_TYPE WHERE FL_DELETED = 0 " . $filter . "ORDER BY POSITION"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $contentsType[] = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $contentsType; } // function getContentsTypeFromId(&$cnn, $contentId) { $contentType = array(); if(LOG_SQL) { $sql = "SELECT * FROM CM_CONTENT_TYPE WHERE ID = $contentId AND FL_DELETED = 0 ORDER BY POSITION"; logWrite($sql, "sql"); } $sql = "SELECT * FROM CM_CONTENT_TYPE WHERE ID = :contentid AND FL_DELETED = 0 ORDER BY POSITION"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":contentid", $contentId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $contentType = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $contentType; } // function getBlocksType(&$cnn) { $blocksType = array(); $sql = "SELECT * FROM CM_BLOCK_TYPE WHERE FL_DELETED = 0 ORDER BY POSITION"; if(LOG_SQL) { logWrite($sql, "sql"); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $blocksType[] = $row; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $blocksType; } // function getSelectedChild(&$menuData) { $childSelected = -1; for($i = 0; $i < count($menuData); $i++) { if($menuData[$i]["SELECTED"] == 1) { $childSelected = $menuData[$i]["ID"]; break; } } return $childSelected; } // function getRootNodes(&$cnn, &$userData, $editMode) { $nodes = array(); $key = "rootNode.ud." . $userData["ID"] . "_em." . $editMode; if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $nodes))) { $tableName = "CM_MENU_S"; if($editMode == "public") { $tableName = "CM_MENU"; } if(LOG_SQL) { $sql = "SELECT * FROM $tableName WHERE PARENTID = 0 AND FL_DELETED = 0"; if($userData["FL_GEST_CM"] == 0) { $sql .= " AND CM > 0"; } $sql .= " ORDER BY POSITION"; logWrite($sql, "sql"); } $sql = "SELECT * FROM \"$tableName\" WHERE PARENTID = 0 AND FL_DELETED = 0"; if($userData["FL_GEST_CM"] == 0) { $sql .= " AND CM > 0"; } $sql .= " ORDER BY POSITION"; logWrite($sql, "sql"); $i = 0; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { //$acls = unpackAcls($row["ACLS"]); $auth = getAuthorization($row["ACLS"], $userData); if($auth["READ"] && $auth["EXECUTE"]) { $nodes[$i] = $row; $nodes[$i]["PARENTPATH"] = ""; $nodes[$i]["PATH"] = $row["ID"]; $nodes[$i]["AUTH"] = $auth; $i++; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "m.", $nodes); } } return $nodes; } // function getNode(&$cnn, &$userData, $nodeId, $editMode, $includeDeleted = FALSE, $forceBackend = FALSE) { $tableName = "CM_MENU_S"; if(!$forceBackend) { if($editMode == "public") { $tableName = "CM_MENU"; } } $node = array(); if($nodeId > 0) { if(LOG_SQL) { $sql = "SELECT * FROM $tableName WHERE ID = $nodeId"; if(!$includeDeleted) { $sql .= " AND FL_DELETED = 0"; } if($userData["FL_GEST_CM"] == 0) { $sql .= " AND CM > 0"; } logWrite($sql, "sql"); } $sql = "SELECT * FROM $tableName WHERE ID = :nodeId"; if(!$includeDeleted) { $sql .= " AND FL_DELETED = 0"; } if($userData["FL_GEST_CM"] == 0) { $sql .= " AND CM > 0"; } $stmt = ociParse($cnn, $sql) or doError("sql", array($sql, ociError($stmt))); ociBindByName($stmt, ":nodeId", $nodeId, 32) or doError("sql", array($sql, ociError($stmt))); ociExecute($stmt) or doError("sql", array($sql, ociError($stmt))); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $active = TRUE; if($editMode == "public") { $tnow = getSqlTs($cnn); $tmp = explode(" ", $row["DT_ACTIVE_FROM"]); $active_from = $tmp[0]; $tmp = explode(" ", $row["DT_ACTIVE_TO"]); $active_to = $tmp[0]; if(($active_from != "0000-00-00") && ($active_from != "")) { $tmp = explode("-", $active_from); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t > $tnow) { $active = FALSE; } } if(($active_to != "0000-00-00") && ($active_to != "")) { $tmp = explode("-", $active_to); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t < $tnow - (86400)) { $active = FALSE; } } } //$acls = unpackAcls($row["ACLS"]); $auth = getAuthorization($row["ACLS"], $userData); if(($auth["READ"] || $auth["EXECUTE"]) && ($active)) { $node = $row; $tmp = getFullPathData($cnn, $userData, $node["PARENTID"], $editMode); $node["PARENTPATH"] = implode(".", $tmp); $tmp[] = $node["ID"]; $node["PATH"] = implode(".", $tmp); $node["AUTH"] = $auth; } else { $node["UNAUTHORIZED"] = TRUE; $node["ID"] = $row["ID"]; $node["PARENTID"] = $row["PARENTID"]; $tmp = getFullPathData($cnn, $userData, $node["PARENTID"], $editMode); $node["PARENTPATH"] = implode(".", $tmp); $tmp[] = $node["ID"]; $node["PATH"] = implode(".", $tmp); $node["AUTH"] = $auth; } } ociFreeStatement($stmt); } return $node; } // function getChilds(&$cnn, &$userData, &$nodeData, $editMode, $includeDeleted = FALSE, $order = "") { $key = "childs." . $nodeData["PATH"] . "_ud." . $userData["ID"] . "_em." . $editMode . "_id." . $includeDeleted . "o." . $order; $childs = array(); if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $childs))) { $tableName = "CM_MENU_S"; if($editMode == "public") { $tableName = "CM_MENU"; } $nodeId = intval($nodeData["ID"]); if(is_array($nodeData) && $nodeId > 0) { if($nodeData["AUTH"]["READ"] && $nodeData["AUTH"]["EXECUTE"]) { if(LOG_SQL) { $sql = "SELECT * FROM $tableName WHERE PARENTID = $nodeId AND CM = " . $nodeData["CM"]; if(!$includeDeleted) { $sql .= " AND FL_DELETED = 0 "; } if ($order != "") { $sql .= $order; } else { $sql .= " ORDER BY POSITION"; } logWrite($sql, "sql"); } $sql = "SELECT * FROM $tableName WHERE PARENTID = :nodeId AND CM = :cm"; if(!$includeDeleted) { $sql .= " AND FL_DELETED = 0 "; } if ($order != "") { $sql .= $order; } else { $sql .= " ORDER BY POSITION"; } $i = 0; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":nodeid", $nodeId, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":cm", $nodeData["CM"], 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $active = TRUE; if($editMode == "public") { $tnow = getSqlTs($cnn); $tmp = explode(" ", $row["DT_ACTIVE_FROM"]); $active_from = $tmp[0]; $tmp = explode(" ", $row["DT_ACTIVE_TO"]); $active_to = $tmp[0]; if(($active_from != "0000-00-00") && ($active_from != "")) { $tmp = explode("-", $active_from); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t > $tnow) { $active = FALSE; } } if(($active_to != "0000-00-00") && ($active_to != "")) { $tmp = explode("-", $active_to); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t < $tnow - (86400)) { $active = FALSE; } } } //$acls = unpackAcls($row["ACLS"]); $auth = getAuthorization($row["ACLS"], $userData); if(($auth["READ"] || $auth["EXECUTE"]) && $active) { $childs[$i] = $row; $childs[$i]["AUTH"] = $auth; $childs[$i]["PARENTPATH"] = $nodeData["PATH"]; $childs[$i]["PATH"] = $childs[$i]["PARENTPATH"] . "." . $childs[$i]["ID"]; $i++; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "m." . $nodeData["PATH"] . ".", $childs); } } return $childs; } // function getChildsId(&$cnn, &$userData, &$nodeData, $editMode, $includeDeleted = FALSE) { $key = "childsId." . $nodeData["PATH"] . "_ud." . $userData["ID"] . "_em." . $editMode . "_id." . $includeDeleted; $childs = array(); if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $childs))) { $tableName = "CM_MENU_S"; if($editMode == "public") { $tableName = "CM_MENU"; } $nodeId = intval($nodeData["ID"]); if(is_array($nodeData) && $nodeId > 0) { if($nodeData["AUTH"]["READ"] && $nodeData["AUTH"]["EXECUTE"]) { if(LOG_SQL) { $sql = "SELECT ID, ACLS, DT_ACTIVE_FROM, DT_ACTIVE_TO FROM $tableName WHERE PARENTID = $nodeId AND CM = " . $nodeData["CM"]; if(!$includeDeleted) { $sql .= " AND FL_DELETED = 0"; } $sql .= " ORDER BY POSITION"; logWrite($sql, "sql"); } $sql = "SELECT ID, ACLS, DT_ACTIVE_FROM, DT_ACTIVE_TO FROM $tableName WHERE PARENTID = :nodeId AND CM = :cm"; if(!$includeDeleted) { $sql .= " AND FL_DELETED = 0"; } $sql .= " ORDER BY POSITION"; $i = 0; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":nodeId", $nodeId, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":cm", $nodeData["CM"], 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $active = TRUE; if($editMode == "public") { $tnow = getSqlTs($cnn); $tmp = explode(" ", $row["DT_ACTIVE_FROM"]); $active_from = $tmp[0]; $tmp = explode(" ", $row["DT_ACTIVE_TO"]); $active_to = $tmp[0]; if(($active_from != "0000-00-00") && ($active_from != "")) { $tmp = explode("-", $active_from); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t > $tnow) { $active = FALSE; } } if(($active_to != "0000-00-00") && ($active_to != "")) { $tmp = explode("-", $active_to); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t < $tnow - (86400)) { $active = FALSE; } } } //$acls = unpackAcls($row["ACLS"]); $auth = getAuthorization($row["ACLS"], $userData); if(($auth["READ"] || $auth["EXECUTE"]) && $active) { $childs[$i] = $row["ID"]; $i++; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "m." . $nodeData["PATH"] . ".", $childs); } } return $childs; } // function getBranchData(&$cnn, &$userData, &$menuData, $editMode, $includeDeleted = FALSE) { $key = "branchData." . implode(".", $menuData) . "_ud." . $userData["ID"] . "_em." . $editMode . "_id." . $includeDeleted; $branchDataClean = array(); if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $branchDataClean))) { $parentId = 0; foreach ($menuData as $k => $v) { $menuData[$k] = intval($v); } for($i = 0; $i < count($menuData); $i++) { $forceBackend = FALSE; if(($i == 0) && ($menuData[$i] == "2")) { $forceBackend = TRUE; } $child = getNode($cnn, $userData, $menuData[$i], $editMode, $includeDeleted, $forceBackend); if(count($child) > 0) { if($child["CSS"] == "") { if($i == 0) { $child["CSS"] = "default"; } else { $child["CSS"] = $branchDataClean[$i - 1]["CSS"]; } } if($child["UNAUTHORIZED"] == TRUE) { $branchDataClean[$i] = $child; break; } if($child["PARENTID"] == $parentId) { if($child["AUTH"]["READ"]) // || $child["AUTH"]["EXECUTE"]) { $branchDataClean[$i] = $child; $branchDataClean[$i]["UNAUTHORIZED"] = FALSE; $parentId = $branchDataClean[$i]["ID"]; } else { $branchDataClean[$i]["UNAUTHORIZED"] = TRUE; } if(!$child["AUTH"]["EXECUTE"]) { $branchDataClean[$i]["UNAUTHORIZED"] = TRUE; break; } } } else { break; } } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "m." . implode(".", $menuData) . ".", $branchDataClean); } } return $branchDataClean; } // function getMenuData(&$cnn, &$userData, &$branchData, $editMode) { $key = "menuData." . $branchData[count($branchData) - 1]["PATH"] . "_ud." . $userData["ID"] . "_em." . $editMode; $menuData = array(); if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $menuData))) { $child = getNode($cnn, $userData, $branchData[0]["ID"], $editMode); if(count($child) > 0) { $menuData[0] = $child; $menuData[0]["SELECTED"] = 1; $menuData[0]["CHILDS"] = array(); $menuData[0]["CHILDS"] = getMenuDataItems($cnn, $userData, $branchData, $editMode, 0); } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "m." . $branchData[count($branchData) - 1]["PATH"] . ".", $menuData); } } return $menuData; } // function getMenuDataItems(&$cnn, &$userData, &$branchData, $editMode, $topItemLevel = 0) { $menuData = array(); $menuData = getChilds($cnn, $userData, $branchData[$topItemLevel], $editMode); for($i = 0; $i < count($menuData); $i++) { $menuData[$i]["SELECTED"] = 0; $menuData[$i]["PARENTPATH"] = $branchData[$topItemLevel]["PATH"]; $menuData[$i]["PATH"] = $menuData[$i]["PARENTPATH"] . "." . $menuData[$i]["ID"] ; if(count($branchData) > $topItemLevel + 1) { if($branchData[$topItemLevel + 1]["ID"] == $menuData[$i]["ID"]) { $menuData[$i]["SELECTED"] = 1; $menuData[$i]["CHILDS"] = array(); if($menuData[$i]["AUTH"]["EXECUTE"]) { $menuData[$i]["CHILDS"] = getMenuDataItems($cnn, $userData, $branchData, $editMode, $topItemLevel + 1); } } } } return $menuData; } // function getContentData(&$cnn, &$userData, &$nodeData, $editMode) { $key = "contentData." . $nodeData["PATH"] . "_ud." . $userData["ID"] . "_em." . $editMode; $contentData = array(); if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $contentData))) { $tableName = "CM_CONTENT_S"; $tableBlockName = "CM_BLOCK_S"; if($editMode == "public") { $tableName = "CM_CONTENT"; $tableBlockName = "CM_BLOCK"; } $auth = $nodeData["AUTH"]; $contentId = $nodeData["ID"]; if($auth["READ"] && ($auth["EXECUTE"] || $userData["FL_PUBLISH"])) { $contentData[0] = array(); if(LOG_SQL) { $sql = "SELECT $tableName.*, CM_CONTENT_TYPE.NAME AS LAYOUTNAME, CM_CONTENT_TYPE.FL_CM AS FL_ADMIN_LAYOUT FROM $tableName LEFT JOIN CM_CONTENT_TYPE ON $tableName.LAYOUT = CM_CONTENT_TYPE.ID AND CM_CONTENT_TYPE.FL_DELETED = 0 WHERE $tableName.ID = $contentId"; logWrite($sql, "sql"); } $sql = "SELECT $tableName.*, CM_CONTENT_TYPE.NAME AS LAYOUTNAME, CM_CONTENT_TYPE.FL_CM AS FL_ADMIN_LAYOUT FROM $tableName LEFT JOIN CM_CONTENT_TYPE ON $tableName.LAYOUT = CM_CONTENT_TYPE.ID AND CM_CONTENT_TYPE.FL_DELETED = 0 WHERE $tableName.ID = :contentId"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":contentId", $contentId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); $counter = 0; while(ociFetchInto($stmt, $row, OCI_ASSOC) && ($counter == 0)) { $counter ++; $auth = getAuthorization($row["ACLS"], $userData); if($auth["READ"] || $auth["EXECUTE"] || $userData["FL_PUBLISH"])// || $auth["NO_EXECUTE"]) { $contentData[0] = $row; $contentData[0]["CM_BLOCK_TYPE"] = getBlocksTypeFromLayout($cnn, $row["LAYOUT"]); } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if($auth["READ"] || $auth["EXECUTE"] || $userData["FL_PUBLISH"])// || $auth["NO_EXECUTE"]) { $contentData[0]["LOCKID"] = $nodeData["LOCKID"]; $contentData[0]["PARENTID"] = $nodeData["PARENTID"]; $contentData[0]["PATH"] = $nodeData["PATH"]; $contentData[0]["PARENTPATH"] = $nodeData["PARENTPATH"]; $contentData[0]["CM"] = $nodeData["CM"]; $contentData[0]["AUTH"] = array(); $contentData[0]["AUTH"] = $auth; $ct = getContentsTypeFromId($cnn, $contentData[0]["LAYOUT"]); $tmpZones = $ct["ZONES"]; $tmp = explode(",", $tmpZones); if(count($tmp) > 0) { for($i = 0; $i < count($tmp); $i++) { $contentData[0]["ZONES"][$i]["LABEL"] = trim($tmp[$i]); } } if($contentData[0]["LAYOUTNAME"] != "nocontent") { if($nodeData["LINK_URL"]) { unset($contentData[0]["CM_BLOCK_TYPE"]); unset($contentData[0]["ZONES"]); $contentData[0]["LAYOUTNAME"] = "default"; $contentData[0]["LABEL"] = "redirect to " . $nodeData["LINK_URL"]; } if(LOG_SQL) { $sql = "SELECT COUNT(*) AS C FROM $tableBlockName WHERE PARENTID = $contentId AND FL_DELETED = 0"; logWrite($sql, "sql"); } $sql = "SELECT COUNT(*) AS C FROM $tableBlockName WHERE PARENTID = :contentId AND FL_DELETED = 0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":contentId", $contentId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $contentData[0]["ACTIVE"] = ($row["C"] == 0) ? 0 : 1; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } } else { $contentData[0]["UNAUTHORIZED"] = TRUE; $contentData[0]["PARENTID"] = $nodeData["PARENTID"]; $contentData[0]["PARENTPATH"] = $nodeData["PARENTPATH"]; $contentData[0]["PATH"] = $nodeData["PATH"]; $contentData[0]["AUTH"] = $auth; } } else { $contentData[0] = 0; } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "m." . $nodeData["PATH"] . ".", $contentData); } } return $contentData[0]; } // function getContentName(&$cnn, &$userData, $contentId, $editMode) { $tableName = "CM_CONTENT_S"; if($editMode == "public") { $tableName = "CM_CONTENT"; } $contentName = ""; if(LOG_SQL) { $sql = "SELECT LABEL FROM $tableName WHERE FL_DELETED = 0 AND ID = $contentId"; logWrite($sql, "sql"); } $sql = "SELECT LABEL FROM $tableName WHERE FL_DELETED = 0 AND ID = :contentId"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":contentId", $contentId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $contentName = $row["LABEL"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $contentName; } // function getBlock(&$cnn, &$userData, &$nodeData, &$contentData, $blockId, $editMode, $alias = FALSE, $includeDeleted = FALSE) { $key = "blockData." . $nodeData["PATH"] . "_cd." . $contentData["ID"] . "_bid." . $blockId . "_ud." . $userData["ID"] . "_em." . $editMode . "_al." . $alias . "_id." . $includeDeleted; if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $blockData))) { $tableName = "CM_BLOCK_S"; if($editMode == "public") { $tableName = "CM_BLOCK"; } if(($contentData["AUTH"]["READ"] && $contentData["AUTH"]["EXECUTE"]) || ($nodeData["AUTH"]["WRITE"] && $userData["FL_PUBLISH"])) { if(LOG_SQL) { $sql = "SELECT $tableName.*, CM_BLOCK_TYPE.NAME AS BLOCKNAME "; $sql .= "FROM $tableName LEFT JOIN CM_BLOCK_TYPE ON $tableName.BLOCKTYPE = CM_BLOCK_TYPE.ID "; $sql .= "WHERE CM_BLOCK_TYPE.FL_DELETED = 0 AND $tableName.ID = $blockId"; if(!$alias) { $sql .= " AND $tableName.PARENTID = " . $contentData["ID"]; } if(!$includeDeleted) { $sql .= " AND $tableName.FL_DELETED = 0"; } $sql = addSqlLimit($sql, 1); logWrite($sql, "sql"); } $sql = "SELECT $tableName.*, CM_BLOCK_TYPE.NAME AS BLOCKNAME "; $sql .= "FROM $tableName LEFT JOIN CM_BLOCK_TYPE ON $tableName.BLOCKTYPE = CM_BLOCK_TYPE.ID "; $sql .= "WHERE CM_BLOCK_TYPE.FL_DELETED = 0 AND $tableName.ID = :blockId"; if(!$alias) { $sql .= " AND $tableName.PARENTID = :contentId"; } if(!$includeDeleted) { $sql .= " AND $tableName.FL_DELETED = 0"; } $sql = addSqlLimit($sql, 1); $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":blockId", $blockId, 32) or doError("sql", ociError($stmt)); if(!$alias) { ociBindByName($stmt, ":contentId", $contentData["ID"], 32) or doError("sql", ociError($stmt)); } ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC + OCI_RETURN_LOBS)) { $blockData = array(); $active = TRUE; if($editMode == "public") { $tnow = getSqlTs($cnn); $tmp = explode(" ", $row["DT_ACTIVE_FROM"]); $active_from = $tmp[0]; $tmp = explode(" ", $row["DT_ACTIVE_TO"]); $active_to = $tmp[0]; if(($active_from != "0000-00-00") && ($active_from != "")) { $tmp = explode("-", $active_from); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t > $tnow) { $active = FALSE; } } if(($active_to != "0000-00-00") && ($active_to != "")) { $tmp = explode("-", $active_to); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t < $tnow - (86400)) { $active = FALSE; } } } //$acls = unpackAcls($row["ACLS"]); $auth = getAuthorization($row["ACLS"], $userData); if(($auth["READ"] || $auth["EXECUTE"] || ($nodeData["AUTH"]["WRITE"] && $userData["FL_PUBLISH"])) && $active) { $blockData = array(); $blockData = $row; $blockData["AUTH"] = $auth; $blockData["LOCKID"] = $contentData["LOCKID"]; $blocksData[$i]["PARENTPATH"] = $contentData["PATH"]; } else { $blockData = 0; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } else { $blockData = 0; } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "m." . $nodeData["PATH"] . ".", $blockData); } } return $blockData; } // function getBlocksData(&$cnn, &$userData, &$nodeData, &$contentData, $editMode, $pageSize = 0, $absPage = 0, $includeDeleted = FALSE) { $key = "blocksData." . $nodeData["PATH"] . "_cd." . $contentData["ID"] . "_ud." . $userData["ID"] . "_em." . $editMode . "_ps." . $pageSize . "_ap." . $absPage . "_id." . $includeDeleted; $blocksData = array(); if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $blocksData))) { $tableName = "CM_BLOCK_S"; if($editMode == "public") { $tableName = "CM_BLOCK"; } if(($contentData["AUTH"]["READ"] && $contentData["AUTH"]["EXECUTE"]) || ($nodeData["AUTH"]["WRITE"] && $userData["FL_PUBLISH"])) { if(LOG_SQL) { $order = ""; $limit = ""; $base = "SELECT $tableName.*, CM_BLOCK_TYPE.NAME AS BLOCKNAME "; $base .= "FROM $tableName LEFT JOIN CM_BLOCK_TYPE ON $tableName.BLOCKTYPE = CM_BLOCK_TYPE.ID "; $base .= "WHERE CM_BLOCK_TYPE.FL_DELETED = 0 AND $tableName.PARENTID = " . $contentData["ID"]; if(!$includeDeleted) { $base .= " AND $tableName.FL_DELETED = 0"; } if(strlen($contentData["CRIT_ORDER"]) > 0) { $order = " ORDER BY $tableName." . $contentData["CRIT_ORDER"]; } else { $order = " ORDER BY $tableName.POSITION "; } $sql = $base . $order; if(($contentData["PAGESIZE"] > 0) && ($absPage > 0) && ($pageSize > 0)) { $sql = addSqlLimit($sql, $absPage * $pageSize, ($absPage - 1) * $pageSize); } logWrite($sql, "sql"); } $order = ""; $limit = ""; $base = "SELECT $tableName.*, CM_BLOCK_TYPE.NAME AS BLOCKNAME "; $base .= "FROM $tableName LEFT JOIN CM_BLOCK_TYPE ON $tableName.BLOCKTYPE = CM_BLOCK_TYPE.ID "; $base .= "WHERE CM_BLOCK_TYPE.FL_DELETED = 0 AND $tableName.PARENTID = :contentid"; if(!$includeDeleted) { $base .= " AND $tableName.FL_DELETED = 0"; } if(strlen($contentData["CRIT_ORDER"]) > 0) { $order = " ORDER BY $tableName." . $contentData["CRIT_ORDER"]; } else { $order = " ORDER BY $tableName.POSITION "; } $sql = $base . $order; if(($contentData["PAGESIZE"] > 0) && ($absPage > 0) && ($pageSize > 0)) { $sql = addSqlLimit($sql, $absPage * $pageSize, ($absPage - 1) * $pageSize); } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":contentid", $contentData["ID"], 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); $i = 0; while (ociFetchInto($stmt, $row, OCI_ASSOC + OCI_RETURN_LOBS)) { $active = TRUE; if($editMode == "public") { $tnow = getSqlTs($cnn); $tmp = explode(" ", $row["DT_ACTIVE_FROM"]); $active_from = $tmp[0]; $tmp = explode(" ", $row["DT_ACTIVE_TO"]); $active_to = $tmp[0]; if(($active_from != "0000-00-00") && ($active_from != "")) { $tmp = explode("-", $active_from); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t > $tnow) { $active = FALSE; } } if(($active_to != "0000-00-00") && ($active_to != "")) { $tmp = explode("-", $active_to); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if(($t < $tnow - (86400)) && $row["ARCH_TARGET"] == 0) { $active = FALSE; } } } //$acls = unpackAcls($row["ACLS"]); $auth = getAuthorization($row["ACLS"], $userData); if(($auth["READ"] || $auth["EXECUTE"] || ($nodeData["AUTH"]["WRITE"] && $userData["FL_PUBLISH"])) && $active) { $blocksData[$i] = $row; $blocksData[$i]["AUTH"] = $auth; $blocksData[$i]["LOCKID"] = $contentData["LOCKID"]; $blocksData[$i]["PARENTPATH"] = $contentData["PATH"]; $i++; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "m." . $nodeData["PATH"] . ".", $blocksData); } } return $blocksData; } // function getBlocksCount(&$cnn, &$userData, &$contentData, $editMode, $checkAcls = TRUE, $includeDeleted = FALSE) { $key = "blocksCount.cd." . $contentData["ID"] . "_ud." . $userData["ID"] . "_em." . $editMode . "_acls." . $checkAcls . "_id." . $includeDeleted; $blocksCount = 0; if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $blocksCount))) { $tableName = "CM_BLOCK_S"; if($editMode == "public") { $tableName = "CM_BLOCK"; } if(!$checkAcls) { if(LOG_SQL) { $sql = "SELECT COUNT(*) AS C "; $sql .= "FROM $tableName INNER JOIN CM_BLOCK_TYPE ON $tableName.BLOCKTYPE = CM_BLOCK_TYPE.ID "; $sql .= "WHERE $tableName.PARENTID = " . $contentData["ID"]; if(!$includeDeleted) { $sql .= " AND $tableName.FL_DELETED = 0"; } logWrite($sql, "sql"); } $sql = "SELECT COUNT(*) AS C "; $sql .= "FROM $tableName INNER JOIN CM_BLOCK_TYPE ON $tableName.BLOCKTYPE = CM_BLOCK_TYPE.ID "; $sql .= "WHERE $tableName.PARENTID = :contentid"; if(!$includeDeleted) { $sql .= " AND $tableName.FL_DELETED = 0"; } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":contentid", $contentData["ID"], 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $blocksCount = $row["C"]; } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } else { if(LOG_SQL) { $sql = "SELECT ACLS FROM $tableName WHERE $tableName.PARENTID = " . $contentData["ID"]; if(!$includeDeleted) { $sql .= " AND $tableName.FL_DELETED = 0"; } logWrite($sql, "sql"); } $sql = "SELECT ACLS FROM $tableName WHERE $tableName.PARENTID = :contentid"; if(!$includeDeleted) { $sql .= " AND $tableName.FL_DELETED = 0"; } $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":contentid", $contentData["ID"], 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { //$acls = unpackAcls($row["ACLS"]); $auth = getAuthorization($row["ACLS"], $userData); if($auth["READ"] || $auth["EXECUTE"]) { $blocksCount++; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "m." . $contentData["PATH"] . ".", $blocksCount); } } return $blocksCount; } // function getAliasableBlocks(&$cnn, &$userData, $editMode, $includeDeleted) { $aliasableBlocks = array(); $tableName = "CM_BLOCK_S"; if($editMode == "public") { $tableName = "CM_BLOCK"; } $sql = "SELECT PARENTID, ID, SHORTNAME, ACLS FROM $tableName WHERE SHORTNAME is not null "; if(!$includeDeleted) { $sql .= " AND $tableName.FL_DELETED = 0"; } if(LOG_SQL) { logWrite($sql, "sql"); } $i = 0; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $auth = getAuthorization($row["ACLS"], $userData); if($auth["READ"] && $auth["EXECUTE"]) { $aliasableBlocks[$i]["ID"] = $row["ID"]; $parentPath = getFullPathData($cnn, $userData, $row["PARENTID"], $editMode); $branch = getBranchData($cnn, $userData, $parentPath, $editMode); $aliasableBlocks[$i]["SHORTNAME"] = ""; for($j = 1;$j < count($branch); $j++) { $aliasableBlocks[$i]["SHORTNAME"] .= $branch[$j]["LABEL"] . " -> "; } $aliasableBlocks[$i]["SHORTNAME"] .= $row["SHORTNAME"]; $i++; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $aliasableBlocks; } // function findFirstContentActive(&$cnn, &$userData, $editMode, &$branchData, &$contentData) { if(!$contentData["ACTIVE"] && (!$contentData["AUTH"]["NO_EXECUTE"]) && (!$contentData["AUTH"]["NO_READ"])) { $tmp = getChildsId($cnn, $userData, $branchData[count($branchData) - 1], $editMode); if(count($tmp)>0) { $tmpNode = getNode($cnn, $userData, $tmp[0], $editMode); $branchData[] = $tmpNode; $tmpContent = getContentData($cnn, $userData, $branchData[count($branchData) - 1], $editMode); if(!$tmpContent["ACTIVE"]) { $branchData = findFirstContentActive($cnn, $userData, $editMode, $branchData, $tmpNode, $tmpContent); } } } return $branchData; } // function getFullPathData(&$cnn, &$userData, $nodeId, $editMode, $reverseOrder = FALSE) { $key = "pathData." . $nodeId . "_ud." . $userData["ID"] . "_em." . $editMode . "_rv." . $reverseOrder; $blocksData = array(); if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $nodes))) { $tableName = "CM_MENU_S"; if($editMode == "public") { $tableName = "CM_MENU"; } $nodes = array(); if(LOG_SQL) { $sql = "SELECT ID, PARENTID FROM $tableName WHERE ID = $nodeId AND ID > 0"; logWrite($sql, "sql"); } $sql = "SELECT ID, PARENTID FROM $tableName WHERE ID = :nodeid AND ID > 0"; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":nodeid", $nodeId, 32) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $tmp = getFullPathData($cnn, $userData, $row["PARENTID"], $editMode, TRUE); $nodes[] = $nodeId; for($i = 0; $i < count($tmp); $i++) { $nodes[] = $tmp[$i]; } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if(!$reverseOrder) { $nodes = array_reverse($nodes); } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "p." . $nodeId . ".", $nodes); } } ///////////////////////////// if(implode(".",$nodes) == "1.1") { PRINT_r($nodes); exit; } return $nodes; } // function getFullPathDataByName(&$cnn, &$userData, $tree, $nodeName, $editMode, $reverseOrder = FALSE) { $key = "getFullPathDataByName.tr." . $tree . "_ud." . $userData["ID"] . "_em." . $editMode . "_mname." . $nodeName . "_revo." . $reverseOrder; $nodes = array(); if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $nodes))) { $tableName = "CM_MENU_S"; if($editMode == "public") { $tableName = "CM_MENU"; } if(LOG_SQL) { $sql = "SELECT ID, PARENTID FROM $tableName "; $sql .= "WHERE FL_DELETED = 0 AND CM = $tree AND SHORTNAME = '$nodeName'"; $sql = addSqlLimit($sql, 1); logWrite($sql, "sql"); } $sql = "SELECT ID, PARENTID FROM $tableName "; $sql .= "WHERE FL_DELETED = 0 AND CM = :cm AND SHORTNAME = :nodename"; $sql = addSqlLimit($sql, 1); $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociBindByName($stmt, ":cm", $tree, 32) or doError("sql", ociError($stmt)); ociBindByName($stmt, ":nodename", $nodeName, strlen($nodeName)) or doError("sql", ociError($stmt)); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { $nodes = getFullPathData($cnn, $userData, $row["ID"], $editMode, $reverseOrder); } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); if(!DISABLE_CACHE) { if($reverseOrder) { $path = implode(".", array_reverse($nodes)); } else { $path = implode(".", $nodes); } writeCacheData($cnn, $userData["ID"], $key, "p." . $path . ".", $nodes); } } return $nodes; } // function getNamedNode(&$cnn, $tree, $nodeName, &$userData, $editMode) { $key = "getNamedNode.tr." . $tree . "_ud." . $userData["ID"] . "_em." . $editMode . "_mname." . $nodeName; $namedNode = array(); if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $namedNode))) { $nodePath = getFullPathDataByName($cnn, $userData, $tree, $nodeName, $editMode); if(count($nodePath) > 0) { $nodeId = implode(".", $nodePath); $branch = getBranchData($cnn, $userData, $nodePath, $editMode); $nodeIdClean = $branch[count($branch) - 1]["PATH"]; if($nodeIdClean == $nodeId) { $namedNode = getNode($cnn, $userData, $nodePath[count($nodePath) - 1], $editMode); } } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "p." . $namedNode["PATH"] . ".", $namedNode); } } return $namedNode; } // function getNamedMenu(&$cnn, $tree, $menuName, $userData, $editMode) { $key = "getNamedMenu.tr." . $tree . "_ud." . $userData["ID"] . "_em." . $editMode . "_mname." . $menuName; if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $namedMenu))) { $namedMenu = array(); $menuPath = getFullPathDataByName($cnn, $userData, $tree, $menuName, $editMode); if(count($menuPath) > 0) { $menuId = implode(".", $menuPath); $branch = getBranchData($cnn, $userData, $menuPath, $editMode); $menuIdClean = $branch[count($branch) - 1]["PATH"]; if($menuIdClean == $menuId) { $namedMenu = getMenuDataItems($cnn, $userData, $branch, $editMode, count($branch) - 1); } } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "p." . $namedMenu[count($namedMenu) - 1]["PATH"] . ".", $namedMenu); } } return $namedMenu; } // function getAbstractNamedMenu(&$cnn, $tree, $menuName, $userData, $editMode) { $key = "getNamedMenu.tr." . $tree . "_ud." . $userData["ID"] . "_em." . $editMode . "_mname." . $menuName; if(DISABLE_CACHE || (!readCacheData($cnn, $userData["ID"], $key, $namedMenu))) { $namedMenu = array(); $menuPath = getFullPathDataByName($cnn, $userData, $tree, $menuName, $editMode); if(count($menuPath) > 0) { $menuId = implode(".", $menuPath); $branch = getBranchData($cnn, $userData, $menuPath, $editMode); $menuIdClean = $branch[count($branch) - 1]["PATH"]; if($menuIdClean == $menuId) { $namedMenu = getMenuDataItems($cnn, $userData, $branch, $editMode, count($branch) - 1); } } if(!DISABLE_CACHE) { writeCacheData($cnn, $userData["ID"], $key, "p." . $namedMenu[count($namedMenu) - 1]["PATH"] . ".", $namedMenu); } } return $namedMenu; } // function searchInBlocks($cnn, $userData, $tree, $menuIdArray, $text, $editMode) { $text = strtolower($text); //$text = quoteForDb($text); $words = explode(" ", $text); foreach($words as $k => $v) { $words[$k] = quoteForDb($v); } $blockTable = "CM_BLOCK_S"; $contentTable ="CM_CONTENT_S"; $menuTable = "CM_MENU_S"; $showInHomePage = true; if($editMode == "public") { $blockTable = "CM_BLOCK"; $contentTable ="CM_CONTENT"; $menuTable = "CM_MENU"; $showInHomePage = false; } $blocksCont = array(); $blocks = array(); $parentId = $menuIdArray[count($menuIdArray)-1]; $sql = "SELECT distinct $contentTable.ID, $blockTable.DT_ACTIVE_FROM, $blockTable.DT_ACTIVE_TO, $blockTable.ACLS ";//, $blockTable.ID AS BLOCKID "; $sql .= " FROM $blockTable RIGHT JOIN $contentTable"; $sql .= " ON $blockTable.PARENTID = $contentTable.ID"; $sql .= " RIGHT JOIN $menuTable"; $sql .= " ON $contentTable.ID = $menuTable.ID"; $sql .= " WHERE $blockTable.FL_DELETED = 0 "; if(!$showInHomePage) { $sql .= " AND $menuTable.ID <> 1 "; } $sql .= " AND $menuTable.CM = $tree AND "; $sql .= " $menuTable.FL_UNSEARCHABLE = 0"; $sql .= " AND ("; $s = array(); foreach($words as $w) { $s[] = "lower($menuTable.LABEL) LIKE '%$w%'"; } if(count($s)) { $sql .= "( " . implode(" AND ", $s) . " )"; } $s = array(); foreach($words as $w) { $s[] = "lower($contentTable.LABEL) LIKE '%$w%'"; } if(count($s)) { $sql .= " OR ( " . implode(" AND ", $s) . " )"; } $s = array(); foreach($words as $w) { $s[] = "lower($blockTable.TXT_BLOB) LIKE '%$w%'"; } if(count($s)) { $sql .= " OR ( " . implode(" AND ", $s) . " )"; } $s = array(); foreach($words as $w) { $s[] = "lower($blockTable.LTXT1) LIKE '%$w%'"; } if(count($s)) { $sql .= " OR ( " . implode(" AND ", $s) . " )"; } for($i = 1; $i < 16; $i++) { $s = array(); foreach($words as $w) { $s[] = "lower($blockTable.STXT" . $i . ") LIKE '%$w%'"; } if(count($s)) { $sql .= " OR ( " . implode(" AND ", $s) . " )"; } } $sql .= ")"; //debug($sql); ////////////////////// //$sql .= " ORDER BY $blockTable.PARENTID"; if(LOG_SQL) { logWrite($sql, "sql"); } $i = 0; $foundBlocks = array(); $prevParentId = -1; $stmt = ociParse($cnn, $sql) or doError("sql", $sql); ociExecute($stmt) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_RETURN_NULLS + OCI_ASSOC)) { $active = TRUE; if($editMode == "public") { $tnow = getSqlTs($cnn); $tmp = explode(" ", $row["DT_ACTIVE_FROM"]); $active_from = $tmp[0]; $tmp = explode(" ", $row["DT_ACTIVE_TO"]); $active_to = $tmp[0]; if(($active_from != "0000-00-00") && ($active_from != "")) { $tmp = explode("-", $active_from); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t > $tnow) { $active = FALSE; } } if(($active_to != "0000-00-00") && ($active_to != "")) { $tmp = explode("-", $active_to); $t = mktime (0,0,0,$tmp[1],$tmp[2],$tmp[0]); if($t < $tnow - (86400)) { $active = FALSE; } } } $auth = getAuthorization($row["ACLS"], $userData); if($auth["READ"] && $active) { //if($prevParentId != $row["PARENTID"]) { $blocksCont[$i] = getFullPathData($cnn, $userData, $row["ID"], $editMode); $blocks[$i] = $row["BLOCKID"]; //$prevParentId = $row["PARENTID"]; //$foundBlocks[] = $row["ID"]; $i++; } } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); $j = 0; for($i = 0; $i < count($blocks); $i++) { $menuId = implode(".", $blocksCont[$i]); $branchData = getBranchData($cnn, $userData, $blocksCont[$i], $editMode); $menuIdClean = $branchData[count($branchData) - 1]["PATH"]; if($menuId == $menuIdClean) { $searchable = TRUE; for($k = 0; $k < count($branchData); $k++) { if($branchData[$k]["FL_UNSEARCHABLE"]) { $searchable = FALSE; break; } } if($searchable) { for($k = 0; $k < count($branchData); $k++) { if(!$branchData[$k]["FL_HIDDEN"] || $branchData[$k]["PARENTPATH"] == "") { $nodeData[$j]["LABELS"][] = $branchData[$k]["LABEL"]; } } $nodeData[$j]["BLOCKID"] = $blocks[$i]; $nodeData[$j]["PATH"] = $menuId; $nodeData[$j]["MENU_LABEL"] = $branchData[count($branchData) - 1]["LABEL"]; $contentData = getContentData($cnn, $userData, $branchData[count($branchData) - 1], $editMode); $nodeData[$j]["CONTENT_LABEL"] = $contentData["LABEL"]; $j++; } } } return $nodeData; } function getTreeInTable(&$cnn, $editMode, &$userData, &$nodeData, $includeDeleted = FALSE, $indent = "", $stopLevel = -1, $order = "", $level = 0) { $locksTable = array(); if($nodeData["AUTH"]["READ"]) { $locksTable[0] = $nodeData; $locksTable[0]["NU_LEVEL"] = $level; if(strlen($indent) > 0) { $prefix = ""; for($i = 0; $i < $level; $i++) { $prefix .= $indent . $indent . $indent; } $locksTable[0]["LABEL"] = $prefix . $locksTable[0]["LABEL"]; } if(($nodeData["AUTH"]["EXECUTE"]) && (($stopLevel == -1) || ($stopLevel > $level))) { $childsData = getChilds($cnn, $userData, $nodeData, $editMode, $includeDeleted, $order); for($i = 0; $i < count($childsData); $i++) { $tmpTable = getTreeInTable($cnn, $editMode, $userData, $childsData[$i], $includeDeleted, $indent, $stopLevel, $order, $level + 1); for($j = 0; $j < count($tmpTable); $j++) { $locksTable[] = $tmpTable[$j]; } } } } return $locksTable; } /* function getMenuTree($cnn, $userData, $editMode) { $rootNodes = getRootNodes($cnn, $userData, $editMode); $menuId = $rootNodes[0]["ID"]; $menuIdArray = explode(".", $menuId); $branchData = getBranchData($cnn, $userData, $menuIdArray, $editMode); return getMenuData($cnn, $userData, $branchData, $editMode); }*/ function getMenuTree(&$cnn, $editMode, $userData, $indent = "", $stopLevel = -1) { $includeDeleted = FALSE; $level = 0; $rootNodes = getRootNodes($cnn, $userData, $editMode); $nodeData = $rootNodes[0]; $k = 0; $treeTable = array(); $treeTable[$k]["ID"] = 0; $treeTable[$k]["PARENTID"] = 0; $treeTable[$k]["LABEL"] = "/"; $treeTable[$k]["NU_LEVEL"] = 0; if($nodeData["AUTH"]["READ"]) { $k ++; $treeTable[$k]["ID"] = $nodeData["ID"]; $treeTable[$k]["PARENTID"] = $nodeData["PARENTID"]; $treeTable[$k]["LABEL"] = $nodeData["LABEL"]; $treeTable[$k]["NU_LEVEL"] = $level; if(strlen($indent) > 0) { $prefix = ""; for($i = 0; $i < $level; $i++) { $prefix .= $indent . $indent . $indent; } $treeTable[$k]["LABEL"] = $prefix . $treeTable[$k]["LABEL"]; } $k ++; if(($nodeData["AUTH"]["EXECUTE"]) && (($stopLevel == -1) || ($stopLevel > $level))) { $childsData = getChilds($cnn, $userData, $nodeData, $editMode, $includeDeleted, $order); for($i = 0; $i < count($childsData); $i++) { $tmpTable = getTreeInTable($cnn, $editMode, $userData, $childsData[$i], $includeDeleted, $indent, $stopLevel, $order, $level + 1); for($j = 0; $j < count($tmpTable); $j++) { $treeTable[$k]["ID"] = $tmpTable[$j]["ID"]; $treeTable[$k]["PARENTID"] = $tmpTable[$j]["PARENTID"]; $treeTable[$k]["LABEL"] = $tmpTable[$j]["LABEL"]; $treeTable[$k]["NU_LEVEL"] = $tmpTable[$j]["NU_LEVEL"]; $k++; } } } } return $treeTable; } // function getEmailTemplate(&$cnn, $item) { $emailData = array(); $emailData["SUBJECT"] = ""; $emailData["EMAIL_BODY"] = ""; if(LOG_SQL) { $sql = "SELECT SUBJECT, EMAIL_BODY FROM CM_EMAIL_TEMPLATE WHERE FL_DELETED=0 AND NAME = '$item'"; logWrite($sql, "sql"); } $sql = "SELECT SUBJECT, EMAIL_BODY FROM CM_EMAIL_TEMPLATE WHERE FL_DELETED=0 AND NAME = :name"; $stmt = ociParse($cnn, $sql) or doError("sql",$sql); ociBindByName($stmt, ":name", $item, strlen($item)) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { if (function_exists("html_entity_decode")) { $emailData["SUBJECT"] = br2nl(html_entity_decode($row["SUBJECT"])); $emailData["EMAIL_BODY"] = br2nl(html_entity_decode($row["EMAIL_BODY"])); } else { $emailData["SUBJECT"] = br2nl(mhtml_entity_decode($row["SUBJECT"])); $emailData["EMAIL_BODY"] = br2nl(mhtml_entity_decode($row["EMAIL_BODY"])); } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $emailData; } // function getSmsTemplate(&$cnn, $item) { $smsData = array(); $smsData["SMS_BODY"] = ""; if(LOG_SQL) { $sql = "SELECT SMS_BODY FROM CM_SMS_TEMPLATE WHERE FL_DELETED=0 AND NAME = '$item'"; logWrite($sql, "sql"); } $sql = "SELECT SMS_BODY FROM CM_SMS_TEMPLATE WHERE FL_DELETED=0 AND NAME = :name"; $stmt = ociParse($cnn, $sql) or doError("sql",$sql); ociBindByName($stmt, ":name", $item, strlen($item)) or doError("sql", ociError($stmt)); ociExecute($stmt, OCI_DEFAULT) or doError("sql", ociError($stmt)); while (ociFetchInto($stmt, $row, OCI_ASSOC)) { if (function_exists("html_entity_decode")) { $smsData["SMS_BODY"] = br2nl(html_entity_decode($row["SMS_BODY"])); } else { $smsData["SMS_BODY"] = br2nl(mhtml_entity_decode($row["SMS_BODY"])); } } ociFreeStatement($stmt) or doError("sql", ociError($stmt)); return $smsData; } // function sendEmailFromTemplate ($subject, $body, $emailData, $from, $to, $html_email = FALSE) { //$html_email=false; //logWrite("is html: " . $html_email, "mail"); //$params["host"] = EMAIL_SMTP; //$mail_object =& Mail::factory('smtp', $params); //$mailheaders = "From: $from\n"; if($emailData) { foreach($emailData as $key => $value) { $subject = str_replace("<$key/>", $value, $subject); $body = str_replace("<$key/>", $value, $body); $html_email = str_replace("<$key/>", $value, $html_email); } } if(SEND_EMAIL) { $dest = explode(";", $to); if(is_array($dest)){ foreach($dest as $to){ $to = trim($to); if($to) { $mail = new PHPMailer(); $mail -> CharSet = "UTF-8"; //$mail->IsSMTP(); //$mail->Mailer = 'smtp'; //$mail->SMTPDebug = 1; //$Mail->SMTPSecure = "tls"; //Secure conection $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = SMTP_SERVER; $mail->Port = SMTP_PORT; // set the SMTP port for the GMAIL server $mail->Username = SMTP_USERNAME; // SMTP account username $mail->Password = SMTP_PASSWORD; // SMTP account password //$mail->From = $from; $mail->FromName = MAIL_SENDER_NAME; $mail->addReplyTo(MAIL_SENDER); $mail->SetFrom($from, MAIL_SENDER_NAME); $mail->AddAddress($to); $mail->Subject = $subject; $mail->Body = $body; $x_mailer = 'X-Mailer: PHP/' . phpversion(); $mail->addCustomHeader($x_mailer); $mail->AltBody = $body; if($html_email) { $mail->Body = $html_email; $mail->IsHTML(true); } else { $mail->IsHTML(false); } if(!$mail->Send()) { logWrite("mail error " . $mail->ErrorInfo . " " . print_r($mail, TRUE), "mail"); return FALSE; } else { logWrite("mail sent to: " . $to . ", subject: " . $subject, "mail"); logWrite("mail sent to: " . $to . ", subject: " . $subject, "main"); return TRUE; } /* $mime = new Mail_mime("\r\n"); $mime -> setTXTBody($body); $mime_param["head_charset"] = "utf-8"; $mime_param["text_charset"] = "utf-8"; $headers["Subject"] = $subject; $headers["To"] = $to; $headers["From"] = $from; $headers["Return-Path"] = $from; $headers["Date"] = date("r"); $body = $mime->get($mime_param); $mailHeaders = $mime->headers($headers); //$mailheaders["Content-Type"] = "text/plain; charset=\"UTF-8\""; $status = $mail_object->send($to, $mailHeaders, $body); if(LOG_EMAIL) { logWrite(print_r($mailHeaders, TRUE), "mail"); } if(PEAR::isError($status)) { logWrite($status -> getMessage() . " " . print_r($mailHeaders, TRUE), "mail"); logWrite($status -> getMessage() . " " . print_r($mailHeaders, TRUE), "main"); return FALSE; }*/ } } } } else { echo "from: " . $from . "
\n"; echo "to: " . $to . "
\n"; echo "subject: " . $subject . "
\n"; echo $body . "
\n"; } return TRUE; } // // function sendEmailFromTemplateMod($subject, $body, $emailData, $from, $to, $html_email = FALSE) { logWrite("mail body is html " .$html_email, "debug"); //$html_email=false; //logWrite("is html: " . $html_email, "mail"); //$params["host"] = EMAIL_SMTP; //$mail_object =& Mail::factory('smtp', $params); //$mailheaders = "From: $from\n"; if($emailData) { foreach($emailData as $key => $value) { $subject = str_replace("<$key/>", $value, $subject); $body = str_replace("<$key/>", $value, $body); $html_email = str_replace("<$key/>", $value, $html_email); } } if(SEND_EMAIL) { $dest = explode(";", $to); if(is_array($dest)){ foreach($dest as $to){ $to = trim($to); if($to) { $mail = new PHPMailer(); $mail -> CharSet = "UTF-8"; //$mail->IsSMTP(); //$mail->Mailer = 'smtp'; $mail->SMTPDebug = 1; //$Mail->SMTPSecure = "tls"; //Secure conection $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = SMTP_SERVER; $mail->Port = SMTP_PORT; // set the SMTP port for the GMAIL server $mail->Username = SMTP_USERNAME; // SMTP account username $mail->Password = SMTP_PASSWORD; // SMTP account password //$mail->From = $from; $mail->FromName = MAIL_SENDER_NAME; $mail->addReplyTo(MAIL_SENDER); $mail->SetFrom($from, MAIL_SENDER_NAME); $mail->AddAddress($to); $mail->Subject = $subject; $mail->Body = $body; $x_mailer = 'X-Mailer: PHP/' . phpversion(); $mail->addCustomHeader($x_mailer); $mail->AltBody = $body; if($html_email) { $mail->Body = $html_email; $mail->IsHTML(true); } else { $mail->IsHTML(false); } logWrite("mail body is html " . intval($html_email), "debug"); if(!$mail->Send()) { logWrite("mail error " . $mail->ErrorInfo . " " . print_r($mail, TRUE), "mail"); return FALSE; } else { logWrite("mail sent to: " . $to . ", subject: " . $subject, "mail"); logWrite("mail sent to: " . $to . ", subject: " . $subject, "main"); return TRUE; } /* $mime = new Mail_mime("\r\n"); $mime -> setTXTBody($body); $mime_param["head_charset"] = "utf-8"; $mime_param["text_charset"] = "utf-8"; $headers["Subject"] = $subject; $headers["To"] = $to; $headers["From"] = $from; $headers["Return-Path"] = $from; $headers["Date"] = date("r"); $body = $mime->get($mime_param); $mailHeaders = $mime->headers($headers); //$mailheaders["Content-Type"] = "text/plain; charset=\"UTF-8\""; $status = $mail_object->send($to, $mailHeaders, $body); if(LOG_EMAIL) { logWrite(print_r($mailHeaders, TRUE), "mail"); } if(PEAR::isError($status)) { logWrite($status -> getMessage() . " " . print_r($mailHeaders, TRUE), "mail"); logWrite($status -> getMessage() . " " . print_r($mailHeaders, TRUE), "main"); return FALSE; }*/ } } } } else { echo "from: " . $from . "
\n"; echo "to: " . $to . "
\n"; echo "subject: " . $subject . "
\n"; echo $body . "
\n"; } return TRUE; } // function sendSmsFromTemplate(&$cnn, $body, $smsData, $from, $to, $compleanno = FALSE) { if (!$compleanno) { $body = utf8_decode($body); } foreach($smsData as $key => $value) { $body = str_replace("<$key/>", $value, $body); } /*if ($smsData["MERCHANT_PHONE"]) { $body .= "\nTel: " . $smsData["MERCHANT_PHONE"]; } if ($smsData["MERCHANT_CELL"]) { $body .= "\nCell: " . $smsData["MERCHANT_CELL"]; } if (!$smsData["MERCHANT_PHONE"] && !$smsData["MERCHANT_CELL"]){ $body .= "\nN" . time() . "K"; //date("d-m-Y H:i:s"); }*/ logWrite("Invio sms from: $from, to: $to, text: \n". $body, "sms"); logWrite("Invio sms from: $from, to: $to, text: \n". $body, "main"); if(SEND_SMS) { $smsStatus = sendSms($cnn, $body, $to, $from); if($smsStatus["sms_ok"] != TRUE) { logWrite("Errore nell invio sms ". print_r($smsStatus, TRUE), "main"); return FALSE; } } return TRUE; } ?>$text"; } if($menuData[$i]["AUTH"]["EXECUTE"]) { $text = "" . $text . ""; } echo "
"; //echo "
"; echo $text; echo "
"; } } } function drawBottomMenu(&$cnn, $baseUrl, &$userData, &$menuData, &$branchData, $editMode) { //debug($menuData); for($i = 0; $i < count($menuData); $i++) { if(!$menuData[$i]["FL_HIDDEN"] || $editMode == "edit") { $text = $menuData[$i]["LABEL"]; if($menuData[$i]["FL_HIDDEN"]) { $text = "$text\n"; } $tmpLocked = ""; if($menuData[$i]["LOCKID"]) { $tmpLocked .= " locked"; } if($menuData[$i]["LOCKID"] == $userData["ID"]) { $tmpLocked .= " lockedbyme"; } $text = "
" . $text . "
\n"; echo "
\n"; echo $text; if($menuData[$i]["AUTH"]["EXECUTE"]) { $childs = getChilds($cnn, $userData, $menuData[$i], $editMode); foreach($childs as $c) { if(!$c["FL_HIDDEN"] || $editMode == "edit") { $target = ""; if($c["LINK_URL"]) { if($c["LINK_TARGET"]) { $target = "target=\"_blank\""; } $link = $c["LINK_URL"]; } else { $link = $baseUrl ."?" . getHumanPathUrlPart($c); } $tmpLocked = ""; if($c["LOCKID"]) { $tmpLocked .= " locked"; } if($c["LOCKID"] == $userData["ID"]) { $tmpLocked .= " lockedbyme"; } $submenu = $c["LABEL"]; if( $c["FL_HIDDEN"]) { $submenu = "$submenu\n"; } if($c["AUTH"]["EXECUTE"]) { $submenu = "" . $submenu . "\n"; } echo "

" . $submenu . "

\n "; } } } echo "
\n"; } } } function drawRootMenu($baseUrl, &$userData, &$menuData, &$branchData, $editMode) { $menuStr = ""; $key = "leftmenu_u." . $userData["ID"] . "_em." . $editMode . "_p." . $branchData[count($branchData) - 1]["PATH"]; $tmpData = array(); if(count($menuData) > 0) { $lev01data = $menuData;//[0]["CHILDS"]; for($i = 0; $i < count($lev01data); $i++ ) { $target = ""; $text = $lev01data[$i]["LABEL"]; if(strlen($text) == 0) { $text = "..."; } $text = ""; if($lev01data[$i]["LINK_URL"] && (!BACKEND_PAGE || $editMode != "edit" )) { if($lev01data[$i]["LINK_TARGET"]) { $target = "target=\"_blank\""; } $link = $lev01data[$i]["LINK_URL"]; } else { $link = $baseUrl ."?" . getHumanPathUrlPart($lev01data[$i]); } $text = "" . $text . ""; $tmpText = ""; $tmpLocked = ""; if($lev01data[$i]["LOCKID"]) { $tmpLocked = "locked"; } if($lev01data[$i]["LOCKID"] == $userData["ID"]) { $tmpLocked .= " lockedbyme"; } $menuStr .= "
\n"; $menuStr .= $text . "\n"; $menuStr .= "
\n"; } } else { $menuStr .= "
\n"; } echo $menuStr; } function drawMainMenu($baseUrl, &$userData, &$menuData, &$branchData, $editMode) { $menuStr = ""; $key = "leftmenu_u." . $userData["ID"] . "_em." . $editMode . "_p." . $branchData[count($branchData) - 1]["PATH"]; $tmpData = array(); if(count($menuData) > 0) { $lev01data = $menuData;//[0]["CHILDS"]; for($i = 0; $i < count($lev01data); $i++ ) { $target = ""; if($lev01data[$i]["SELECTED"]) { $lev02data = $lev01data[$i]["CHILDS"]; } } } //level 1 begin $lev02data = $menuData[0]["CHILDS"]; for($i = 0; $i < count($lev02data); $i++) { if(!$lev02data[$i]["FL_HIDDEN"] || $editMode == "edit") { // if($lev02data[$i]["FL_SEPARATOR"]) // { // $menuStr .= "
  • \n"; // $menuStr .= "
    " . "\n"; // $menuStr .= "
  • \n"; // } // else { $itemId2 = $lev02data[$i]["ID"]; $text = $lev02data[$i]["LABEL"]; if(strlen($text) == 0) { $text = "..."; } $css=""; if($lev02data[$i]["SELECTED"]) { $lev02sel = $lev02data[$i]; //if(count($lev02data[$i]["CHILDS"]) == 0 ) { $css = "selected"; } } if($lev02data[$i]["FL_HIDDEN"]) { $text = "$text"; } if($lev02data[$i]["AUTH"]["EXECUTE"]) { $target = ""; if($lev02data[$i]["LINK_URL"] && (!BACKEND_PAGE || $editMode != "edit" )) { if($lev02data[$i]["LINK_TARGET"]) { $target = "target=\"_blank\""; } $link = $baseUrl . $lev02data[$i]["LINK_URL"]; } else { $link = $baseUrl ."?" . getHumanPathUrlPart($lev02data[$i]); } $text = "" . $text . ""; } $tmpLocked = ""; if($lev02data[$i]["LOCKID"]) { $tmpLocked = "locked"; } if($lev02data[$i]["LOCKID"] == $userData["ID"]) { $tmpLocked .= " lockedbyme"; } $menuStr .= "
    "; $menuStr .= "
    "; $menuStr .= $text . "\n"; $menuStr .= "
    \n"; $menuStr .= "
    \n"; } } } //level 1 end echo $menuStr; } function drawSubMenu($baseUrl, &$userData, &$menuData, &$branchData, $editMode) { $menuStr = ""; $key = "leftmenu_u." . $userData["ID"] . "_em." . $editMode . "_p." . $branchData[count($branchData) - 1]["PATH"]; $tmpData = array(); if(count($menuData) > 0) { $lev01data = $menuData;//[0]["CHILDS"]; for($i = 0; $i < count($lev01data); $i++ ) { $target = ""; if($lev01data[$i]["SELECTED"]) { $lev02data = $lev01data[$i]["CHILDS"]; } } } //level 1 begin $lev02data = $menuData[0]["CHILDS"]; for($i = 0; $i < count($lev02data); $i++) { if(!$lev02data[$i]["FL_HIDDEN"] || $editMode == "edit") { //level 2 begin if($lev02data[$i]["SELECTED"]) { $lev03data = $lev02data[$i]["CHILDS"]; for($j = 0; $j < count($lev03data); $j++) { if($lev03data[$j]["FL_SEPARATOR"]) { $menuStr .= "
  • \n"; $menuStr .= "
    " . "\n"; $menuStr .= "
  • \n"; } else { if(!$lev03data[$j]["FL_HIDDEN"] || $editMode == "edit") { $itemId3 = $lev03data[$j]["ID"]; $text = $lev03data[$j]["LABEL"]; if(strlen($text) == 0) { $text = "..."; } $css=""; if($lev03data[$j]["SELECTED"]) { $lev03sel = $lev03data[$j]; //if(count($lev03data[$j]["CHILDS"]) == 0 ) { $css = "selected"; } } if($lev03data[$j]["FL_HIDDEN"]) { $text = "$text"; } if($lev03data[$j]["AUTH"]["EXECUTE"]) { $target = ""; if($lev03data[$j]["LINK_URL"] && (!BACKEND_PAGE || $editMode != "edit" )) { if($lev03data[$j]["LINK_TARGET"]) { $target = "target=\"_blank\""; } $link = $lev03data[$j]["LINK_URL"]; } else { $link = $baseUrl ."?" . getHumanPathUrlPart($lev03data[$j]); } $text = "" . $text . ""; } $tmpLocked = ""; if($lev03data[$j]["LOCKID"]) { $tmpLocked = "locked"; } if($lev03data[$j]["LOCKID"] == $userData["ID"]) { $tmpLocked .= " lockedbyme"; } $menuStr .= "
  • \n"; $menuStr .= $text . "\n"; $menuStr .= "
  • \n"; //level 3 begin if($lev03data[$j]["SELECTED"]) { $lev04data = $lev03data[$j]["CHILDS"]; for($k = 0; $k < count($lev04data); $k++) { if(!$lev04data[$i]["FL_HIDDEN"] || $editMode == "edit") { if($lev04data[$k]["FL_SEPARATOR"]) { $menuStr .= "
  • \n"; $menuStr .= "
    " . "\n"; $menuStr .= "
  • \n"; } else { $itemId4 = $lev04data[$k]["ID"]; $text = $lev04data[$k]["LABEL"]; if(strlen($text) == 0) { $text = "..."; } $css=""; if($lev04data[$k]["SELECTED"]) { $lev04sel = $lev04data[$k]; //if(count($lev04data[$i]["CHILDS"]) == 0 ) { $css = "selected"; } } if($lev04data[$k]["FL_HIDDEN"]) { $text = "$text"; } if($lev04data[$k]["AUTH"]["EXECUTE"]) { $target = ""; if($lev04data[$k]["LINK_URL"] && (!BACKEND_PAGE || $editMode != "edit" )) { if($lev04data[$k]["LINK_TARGET"]) { $target = "target=\"_blank\""; } $link = $lev04data[$k]["LINK_URL"]; } else { $link = $baseUrl ."?" . getHumanPathUrlPart($lev04data[$k]); } $text = "" . $text . ""; } $tmpLocked = ""; if($lev04data[$k]["LOCKID"]) { $tmpLocked = "locked"; } if($lev04data[$k]["LOCKID"] == $userData["ID"]) { $tmpLocked .= " lockedbyme"; } $menuStr .= "
  • \n"; $menuStr .= $text . "\n"; $menuStr .= "
  • \n"; } //level 4 end } } } } //level 3 end } } } //level 2 end } } //level 1 end return $menuStr; } // function drawContentHeader(&$userData, &$branchData, &$contentData, $editMode, $blocksCount, $pageSize, $absPage) { drawNavBar($baseUrl, $editMode, $branchData, TRUE); drawContentTitle($userData, $contentData, $editMode, $blocksCount); } function drawContentTitle(&$userData, &$contentData, $editMode, $blocksCount) { //if($contentData["ACTIVE"] || $editMode == "edit") { echo "

    "; echo "\n"; echo $contentData['LABEL'] == "" ? " " : $contentData['LABEL']; echo "\n"; echo "

    \n"; } } // function drawContentCell(&$cnn, $aux, $baseUrl, &$userData, &$contentData, &$blocksData, $editMode, $cellId, $pageSize, $absPage, $zoom = 0, $nodeTable = "") { $prevType = -1; for($i = 0; $i < count($blocksData); $i++) { if ($blocksData[$i]["CELLID"] == $cellId && array_key_exists("ID",$blocksData[$i])) { $blocksData[$i]["PREV_BLOCKTYPE"] = $prevType; drawSingleBlock($cnn, $aux, $baseUrl, $userData, $contentData, $prevType, $blocksData[$i], $editMode, $cellId, $pageSize, $absPage, $zoom, FALSE, $nodeTable); $prevType = $blocksData[$i]["BLOCKTYPE"]; } } } // function drawSingleBlock(&$cnn, $aux, $baseUrl, &$userData, &$contentData, $prevType, &$blockData, $editMode, $cellId, $pageSize, $absPage, $zoom, $alias = FALSE, $nodeTable = "", $targetBlock = "", $showCommands = TRUE) { $blockHtmlText = ""; @$key = "singleblock_u." . $userData["ID"] . "_em." . $editMode . "_cid." . $contentData["ID"] . "_bid." . $blockData["ID"] . "_c." . $cellId . "_z." . $zoom . "_ps." . $pageSize . "_ap." . $absPage . "_a." . $alias . "_sc." . $showCommands . "_tb." . $targetBlock["ID"] . "_nt." . $nodeTable . "_aux." . $aux; if(($zoom == 0)) { $blockFile = "../blocks/" . $blockData['BLOCKNAME'] . ".php"; } else { if(is_file("../blocks/" . $blockData['BLOCKNAME'] . "_zoom.php")) { $blockFile = "../blocks/" . $blockData['BLOCKNAME'] . "_zoom.php"; } else { $blockFile = "../blocks/" . $blockData['BLOCKNAME'] . ".php"; } } if (!$alias) { $condition = ($blockData["CELLID"] == $cellId); } else { $condition = 1; } if(!file_exists($blockFile) && $editMode == "edit") { echo "
    "; echo "block file $blockFile not found!"; echo "
    "; } if(file_exists($blockFile) && $condition) { if ($blockData["SHADOW"] == 1) { if ($blockData["BLOCKNAME"] != "alias") { $class = "style='padding:10px'"; } } if($blockData["SUMMARY"] == 1 && $blockData["BLOCKNAME"] != "alias") { $blockData["LTXT1"] = cutText($blockData["LTXT1"], HOMESTRLIMIT); $blockData["TXT_BLOB"] = cutText($blockData["TXT_BLOB"], HOMESTRLIMIT); $myRealPath = implode(".", getFullPathData($cnn, $userData, $blockData["PARENTID"], $editMode)); $blockData["LTXT1"] .= "... [ » ]"; $blockData["TXT_BLOB"] .= "... [ » ]"; if($blockData["BLOCKNAME"] == "sentenze") { $blockData["STXT1"] = "" . strtoupper($blockData["STXT1"]) . ""; } } foreach($blockData as $k => $v) { $$k = $v; } $blockHtmlText = ""; if($blockData["DIRECT_PRINT"]) { echo "\n"; echo "
    \n"; echo ""; include ($blockFile); echo "
    \n"; echo "\n"; } else { $blockHtmlText = "\n"; $blockHtmlText .= "
    \n"; $blockHtmlText .= ""; include ($blockFile); $blockHtmlText .= "
    \n"; $blockHtmlText .= "\n"; } } echo $blockHtmlText; } // function drawNavBar(&$baseUrl, &$editMode, &$branchData, $includeHome = FALSE, $enableLink = TRUE, $enableLastLink = FALSE) { if (count($branchData) > 1) { $text = str_replace("
    ", " ", $branchData[0]["LABEL"]); if((count($branchData) > 1) || $includeHome) { for($i = 0; $i < count($branchData) - 1; $i++) { $itemId = $branchData[$i]["ID"]; //$path .= "." . $itemId; $path = $branchData[$i]["PATH"]; $text = str_replace("
    ", " ", $branchData[$i]["LABEL"]); $style = ""; if($branchData[$i]["FL_HIDDEN"]) { if($editMode == "edit") { $text = "$text"; } else { $style = ""; $text = ""; } } if($enableLink) { $text = "$text"; } echo $text; if(!$branchData[$i]["FL_HIDDEN"] || ($editMode == "edit")) { echo "  »  " ; } } $text = str_replace("
    ", " ", $branchData[count($branchData) - 1]["LABEL"]); $style = ""; if($branchData[count($branchData) - 1]["FL_HIDDEN"]) { if($editMode == "edit") { $text = "$text"; } else { $style = ""; $text = ""; } } $text = "$text\n"; if($enableLastLink) { $path = $branchData[count($branchData) - 1]["PATH"]; $text = "$text"; } echo $text; } } } function drawSearchResult($baseUrl, $data) { if(count($data) == 0) { echo "

    Nessun dato soddisfa la ricerca

    "; } else { for($i = 0; $i < count($data); $i++) { $menu = "» "; $param = "menuId=" . $data[$i]["PATH"]; if($data[$i]["BLOCKID"] > 0) { $param .= "&b=" . $data[$i]["BLOCKID"]; } for($j=0; $j < count($data[$i]["LABELS"]); $j++) { if(!$data[$i]["FL_HIDDEN"]) { if($j > 1) { $menu .= " » "; } if(($j > 0) || (count($data[$i]["LABELS"]) == 1)) { $text = str_replace("
    ", " ", $data[$i]["LABELS"][$j]); $text = str_replace("
    ", " ", $text); $menu .= $text; } } } echo "

    \n"; echo ""; if($menu) { echo $menu; } echo "
    \n"; if($data[$i]["CONTENT_LABEL"] && $data[$i]["CONTENT_LABEL"] != $data[$i]["LABELS"][count($data[$i]["LABELS"]) - 1]) { echo "(" . $data[$i]["CONTENT_LABEL"] . ")\n"; } echo "

    \n"; } } } // function getUserBlockIcons($target, $family, $extra, &$userData, &$contentData, $itemId = 0, $winname = "block", $winBehaviour = "") { $separator = "
    \n"; if($extra == "param1=csv_nwl") { $separator = "\n"; } $icone = ""; switch ($family) { case "download": //if($contentData["AUTH"]["WRITE"]) { $icone .= "$separator"; } break; } return $icone; } // function getCmAdminBlockIcons($target, $family, $extra, &$userData, &$contentData, $itemId = 0, $winname = "block", $winBehaviour = "") { $separator = "\n"; $icone = ""; switch ($family) { case "edit": $p = "$extra&target=$target&path=" . $contentData["PATH"] . "&nodeId=" . $itemId; $pp = $p; if ($winBehaviour != "") { if ($winBehaviour == "refresh") { $pp .= "&winBehaviour=$winBehaviour"; } } $icone .= "$separator"; $pp = $p; if ($winBehaviour != "") { if ($winBehaviour == "refresh") { $pp .= "&winBehaviour=backRefresh"; } } if(($contentData["LOCKID"] == $userData["ID"]) && $contentData["AUTH"]["WRITE"]) { $icone .= ""; } break; case "addblock": $p = "$extra&target=$target&path=" . $contentData["PATH"] . "&nodeId=0"; if ($winBehaviour != "") { $p .= "&winBehaviour=$winBehaviour"; } if(($contentData["LOCKID"] == $userData["ID"]) && $contentData["AUTH"]["WRITE"]) { $icone .= "$separator"; } break; } return $icone; } // function getGestioneBlockIcons($family, $extra, &$userData, &$contentData, $itemId = 0, $winname = "block", $winBehaviour = "") { $separator = "\n"; $icone = ""; switch ($family) { case "edit": $p = "$extra&action=gestione&path=" . $contentData["PATH"] . "&nodeId=" . $itemId; $pp = $p; if ($winBehaviour != "") { if ($winBehaviour == "refresh") { $pp .= "&winBehaviour=$winBehaviour"; } } $icone .= "$separator"; $pp = $p; if ($winBehaviour != "") { if ($winBehaviour == "refresh") { $pp .= "&winBehaviour=backRefresh"; } } $icone .= ""; break; case "addblock": $p = "$extra&action=gestione&path=" . $contentData["PATH"] . "&nodeId=0"; if ($winBehaviour != "") { $p .= "&winBehaviour=$winBehaviour"; } $icone .= "$separator"; break; } return $icone; } // function getLeftMenu(&$cnn, $baseUrl, &$userData, &$menuData, &$branchData, $editMode, $includeRoot = FALSE, $recursive = TRUE) { $branchSelected = array(); foreach($branchData as $b) { $branchSelected[] = $b["ID"]; } $menuStr = "\n"; return $menuStr; } ?> 0) { $data["table"] = $tableName; } else { $data["table"] = $section["table"]; } $data["fields"] = $fields; $data["key"] = $section["key"]; //$data["owner"] = $section["owner"]; $data["order"] = $section["orderby"]; $data["filter"] = $section["filter"]; for($i=0 ; $i < count($fields) ; $i++) { $field = $fields[$i]; $data[$field] = Array(); $data[$field]["label"] = $section[$field . "_label"]; if(strlen($data[$field]["label"]) == 0) { $data[$field]["label"] = $field; } $data[$field]["type"] = strtolower($section[$field . "_type"]); if(strlen($data[$field]["type"]) == 0) { $data[$field]["type"] = "text"; } $data[$field]["ro"] = FALSE; $data[$field]["insertvalue"] = ""; $data[$field]["defaultvalue"] = ""; $data[$field]["size"] = 0; //$data[$field]["optional"] = FALSE; $data[$field]["required"] = FALSE; $data[$field]["validation"] = ""; $data[$field]["skipempty"] = FALSE; $data[$field]["minlen"] = 0; if(array_key_exists($field . "_source", $section)) { $data[$field]["source"] = trim($section[$field . "_source"]); } if(array_key_exists($field . "_ro", $section)) { $data[$field]["ro"] = ($section[$field . "_ro"] == TRUE ) ? TRUE : FALSE; } if(array_key_exists($field . "_insertvalue", $section)) { $data[$field]["insertvalue"] = $section[$field . "_insertvalue"]; //$data[$field]["ro"] = TRUE; } if(array_key_exists($field . "_defaultvalue", $section)) { $data[$field]["defaultvalue"] = $section[$field . "_defaultvalue"]; } if(array_key_exists($field . "_size", $section)) { $data[$field]["size"] = intval($section[$field . "_size"]); } if(array_key_exists($field . "_minlen", $section)) { $data[$field]["minlen"] = intval($section[$field . "_minlen"]); } //if(array_key_exists($field . "_optional", $section)) //{ // $data[$field]["optional"] = ($section[$field . "_optional"] == TRUE ) ? TRUE : FALSE; //} if(array_key_exists($field . "_required", $section)) { $data[$field]["required"] = ($section[$field . "_required"] == TRUE ) ? TRUE : FALSE; } if(array_key_exists($field . "_validation", $section)) { $data[$field]["validation"] = strtolower($section[$field . "_validation"]); } if(array_key_exists($field . "_skipempty", $section)) { $data[$field]["skipempty"] = ($section[$field . "_skipempty"] == TRUE ) ? TRUE : FALSE; } if(array_key_exists($field . "_forcecast", $section)) { $data[$field]["forcecast"] = $section[$field . "_forcecast"]; } switch($section[$field . "_type"]) { case "combo": $data[$field]["combo_source"] = $section[$field . "_combo_source"]; switch($data[$field]["combo_source"]) { case "table": $data[$field]["combo_lookup"] = $section[$field . "_combo_lookup"]; $data[$field]["combo_key"] = $section[$field . "_combo_key"]; $data[$field]["combo_value"] = $section[$field . "_combo_value"]; $data[$field]["combo_filter"] = $section[$field . "_combo_filter"]; $data[$field]["combo_order"] = $section[$field . "_combo_order"]; break; case "sql": $data[$field]["combo_sql"] = $section[$field . "_combo_sql"]; $data[$field]["combo_key"] = $section[$field . "_combo_key"]; $data[$field]["combo_value"] = $section[$field . "_combo_value"]; break; case "values": $data[$field]["combo_key_val"] = $section[$field . "combo_key_val"]; break; case "array": $data[$field]["combo_lookup"] = $section[$field . "_combo_lookup"]; $data[$field]["combo_lookup_key"] = $section[$field . "_combo_lookup_key"]; $data[$field]["combo_key"] = $section[$field . "_combo_key"]; $data[$field]["combo_value"] = $section[$field . "_combo_value"]; break; case "variable": //todo break; } $data[$field]["combo_widget"] = "list"; if (strtolower($section[$field . "_combo_widget"]) == "group" ) { $data[$field]["combo_widget"] = "group"; } $data[$field]["combo_emptyline"] = ($section[$field . "_combo_emptyline"] == TRUE ) ? TRUE : FALSE; $data[$field]["combo_multiple"] = ($section[$field . "_combo_multiple"] == TRUE ) ? TRUE : FALSE; break; case "file": $data[$field]["enable_delete"] = ($section[$field . "_disable_delete"] == TRUE ) ? FALSE : TRUE; break; case "img": $data[$field]["enable_delete"] = ($section[$field . "_disable_delete"] == TRUE ) ? FALSE : TRUE; break; case "text": case "password": $data[$field]["width"] = intval($section[$field . "_cols"]); break; case "textarea": $data[$field]["width"] = intval($section[$field . "_cols"]); $data[$field]["height"] = intval($section[$field . "_rows"]); break; case "htmlarea": $data[$field]["width"] = intval($section[$field . "_cols"]); $data[$field]["height"] = intval($section[$field . "_rows"]); $data[$field]["config"] = $section[$field . "_config"]; break; case "checkbox": break; case "radio": $data[$field]["radio_source"] = $section[$field . "_radio_source"]; switch($data[$field]["radio_source"]) { case "table": $data[$field]["radio_lookup"] = $section[$field . "_radio_lookup"]; $data[$field]["radio_key"] = $section[$field . "_radio_key"]; $data[$field]["radio_value"] = $section[$field . "_radio_value"]; $data[$field]["radio_filter"] = $section[$field . "_radio_filter"]; $data[$field]["radio_order"] = $section[$field . "_radio_order"]; break; case "sql": $data[$field]["radio_sql"] = $section[$field . "_radio_sql"]; $data[$field]["radio_key"] = $section[$field . "_radio_key"]; $data[$field]["radio_value"] = $section[$field . "_radio_value"]; break; case "values": $data[$field]["radio_value"] = explode(",", $section[$field . "_radio_value"]); break; case "variable": //todo break; } break; } } for($i=0 ; $i < count($fields) ; $i++) { if($data[$fields[$i]]["datasize"] == 0) { $data[$fields[$i]]["datasize"] = $data[$fields[$i]]["size"]; } } } $ini = $iniFile; $sec = $iniSection; $tab = $tableName; } } return $data; } function getRowsFromTableMS(&$cnn, $tableName, $fields = "", $whereCriteria = "", $orderCriteria = "", $pageSize = 0, $absPage = 0) { $sql = ""; $selectFields = "*"; if(is_array($fields) && count($fields) > 0) { $selectFields = implode(', ', $fields); } $outData = array(); if(($absPage > 0) && ($pageSize > 0)) { $numPag = $absPage-1; $inizio = $numPag * $pageSize + 1; $fine = (1 + $numPag) * $pageSize; $sql = "SET ROWCOUNT $pageSize; SELECT $selectFields FROM ( SELECT ROW_NUMBER() OVER ("; if(strlen($orderCriteria) > 0) { $sql .= "ORDER BY $orderCriteria"; } else { $sql .= "ORDER BY 1"; } $sql .= ") AS [indiceRiga], * FROM $tableName"; if(strlen($whereCriteria) > 0) { $sql .= " WHERE $whereCriteria"; } $sql .= ") AS T WHERE T.indiceRiga BETWEEN $inizio AND $fine"; } else { $base = "SELECT $selectFields FROM $tableName"; if(strlen($whereCriteria) > 0) { $base .= " WHERE $whereCriteria"; } $order = ""; if(strlen($orderCriteria) > 0) { $order .= " ORDER BY $orderCriteria"; } $sql = $base . $order; } if(LOG_SQL) { logWrite($sql, "sql"); } //debug( $sql); $rs = @mssql_query($sql, $cnn) or doError("sql", mssql_get_last_message()); //$count = mssql_num_rows ($rs); while ($row = mssql_fetch_assoc($rs)) { $outData[] = $row; } mssql_free_result($rs); return $outData; } function countRowsFromTableMS(&$cnn, $tableName, $whereCriteria = "") { $blocksCount = 0; $sql = "SELECT count(*) as C FROM $tableName"; if(strlen($whereCriteria) > 0) { $sql .= " WHERE $whereCriteria"; } //$sql = "SET ANSI_WARNINGS OFF;SET ANSI_NULLS ON;" . $sql; if(LOG_SQL) { logWrite($sql, "sql"); } $rs = mssql_query($sql, $cnn) or doError("sql", mssql_get_last_message()); while ($row = mssql_fetch_assoc($rs)) { $blocksCount = $row["C"]; } mssql_free_result($rs); return $blocksCount; } function getMsDateTime(&$cnn) { $dt = ""; $sql = "select convert(varchar, getdate(), 121 ) as dt"; $rs = mssql_query($sql, $cnn) or doError("sql", mssql_get_last_message()); while($row = mssql_fetch_assoc($rs)) { $dt = $row["dt"]; } mssql_free_result($rs); return $dt; } ?> RAVIGGIOLO di Cernusco sul Naviglio
    Il Raviggiolo di Cernusco

    Sabato 16 gennaio 2016

    Il Raviggiolo si presenta alla città

    La Filanda - Via Pietro da Cernusco, 2

    Sabato 16 gennaio 2016

    "Il Raviggiolo si presenta alla città"

    Presso LA FILANDA
    Via Pietro da Cernusco, 2

     

     

    NOTA IMPORTANTE:
    Le iscrizioni alla DEGUSTAZIONE e a RAVIGGIOLO FOR KIDS saranno accettate con riserva anche dopo il raggiungimento del numero massimo di partecipanti. In caso di rinuncia da parte di un iscritto, verranno invitati a partecipare gli iscritti successivi, secondo l'ordine di iscrizione.

     

    Programma

    16.30 - 17.45: Cernusco sul Naviglio: di che pasta siamo fatti?

    Identità, etica e visioni di futuro attorno al cibo

    Dialogo e idee attorno alla Cultura Enogastronomica italiana: le radici storiche, l'educazione alimentare, l'etica in cucina, le grandi opportunità offerte dalla Cultura del Cibo alle economie dei territori.

    Ne parlano Giancarlo Morelli (Chef Patron del Pomiroeu di Seregno), Toni Sàrcina (Fondatore e titolare di Altopalato - Centro di Cultura Enogastronomica), Paolo Albano (Architetto e designer), Eugenio Comincini (Sindaco di Cernusco sul Naviglio e vice Sindaco della Città metropolitana di Milano), Ermanno Zacchetti (Ass.re al Commercio e alle Attività Produttive di Cernusco sul Naviglio) (vedi i relatori)

    16.30 - 17.45: Raviggiolo for Kids

    Laboratorio-gioco per bambini e bambine da 6 ad 11 anni che, sotto la guida di educatori e dello staff di Giancarlo Morelli, produrranno il loro Raviggiolo (clicca qui per l'iscrizione)

    18.00 - 19.15: Degustazione del Raviggiolo di Cernusco sul Naviglio

    Lo Chef Giancarlo Morelli proporrà in degustazione un assaggio del Raviggiolo di Cernusco sul Naviglio (clicca qui per prenotarti)

     

    » Tutti gli eventi sono ad INGRESSO LIBERO SINO AD ESAURIMENTO POSTI

    » La DEGUSTAZIONE e il LABORATORIO DIDATTICO hanno disponibilit√† limitata.

    Torna a www.ilraviggiolodicernusco.com