/** * This function displays any errors or warnings, in a javascript alert if the * browser has scripting enabled. /**/ function display_errors($leading = '<p align="center">', $trailing = '</p>') { global $Errors, $Warnings; // Errors or warnings from a previous page? if (is_array($_SESSION['WARNINGS']) && count($_SESSION['WARNINGS'])) { foreach ($_SESSION['WARNINGS'] as $warning) { $Warnings[] = $warning; } unset($_SESSION['WARNINGS']); } // Nothing to show? if (!errors() && !warnings()) { return; } // Load the errors $js_errstr = ''; if (is_array($Errors) && count($Errors) > 0) { $js_errstr .= "Error:\n" . implode("\n", $Errors); } if (is_array($Warnings) && count($Warnings) > 0) { $js_errstr .= "Warning:\n" . implode("\n", $Warnings); } $errstr = str_replace("\n", "<br />\n", htmlentities($js_errstr)); // Clean up the javascript error string $js_errstr = str_replace("\n", "\\n", str_replace('"', '\\"', preg_replace('/<.*?>/', '', $js_errstr))); // Print echo <<<EOF <script type="text/javascript"> <!-- Event.observe(window, 'load', display_errors); function display_errors() { alert("{$js_errstr}"); }; // --> </script> <noscript> {$leading} <table border="1" cellspacing="0" cellpadding="8" class="error"> <tr> <td>{$errstr}</td> </tr> </table> {$trailing} </noscript> EOF; }
function get_validation_logs() { $valid_logs; $pattern_date = "/^\\d{2}-\\d{2}-\\d{4}\$/i"; if (!preg_match($pattern_date, $this->from) or !preg_match($pattern_date, $this->to)) { $valid_logs[0] = 1; } else { $from = explode("-", $this->from); $to = explode("-", $this->to); $this->day_from = $from[0]; $this->month_from = $from[1]; $this->year_from = $from[2]; $this->day_to = $to[0]; $this->month_to = $to[1]; $this->year_to = $to[2]; settype($this->day_from, 'integer'); settype($this->day_to, 'integer'); settype($this->month_from, 'integer'); settype($this->month_to, 'integer'); settype($this->year_from, 'integer'); settype($this->year_to, 'integer'); if ($this->year_from < 1970 or $this->year_to < 1970 or $this->year_from > 2038 or $this->year_to > 2038) { $valid_logs[1] = 1; } else { if ($this->month_from <= 12 and $this->month_to <= 12 and $this->month_from > 0 and $this->month_to > 0) { switch ($this->month_from) { case 2: if (leap_year($this->year_from) == true) { if ($this->day_from > 29 or $this->day_from == 0) { $valid_logs[2] = 1; } } else { if ($this->day_from > 28 or $this->day_from == 0) { $valid_logs[2] = 1; } } break; case 4: if ($this->day_from > 30 or $this->day_from == 0) { $valid_logs[2] = 1; } break; case 6: if ($this->day_from > 30 or $this->day_from == 0) { $valid_logs[2] = 1; } break; case 9: if ($this->day_from > 30 or $this->day_from == 0) { $valid_logs[2] = 1; } break; case 11: if ($this->day_from > 30 or $this->day_from == 0) { $valid_logs[2] = 1; } break; default: if ($this->day_from > 31 or $this->day_from == 0) { $valid_logs[2] = 1; } } switch ($this->month_to) { case 2: if (leap_year($this->year_to) == true) { if ($this->day_to > 29 or $this->day_to == 0) { $valid_logs[2] = 1; } } else { if ($this->day_to > 28 or $this->day_to == 0) { $valid_logs[2] = 1; } } break; case 4: if ($this->day_to > 30 or $this->day_to == 0) { $valid_logs[2] = 1; } break; case 6: if ($this->day_to > 30 or $this->day_to == 0) { $valid_logs[2] = 1; } break; case 9: if ($this->day_to > 30 or $this->day_to == 0) { $valid_logs[2] = 1; } break; case 11: if ($this->day_to > 30 or $this->day_to == 0) { $valid_logs[2] = 1; } break; default: if ($this->day_to > 31 or $this->day_to == 0) { $valid_logs[2] = 1; } } } else { $valid_logs[2] = 1; } } } if (empty($valid_logs)) { $timestamp_from = strtotime($this->from); $timestamp_to = strtotime($this->to); if ($timestamp_from > $timestamp_to) { $valid_logs[3] = 1; } } warnings($valid_logs); if (empty($valid_logs)) { return false; } else { return true; } }
/** * Callback for createList() * Used to get all issued warnings in the system * Uses warnings function in moderation.subs * * @param int $start * @param int $items_per_page * @param string $sort * @param string $query_string * @param mixed[] $query_params */ public function list_getWarnings($start, $items_per_page, $sort, $query_string, $query_params) { return warnings($start, $items_per_page, $sort, $query_string, $query_params); }
<title>Microfolio :: <?=$admin_title?></title> </head> <iframe id="mainFrame" name="mainFrame" class="ui-layout-center" frameborder="0" scrolling="auto" src=""> </iframe> <div class="ui-layout-west"> <div id="design" > </div> <div id="header" > <div class="in" > <div class="middle" > <a href="#" >Microfolio</a> </div> <div class="left" > <a href="<?=makeUrl('admin/projects');?>" ><?=$admin_title?></a> </div> <div class="right" > <ul id="menu"> <li><a href="<?=makeUrl('admin/settings');?>" >Settings</a></li> <li><a href="<?=makeUrl('admin/help');?>" >Help</a></li> <li class="last" ><a href="<?=makeUrl('logout');?>" >Logout</a></li> </ul> </div> </div> </div> <div class="warnings" > <?=warnings();?> </div> <div id="main" >