root/modules/branches/2.7/logfiles/page.logfiles.php

Revision 8493, 2.8 kB (checked in by mbrevda, 3 years ago)

replace str_ireplace with str_replace for old men still using php4

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1 <?php
2
3 $display = $_REQUEST['display'];
4 $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'tool';
5 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
6 $lines=isset($_REQUEST['lines'])?ereg_replace("[^0-9]", "",$_REQUEST['lines']):'';
7
8 ?>
9 </div>
10 <div class="content">
11 <?php
12 if(!$lines){$action='';}//promts for lines if its not set
13 switch($action) {
14   case 'showlog':
15   $color = array(
16   chr(27).'[0;33;40m' => '<span class="brown">',
17   chr(27).'[0;36;40m' => '<span class="cyan">',
18   chr(27).'[1;30;40m' => '<span class="black">',
19   chr(27).'[1;31;40m' => '<span class="red">',
20   chr(27).'[1;32;40m' => '<span class="green">',
21   chr(27).'[1;33;40m' => '<span class="yellow">',
22   chr(27).'[1;34;40m' => '<span class="blue">',
23   chr(27).'[1;35;40m' => '<span class="magenta">',
24   chr(27).'[1;36;40m' => '<span class="cyan">',
25   chr(27).'[0;37;40m' => '<span class="black">',//this should really be white - but that would leave text unreadable on the white background of the page
26  
27   chr(27).'[1;40m' => '<span class="bold">',
28   chr(27).'[4;40m' => '<span class="underline">',
29  
30   chr(27).'[0;40m'   => '</span>',
31 );
32 ?> 
33     <style type="text/css">
34     .brown{color:brown;}
35     .cyan{color:cyan;}
36     .black{color:black;}
37     .red{color:red;}
38     .orange{color:orange;}
39     .green{color:green;}
40     .yellow{color:yellow;}
41     .blue{color:blue;}
42     .magenta{color:magenta;}
43     .cyan{color:cyan;}
44     .white{color:white;}
45     .bold{font-weight: bold;}
46     .underline{text-decoration:underline;}
47     .pre{font-family:"Courier New", Courier, monospace;font-size:0.85em}
48     </style>
49     <h2>
50       <?php echo sprintf(_('%s - last %s lines'),$amp_conf['ASTLOGDIR']."/full",$lines) ?>
51     </h2>
52     <a href="config.php?<?php echo "display=$display&type=$type&action=showlog&lines=$lines"?>"><?php echo sprintf(_('Redisplay Asterisk Full debug log (last %s lines)'),$lines) ?></a><br>
53     <hr><br>
54     <?php
55       exec('tail -n'.$lines.' '.$amp_conf['ASTLOGDIR'].'/full | sed -e "s,<,\&lt;,g;s,>,\&gt;,g;s/$/<br>/"',$log);
56       echo '<div class="pre">';
57       foreach($log as $l){
58         if(strpos($l, 'WARNING')){$l='<span class="orange">'.$l.'</span>';}
59         if(strpos($l, 'DEBUG')){$l='<span class="green">'.$l.'</span>';}
60         if(strpos($l, 'NOTICE')){$l='<span class="blue">'.$l.'</span>';}
61         if(strpos($l, 'ERROR')){$l='<span class="red">'.$l.'</span>';}
62         $l=str_replace(array_keys($color), $color, $l);
63         echo $l;
64       }
65 echo '</div>';
66     break;
67
68   default:
69     echo "<h2>"._("Asterisk Log Files")."</h2>";
70 ?>
71         <form action="config.php?<?php echo "display=$display&type=$type&action=showlog"?>" method="post">
72         <?php echo _('Display Asterisk Full debug log. How many lines would you like to display?')?><br>
73         <input type="text" name="lines" value="500">
74         <input type="submit" value="<?php echo _('View log');?>" />
75         </form>
76         <br><br><br><br><br><br><br><br><br><br><br><br>
77 <?php
78     break;
79 }
80 ?>
81 </div>
Note: See TracBrowser for help on using the browser.