'.$query.'
'; echo 'MSG: Nu ma pot conecta la baza de date!
'; echo 'ERR: '.$err.'
'; echo '
'; } else { if (!is_callable("uiError")) { include "ui/ui.php"; } uiError("Eroare SQL", "Nu ma pot conecta la baza de date!", '', 1, $afisare_mai_tarziu = 1); } } else { if (DB == 'MYSQL') mysql_query("USE $dbName"); if (DB == 'MSSQL') mssql_query("USE $dbName"); } return $connection; } function dbQuery($query, $noErr = 0, $mysql = null) { global $connection, $dbHost, $dbUser, $dbPass; if (!$connection) $connection = dbConnect($dbHost, $dbUser, $dbPass); if (!is_resource($mysql)) $mysql = $connection; if (DB == 'MYSQL') { $res = @mysql_query($query, $mysql); if ((mysql_errno() != 0) and $noErr == 0) { $f = fopen("err_log.txt", "a"); fwrite($f, str_repeat("-", 80).chr(13).chr(10).$_SERVER['REQUEST_URI']." (".$_SESSION['userNAME'].") ".chr(13).chr(10).$query.chr(13).chr(10).mysql_error()."\n\n"); fclose($f); if ($_SESSION['isDeveloper'] == 1) { echo '
'.$query.'
'; echo 'Eroare (apare doar pentru developer): '.mysql_errno().'
'; echo 'Mesaj: '.mysql_error().'
'; echo '
'; } else { if (!is_callable("uiError")) { include "ui/ui.php"; } if ($GLOBALS['err_sql'] == 0) uiError("Eroare SQL", "Au aparut erori SQL. Datele afisate pot sa nu fie cele corecte.

Va rugam sa verificatii valorile introduse sau sa incercati in cateva minute.", '', 1, $afisare_mai_tarziu = 1); $GLOBALS['err_sql']++; } } } if (DB == 'MSSQL') { $res = @mssql_query($query, $mysql); if ((!$res) and $noErr == 0) { $f = fopen("err_log.txt", "a"); fwrite($f, $_SERVER['REQUEST_URI'].chr(13).chr(10)."-------------------------------------------------------------\n$query\n".mssql_get_last_message()."\n\n"); fclose($f); echo '
QUERY: '.$query.'
'; echo 'ERR: -
'; echo 'MSG: '.mssql_get_last_message().'
'; echo '
'; } } return $res; } function dbFetch($query) { if (!is_resource($query)) $query = dbQuery($query); if (DB == 'MYSQL') $row = @mysql_fetch_array($query); if (DB == 'MSSQL') $row = @mssql_fetch_array($query); return $row; } function dbFetch0($query) { list($ret) = dbFetch($query); return $ret; } function dbUpdate($table, $id, $r, $_id = '') { if (!is_array($id)) { if (strlen($_id) == 0) $_id = $id; $id = array($id); } $cond = ''; foreach ($id as $k=>$v) { if (strlen($cond) > 0) $cond .= ' AND '; $cond .= $v . " = '".$r[$v]."'"; if ((strlen($_id) == 0) and (stristr($k, 'id'))) $_id = $k; } $tmp = dbFetch("SELECT $_id FROM $table WHERE $cond"); if ($tmp[$_id] == 0) { foreach ($r as $k => $v) { if (strlen($fields) > 0) { $fields .= ', '; $values .= ', '; } $fields .= '`' . $k . '`'; $values .= "'".$v."'"; } dbQuery("INSERT INTO $table ($fields) VALUES($values)"); return LastIdentity(); //list($r[$_id]) = dbFetch("SELECT $_id FROM $table WHERE $cond"); } else { $str = ''; foreach ($r as $k => $v) { if ($k == $_id) continue; if (strlen($str) > 0) $str .= ', '; $str .= '`' . $k . "` = '".$v."'"; } dbQuery("UPDATE $table SET $str WHERE $cond"); return $tmp[$_id]; } return $r[$_id]; } function dbNumRows($res) { if (DB == 'MYSQL') $rows=mysql_num_rows($res); if (DB == 'MSSQL') $rows=mssql_num_rows($res); return $rows; } function LastIdentity() { if (DB == 'MYSQL') { $lastIdentity = mysql_insert_id(); if ($lastIdentity ) $lastIdentity = dbFetch0("SELECT LAST_INSERT_ID()"); } if (DB == 'MSSQL') $lastIdentity = dbFetch0("SELECT @@IDENTITY"); return $lastIdentity; } ?>'; print_r($arr); echo ''; } function tostrn($str, $len, $fill = '0', $align = 1) { if ($len - strlen($str) > 0) $str = str_repeat($fill, $len - strlen($str)) . $str; $str = substr($str, (-1) * $len); return $str; } function queryToJSArray($var, $query) { $str = ''; echo $str; } function queryWEB($query, $param = array()) { global $open_url_method; if (strlen($GLOBALS['siteACE']) == 0) { include "config.php"; if (strlen($GLOBALS['siteACE']) == 0) { echo 'Eroare de configurare. Nu am serverul de legatura'; exit; } } $host = $GLOBALS['siteACE'] . 'query_web.php'; $query = urlencode($query); $link = $host . '?query='.$query; $arrp = array(); if (is_array($param)) { foreach ($param as $k=>$v) $link .= '&'.$k.'='.urlencode($v); } if (strlen($GLOBALS['gApplication']) > 0) $link .= '&gApplication=' . $GLOBALS['gApplication']; if (isset($GLOBALS['hash_key']) and strlen($GLOBALS['hash_key']) > 0) { $hash = genereazaHash($link); $link .= "&hash=" . $hash; } //echo $link."
"; if ($open_url_method == 1) $tmp = file_get_contents($link); else if($open_url_method==2) $tmp = curl_get_contents($link); if ($_SERVER['REMOTE_ADDR'] == '92.86.26.98' or substr($_SERVER['REMOTE_ADDR'], 0, 9) == '10.11.32.') { //echo "LINK: $link
"; //echo "RESULT: $tmp
"; } if ($tmp === false or strlen($tmp) == 0) { global $inMain; if ($inMain) { uiError("Eroare", "Nu se poate realiza conexiunea cu serverul de clienti. Cererea dumneavoastra nu poate fi procesata in acest moment.

