L_TRANSLATION; return ($entities ? htmlentities ($row->L_TRANSLATION) : $row->L_TRANSLATION); } //============================================================================== // gs_genericButtons ($db, $link, $locale, $buttons, $horizontal, $size, $styles) // $db : database name // $link : database link // $locale : locale code // $buttons : (...) // $horizontal : true if the buttons are horizontal, false otherwise // $appl : application name for labels // $size : (...) // $styles : (...) // // Button generation. // // $buttons is an array of button descriptions, each description is itself an // array, with the following informations: // - text : the label (according to gs_getLabel) of the button // - url : the URL to launch // - on : boolean, true is the button is on // - space : boolean, true if we have a space between two vertical buttons. // - appl : application name, for labels // // $size is another indexed array: // - width : button width // - height : button height // - space : space between two buttons // // $styles is the last indexed array: // - cssborder : style for border // - csson : style is the button is on // - cssoff : style is the button is off //============================================================================== function gs_genericButtons ($db, $link, $locale, $buttons, $horizontal = true, $size = '', $styles = '') { //---------------------------------------------------------------------------- // Set the sizes. if ((sizeof ($size) == 0) || (! is_array ($size))) { $width = 100; $height = 20; $space = 5; } else { $width = (isset ($size['width']) ? $size['width'] : 100); $height = (isset ($size['height']) ? $size['height'] : 20); $space = (isset ($size['space']) ? $size['space'] : 5); } //---------------------------------------------------------------------------- // Set the styles. if ((sizeof ($styles) == 0) || (! is_array ($styles))) { $cssborder = 'line'; $csson = 'btActive'; $cssoff = 'btInactive'; } else { $cssborder = (isset ($styles['cssborder']) ? $styles['cssborder'] : 'line'); $csson = (isset ($styles['csson']) ? $styles['csson'] : 'btActive'); $cssoff = (isset ($styles['cssoff']) ? $styles['cssoff'] : 'btInactive'); } //============================================================================ // Build the buttons. $str = ''; //---------------------------------------------------------------------------- // Main table. $str .= ''; //---------------------------------------------------------------------------- // If the buttons are horizontal, we put top lines. if ($horizontal) { $str .= "\n".' '; for ($i = 0; $i < sizeof ($buttons); $i++) { $str .= "\n".' '; $str .= "\n".' '; } $str .= "\n".' '; } //---------------------------------------------------------------------------- // Now, the buttons. If they are horizontal, we need only one TR. Otherwise, // we'll have one (several) TR for each button. if ($horizontal) $str .= "\n".' '; for ($i = 0; $i < sizeof ($buttons); $i++) { //-- Get the infos. $btinfo = $buttons[$i]; //-- The space between two buttons. if (isset ($btinfo['space']) && ($btinfo['space'] === true)) { if (! $horizontal) { $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; } continue; } //-- Button text: label ? $btText = (empty ($btinfo['text']) ? htmlentities ($btinfo['plaintext']) : gs_getLabel ($db, $link, $btinfo['text'], $locale, (empty ($btinfo['appl']) ? '' : $btinfo['appl']))); //-- If the button is on, we build an anchor with URL. Otherwise, we only //-- put the label. //-- Correct style is saved in $btStyle. if ((! isset ($btinfo['on'])) || $btinfo['on']) { $target = (empty ($btinfo['target']) ? '' : ' target="'.$btinfo['target'].'"'); $url = ''.$btText.''; $btStyle = $csson; } else { $url = $btText; $btStyle = $cssoff; } //-- If the buttons are not horizontal, we put the top-line. if (! $horizontal) { $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; } //-- Now, we put the button itself. $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; //-- If the button are horizontal, we put the space between two buttons. if ($horizontal) { $str .= "\n".' '; } else { //-- If they are vertical, we end the box with a border (who block the //-- cell). $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; //-- And the space between two buttons. $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; } } if ($horizontal) { //-- We put a line to fix the button width. $str .= "\n".' '; for ($i = 0; $i < sizeof ($buttons); $i++) { $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; } $str .= "\n".' '; //-- And the last line, to close the box. $str .= "\n".' '; for ($i = 0; $i < sizeof ($buttons); $i++) { $str .= "\n".' '; $str .= "\n".' '; } $str .= "\n".' '; } //-- The end of the table. $str .= "\n".'
 '.$url.' 
