ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/WEBCONDDB/php_CondDB/utils/configurer.php
Revision: 1.1
Committed: Fri Jun 29 07:53:08 2007 UTC (17 years, 10 months ago) by kdziedzi
Branch: MAIN
CVS Tags: V01-01-02, V01-01-01, V1_01_00, V01-01-00, V1_00_01, HEAD
Error occurred while calculating annotation data.
Log Message:
Introducing new order in project

File Contents

# Content
1 <?php
2 /*
3 * Created on Sep 27, 2006
4 * by Katarzyna Maria Dziedziniewicz
5 * Contains:
6 *
7 *
8 */
9 session_start();
10 class Configurer
11 {
12 function tag_start($parser, $attr, $params)
13 {
14 //echo 'param '.$attr.' val '.$params['VALUE'];
15 $_SESSION[$attr] = $params['VALUE'];
16 }
17
18 function tag_end($parser, $attr)
19 {
20 /// DO NOTHING
21 }
22
23 function parse()
24 {
25 //echo '<br>parsing configuration<br>';
26 $parser = xml_parser_create();
27 xml_set_object ( $parser, $this );
28 xml_set_element_handler ( $parser, 'tag_start', 'tag_end' );
29
30
31 if(!($fp = fopen('configuration/configuration.xml', 'r')))
32 {
33 die('Configuration file configuration.xml cannot be open. Person responsible was contacted');
34 }
35
36
37 while($data = fread($fp, 4096))
38 {
39 if(!xml_parse($parser, $data, feof($fp)))
40 {
41 die(sprintf("Configuration error : %s in line %d",
42 xml_error_string(xml_get_error_code($parser)),
43 xml_get_current_line_number($parser)));
44 }
45 }
46 xml_parser_free($parser);
47 }
48
49 function checkConfig($varName)
50 {
51 if ($_SESSION[$varName] == null)
52 {
53 return false;
54 }
55
56 }
57 }
58
59 function sendErrorInformation($errorMsg, $type = 'internal')
60 {
61
62 if ($type = 'user')
63 {
64 echo $errorMsg;
65 }
66 else
67 {
68 echo '<script type="text/javascript">' .
69 'var er = document.getElementById("error_div");' .
70 'er.textContent="' .
71 'Page encountred an error.
72 System administrator was contacted.
73 Sorry for the inconvinience";
74 er.style.visibility="visible";
75 window.scroll(0,0);' .
76 '</script>
77 ';
78 send_mail('CmsCondWeb page - Error monitoring tested <br>'.$errorMsg);
79 }
80 exit;
81 }
82
83 function send_mail($body)
84 {
85 $eol="\r\n";
86 $mime_boundary=md5(time());
87 $fromaddress = "CMSCondWebPage@cern.ch";
88 $emailsubject = "CmsCondWebPage ERROR";
89
90 # Common Headers
91 $headers .= 'From: CMSCondWebPage<'.$fromaddress.'>'.$eol;
92 $headers .= "Message-ID: <".time()." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
93 $headers .= "X-Mailer: PHP v".phpversion().$eol; // These two to help avoid spam-filters
94
95 $msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol;
96
97 # SEND THE EMAIL
98 ini_set(sendmail_from,$fromaddress); // the INI lines are to force the From Address to be used !
99
100
101
102 mail($_SESSION['CONF_ADMINS'], $emailsubject, $msg, $headers);
103
104 ini_restore(sendmail_from);
105 }
106
107 ?>
108