]*)>#' => ' ', '# #' => '', '# +#' => '', '#<[/]?(link|font|span|xml|del|ins|[ovwxp]:\w+)[^>]*?>#mis' => '', '##mis' => '', '#<([^>]*)(?:class|lang|face|[ovwxp]:\w+)=(?:\'[^\']*\'|""[^""]*""|[^\s>]+)([^>]*)>#' => '<\1\4>', '#

#' => '
', '|#e0|' => 'agrave', '|#e8|' => 'egrave', '|#f2|' => 'ograve', '|\bE\' |' => 'È ', ); } $text = preg_replace(array_keys($__UNREGEXP), array_values($__UNREGEXP), $text); // $text = str_replace(array_keys($__UNWORD), array_values($__UNWORD), $text); return $text; } function getInfoBlock($text) { $default = array( 'date' => 0, 'title' => 'Titolo Sconosciuto', 'author'=> 'N/A', ); if (!preg_match('//ms', $text, $gregs)) return $default; return array_merge($default, unserialize(gzuncompress(base64_decode($gregs[1])))); } function setInfoBlock($var) { $default = array( 'date' => time(), 'title' => 'Titolo Sconosciuto', 'author'=> $_SESSION['user'], ); return ''; } function clearInfoBlock($text) { return preg_replace('/\s*\s*/ms', '', $text); } if (isset($_REQUEST['h'])) { $_REQUEST['p'] = $_REQUEST['h']; $template = file_get_contents('static/helptemplate.html'); } else if (isset($_REQUEST['print'])) { $_REQUEST['p'] = $_REQUEST['print']; $template = file_get_contents('static/print.html'); } else $template = file_get_contents('static/template.html'); // Qui i default... $xlat = array(); preg_match_all('/({{{[^}]*}}})/ms', $template, $gregs); foreach($gregs[1] as $var) $xlat[$var] = ''; if (!isset($_REQUEST['m'])) $module = 'showpage'; else $module = basename($_REQUEST['m']); if (isset($_REQUEST['p'])) $p = basename($_REQUEST['p']); else $p = 'home'; require 'modules/menucode.php'; $giorno = $giorni[(int)date('w')]; $mese = $mesi[(int)date('m')-1]; $xlat['{{{MAINMENU}}}'] = $menucode; $xlat['{{{CONTROLPANEL}}}'] = ''; $xlat['{{{URI}}}'] = urlencode("http://$_SERVER[SERVER_NAME]$_SERVER[SCRIPT_NAME]?$_SERVER[QUERY_STRING]"); $caps = $public_modules; if (isset($_SESSION['cap']) && is_array($_SESSION['cap'])) $caps = $_SESSION['cap']; else $_SESSION['cap'] = $caps; if (!in_array($module, $public_modules)) if (!in_array($module, $caps)) { if (isset($aka_modules[$module])) { $aka = $aka_modules[$module]; if (!in_array($aka, $caps)) $module = 'showpage'; } else { $module = 'showpage'; } } if (file_exists("modules/$module.php")) { include "modules/$module.php"; if (file_exists($hlp = "static/help$module.html")) { $helpbody = file_get_contents($hlp); $xlat['{{{HELP}}}'] = <<Aiuto
$helpbody
HELPTEXT; } } else die("Modulo richiesto ($module) non installato o non esistente."); if (!isset($_SESSION['user_full_name'])) $xlat['{{{USER}}}'] = 'Anonimo'; else $xlat['{{{USER}}}'] = $_SESSION['user_full_name']; $xlat['{{{DATA}}}'] = $giorno . date(' d ') . $mese . date(' Y'); if (!isset($_SESSION['user'])) { $xlat['{{{LOGIN}}}'] = <<Login
Nome utente:

Password:

Ricordati di me

Hai perso la password?
Registrati ora
LOGIN_CODE; } else { $xlat['{{{LOGIN}}}'] = <<
Logout
LOGOUT_CODE; if (isset($ptxt) && !isset($_DONT_EDIT)) if (in_array('editor', $caps)) $xlat['{{{CONTENT}}}'] .= '
'; /* I menu amministrativi */ $extra = ''; foreach($caps as $i => $thiscap) { if (file_exists("modules/$thiscap.php")) { if (file_exists("images/$thiscap.png")) { $mdesc = $thiscap; if (isset($alldesc) && isset($alldesc[$mdesc])) $mdesc = $alldesc[$mdesc]; $extra .= "\"$mdesc\""; } } } if ('' != $extra) $xlat['{{{CONTROLPANEL}}}'] .= <<
Strumenti
$extra
CONTROLPANEL; } function newsMaker($section, $w, $h, $options) { GLOBAL $outScript, $db; $textbox = ''; $defaults = array( 'scroll' => 1, 'header' => 1, 'items' => 999, 'range' => 200, ); $optz = explode(',', $options); $options= array(); foreach($optz as $opt) { list($optkey, $optval) = explode('=', $opt . '='); $optkey = trim($optkey); $optval = trim($optval); $options[$optkey] = $optval; } $options = array_merge($defaults,$options); if ($options['scroll']) if (!isset($outScript)) { $textbox .= ''; $outScript = true; } $w20 = $w + 28; $hk = (int)$h; if ($hk == $h) $h .= 'px'; $section = preg_replace('/[^a-z_0-9 -]+/', '', $section); if ('all' == $section) $where = ''; else $where = "WHERE sezione='$section'"; if (!($result = $db->sql_query("SELECT * FROM news $where ORDER BY orario DESC LIMIT 32;"))) { return "NEWS: error in query: " . mysql_error(); } $rows = $db->sql_numrows($result); $rr = $options['range']; if ($options['scroll']) { // era $hk $textbox .= << function Scroll_{$w}_{$rr}() { var scr1 = new dw_scroller('cnt', $w, $rr, $rows, "v", true); scr1.setTiming(100, 2000); } NEWSBOXSCROLL; $scroller = "onload=\"Scroll_{$w}_{$rr}()\""; $itemstyle = "style=\"width: {$w}px; height: $h;\""; $itemborder = ''; } else { $scroller = ''; $wx = $w - 10; $itemstyle = "style=\"width: {$wx}px; padding-bottom: 2px; border-bottom: 2px dotted black;\""; $itemborder = 'overflow: visible;'; } if ($options['header']) $image = 'style="align: bottom;"'; else $image = 'width="1" height="1" style="display: none;"'; $textbox .= <<
NEWSBOX; $copybox = ''; $num = 0; if (!file_exists($ned = 'static/newsentry.html')) { $newsEntry = << [iflink]

[icona] [titolo]

[else]

[icona] [titolo]

[endlink]

[sommario]

...

NEWSENTRYDEFAULT; $fp = fopen($ned, 'w'); fwrite($fp, $newsEntry); fclose($fp); } else $newsEntry = file_get_contents($ned); $spool = ''; while($row = $db->sql_fetchrow($result)) { if ($num++ == $options['items']) break; if (0 === strpos($row['url'], '?p=')) $target = ''; else $target = 'target="_blank"'; if ('' == $row['icona']) { /// $icon = ''; $row['showicon'] = 'none'; } else { /// $icon = "\"$row[icona]\""; $row['showicon'] = 'block'; } if ('' != trim($row['completo'])) { $row['showdetails'] = 'block'; } else { $row['showdetails'] = 'none'; } if ('' != ($row['url'] = trim($row['url']))) { $row['iflink'] = '
'; $row['else'] = '
'; $row['endlink'] = '
'; } else { $row['iflink'] = '
'; $row['else'] = '
'; $row['endlink'] = '
'; } $text = preg_replace("/[[]([a-z]*)[]]/em", 'isset($row["\1"])? $row["\1"] : ""', $newsEntry); //if ('' == $copybox) // $copybox = $text; $spool .= $text; } $textbox .= $spool; $textbox .= $spool; $textbox .= "
"; return $textbox; } function QuickMaker($section, $w, $h, $options) { GLOBAL $outScript, $db; $textbox = ''; $defaults = array( 'items' => 999, ); $optz = explode(',', $options); $options= array(); foreach($optz as $opt) { list($optkey, $optval) = explode('=', $opt . '='); $optkey = trim($optkey); $optval = trim($optval); $options[$optkey] = $optval; } $options = array_merge($defaults,$options); $w20 = $w + 28; $section = preg_replace('/[^a-z_0-9 -]+/', '', $section); if ('all' == $section) $where = ''; else $where = "WHERE sezione='$section'"; if (!($result = $db->sql_query("SELECT * FROM news $where ORDER BY orario DESC LIMIT 32;"))) { return "NEWS: error in query: " . mysql_error(); } $rows = $db->sql_numrows($result) + 1; if ($options['header']) $image = 'style="align: bottom;"'; else $image = 'width="1" height="1" style="display: none;"'; $textbox .= << NEWSBOX; $copybox = ''; $num = 0; if (!file_exists($ned = 'static/newsentry.html')) { $newsEntry = << [iflink]

[icona] [titolo]

[else]

[icona] [titolo]

[endlink]

[sommario]

...

NEWSENTRYDEFAULT; $fp = fopen($ned, 'w'); fwrite($fp, $newsEntry); fclose($fp); } else $newsEntry = file_get_contents($ned); while($row = $db->sql_fetchrow($result)) { if ($num++ == $options['items']) break; if (0 === strpos($row['url'], '?p=')) $target = ''; else $target = 'target="_blank"'; if ('' == $row['icona']) $row['showicon'] = 'none'; else $row['showicon'] = 'block'; if ('' != trim($row['completo'])) $row['showdetails'] = 'block'; else $row['showdetails'] = 'none'; if ('' != ($row['url'] = trim($row['url']))) { $row['iflink'] = '
'; $row['else'] = '
'; $row['endlink'] = '
'; } else { $row['iflink'] = '
'; $row['else'] = '
'; $row['endlink'] = '
'; } $text = preg_replace("/[[]([a-z]*)[]]/em", 'isset($row["\1"])? $row["\1"] : ""', $newsEntry); if ('' == $copybox) $copybox = $text; $textbox .= $text; } if (999 == $options['items']) $textbox .= $copybox; $textbox .= ""; return $textbox; } function includeBlock($name, $print, $style) { $page = './static/' . basename($name); if (!file_exists($page)) $contents = "missing include: $name"; else $contents = decodeSyntax(clearInfoBlock(file_get_contents($page)), $print, false); return "
$contents
"; } function decodeSyntax($contents, $print, $recurse = true) { $spUrls = array( '/{{{\?(\w+)\?}}}/' => '', '/{{{\!(\w+)\|([^!]+)\!}}}/' => '\2', '/{{{=([^{}]*)\(ICONA\)([^{}]*)=}}}/' => $print, /* PDF */ '/{{{\s*(\w\w\w):([A-Za-z0-9_\.-]+\.pdf)\s*}}}/' => '', /* --- */ '/{{{\s*(\w\w\w):([A-Za-z0-9_\.-]+)\s*}}}/' => '', '/{{{\s*show([a-z]*):([A-Za-z0-9_\.-]+)\s*}}}/' => '\\2', '/{{{NEWS:([a-z]+):([0-9]+):([0-9%]+):*([a-z0-9=,]*)}}}/e' => 'newsMaker(\'\1\',\2,\'\3\',\'\4\')', '/{{{NEWS2:([a-z]+):([0-9]+):([0-9%]+):*([a-z0-9=,]*)}}}/e' => 'QuickMaker(\'\1\',\2,\'\3\',\'\4\')', '/{{{--+}}}/' => '
', '/{{{-+ (.*?) -+}}}/' => '
', ); if ($recurse) $spUrls['/{{{include:(\w+):*([^}]*)}}}/e'] = "includeBlock('\\1','$print','\\2')"; return preg_replace(array_keys($spUrls), array_values($spUrls), $contents); } $challenge = array_keys($xlat); $response = array_values($xlat); $contents = str_replace($challenge, $response, $template); if ('editor' != $module) { $print = ''; if (isset($ptxt) && !isset($_REQUEST['print'])) $print = "\\1\\2"; $contents= decodeSyntax($contents, $print); } Header('Content-Type: text/html; charset=UTF-8;'); print $contents; // print "
";
	// print_r($_SESSION);
?>