'; return $str; } //============================================================================== // gs_buildControlAndPages ($db, $link, $locale, $url, $first, $max, $numItems, // $noResponse, $oneResponse, $responses, // $width, $style, $imgdir) // $db : database name // $link : database link // $locale : locale code // $url : URL to show datas, without first and max limits // $first : in the result set, the index of the first item to show // $max : max count of results by page // $numItems : results count // $noResponse : label (if no responses) // $oneResponse : label (if only one response) // $responses : label (if more than one response) // $width : table widh (if equal to zero, 100%) // $style : style used into the images control cells // $imgdir : the image set used for the control buttons // // Generation of control buttons (first, previous, next, last) and pages numbers // (search result, for example). //============================================================================== function gs_buildControlAndPages ($db, $link, $locale, $url, $first, $max, $numItems, $noResponse = null, $oneResponse = null, $responses = null, $width = null, $style = null, $imgdir = null, $appl = 'gsite') { //---------------------------------------------------------------------------- // Manage default values. if (empty ($noResponse)) $noResponse = 'ctrl_no_response'; if (empty ($oneResponse)) $oneResponse = 'ctrl_one_response'; if (empty ($responses)) $responses = 'ctrl_responses'; if (empty ($width)) $width = '100%'; if (empty ($style)) $style = 'line'; if (empty ($imgdir)) $imgdir = 'dft'; //---------------------------------------------------------------------------- // Build style. global $GS_GLOBAL; $STYLErow = $GS_GLOBAL['style_row']; $fontStyle = "font-family:$STYLErow->S_FONT_FAMILY;". "font-size:$STYLErow->S_FONT_SIZE_SMALL;". "color:$STYLErow->S_COLOR_TEXT;". "font-style:normal;". "font-weight:bold;"; $anchorStyle = ""; // "text-decoration:none;". // "color:$STYLErow->S_COLOR_TEXT;"; //---------------------------------------------------------------------------- // Get labels. $pageLabel = gs_getLabel ($db, $link, 'ctrl_page', $locale, $appl); $numresLabel0 = gs_getLabel ($db, $link, $noResponse, $locale, $appl); $numresLabel1 = gs_getLabel ($db, $link, $oneResponse, $locale, $appl); $numresLabel = gs_getLabel ($db, $link, $responses, $locale, $appl); //---------------------------------------------------------------------------- // Build labels, switch number of results. $responses = ''; if ($numItems == 0) { $responses = $numresLabel0; } else if ($numItems == 1) { $responses = $numresLabel1; } else { $responses = $numresLabel.' : '.$numItems; } //---------------------------------------------------------------------------- // Build pages count. if ($numItems > $max) { //-- More than one page. $count = $pageLabel.' :'; $pgcount = 1; //-- For all sets of items. $current = 0; $blockArray = array (); for ($i = 0; $i < $numItems; $i += $max) { if ($first == $i) { //-- This is the current set. $current = $pgcount; $tag = '['.$pgcount.']'; } else { //-- Another set: [$i, $i+$max] $href = $url.'&first='.$i.'&max='.$max; $tag = (''.$pgcount.''); } $blockArray[$pgcount] = $tag; $pgcount++; } $firstTag = ($current - 5 > 0 ? $current - 5 : 1); $lastTag = $firstTag + 10; if ($firstTag > 1) $count .= ' ... '; while (list ($k, $v) = each ($blockArray)) { if (($k >= $firstTag) && ($k <= $lastTag)) { $count .= ' '.$v; } } if ($lastTag + 1 < $pgcount) $count .= ' ... '; } else { //-- Zero or one page. $count = ' '; } //---------------------------------------------------------------------------- // Build table. $str = ''; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".'
'.gs_buildControl ($url, $first, $max, $numItems, $style, $imgdir).''.$responses.''.$count.'
'; return $str; } //============================================================================== // gs_buildControl ($url, $first, $max, $numItems, $style = 'line', $imgdir = 'dft') // $url : URL to show datas, without first and max limits // $first : in the result set, the index of the first item to show // $max : max count of results by page // $numItems : results count // $style : style used into the images control cells // $imgdir : the image set used for the control buttons // // Generation of control buttons (first, previous, next, last) for search // result, for example. //============================================================================== function gs_buildControl ($url, $first, $max, $numItems, $style = 'line', $imgdir = 'dft') { //---------------------------------------------------------------------------- // Compute index of last set. if ($numItems == 0) { $last = 0; } else { $last = ($numItems % $max == 0 ? ((int)($numItems / $max) - 1) * $max : ((int)($numItems / $max)) * $max); } //---------------------------------------------------------------------------- // Build infos for gs_control. $ctrlParam = array ( 'style' => $style, 'imgdir' => $imgdir, 'begin' => $url.'&first=0&max='.$max, 'last' => $url.'&first='.$last.'&max='.$max ); if ($first > 0) { $ctrlParam['prev'] = $url.'&first='.($first - $max).'&max='.$max; } if ($first + $max < $numItems) { $ctrlParam['next'] = $url.'&first='.($first + $max).'&max='.$max; } //---------------------------------------------------------------------------- // Build control. return gs_control ($ctrlParam); } //============================================================================== // gs_control ($param) // $param : (...) // // Dump a table containing images for first, prev, next, last navigation, // according to $param parameters array. // // $param is an array, with the following items: // - style : style used for the table cells // - imgdir : the directory of the control images set (Local/controls/$imgdir) // - begin : URL to the first set // - prev : URL to the previous set // - next : URL to the next set // - last : URL to the last set //============================================================================== function gs_control ($param) { $imgdir = (empty ($param['imgdir']) ? 'dft' : $param['imgdir']); $icon1 = "Local/controls/$imgdir/01$imgdir.gif"; $icon2 = "Local/controls/$imgdir/02$imgdir.gif"; $icon3 = "Local/controls/$imgdir/03$imgdir.gif"; $icon4 = "Local/controls/$imgdir/04$imgdir.gif"; $icon5 = "Local/controls/$imgdir/05$imgdir.gif"; $icon6 = "Local/controls/$imgdir/06$imgdir.gif"; $beginImg = ''; $prevImg = ''; $nextImg = ''; $lastImg = ''; $style = (empty ($param['style']) ? '' : ' class="'.$param['style'].'"'); $beginImg = (empty ($param['begin']) ? $beginImg : ''.$beginImg.''); $prevImg = (empty ($param['prev']) ? $prevImg : ''.$prevImg.''); $nextImg = (empty ($param['next']) ? $nextImg : ''.$nextImg.''); $lastImg = (empty ($param['last']) ? $lastImg : ''.$lastImg.''); $str = ''; $str .= "\n".''; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".' '.$beginImg.''; $str .= "\n".' '.$prevImg.''; $str .= "\n".' '.$nextImg.''; $str .= "\n".' '.$lastImg.''; $str .= "\n".' '; $str .= "\n".' '; $str .= "\n".'
'; return $str; } //============================================================================== // gs_buildOptionInVar ($db, $link, $query, $current, $valueFieldName, $labelFieldName, $locale, $appl, $isLabel) // $db : database name // $link : database link // $query : query to perform // $current : current expected value of the select (option SELECTED) // $valueFieldName : in the query, the field name of the value // $labelFieldName : in the query, the field name of the text // $locale : current locale, in case of labelled text // $name : name of application, for labels // $isLabel : true if $labelFieldName field is a label name. // // According to the result of the query $query, build SELECT options. The result // is a string. //============================================================================== function gs_buildOptionInVar ($db, $link, $query, $current, $valueFieldName, $labelFieldName, $locale = '', $appl= '', $isLabel = false) { //---------------------------------------------------------------------------- // Perform query. $res = mysql_query ($query, $link); if (! $res) { die ("Unable to perform query ($query / " . mysql_error ($link) . ")"); } //---------------------------------------------------------------------------- // Build options. $str = ''; while ($row = mysql_fetch_array ($res)) { //-- Option label. If $isLabel is true, the field named $labelFieldName is //-- used as a label. Otherwise, it's only a string. $label = ($isLabel ? gs_getLabel ($db, $link, $row[$labelFieldName], $locale, $appl) : htmlentities ($row[$labelFieldName])); //-- The value: field $valueFieldName of the result set. $value = $row[$valueFieldName]; //-- If the value if equal to $current, this option is selected. $selected = ($current == $value ? ' selected' : ''); //-- Build option. $str .= "\n".''; } mysql_free_result ($res); return $str; } //============================================================================== // gs_localePutLanguagesFlagsInVar ($dbname, $dblink, $project) // $dbname : database name // $dblink : database link // $project : project name // // Dump array of flags, one for each language supported by the project. // Images are taken from Local/flags directory. //============================================================================== function gs_localePutLanguagesFlagsInVar ($dbname, $dblink, $project) { //---------------------------------------------------------------------------- // List of all the languages supported by project. $query = "select * from $dbname.LOCALE, $dbname.LOCALE_PRJ". " where LP_PROJECT='$project' and LP_CODE=L_CODE". " order by LP_ORDER"; $result = mysql_query ($query, $dblink); if (! $result) { die ("Unable to perform query (" . mysql_error ($dblink) . ")"); } //---------------------------------------------------------------------------- // Only one language ? Do nothing. if (mysql_num_rows ($result) <= 1) { mysql_free_result ($result); return; } //---------------------------------------------------------------------------- // Dump array of flags. $outputText = ''; $outputText .= "\n".''; $outputText .= "\n".' '; while ($row = mysql_fetch_object ($result)) { //-------------------------------------------------------------------------- // The flags images are taken from Local/flags. $url = "index.php?project=$project&locale=$row->LP_CODE"; $img = "Local/flags/$row->L_FLAG"; $alt = htmlentities ($row->L_DESCRIPTION); $outputText .= "\n".''; } $outputText .= "\n".' '; $outputText .= "\n".'
'; $outputText .= ''; $outputText .= ''.$alt.''; $outputText .= ''; $outputText .= '
'; mysql_free_result ($result); return $outputText; } //============================================================================== // FUNCTION gs_putAmount ($frf, $euro) // // Convert an amount into euro. // // NOTE: must be move into project module. //============================================================================== function gs_putAmount ($frf, $euro) { if ($euro == 0) { $euro = $frf / 6.55957; $euro = (round ($euro * 100)) / 100; } if ($euro == 0) return ' '; if ($euro >= 150000) return 'A ( >= 150 000 € )'; if ($euro >= 45000) return 'B ( < 150 000 €, >= 45 000 € )'; if ($euro >= 15000) return 'C ( < 45 000 €, >= 15 000 € )'; return 'D ( < 15 000 €)'; } //============================================================================== // FUNCTION browserAcceptGzip // // If the browser supports compression, return content encoding. Returns an // empty string otherwise. //============================================================================== function browserAcceptGzip () { global $SERVER_PROTOCOL; global $HTTP_ACCEPT_ENCODING; if (headers_sent ()) return ''; if ($SERVER_PROTOCOL != 'HTTP/1.1') return ''; if (strpos ($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false) return 'x-gzip'; if (strpos ($HTTP_ACCEPT_ENCODING, 'gzip') !== false) return 'gzip'; return ''; } //============================================================================== // FUNCTION dumpCompressedData ($data) // // Try to dump compressed data back to the browser. Returns true if the data is // send. //============================================================================== function dumpCompressedData ($data) { //---------------------------------------------------------------------------- // Browser supports compression ? $encoding = browserAcceptGzip (); //---------------------------------------------------------------------------- // No compression supported. if ($encoding == '') { $uncompressed = gzuncompress ($data); if (! $uncompressed) return false; echo $uncompressed; return true; } //---------------------------------------------------------------------------- // OK, we send compressed data. header("Content-Encoding: gzip"); echo "\x1f\x8b\x08\x00\x00\x00\x00\x00"; echo $data; return true; } //============================================================================== // FUNCTION dumpData ($data) // // Try to dump data back to the browser, with compression if the browser can. //============================================================================== function dumpData ($data) { //---------------------------------------------------------------------------- // zlib extension loaded ? $hasZLIB = extension_loaded ('zlib'); if (! $hasZLIB) { echo $data; return; } //---------------------------------------------------------------------------- // Browser supports compression ? $encoding = browserAcceptGzip (); //---------------------------------------------------------------------------- // No compression supported, or not enougth data. if (($encoding == '') || (strlen ($data) < 2048)) { echo $data; return; } //---------------------------------------------------------------------------- // Try to compress data. $zipped = gzcompress ($data, 9); if (! $zipped) { echo $data; return; } //---------------------------------------------------------------------------- // OK, we send compressed data. header ("Content-Encoding: gzip"); echo "\x1f\x8b\x08\x00\x00\x00\x00\x00"; echo $zipped; } //============================================================================== // FUNCTION gs_includeFile ($incFiles, $msg) // // Include file. //============================================================================== function gs_includeFile ($incFiles, $msg) { if (! isset ($incFiles)) die ('Bad include path'); if (! is_array ($incFiles)) die ('Bad include path'); $searchPath = ''; for ($i = 0; $i < count ($incFiles); $i++) { $searchPath .= $incFiles[$i].'
'."\n"; if (file_exists ($incFiles[$i])) { include ($incFiles[$i]); return; } } die ("$msg
\nSearch path:
\n$searchPath"); } //============================================================================== // FUNCTION gs_getUser ($db, $link, $annu, $userid) // // Returns an array with user informations. //============================================================================== function gs_getUser ($db, $link, $annu, $userid) { $query = "select * from $db.annu_USERS". " where U_ID=$userid". " and U_ANNU_NAME='$annu'"; $result = mysql_query ($query, $link); if (! $result) { die ("Unable to perform query ($query / " . mysql_error ($link) . ")"); } $row = mysql_fetch_object ($result); if (! $row) return false; $userInfo['login'] = $row->U_LOGIN; $userInfo['name'] = $row->U_NAME; $userInfo['surname'] = $row->U_SURNAME; $userInfo['row'] = $row; mysql_free_result ($result); return $userInfo; } //============================================================================== // FUNCTION gs_tabStyles ($STYLErow) // // Default styles for tab generation. //============================================================================== function gs_tabStyles ($STYLErow) { $text = ''; $text .= ".tabBackground {\n"; $text .= " background-color: $STYLErow->S_COLOR_1;\n"; $text .= "}\n"; $text .= ".tabActive {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: normal;\n"; $text .= " text-align: left;\n"; $text .= " vertical-align: top;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_7;\n"; $text .= "}\n"; $text .= ".tabInactive {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: normal;\n"; $text .= " text-align: left;\n"; $text .= " vertical-align: top;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_4;\n"; $text .= "}\n"; $text .= ".tabInactiveAnchor {\n"; $text .= " text-decoration : none;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT_INVERSE;\n"; $text .= "}\n"; return $text; } //============================================================================== // FUNCTION gs_styles ($STYLErow) // // Default styles. //============================================================================== function gs_styles ($STYLErow) { $text = ''; //-- Line. $text .= ".line {\n"; $text .= " background-color: $STYLErow->S_COLOR_2;\n"; $text .= "}\n"; //-- Anchor. $text .= ".anchor {\n"; $text .= " text-decoration : none;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= "}\n"; $text .= ".anchorAnim {\n"; $text .= " text-decoration : none;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= "}\n"; $text .= ".anchorAnim:hover { color: red }\n"; //-- Text. $text .= ".basicText {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: normal;\n"; $text .= "}\n"; $text .= ".text {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: normal;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_3;\n"; $text .= "}\n"; $text .= ".textJustify {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: normal;\n"; $text .= " text-align: justify;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_3;\n"; $text .= "}\n"; $text .= ".text1 {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: normal;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_5;\n"; $text .= "}\n"; $text .= "\n"; $text .= ".text2 {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: normal;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_6;\n"; $text .= "}\n"; $text .= "\n"; $text .= ".dump {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= "}\n"; $text .= ".bold {\n"; $text .= " font-weight: bold;\n"; $text .= "}\n"; $text .= ".italic {\n"; $text .= " font-style: italic;\n"; $text .= "}\n"; //-- Titles. $text .= ".title {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: bold;\n"; $text .= " text-decoration: none;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_3;\n"; $text .= "}\n"; $text .= ".title1 {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: bold;\n"; $text .= " text-decoration: none;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_5;\n"; $text .= "}\n"; $text .= ".title2 {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: bold;\n"; $text .= " text-decoration: none;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_6;\n"; $text .= "}\n"; $text .= ".titleBig {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_BIG;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: bold;\n"; $text .= " text-decoration: none;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_3;\n"; $text .= "}\n"; //-- Inputs. $text .= ".formLabel {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: bold;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_5;\n"; $text .= "}\n"; $text .= "\n"; $text .= ".formLabelMandatory {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: italic;\n"; $text .= " font-weight: bold;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_5;\n"; $text .= "}\n"; $text .= "\n"; $text .= ".formInput {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: normal;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_6;\n"; $text .= "}\n"; $text .= "\n"; //-- Error. $text .= ".error {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_BIG;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: bold;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT_ALERT;\n"; $text .= " background-color: $STYLErow->S_COLOR_3;\n"; $text .= "}\n"; //-- Buttons. $text .= ".btActive {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: bold;\n"; $text .= " text-align: center;\n"; $text .= " vertical-align: middle;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_1;\n"; $text .= "}\n"; $text .= ".btInactive {\n"; $text .= " font-family: $STYLErow->S_FONT_FAMILY;\n"; $text .= " font-size: $STYLErow->S_FONT_SIZE_SMALL;\n"; $text .= " font-style: normal;\n"; $text .= " font-weight: bold;\n"; $text .= " text-align: center;\n"; $text .= " vertical-align: middle;\n"; $text .= " color: $STYLErow->S_COLOR_TEXT;\n"; $text .= " background-color: $STYLErow->S_COLOR_3;\n"; $text .= "}\n"; return $text; } //============================================================================== //============================================================================== function gs_getDocumentAndPage ($doc, $pagendx, $page) { //---------------------------------------------------------------------------- // Tags. global $GS_GLOBAL; //---------------------------------------------------------------------------- // Global variables. $db = $GS_GLOBAL['mysql_db']; $project = $GS_GLOBAL['project']; $locale = $GS_GLOBAL['locale']; //---------------------------------------------------------------------------- // Looking for document. $query = "select * from $db.DOCUMENT, $db.annu_USERS". " where D_NAME='$doc'". " and D_PROJECT='$project'". " and D_LOCALE='$locale'". " and D_AUTHOR_ID=U_ID"; $DOCresult = mysql_query ($query, $GS_GLOBAL['link']); if (! $DOCresult) { die ("Unable to perform query ($query / " . mysql_error ($GS_GLOBAL['link']) . ")"); } if (mysql_num_rows ($DOCresult) == 0) { die ("Unknown document (name=$doc, locale=$locale)"); } if (mysql_num_rows ($DOCresult) > 1) { die ("Too much documents ($doc)"); } $GS_GLOBAL['document_row'] = mysql_fetch_object ($DOCresult); mysql_free_result ($DOCresult); //---------------------------------------------------------------------------- // Looking for pages associated to document. $docIndex = $GS_GLOBAL['document_row']->D_INDEX; $query = "select * from $db.PAGE". " where P_DOCUMENT=$docIndex". " order by P_ORDER"; $GS_GLOBAL['pages_result'] = mysql_query ($query, $GS_GLOBAL['link']); if (! $GS_GLOBAL['pages_result']) { die ("Unable to perform query ($query / " . mysql_error ($GS_GLOBAL['link']) . ")"); } //---------------------------------------------------------------------------- // Find application. if (mysql_num_rows ($GS_GLOBAL['pages_result']) == 0) { //-------------------------------------------------------------------------- // No page: assuming this is a txt application. $GS_GLOBAL['no_page'] = true; $GS_GLOBAL['current_page_ndx'] = 0; $GS_GLOBAL['current_page_row'] = null; $GS_GLOBAL['application'] = 'txt'; } else { //-------------------------------------------------------------------------- // There is at least one page. We try to find the current page. // If $page is set, we use P_ORDER. // If $pagendx is set, we use P_INDEX. // // If nothing is set, or if we can't get a page, we'll use the first one. mysql_data_seek ($GS_GLOBAL['pages_result'], 0); $row = mysql_fetch_object ($GS_GLOBAL['pages_result']); $GS_GLOBAL['no_page'] = false; $GS_GLOBAL['current_page_ndx'] = $row->P_ORDER; $GS_GLOBAL['current_page_row'] = $row; //-------------------------------------------------------------------------- // We perform the search. mysql_data_seek ($GS_GLOBAL['pages_result'], 0); if (! empty ($pagendx)) { //------------------------------------------------------------------------ // We use $pagendx. while ($row = mysql_fetch_object ($GS_GLOBAL['pages_result'])) { if ($pagendx == $row->P_INDEX) { //-------------------------------------------------------------------- // We found the current page. $GS_GLOBAL['current_page_ndx'] = $row->P_ORDER; $GS_GLOBAL['current_page_row'] = $row; break; } } } else if (! empty ($page)) { //------------------------------------------------------------------------ // We use $page. while ($row = mysql_fetch_object ($GS_GLOBAL['pages_result'])) { if ($page == $row->P_ORDER) { //-------------------------------------------------------------------- // We found the current page. $GS_GLOBAL['current_page_ndx'] = $page; $GS_GLOBAL['current_page_row'] = $row; break; } } } //-------------------------------------------------------------------------- // In any case, we have set the tag current_page_row. So, we can set the tag // application. $GS_GLOBAL['application'] = ($GS_GLOBAL['current_page_row']->P_APPLICATION == '' ? 'txt' : $GS_GLOBAL['current_page_row']->P_APPLICATION); } //---------------------------------------------------------------------------- // Arguments. global $GS_PROJECT_ARGUMENTS; global $GS_ARGUMENTS; $args = explode (' ', $GS_GLOBAL['current_page_row']->P_ARGUMENT); $GS_ARGUMENTS['cache'] = false; $GS_ARGUMENTS['nocache'] = false; $GS_ARGUMENTS['cache_delay'] = $GS_PROJECT_ARGUMENTS['cache_delay']; $GS_ARGUMENTS['cookie'] = false; $GS_ARGUMENTS['cachectrl'] = false; for ($i = 0; $i < count ($args); $i++) { $attr = explode ('=', $args[$i]); if ($attr[0] == 'cache') { $GS_ARGUMENTS['cache'] = ($attr[1] == 'true'); } else if ($attr[0] == 'nocache') { $GS_ARGUMENTS['nocache'] = ($attr[1] == 'true'); } else if ($attr[0] == 'cache_delay') { $GS_ARGUMENTS['cache_delay'] = $attr[1]; } else if ($attr[0] == 'cookie') { $GS_ARGUMENTS['cookie'] = ($attr[1] == 'true'); } else if ($attr[0] == 'cachectrl') { $GS_ARGUMENTS['cachectrl'] = ($attr[1] == 'true'); } else if ($attr[0] != '') { $GS_ARGUMENTS[$attr[0]] = (isset ($attr[1]) ? $attr[1] : ''); } } } //============================================================================== //============================================================================== function js_init () { global $G_Javascript; global $G_JavascriptFiles; global $G_JavascriptFunctions; $G_Javascript = ''; $G_JavascriptFiles = array (); $G_JavascriptFunctions = array (); $G_JavascriptFiles['gsite'] = 'gsite.js'; } //============================================================================== //============================================================================== function js_register ($fctName, $body) { global $G_JavascriptFunctions; if (empty ($G_JavascriptFunctions[$fctName])) { $G_JavascriptFunctions[$fctName] = $body; } } //============================================================================== //============================================================================== function js_registerFile ($tag, $fileName) { global $G_JavascriptFiles; if (empty ($G_JavascriptFiles[$tag])) { $G_JavascriptFiles[$tag] = $fileName; } } //============================================================================== //============================================================================== function js_dump () { global $G_Javascript; global $G_JavascriptFiles; global $G_JavascriptFunctions; $files = ''; if (isset ($G_JavascriptFiles)) { while (list ($k, $v) = each ($G_JavascriptFiles)) { $files .= "\n".''; } } $fct = ''; while (list ($k, $v) = each ($G_JavascriptFunctions)) { $fct .= $v; } return $files. "\n".''; } //============================================================================== // FUNCTION messageTo ($project, $locale, $to) // // Dump an icon to send a message. //============================================================================== function messageTo ($project, $locale, $to) { $args = "'$project', '$locale', $to"; $icon = ''; return ''. $icon. ''; } //============================================================================== //============================================================================== function gs_print ($item) { ob_start (); print_r ($item); $p = ob_get_contents (); ob_end_clean (); echo '
'.htmlentities ($p).'
'; } //------------------------------------------------------------------------------ // $Log: common.php,v $ // Revision 1.3 2002/12/16 16:25:12 jpm // Suppression des doubles saut de ligne. // // Revision 1.2 2002/10/04 09:34:29 jpm // Suppression espace apr�s balise fermeture php // // Revision 1.1.1.1 2002/10/02 07:32:21 root // initialisation site de Tela // // Revision 1.34 2002/06/25 11:06:51 lc // Add gs_print and anchorAnim // // Revision 1.33 2002/06/20 07:39:32 lc // Add cache management for labels. // Add basicText style. // // Revision 1.32 2002/06/18 13:21:12 lc // Add messageTo. // // Revision 1.31 2002/06/18 13:09:33 lc // Add title1 and title2 styles // // Revision 1.30 2002/06/18 07:19:39 lc // Add function js_registerFile // // Revision 1.29 2002/06/14 07:36:31 lc // Bug LC0021 : use js_init, js_register and js_dump // Bug LC0021 : use external js file // // Revision 1.28 2002/06/10 16:12:04 lc // Add annu and project into browser. // // Revision 1.27 2002/06/10 09:04:39 lc // Bug LC0006 : add nocache argument // Bug LC0008 : check if zlib extension is loaded // // Revision 1.26 2002/06/05 13:07:17 lc // Bug LC0002 // // Revision 1.25 2002/06/04 06:39:18 lc // Add function gs_localizeDateTime(). // // Revision 1.24 2002/05/29 13:14:26 lc // Javascript function eraseBrowserFields is now in php/common.php // // Revision 1.23 2002/05/29 06:44:52 lc // Add gs_JavascriptOpenBrowser function. // // Revision 1.22 2002/05/23 16:32:16 lc // Add gs_getDocumentAndPage. // Add isYear javascript function. // Add style formLabelMandatory. // Add openPopup javascript function. // // Revision 1.21 2002/05/23 08:32:37 lc // Show only a limited number of pages. // Comments. // // Revision 1.20 2002/05/22 09:52:09 lc // Add javascript function gs_JavascriptOpenDocumentPopup (open a popup with a document and a set). // // Revision 1.19 2002/05/15 09:48:41 lc // Add some default styles. // // Revision 1.18 2002/05/15 09:23:08 lc // Change buttons styles. // Add default styles generation. // // Revision 1.17 2002/05/14 12:42:40 lc // Modify default parameters for controls. // // Revision 1.16 2002/04/24 15:29:50 lc // Add gs_getUser. // // Revision 1.15 2002/04/19 06:46:17 lc // Add gs_JavascriptCheckFrenchZipCode (validation of french ZIP code). // // Revision 1.14 2002/04/18 14:05:38 lc // Bug: replace fr by sp... // // Revision 1.13 2002/04/10 09:28:40 lc // Add gs_localizeTimestamp. // // Revision 1.12 2002/03/07 09:23:07 lc // Add gs_includeFile (protection from URL). // // Revision 1.11 2002/02/28 18:48:39 schneid // Warnings... // // Revision 1.10 2002/02/26 13:31:25 lc // Bug in array test. // // Revision 1.9 2002/02/25 17:24:28 lc // Remove old compatibility. // // Revision 1.8 2002/02/25 16:32:56 lc // gs_localePutLanguagesFlags replaced by gs_localePutLanguagesFlagsInVar. // Compression management. // // Revision 1.7 2002/02/15 17:37:38 lc // Bas use of some variables... // // Revision 1.6 2002/02/13 17:38:26 lc // Modify project locale management. // // Revision 1.5 2002/02/08 15:52:22 lc // Add application in label table // // Revision 1.4 2002/01/15 16:00:02 lc // Add space between two buttons. // // Revision 1.3 2001/12/20 19:21:35 lc // Add table LABELS in comments. // // Revision 1.2 2001/12/17 20:16:40 lc // Error in comment. // // Revision 1.1 2001/12/17 20:15:03 lc // Initial version. // //-- End of source ------------------------------------------------------------ ?> NOW()"; global $GS_PROJECT_ARGUMENTS; if ($GS_PROJECT_ARGUMENTS['verify_ip']) { global $REMOTE_ADDR; $query .= " and S_ADDR_IP='$REMOTE_ADDR'"; } $result = mysql_query ($query, $dblink); if (! $result) { die ("Unable to perform query ($query / " . mysql_error ($dblink) . ")"); } $existInBDD = (mysql_num_rows ($result) == 1); mysql_free_result ($result); return $existInBDD; } //============================================================================== // string gs_sessionStart ($dbname, $dblink, $project, $delay = 3600, $cleanup = false) // $dbname : current database // $dblink : MySQL link // $project : current project // $delay : connexion lifetime (in seconds) // $cleanup : delete expired rows // // Start a new session. This function returns a session ID. //============================================================================== function gs_sessionStart ($dbname, $dblink, $project, $delay = 3600, $cleanup = false) { //---------------------------------------------------------------------------- // The cookie name is 'gsite_$project'. $cookieName = "gsite_$project"; global $$cookieName; $cookieValue = (isset ($$cookieName) ? $$cookieName : ''); //---------------------------------------------------------------------------- // Cleanup database. // Cleanup BDD is a way to reduce BDD size. But, if we store all the data, we // can perform a lot of statistics... if ($cleanup) gs_sessionCleanupBdd ($dbname, $dblink, $project); //---------------------------------------------------------------------------- // The right cookie is set ? if ($cookieValue != '') { //-------------------------------------------------------------------------- // We have a session cookie. Is it valid ? if (gs_sessionBddValidateCookie ($dbname, $dblink, $project, $cookieValue, $delay)) { //------------------------------------------------------------------------ // Update database (new END date). gs_sessionBddUpdate ($dbname, $dblink, $cookieValue, $delay); //------------------------------------------------------------------------ // Update cookie (new END date). gs_sessionSetCookie ($cookieName, $cookieValue, $delay); return $cookieValue; } } //---------------------------------------------------------------------------- // No cookie session, or invalid cookie. We build a new one. $cookieValue = gs_sessionCookieValue (); //---------------------------------------------------------------------------- // Adding new session in database. gs_sessionBddAdd ($dbname, $dblink, $project, $cookieValue, $delay); //---------------------------------------------------------------------------- // Setting cookie. gs_sessionSetCookie ($cookieName, $cookieValue, $delay); //---------------------------------------------------------------------------- // Returning cookie value as session ID. return $cookieValue; } //============================================================================== // int gs_sessionCountVisits ($dbname, $dblink, $project) // $dbname : current database // $dblink : MySQL link // $project : current project // // Count access for a project. //============================================================================== function gs_sessionCountVisits ($dbname, $dblink, $project) { $query = "select COUNT(S_ID) as TOTAL". " from $dbname.SESSION". " where S_PROJECT='$project'"; $result = mysql_query ($query, $dblink); if (! $result) { die ("Unable to perform query ($query / " . mysql_error ($dblink) . ")"); } $row = mysql_fetch_object ($result); $total = (! $row ? 0 : $row->TOTAL); mysql_free_result ($result); return $total; } //------------------------------------------------------------------------------ // $Log: session.php,v $ // Revision 1.1.1.1 2002/10/02 07:32:21 root // initialisation site de Tela // // Revision 1.3 2002/03/18 10:46:19 lc // Check IP address, or not. // // Revision 1.2 2002/02/25 16:32:06 lc // echo replaced by die. // // Revision 1.1 2002/01/14 10:27:50 lc // Initial version. // //-- End of source ------------------------------------------------------------ ?>