Va rugam incercati mai tarziu."); } else { $GLOBALS['erori'][] = array('titlu' => 'Eroare', 'mesaj' => 'Nu se poate realiza conexiunea cu serverul de clienti. Cererea dumneavoastra nu poate f procesata in acest moment.

Datele despre client nu pot fi afisate in acest moment.', 'actiuni' => ''); } return; } if ($query == 'daFacturaPDF' || $query=="FILE") { return $tmp; exit; } $tmp2 = unserialize($tmp); if ((strlen($tmp) > 20) and (count($tmp2) == 0)) return $tmp; return $tmp2; } function curl_get_contents($url) { $ch = curl_init(); $timeout = 20; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } function sendMail($to, $subject, $message, $tip) { if ($tip == 'HTML')/* To send HTML mail, you can set the Content-type header. */ { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; /* additional headers */ $compania = dbFetch0("SELECT valoare FROM setari WHERE variabila = 'companie'"); $email = dbFetch0("SELECT valoare FROM setari WHERE variabila = 'email_admin'"); $headers .= "From: \"$compania\" <$email>\r\n"; } //varianta veche //@mail($to, $subject, $message, $headers); //varianta noua $smail = new MailAuth($to, $subject, $message); //$smail->username = $email; //$smail->smtpServer = "10.11.32.12"; $smail->sendMail(); } function Send_Mail($nume, $email, $userFR,$from) { $mail = new PHPMailer(); $body = $mail->getFile('email_format.html'); $body = eregi_replace("[\]",'',$body); $body =str_replace(' _data_','',$body); $body =str_replace('_restanta_','',$body); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $mail->From = $from; $mail->Subject ="Instiintare restanta plata facturi"; $mail->MsgHTML($body); $mail->AddAddress($email, $nume); if(!$mail->Send()) echo "Mailer Error: " . $mail->ErrorInfo; else echo "Message sent!"; } function DaValoareData($strTime) { if(eregi("0000-00-00", $strTime)) $strTime=""; if(strlen($strTime)<=0) { return ""; } else { $time = strtotime($strTime); return @date("d.m.Y", $time); } } function DaValoareTimp($strTime) { if(eregi("0000-00-00", $strTime)) $strTime=""; $time = strtotime($strTime); return @date("d.m.Y H:i", $time); } function MesajOperatieOk($descriere,$operatie, $tabela, $computerIP="", $id_utilizator="") { global $operatiiLog; /* ADD, MOD, DEL ADAUGARE, MODIFICARE, STERGERE 1,2,3 */ $id_user = $_SESSION['userID']; if(!$id_user) $id_user = $id_utilizator; if(!$id_user) $id_user = 0; //$computer = $_SESSION["gComputerName"]; if(!$computerIP) $ip = $_SESSION["computerIP"]; else $ip=$computerIP; $data_azi = date("Y-m-d G:i:s"); if(intval($operatie) > 0) { $id_operatie = $operatie; } else { $operatie = trim(strtoupper($operatie)); if($operatie == "ADD") $operatie_search = "ADAUGARE"; else if($operatie == "MOD") $operatie_search = "MODIFICARE"; else if($operatie=="DEL") $operatie_search = "STERGERE"; else $operatie_search = $operatie; } $id_operatie=$operatiiLog[$operatie_search]; $descriere = trim($descriere); $tabela = trim($tabela); dbQuery("INSERT INTO log (id_utilizator, tip_operatie, descriere, obiect, ip, data) VALUES ($id_user, $id_operatie, '$descriere', '$tabela', '$ip', '$data_azi')"); } function isAdmin() { $r = dbFetch("SELECT * FROM utilizatori WHERE id = ".($_SESSION['userID'] * 1)); return $r['developer']; } ?>name = $name; $this->setItems($items); $this->selected = $selected; } function setItems($items) { if (is_array($items)) $this->items = $items; else if (is_string($items)) $items = dbQuery($items); else if (is_resource($items)) { $this->items = array(); while ($r = dbFetch($items)) $this->items[$r[0]] = $r[1]; } } function setExtraHTML($extra) { $this->extraHTML = $extra; } function generateHTML() { if ($this->readOnly) return $this->items[$this->selected]; $html = ''; return $html; } function show() { echo $this->generateHTML(); } } ?>name = $name; $this->width = '95%'; //page if ($_GET[$this->name . '_page'] > 0) $_SESSION[$this->name]['page'] = $_GET[$this->name . '_page']; $this->page = $_SESSION[$this->name]['page']; if ($this->page == 0) $this->page = 1; //filters if (strlen($_POST['filtreaza_'.$this->name]) > 0) { $pos = strlen($this->name); foreach ($_POST as $k=>$v) { if (substr($k, 0, $pos) == $this->name) $_SESSION[$this->name]['filter'][substr($k, $pos + 1)] = $v; if (substr($k, 0, $pos+3) == 'op_'.$this->name) $_SESSION[$this->name]['filter']['op_'.substr($k, $pos + 4)] = $v; } } //order if ( (isset($_GET['order_id'])) || (isset($_POST['order_id'])) ) $_SESSION[$this->name]['order_id'] = $_GET['order_id'] . $_POST['order_id']; if (isset($_SESSION[$this->name]['order_id'])) $this->order_id = $_SESSION[$this->name]['order_id'] * 1; if ( (isset($_GET['order'])) || (isset($_POST['order'])) ) $_SESSION[$this->name]['order'] = $_GET['order'] . $_POST['order']; if (isset($_SESSION[$this->name]['order'])) $this->order = $_SESSION[$this->name]['order']; } function setDefaultOrder($column, $order) { if (isset($this->order_id)) return; foreach ($this->columns as $k => $v) { if ($v == $column) { $this->order_id = $k; break; } } if ($order == 1 or strtolower($order) == 'desc') $this->order = 1; else $this->order = 0; } function addFilter($type, $text, $condition = '', $param = '') { $this->filters[] = array( 'type' => $type, 'text' => $text, 'condition' => $condition, 'param' => $param, ); } function addButton($type, $link) { //verific daca trebuie sa adaug hash if (strpos($link, '&hash') === false and strlen($GLOBALS['hash_key'])) { $link .= '&hash='. genereazaHash($link); } $this->buttons[] = array('type' => $type, 'link' => $link); } function setQuery($query) { $this->query = $query; } function setActions($actions, $titles = array()) { $this->actions = $actions; $this->actionsTitles = $titles; } function setHeader($header) { $this->header = $header; } function setColumns($columns) { $this->columns = $columns; } function setAlign($align) { $this->align = $align; } function getLink() { $str = ''; $tableOnly = array('order' => 1, 'order_id' => 1); foreach ($_GET as $k=>$v) { if (strlen($str) > 0) $str .= '&'; else $str = '?'; if ($tableOnly[$k] != 1) $str .= $k .'='.$v; } if (strlen($str) > 0) $str .= '&'; else $str .= '?'; return $str; } function getActionsCell($row) { $str = ''; foreach ($this->actions as $k => $v) { $param = ''; if (is_array($v)) { foreach($v as $kk => $vv) { if (strlen($param) > 0) $param .= ', '; $param .= "'".$row[$vv]."'"; } } else $param = "'".$row[$v]."'"; $img = ''; if (file_exists('images/'.$k.'.gif')) $img = $k.'.gif'; if (($k == 'view') || ($k == 'edit') || ($k == 'delete') || ($k == 'execute') || ($k == 'print') || ($k == 'input_reading') || ($k == 'blocare') || ($k == 'contracte')) $img = $k; $show = 1; if (is_array($this->disableAction[$k])) { foreach ($this->disableAction[$k] as $kk=>$vv) { if ($row[$vv[0]] == $vv[1]) { $show = 0; break; } } } if ($show) { $title = ''; if ($k == 'view') $title = 'vizualizare'; if ($k == 'edit') $title = 'modificare'; if ($k == 'delete') $title = 'stergere'; if ($k == 'print') $title = 'printare'; if (strlen($this->actionsTitles[$k]) > 0) $title = $this->actionsTitles[$k]; if (strlen($img) > 0) $str .= ' '; else $str .= ''.$k.' '; } } return ''.$str.''; } function generateHTML() { //filters $link = $this->getLink(); $gotActions = 0; if (count($this->actions) > 0) $gotActions = 1; $html .= ''; //header $html .= ''; foreach ($this->columns as $k=>$v) { if ($this->order_id != $k) $order = 1; if ($this->order_id == $k) $order = ($this->order + 1) % 2; if ($this->order_id == $k) { global $default_template; if ($order == 0) $img = ''; else $img = ''; } else $img = ''; $html .= ''; } if (count($this->actions) > 0) $html .= ''; $html .= ''; $html .= '
'; //content $res = dbQuery($this->getQuery()); if ($_SESSION['isDeveloper'] and $_SESSION['show_all_params']) { arp($this->getQuery()); echo '
'; } while ($r = dbFetch($res)) { $c = ($c + 1) % 2; $html .= ''; foreach ($this->columns as $k=>$v) { if (strlen($r[$v]) == 0) $r[$v] = ' '; $extra = ''; if (strlen($this->align[$k]) > 0) $extra .= ' align="'.$this->align[$k].'"'; if (strlen($this->align[$v]) > 0) $extra .= ' align="'.$this->align[$v].'"'; if (is_array($this->special[$v])) $html .= ''; else if (strlen($this->special[$v]) > 0) $html .= ''; else $html .= ''; } if ($gotActions) $html .= $this->getActionsCell($r); $html .= ''; } //buttons and paging $html .= ''; $html .= '
'.$this->header[$k].' '.$img.' 
'.$this->special[$v][$r[$v]].''.$this->special[$v]($r).''.$r[$v].'
'; if (count($this->buttons) > 0) $html .= '
'.$this->generateHTMLButtons().''; $html .= $this->getPages(); if (count($this->buttons) > 0) $html .= '
'; $html .= '
'; //filters if (count($this->filters) > 0) { $htmlFiltre .= ''; foreach($this->filters as $k=>$v) { $name = $this->name . '_' . $k; $htmlFiltre .= ''; $value = stripslashes($_SESSION[$this->name]['filter'][$k]); $value_op = $_SESSION[$this->name]['filter']['op_'.$k]; if ($v['type'] == F_TEXT) $obj = new uiText($name, $value); if ($v['type'] == F_DATE) $obj = new uiDate($name, $value); if ($v['type'] == F_NUMERIC) $obj = new uiNumeric($name, $value); if ($v['type'] == F_DECIMAL) $obj = new uiDecimal($name, $value, $param); if ($v['type'] == F_SELECT) { if (is_array($v['param'])) { $new_arr = array('' => ''); foreach ($v['param'] as $kk => $vv) $new_arr[$kk] = $vv; } else { $new_arr = array('' => ''); $res = dbQuery($v['param']); while ($r = dbFetch($res)) $new_arr[$r[0]] = $r[1]; } $obj = new uiCombo($name, $new_arr, $value); } if ($v['type'] == F_AUTOCOMBO) { $obj = new uiAutoCombo($name, $v['param'], $value); } $extra_op = ''; if (($v['type'] == F_DATE) or ($v['type'] == F_NUMERIC) or ($v['type'] == F_DECIMAL)) { $operatii = array(0=>'=', -1 => '<', 1=>'>', 2=>'<>'); $tmp = new uiCombo('op_'.$name, $operatii, $value_op); $extra_op = $tmp->generateHTML() . '   '; } $htmlFiltre .= ''; $htmlFiltre .= ''; } $htmlFiltre .= ''; $htmlFiltre .= ''; $htmlFiltre .= '
'.$v['text'].':'.$extra_op.$obj->generateHTML().'
'; $html = '
'.uiMessage('Filtre', $htmlFiltre, '', '', '60%', 0, 0) . '
' . $html; } //end filters //($title, $text, $ok = '', $cancel = '', $width = '90%', $critical = 0, $display = 1) return $html; } function getPages() { $html = ''; $link = $this->getLink(); $p = $this->page; if ($p + 5 > ceil($this->count / $this->per_page)) $p = ceil($this->count / $this->per_page) - 5; if ($p - 5 < 1) $p = 1 + 5; $min = $p - 5; $max = $p + 5; if ($min < 1) $min = 1; if ($max > ceil($this->count / $this->per_page)) $max = ceil($this->count / $this->per_page); //for ($q = 1; $q <= ceil($this->count / $this->per_page); $q++) if ($this->page > 1) $html .= 'inapoi '; for ($q = $min; $q <= $max; $q++) { if ($this->page != $q) $html .= ''; $html .= $q; if ($this->page != $q) $html .= ''; $html .= ' '; } if ($this->page < ceil($this->count / $this->per_page)) $html .= 'inainte '; return $html; } function getQuery() { $query = $this->query; $pos_from = strpos($query, 'FROM'); $pos_where = strpos($query, 'WHERE'); $pos_group = strpos($query, 'GROUP'); $pos_having = strpos($query, 'HAVING'); $pos_order = strpos($query, 'ORDER'); $pos_limit = strpos($query, 'LIMIT'); $pos_after_where = $pos_group; if ($pos_after_where == 0) $pos_after_where = $pos_having; if ($pos_after_where == 0) $pos_after_where = $pos_order; if ($pos_after_where == 0) $pos_after_where = $pos_limit; if ($pos_after_where == 0) $pos_after_where = strlen($query); $condition = ''; foreach($this->filters as $k=>$v) { $value = $_SESSION[$this->name]['filter'][$k]; $value_op = $_SESSION[$this->name]['filter']['op_'.$k]; if (strlen($value) > 0) { if (strlen($condition) > 0) $condition .= ' AND '; if ($value_op == -1) $operatie = '<'; if ($value_op == 0) $operatie = '='; if ($value_op == 1) $operatie = '>'; if ($value_op == 2) $operatie = '<>'; if(DB == 'MYSQL' && $v['type']==6) //data { list($_zi, $_luna, $_an) = explode(".", $value); $value = $_an."-".$_luna."-".$_zi; } $v['condition'] = str_replace('=', $operatie, $v['condition']); $condition .= str_replace('#', $value, $v['condition']); } } if (strlen($condition) > 0) { if ($pos_where == 0) $condition = ' WHERE ' . $condition; else $condition = ' AND ' . $condition; $query = substr($query, 0, $pos_after_where) . $condition . ' ' . substr($query, $pos_after_where); } $query_count = "SELECT COUNT(*) " . substr($query, $pos_from); $res = dbQuery($query_count); $this->count = dbFetch0($res); if (dbNumRows($res) > 1) $this->count = dbNumRows($res); if ($_SESSION['isDeveloper'] and $_SESSION['show_all_params']) { arp($query_count); echo '
'; } //$query .= " ORDER BY ".($this->order_id + 1); if (strlen($this->columns[$this->order_id])) { $query .= " ORDER BY ".$this->columns[$this->order_id]; if ($this->order == 1) $query .= ' DESC'; } if (DB == 'MYSQL') $query .= " LIMIT ".(($this->page - 1) * $this->per_page).", " . $this->per_page; else echo 'ar trebui modificat la limit'; return $query; } function show() { //echo $this->getQuery().'
'; echo $this->generateHTML(); } function generateHTMLButtons() { foreach ($this->buttons as $k => $v) { $txt = $v['type']; if ($v['type'] == 'add') $txt = 'ADAUGA'; if ($v['type'] == 'ok') $txt = 'CONTINUA'; if ($v['type'] == 'cancel') $txt = 'RENUNTA'; if ($v['type'] == 'modify') $txt = 'MODIFICA'; if (substr($v['link'], 0, 11) == 'javascript:') $onClick = str_replace('javascript:', '', $v['link']); else $onClick = "document.location='$v[link]';"; $id = 'btn' . $this->name . '_' . ++$GLOBALS['btn'][$this->name]; $str .= '  '; } return $str; } function setColumnsSpecial($special) { if (is_array($this->special)) $this->special = array_merge($this->special, $special); else $this->special = $special; } function addDisableAction($action, $field, $value) { $this->disableAction[$action][] = array($field, $value); } } ?>'; echo ''; class uiAutoCombo { var $query; var $name; var $selected; var $type = 'uiAutoCombo'; function uiAutoCombo($name, $query, $selected) { $this->name = $name; $this->query = $query; $this->selected = $selected; $this->queryID = $this->getQueryID($this->query); } function getQueryID($query) { if (!file_exists('interogari')) @mkdir('interogari'); $tmp = file_get_contents('interogari/id_interogari.txt'); if (strlen($tmp) > 0) $tmp = unserialize($tmp); else $tmp = array(); if ($tmp[$query] > 0) { fclose($fp); return $tmp[$query]; } //lock temporar $fp = fopen("interogari/lock_interogari.txt", "w"); flock($fp, LOCK_EX); //recitesc fisierul sa fiu sigur ca nu s-a modificat $tmp = file_get_contents('interogari/id_interogari.txt'); $tmp[$query] = count($tmp) + 1; //scriu interogarile $f = fopen("interogari/id_interogari.txt", "w"); fwrite($f, serialize($tmp)); fclose($f); //scriu interogarile $interogari = unserialize(file_get_contents('interogari/interogari.txt')); $interogari[$tmp[$query]] = $query; $f = fopen("interogari/interogari.txt", "w"); fwrite($f, serialize($interogari)); fclose($f); fclose($fp); return $tmp[$query]; } function getQueryText() { $query = $this->query; //ID $pos = strpos($query, ','); $id = substr($query, 7, $pos - 7); //AS $pos = strpos(strtoupper($id), ' AS '); $id = substr($id, 0, $pos); $id = str_replace('DISTINCT', '', $id); //WHERE $pos = strpos($query, 'WHERE'); $query = substr($query, 0, $pos) . 'WHERE '.$id." = '".$this->selected."'"; $r = dbFetch($query); return $r[1]; } function setExtraHTML($extra) { $this->extraHTML = $extra; } function generateHTML() { $display = "none"; if ($_SESSION['isDeveloper']) $display = ''; $display = "none"; $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; if ($this->readOnly) { $html = $this->getQueryText(); } return $html; } function show() { echo $this->generateHTML(); } } ?>name = $name; $this->value = $value; } function generateHTML() { $html = ''; //if ($this->readOnly) $html = $this->value; return $html; } function show() { echo $this->generateHTML(); } } class uiText { var $name; var $value; var $length; var $type = 'uiText'; var $align = 'left'; function uiText($name, $value) { $this->name = $name; $this->value = $value; } function setNumeric($decimals = 0, $length = 0) { $this->numeric = 1; $this->decimals = $decimals; $this->length = $length; if ($this->decimals > 0) $this->length++; } function setLength($length) { $this->length = $length; } function setExtraHTML($extra) { $this->extraHTML .= $extra; } function addonKeyUp($function) { if (strlen($this->keyUp) > 0) $this->keyUp .= ';'; $this->keyUp .= $function; } function setPassword($char) { $this->password = $char; } function generateHTML() { if ($this->maxLength > 0) $extra .= ' maxlength="'.$this->maxLength.'"'; if ($this->size > 0) $extra .= ' size="'.$this->size.'"'; $this->extraHTML .= ' onKeyUp = "'.$this->keyUp.'"'; $extra .= $this->extraHTML; if (strlen($this->password) == 0) $tip = 'text'; else $tip = 'password'; $html = ''; if ($this->readOnly) $html = $this->value; return $html; } function setHelpID($id) { global $helpTEXT; $this->helpID = $id; if (strlen($helpTEXT[$id]) > 0) $this->helpTEXT = $helpTEXT[$id]; } function show() { echo $this->generateHTML(); } } class uiDecimal extends uiText { function uiDecimal($name, $value, $digits, $allow_negative = 1) { $this->uiText($name, $value); $digits *= 1; if ($digits < 0) $digits = 0; $this->setNumeric($digits); $this->type = 'uiDecimal'; $this->align = 'right'; $this->addonKeyUp("verificaNumeric(this, $digits, $allow_negative)"); //$this->extraHTML = 'onKeyUp="verificaNumeric(this, '.$digits.', '.$allow_negative.');" '; //$this->extraHTML .= 'onKeyPress="verificaNumeric(this, '.$digits.', '.$allow_negative.');" '; } } class uiNumeric extends uiDecimal { function uiNumeric($name, $value, $allow_negative = 1) { $this->uiText($name, $value); $this->setNumeric(0); $this->type = 'uiNumeric'; $this->align = 'right'; $this->addonKeyUp("verificaNumeric(this, 0, $allow_negative)"); //$this->extraHTML = 'onKeyUp="verificaNumeric(this, 0, '.$allow_negative.');"'; //$this->extraHTML .= 'onKeyPress="verificaNumeric(this, 0, '.$allow_negative.');"'; } } if ($GLOBALS['inserat_functii_js_uitext'] == 0) { $GLOBALS['inserat_functii_js_uitext'] = 1; echo ''; } ?>name = $name; $this->value = $value; } function setNumeric($decimals = 0, $length = 0) { $this->numeric = 1; $this->decimals = $decimals; $this->length = $length; if ($this->decimals > 0) $this->length++; } function setLength($length) { $this->length = $length; } function setExtraHTML($extra) { $this->extraHTML = $extra; } function generateHTML() { if ($this->maxLength > 0) $extra .= ' maxlength="'.$this->maxLength.'"'; if ($this->size > 0) $extra .= ' size="'.$this->size.'"'; $extra .= $this->extraHTML; if ($this->value == 1) $extra .= ' checked '; $html = ''; if ($this->readOnly) { if ($this->value) $html = 'Da'; else $html = 'Nu'; } return $html; } function show() { echo $this->generateHTML(); } } ?>name = $name; $this->title = $title; $this->action = $action; $this->method = $method; $this->target = $target; $this->fields = array(); $this->state = 0; $this->width = '100%'; $this->readOnly = false; } function addField($name, $caption, $type = F_TEXT, $value = '', $param = '', $extra = '', $helpID = '') { $value = stripslashes($value); $field = array( 'name' => $name, 'caption' => $caption, 'type' => $type, 'value' => $value, 'param' => $param, 'extra' => $extra, 'helpID' => $helpID, ); $this->fields[] = $field; } function addSeparator($text = '') { $this->fields[] = array('type' => 'separator', 'caption' => $text); } function addHTML($text = '', $param = '') { $this->fields[] = array('type' => F_HTML, 'caption' => $text, 'param' => $param); } function generateHTML() { $html = '
'; $html .= ''; foreach ($this->fields as $k => $v) { $str = ''; unset($obj); if ($v['type'] == F_CAPTCHA) { if (!is_callable('addCaptcha')) require_once 'lib/captcha.php'; $v['type'] = F_HTML; $v['value'] = addCaptcha(); } if ($v['type'] == F_HIDDEN) { $html .= uiHidden($v['name'], $v['value']); continue; } if ($v['type'] === 'separator') { if (strlen($v['caption']) > 0) $v['caption'] = '    '.$v['caption']; $html .= ''; continue; } if ($v['type'] == F_TEXT) $obj = new uiText($v['name'], $v['value']); if ($v['type'] == F_DATE) $obj = new uiDate($v['name'], $v['value']); if ($v['type'] == F_PASSWORD) { $obj = new uiText($v['name'], $v['value']); $obj->setPassword('*'); } if ($v['type'] == F_CHECKBOX) $obj = new uiCheckbox($v['name'], $v['value']); if ($v['type'] == F_NUMERIC) $obj = new uiNumeric($v['name'], $v['value']); if ($v['type'] == F_DECIMAL) $obj = new uiDecimal($v['name'], $v['value'], $v['param']); if ($v['type'] == F_SELECT) $obj = new uiCombo($v['name'], $v['param'], $v['value']); if ($v['type'] == F_AUTOCOMBO) $obj = new uiAutoCombo($v['name'], $v['param'], $v['value']); if (isset($obj)) $obj->readOnly = $this->readOnly; $c = ($c + 1) % 2; if ($v['type'] == F_HTML) { $html .= ''; continue; } $obj->setExtraHTML($v['extra']); if (strlen($v['helpID']) > 0 and is_callable(array($obj, 'setHelpID'))) $obj->setHelpID($v['helpID']); $html .= ''; } $html .= '
'.$v['caption'].'
'.$v['caption'].''.$v['value'].' 
'.$v['caption'].':'.$obj->generateHTML().'
'; $html .= '
'; return $html; } function addAction($name, $action) { $this->actions[$name] = $action; } function show() { uiMessage($this->title, $this->generateHTML(), $this->actions, '', $this->width); } } ?>'; $included_uiJSTable = 1; class uiJSTable { var $name; function uiJSTable($name) { $this->name = $name; $this->width = '100%'; $this->align = ' align="center"'; } function setHidden($arr) { $this->hidden = $arr; } function setColumns($arr) { $this->columns = $arr; } function setHeader($arr) { $this->header = $arr; } function setQuery($query) { $this->query = $query; $this->values = array(); $res = dbQuery($query); while ($r = dbFetch($res)) $this->values[] = $r; } function setArray($array) { $this->values = $array; } function generateHTML() { /* $str = ''; //header $str .= ''; foreach ($this->header as $k=>$v) { $str .= ''; } $str .= ''; //values foreach ($this->values as $k => $v) { $str .= ''; foreach ($this->columns as $kk => $vv) $str .= ''; $str .= ''; } $str .= '
'.$v.'
'.$k.':'.$v[$vv].'
'; $str .= ''; */ //TEMPORAR $str = ''; $str_header = ''; foreach ($this->header as $k=>$v) { if (strlen($str_header) > 0) $str_header .= ', '; $str_header .= '"'.$v.'"'; } $str .= ''; $str .= '
'; //values $str .= ''; return $str; } function show() { echo $this->generateHTML(); } } ?>name = $name; $this->value = $value; if (strlen($value) == 0) { $this->zi = $_GET[$name.'_zi'].$_POST[$name.'_zi']; $this->luna = $_GET[$name.'_luna'].$_POST[$name.'_luna']; $this->an = $_GET[$name.'_an'].$_POST[$name.'_an']; $value = $this->zi . '.' . $this->luna . '.' . $this->an; } $tmp = explode(' ', $value); $data = $tmp[0]; $ora = $tmp[1]; $tmp = explode('.', $data); $tmp2 = array(); if (count($tmp) == 0) $tmp2 = explode('-', $data); $this->zi = $tmp[0].$tmp2[2]; $this->luna = $tmp[1].$tmp2[1]; $this->an = $tmp[2].$tmp2[0]; $ok = 1; if (($this->zi < 1) or ($this->zi > 31)) $ok = 0; if (($this->luna < 1) or ($this->luna > 12)) $ok = 0; if (($this->an < 1970) or ($this->an > 2035)) $ok = 0; if ($ok) $this->data = $this->zi . '.' . $this->luna . '.' . $this->an; else $this->data = ''; } function setExtraHTML($extra) { $this->extraHTML .= $extra; } function generateHTML() { if ($this->maxLength > 0) $extra .= ' maxlength="'.$this->maxLength.'"'; if ($this->size > 0) $extra .= ' size="'.$this->size.'"'; $this->keyUp = 'verificaNumeric(this, 0, 0); compuneData(\''.$this->name.'\')'; $this->extraHTML .= ' onKeyUp = "'.$this->keyUp.'"'; $extra .= $this->extraHTML; if (strlen($this->password) == 0) $tip = 'text'; else $tip = 'password'; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ' '; $html .= ''; if ($this->readOnly) $html = $this->value; /* echo ''; */ return $html; } function show() { echo $this->generateHTML(); } } if ($notFirstTime == 0) { //echo ''; echo ''; $notFirstTime = 1; } ?> $v) { $procesat[$v] = 1; $tmp[$v]['tip'] = 'numeric'; } foreach ($arrString as $k => $v) { $procesat[$v] = 1; $tmp[$v]['tip'] = 'string'; } foreach ($arrDate as $k => $v) { $procesat[$v] = 1; $tmp[$v]['tip'] = 'date'; } foreach ($_POST as $k => $v) { $v = strip_tags($v); if (strlen($v) > strlen($tmp[$k]['ex'])) $tmp[$k]['ex'] = $v; $tmp[$k]['cnt']++; $tmp[$k]['interfata'][$action]++; if (strlen($tmp[$k]['tip']) > 0) continue; //POST if (is_numeric($v) and strlen($v) > 0) $tmp[$k]['tip'] = 'numeric'; if (!is_numeric($v) and strlen($v) > 0) $tmp[$k]['tip'] = 'string'; } foreach ($_GET as $k => $v) { $v = strip_tags($v); if (strlen($v) > strlen($tmp[$k]['ex'])) $tmp[$k]['ex'] = $v; $tmp[$k]['cnt']++; $tmp[$k]['interfata'][$action]++; if (strlen($tmp[$k]['tip']) > 0) continue; //GET if (is_numeric($v) and strlen($v) > 0) $tmp[$k]['tip'] = 'numeric'; if (!is_numeric($v) and strlen($v) > 0) $tmp[$k]['tip'] = 'string'; } $f = fopen('all_params.txt', 'w'); fwrite($f, serialize($tmp)); fclose($f); if (isset($_GET['show_all_params'])) $_SESSION['show_all_params'] = $_GET['show_all_params']; if ($_SESSION['show_all_params'] == 1) { echo ''; foreach ($tmp as $k => $v) { if ($tmp[$k]['cnt'] == 0) continue; $interfata = ''; foreach ($tmp[$k]['interfata'] as $kk => $vv) { if (strlen($interfata) > 0) $interfata .= ', '; $interfata .= $kk; } $culoare = ' bgcolor="#FFAAAA"'; if ($procesat[$k]) $culoare = ''; echo ''; } echo '
Variabila Tip Ex. valoare Interfata Nr. aparitii
' . $k . ' ' . $tmp[$k]['tip'] . ' ' . $tmp[$k]['ex'] . ' ' . $interfata . ' ' . $tmp[$k]['cnt'] . '
'; } unset($tmp); //PROCESARE //INT foreach ($arrInt as $k => $v) { if (isset($$v)) $$v = protejeazaInt($$v); if (isset($_GET[$v])) $_GET[$v] = protejeazaInt($_GET[$v]); if (isset($_POST[$v])) $_POST[$v] = protejeazaInt($_POST[$v]); } //STRING foreach ($arrString as $k => $v) { if (isset($$v)) $$v = protejeazaString($$v); if (isset($_GET[$v])) $_GET[$v] = protejeazaString($_GET[$v]); if (isset($_POST[$v])) $_POST[$v] = protejeazaString($_POST[$v]); } //END SQL INJECTION function protejeazaString($var) { $var = str_replace("'", '', $var); $var = str_replace('"', '', $var); $var = strip_tags($var); return $var; } function protejeazaInt($var) { if (strlen($var) == 0) return $var; $procesat = $var * 1; if ($procesat . '' != $var . '') { //123,45 -> 123.45 //8.454,54 -> 8454,54 $posv = strpos($var, ','); $posp = strpos($var, '.'); if ($posv > 0 and $posp == 0) $var = str_replace(',', '.', $var); if ($posv > 0 and $posp > 0) { $var = str_replace('.', '', $var); $var = str_replace(',', '.', $var); } $procesat = $var * 1; } return $var; } function protejeazaDate($var) { if (strlen($var) < 6) return ''; list($z, $l, $a) = explode('.', $var); $z = protejeazaInt($z); $l = protejeazaInt($l); $a = protejeazaInt($a); if ($a < 1900 or $a > 2035) return ''; if ($l < 1 or $l > 12) return ''; if ($z < 1 or $z > 31) return ''; return $var; } ?> Thermonet Suceava - situatie clienti'; if (file_exists("texte_help_contextual_".$_SESSION['templateName'].".txt")) $fisier = "texte_help_contextual_" . $_SESSION['templateName'].".txt"; else if (file_exists("texte_help_contextual.txt")) $fisier = "texte_help_contextual.txt"; $str = file_get_contents($fisier); $tmp = explode("\r\n", $str); $q = 0; while ($q < count($tmp)) { $helpTEXT[$tmp[$q]] = $tmp[$q + 1]; $q += 2; } echo '' ?>template = $template; $this->hasTemplate = file_exists("templates/".$this->template.'/template.html'); } function show($page, $show = 1) { global $template; $file = "templates/".$this->template.'/'.$page; $str = file_get_contents($file); $pos = strpos($str, '{{necesita autentificare}}'); if (($pos > 0) and ($_SESSION['userID'] == 0)) { $file = "templates/".$this->template.'/login.html'; $str = file_get_contents($file); } if (($pos > 0) and ($_SESSION['userID'] > 0)) $str = str_replace('{{necesita autentificare}}', '', $str); $str = ''.$str; //variabile si fisiere $pos = strpos($str, '['); while ($pos > 0) { $pos2 = 0; $pos2 = strpos($str, ']', $pos); $var = substr($str, $pos, ($pos2 - $pos) + 1); if ($pos2 > 0) { $html = strpos($var, '.html'); $php = strpos($var, '.php'); $var = substr($var, 1, -1); if ($html > 0) { $file = 'templates/'.$this->template.'/'.$var; if (file_exists($file)) $de_inclus = file_get_contents($file); else $de_inclus = 'nu gasesc fisierul '.$file.''; $str = substr_replace($str, $de_inclus, $pos, $pos2 - $pos + 1); } if ($php > 0) { //memorez linia la care trebuie sa execut cod $cod[$pos] = $var; $str = substr_replace($str, '', $pos, $pos2 - $pos + 1); } } $pos = strpos($str, '[', $pos + 1); } if ($show) { if (count($cod) == 0) echo $str; else { //afisez pe bucati si execut codul $last = 0; foreach ($cod as $ktemplate => $vtemplate) { $file = $vtemplate; echo substr($str, $last, $ktemplate - $last); include $file; $last = $ktemplate; } if ($last > 0) echo substr($str, $last); } } else return $str; } } ?>