2 $monLibrary= dirname(__FILE__) .
"/../library";
3 $sharedLibrary= dirname(__FILE__) .
"/../../shared/library";
4 require_once(
"$monLibrary/cu_top.i");
5 require_once(
"$monLibrary/ck_hticket.i");
6 require_once(
"$sharedLibrary/cu_flagconst.i");
8 if (!CheckPerm($link, $Hu, basename($_SERVER[
'SCRIPT_NAME']), $_SERVER[
'REMOTE_ADDR'])) {
11 header(
"Location: /hcuadm/hcu_noperm.prg");
15 $dms_ok=array(
'action'=>
'string',
'AddChange'=>
'string',
'msg'=>
'string',
16 'sname'=>
'string',
'sstart'=>
'string',
'sstop'=>
'string',
'banner'=>
'string',
17 'todelete'=>
'string',
'bannertext'=>
'string',
'rowid'=>
'string',
'stype'=>
'digits');
19 $cu = strtoupper(prep_save($rowid, 10));
21 $banner = (empty($banner) ?
"" : trim($banner));
22 $self = $_SERVER[
'PHP_SELF'] ;
24 $action = (empty($action) ?
"ok" : $action);
25 $action = strtolower($action);
26 $action = trim($action);
28 $msg = (empty($msg) ?
"NO MESSAGE" : $msg);
30 $today = date(
"m/d/Y");
31 $oneyear = date(
"m/d/Y",mktime (0,0,0,date(
"m"),date(
"d"),date(
"Y")+1));
35 banner_update(
"delete");
38 confirm($banner, $action);
42 banner_update(
"$action");
53 function banner_update($action) {
72 if ($action ==
"add" || $action ==
"save") {
73 $sname = (trim($sname) ==
"" ?
"" : $sname);
74 $sstart = (trim($sstart) ==
"" ?
"$today" : $sstart);
75 $sstop = (trim($sstop) ==
"" ?
"$oneyear" : $sstop);
76 $bannertext = (trim($bannertext) ==
"" ?
"" : $bannertext);
78 # need to check start and stop dates here 79 if (trim($banner) ==
""){ $msg .=
"Please Select a Banner<br>\n"; }
80 if (trim($bannertext) ==
""){ $msg .=
"Please Specify Banner Text<br>\n"; }
81 if (preg_match(
"/^ *$/",$banner)) { $msg .=
"Invalid Banner ID<br>\n";}
82 if (($starttime = strtotime($sstart)) === -1) {
83 $msg .=
"Invalid Start Date<br>\n";
85 list($mm,$dd,$yyyy) = explode(
"/",$sstart);
86 if (!dms_checkdate(
"$mm",
"$dd",
"$yyyy")) {
87 $msg .=
"Invalid Start Date<br>\n";}
89 if (($stoptime = strtotime($sstop)) === -1) {
90 $msg .=
"Invalid Stop Date<br>\n";
92 list($mm,$dd,$yyyy) = explode(
"/",$sstop);
93 if (!dms_checkdate(
"$mm",
"$dd",
"$yyyy")) {
94 $msg .=
"Invalid Stop Date<br>\n";}
96 if ($starttime > $stoptime) {
97 $msg .=
"Start Date must be before Stop Date<br>\n";}
105 $bannertext = str_replace(
'"',
"'", $bannertext);
109 $testbannertext=stripslashes($bannertext);
111 if (php_syntax_error(
"\$bannertext=sprintf ('%s',\"$testbannertext\");")) {
112 $msg .=
"There is a problem with the syntax of the banner text you entered. Please review the text and look for any double quotes or declaration of php variables that may have caused the problem.<br>";
119 $sql =
"delete from cusurveymaster 120 where surveyid='" . intval($banner) .
"' and cu='$cu';";
124 $sql=
"update cusurveymaster set 125 startdate='$sstart', stopdate='$sstop', 127 question='" . prep_save($bannertext) .
"', 128 qstyle='3', runstat=1, 129 employee='Y', inc_balances='Y', 132 where surveyid='" . intval($banner) .
"' and cu='$cu'";
139 $sql =
"insert into cusurveymaster (cu,surveyid, startdate, 140 stopdate, surveyname, question, qstyle, 141 runstat, employee, surveytype, dontshow, inc_balances) 143 '$cu',nextval('cusurveymaster_surveyid_seq'),'$sstart', 144 '$sstop','$sname','" . prep_save($bannertext) .
"', '3', 145 1, 'Y',$stype,'Y','Y');";
150 $sth = db_query($sql,$link);
151 $msg = pg_errormessage();
153 require(
"errormail.i");
155 $notify->line=__LINE__;
156 $notify->file=__FILE__;
157 $notify->callingfunction = __FUNCTION__;
160 $notify->banner=
"$banner";
164 if ($msg ==
"") { update_success($what);}
166 db_free_result($sth);
180 function getbanner($msg) {
196 header(
"Expires: Sat 20 May 1995 03:32:38 GMT");
197 header(
"Pragma: no-cache");
198 header(
"Cache-Control: no-cache, must-revalidate");
200 cu_header(
"Banner Maintenance");
202 <script language=
"JAVASCRIPT">
204 function show_preview(sform)
206 var marker=
"BannerView?cu=$cu";
207 viewwin=window.open(
"",
"_Preview",
"toolbar=1,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,width=600,height=380");
208 document.viewform.viewtext.value=sform.bannertext.value;
209 document.viewform.submit();
213 function validate(mode,sform)
215 var strSurvey = sform.banner.value;
216 var strBanner = sform.bannertext.value;
218 var patSpaces = /^ *$/;
222 if (strSurvey.length == 0)
223 { strMessage +=
"Please Select a Banner Number.\\n";}
224 if (strBanner.length == 0)
225 { strMessage +=
"Please Specify Banner Text.\\n";}
226 if (patSpaces.exec(strSurvey) !=
null)
227 { strMessage +=
"Invalid Banner Number.\\n";}
228 if (strSurvey.indexOf(
"'") != -1 || strSurvey.indexOf(
'"') != -1)
229 { strMessage +=
"Invalid Characters in Banner Number.\\n";}
232 if (strMessage.length > 0)
237 sform.action.value=mode;
248 $sql=
"select surveyid, 249 to_char(startdate,'mm/dd/yyyy'), 250 to_char(stopdate,'mm/dd/yyyy'), 255 and surveytype in (2,3) 256 order by surveytype";
258 $sth = db_query($sql,$link);
262 for ($row=0;list($banner,$sstart,$sstop,$bannertext,$stype) = db_fetch_array($sth,$row); $row++) {
264 $blist[$stype][0]=$banner;
265 $blist[$stype][1]=$sstart;
266 $blist[$stype][2]=$sstop;
267 $blist[$stype][3]=$bannertext;
269 if (
"$msg" !=
"NO MESSAGE") {
271 <table width=95% cellspacing=1 cellpadding=4 border=0>
272 <tr><td
class=
"ahd" align=
'center'><img src=
'/monitor/images/alert.black.gif'>
273 $msg</td></tr></table>
277 <form name=
'viewform' action=
'BannerView?cu=$cu&chome=$rowid' method=
'POST' target=
'_Preview'>
278 <input type=
'hidden' name=
'viewtext' value=
''>
279 <input type=
'hidden' name=
'cu' value=
'$cu'>
280 <input type=
'hidden' name=
'chome' value=
'$rowid'>
283 for ($stype=2;$stype < 3; $stype++) {
284 list ($banner, $sstart,$sstop,$bannertext) = $blist[$stype];
285 $AddChange = ($blist[$stype][0] ==
"" ?
"Add" :
"Save");
286 $banner = ($AddChange ==
"Add" ?
"new" : $banner);
287 $sstart = (trim($sstart) ==
"" ?
"$today" : $sstart);
288 $sstop = (trim($sstop) ==
"" ?
"$oneyear" : $sstop);
289 $sname = ($stype == 2 ?
"Desktop" :
"Mobile");
291 <div align=center><br><form name=
'${sname}form' action=
'$self'>
292 <table width=95% cellspacing=1 cellpadding=4 border=0>
293 <tr><td
class=
'bar' colspan=2 align=center>$cu $sname Banner</td></tr>
294 <tr><td
class=
'dtll' width=
'50%'> </td>
297 if ($banner !=
"new") {
299 <a href=
"$self?rowid=$rowid&banner=$banner&action=delete&sname=$sname"> Delete </a> | <a href=
"javascript:show_preview(document.${sname}form)"> View </a>
301 }
else { print
" ";}
304 <tr><td
class=
'dtlc' valign=top colspan=
'2'>
305 <textarea cols=
'60' rows=
'6' wrap=
'virtual' name=
'bannertext'>$bannertext</textarea>
308 <td
class=
'dtlr'>Effective Dates: </td>
309 <td
class=
'dtll'>
310 <input type=text name=
'sstart' size=
'10' maxlength=
'10' value=
'$sstart'>
312 <input type=text name=
'sstop' size=
'10' maxlength=
'10' value=
'$sstop'>
315 <tr><td
class=
'dtlc' colspan=
'2'>
316 <input type=
'hidden' name=
'stype' value=
'$stype'>
317 <input type=
'hidden' name=
'rowid' value=
'$rowid'>
318 <input type=
'hidden' name=
'banner' value=
'$banner'>
319 <input type=
'hidden' name=
'action' value=
'$AddChange'>
320 <input type=hidden name=
'AddChange' value=
'$AddChange'>
322 <input type=button value=
'$AddChange' onClick=
"validate('$AddChange',this.form);">
323 </td></tr></table></form>
329 function confirm($banner, $action) {
337 getbanner(
"You must select a banner type");
340 header(
"Expires: Sat 20 May 1995 03:32:38 GMT");
341 header(
"Pragma: no-cache");
342 header(
"Cache-Control: no-cache, must-revalidate");
343 cu_header(
"Banner Maintenance");
344 $sname = (trim($sname) ==
"" ?
"" : stripslashes($sname));
347 <div align=center><br><form name=
"form1" action=
"$self">
348 <input type=
"hidden" name=
"rowid" value=
"$rowid">
349 <table width=90% cellspacing=0 cellpadding=4 border=0>
350 <tr><td
class=
"bar" colspan=2 align=center>$cu Banner</td></tr>
352 <tr><td
class=
'ahd' colspan=2 align=center>Warning! This will
delete the $sname banner
for $cu. Do you wish to
continue?</td></tr>
354 <tr><td
class=
"hdr" colspan=2><hr></td>
355 <tr><td
class=
"hdr" align=right>
356 <input type=submit name=
"action" value=
"Yes">
358 <td
class=
"hdr" align=left>
359 <input type=submit name=
"action" value=
"No">
363 <input type=hidden name=
"banner" value=
"$banner">
364 <input type=hidden name=
"todelete" value=
"delete">
369 function update_success($what) {
374 $msg=urlencode(
"Banner $what Successfully");
375 header(
"Location: $main_url?rowid=$rowid&msg=$msg");
377 function disp_msg($msg,$mode) {
378 # return htmlspecialchars(trim(stripslashes($msg))); 381 $msg=htmlentities(trim(stripslashes($msg)),ENT_QUOTES);
385 # translate the htmlspecial character 386 $msg=htmlspecialchars(trim(stripslashes($msg)));
389 # and then put back the numeric entity codes 390 $msg=str_replace(
'&#',
'&#',$msg);
393 function error_exit($reason) {
397 <TABLE BORDER=0 CELLPADDING=6 WIDTH=90%>
398 <tr><td CLASS=
"bar" align=
"center">$cu $pg_ttl
400 <td
class=
'hdr' align=
'center'>
401 Unable to complete your request</td></tr>
402 <tr><td
class=
'dtl' align=
'center'>
413 function php_syntax_error($code){
416 foreach (token_get_all(
'<?php ' . $code) as $token) {
417 if (is_array($token)) {
420 case T_DOLLAR_OPEN_CURLY_BRACES:
421 case T_START_HEREDOC: ++$inString;
break;
422 case T_END_HEREDOC: --$inString;
break;
424 }
else if ($inString & 1) {
427 case '"': --$inString;
break;
432 case '"': ++$inString;
break;
433 case '{': ++$braces;
break;
439 if ($braces < 0)
break 2;
445 $inString = @ini_set(
'log_errors',
false);
446 $token = @ini_set(
'display_errors',
true);
448 $braces || $code =
"if(0){{$code}\n}";
449 if (eval($code) ===
false) {
451 $braces = PHP_INT_MAX;
453 false !== strpos($code,CR) && $code = strtr(str_replace(CRLF,LF,$code),CR,LF);
454 $braces = substr_count($code,LF);
456 $code = ob_get_clean();
457 $code = strip_tags($code);
458 if (preg_match(
"'syntax error, (.+) in .+ on line \d+)$'s", $code, $code)) {
459 $code[2] = (int) $code[2];
460 $code = $code[2] <= $braces
461 ? array($code[1], $code[2])
462 : array(
'unexpected $end' . substr($code[1], 14), $braces);
463 }
else $code = array(
'syntax error', 0);
468 @ini_set(
'display_errors', $token);
469 @ini_set(
'log_errors', $inString);