Do not use global $page variable in form_value_cb func

This commit is contained in:
Dmitriy Simushev 2014-01-16 15:33:31 +00:00
parent d9530d1590
commit 3d907f260e
4 changed files with 31 additions and 24 deletions

View File

@ -29,11 +29,18 @@ function form_value($page, $name) {
return "";
}
function form_value_cb($key)
{
global $page;
if (isset($page) && isset($page["form$key"]))
return $page["form$key"] === true;
/**
* Checks if a form variable is true.
*
* @param array $page The page array. All form variables are prefixed with
* "form" string.
* @param string $name Form variable name.
* @return boolean Returns TRUE only if specified form variable is set, has boolean type
* and equals to TRUE. In all other cases returns FALSE.
*/
function form_value_cb($page, $name) {
if (!empty($page) && isset($page["form$name"]))
return $page["form$name"] === true;
return false;
}

View File

@ -49,7 +49,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="usercanchangename" class="flabel"><?php echo getlocal('settings.usercanchangename') ?></label>
<div class="fvalue">
<input id="usercanchangename" type="checkbox" name="usercanchangename" value="on"<?php echo form_value_cb('usercanchangename') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="usercanchangename" type="checkbox" name="usercanchangename" value="on"<?php echo form_value_cb($page, 'usercanchangename') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="usercanchangename" class="fdescr"> &mdash; <?php echo getlocal('settings.usercanchangename.description') ?></label>
<br clear="all"/>
@ -58,7 +58,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="enablessl" class="flabel"><?php echo getlocal('settings.enablessl') ?></label>
<div class="fvalue">
<input id="enablessl" type="checkbox" name="enablessl" value="on"<?php echo form_value_cb('enablessl') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="enablessl" type="checkbox" name="enablessl" value="on"<?php echo form_value_cb($page, 'enablessl') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="enablessl" class="fdescr"> &mdash; <?php echo getlocal('settings.enablessl.description') ?></label>
<br clear="all"/>
@ -66,7 +66,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="subfield underssl">
<label for="forcessl" class="flabel"><?php echo getlocal('settings.forcessl') ?></label>
<div class="fvalue">
<input id="forcessl" type="checkbox" name="forcessl" value="on"<?php echo form_value_cb('forcessl') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="forcessl" type="checkbox" name="forcessl" value="on"<?php echo form_value_cb($page, 'forcessl') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="forcessl" class="fdescr"> &mdash; <?php echo getlocal('settings.forcessl.description') ?></label>
<br clear="all"/>
@ -76,7 +76,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="enablegroups" class="flabel"><?php echo getlocal('settings.enablegroups') ?></label>
<div class="fvalue">
<input id="enablegroups" type="checkbox" name="enablegroups" value="on"<?php echo form_value_cb('enablegroups') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="enablegroups" type="checkbox" name="enablegroups" value="on"<?php echo form_value_cb($page, 'enablegroups') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="enablegroups" class="fdescr"> &mdash; <?php echo getlocal('settings.enablegroups.description') ?></label>
<br clear="all"/>
@ -84,7 +84,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="subfield undergroups">
<label for="enablegroupsisolation" class="flabel"><?php echo getlocal('settings.enablegroupsisolation') ?></label>
<div class="fvalue">
<input id="enablegroupsisolation" type="checkbox" name="enablegroupsisolation" value="on"<?php echo form_value_cb('enablegroupsisolation') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="enablegroupsisolation" type="checkbox" name="enablegroupsisolation" value="on"<?php echo form_value_cb($page, 'enablegroupsisolation') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="enablegroupsisolation" class="fdescr"> &mdash; <?php echo getlocal('settings.enablegroupsisolation.description') ?></label>
<br clear="all"/>
@ -94,7 +94,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="enablestatistics" class="flabel"><?php echo getlocal('settings.enablestatistics') ?></label>
<div class="fvalue">
<input id="enablestatistics" type="checkbox" name="enablestatistics" value="on"<?php echo form_value_cb('enablestatistics') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="enablestatistics" type="checkbox" name="enablestatistics" value="on"<?php echo form_value_cb($page, 'enablestatistics') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="enablestatistics" class="fdescr"> &mdash; <?php echo getlocal('settings.enablestatistics.description') ?></label>
<br clear="all"/>
@ -103,7 +103,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="enabletracking" class="flabel"><?php echo getlocal('settings.enabletracking') ?></label>
<div class="fvalue">
<input id="enabletracking" type="checkbox" name="enabletracking" value="on"<?php echo form_value_cb('enabletracking') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="enabletracking" type="checkbox" name="enabletracking" value="on"<?php echo form_value_cb($page, 'enabletracking') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="enabletracking" class="fdescr"> &mdash; <?php echo getlocal('settings.enabletracking.description') ?></label>
<br clear="all"/>
@ -112,7 +112,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="enableban" class="flabel"><?php echo getlocal('settings.enableban') ?></label>
<div class="fvalue">
<input id="enableban" type="checkbox" name="enableban" value="on"<?php echo form_value_cb('enableban') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="enableban" type="checkbox" name="enableban" value="on"<?php echo form_value_cb($page, 'enableban') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="enableban" class="fdescr"> &mdash; <?php echo getlocal('settings.enableban.description') ?></label>
<br clear="all"/>
@ -121,7 +121,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="enablepresurvey" class="flabel"><?php echo getlocal('settings.enablepresurvey') ?></label>
<div class="fvalue">
<input id="enablepresurvey" type="checkbox" name="enablepresurvey" value="on"<?php echo form_value_cb('enablepresurvey') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="enablepresurvey" type="checkbox" name="enablepresurvey" value="on"<?php echo form_value_cb($page, 'enablepresurvey') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="enablepresurvey" class="fdescr"> &mdash; <?php echo getlocal('settings.enablepresurvey.description') ?></label>
<br clear="all"/>
@ -129,7 +129,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="subfield undersurvey">
<label for="surveyaskmail" class="flabel"><?php echo getlocal('settings.survey.askmail') ?></label>
<div class="fvalue">
<input id="surveyaskmail" type="checkbox" name="surveyaskmail" value="on"<?php echo form_value_cb('surveyaskmail') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="surveyaskmail" type="checkbox" name="surveyaskmail" value="on"<?php echo form_value_cb($page, 'surveyaskmail') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="surveyaskmail" class="fdescr"> &mdash; <?php echo getlocal('settings.survey.askmail.description') ?></label>
<br clear="all"/>
@ -138,7 +138,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="subfield undersurvey">
<label for="surveyaskgroup" class="flabel"><?php echo getlocal('settings.survey.askgroup') ?></label>
<div class="fvalue">
<input id="surveyaskgroup" type="checkbox" name="surveyaskgroup" value="on"<?php echo form_value_cb('surveyaskgroup') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="surveyaskgroup" type="checkbox" name="surveyaskgroup" value="on"<?php echo form_value_cb($page, 'surveyaskgroup') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="surveyaskgroup" class="fdescr"> &mdash; <?php echo getlocal('settings.survey.askgroup.description') ?></label>
<br clear="all"/>
@ -147,7 +147,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="subfield undersurvey">
<label for="surveyaskmessage" class="flabel"><?php echo getlocal('settings.survey.askmessage') ?></label>
<div class="fvalue">
<input id="surveyaskmessage" type="checkbox" name="surveyaskmessage" value="on"<?php echo form_value_cb('surveyaskmessage') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="surveyaskmessage" type="checkbox" name="surveyaskmessage" value="on"<?php echo form_value_cb($page, 'surveyaskmessage') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="surveyaskmessage" class="fdescr"> &mdash; <?php echo getlocal('settings.survey.askmessage.description') ?></label>
<br clear="all"/>
@ -157,7 +157,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="enablepopupnotification" class="flabel"><?php echo getlocal('settings.popup_notification') ?></label>
<div class="fvalue">
<input id="enablepopupnotification" type="checkbox" name="enablepopupnotification" value="on"<?php echo form_value_cb('enablepopupnotification') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="enablepopupnotification" type="checkbox" name="enablepopupnotification" value="on"<?php echo form_value_cb($page, 'enablepopupnotification') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="enablepopupnotification" class="fdescr"> &mdash; <?php echo getlocal('settings.popup_notification.description') ?></label>
<br clear="all"/>
@ -166,7 +166,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="showonlineoperators" class="flabel"><?php echo getlocal('settings.show_online_operators') ?></label>
<div class="fvalue">
<input id="showonlineoperators" type="checkbox" name="showonlineoperators" value="on"<?php echo form_value_cb('showonlineoperators') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="showonlineoperators" type="checkbox" name="showonlineoperators" value="on"<?php echo form_value_cb($page, 'showonlineoperators') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="showonlineoperators" class="fdescr"> &mdash; <?php echo getlocal('settings.show_online_operators.description') ?></label>
<br clear="all"/>
@ -175,7 +175,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="enablecaptcha" class="flabel"><?php echo getlocal('settings.leavemessage_captcha') ?></label>
<div class="fvalue">
<input id="enablecaptcha" type="checkbox" name="enablecaptcha" value="on"<?php echo form_value_cb('enablecaptcha') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
<input id="enablecaptcha" type="checkbox" name="enablecaptcha" value="on"<?php echo form_value_cb($page, 'enablecaptcha') ? " checked=\"checked\"" : "" ?><?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div>
<label for="enablecaptcha" class="fdescr"> &mdash; <?php echo getlocal('settings.leavemessage_captcha.description') ?></label>
<br clear="all"/>

View File

@ -84,7 +84,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="fieldinrow">
<label for="hostname" class="flabel"><?php echo getlocal("page.gen_button.include_site_name") ?></label>
<div class="fvaluenodesc">
<input id="hostname" type="checkbox" name="hostname" value="on"<?php echo form_value_cb('hostname') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
<input id="hostname" type="checkbox" name="hostname" value="on"<?php echo form_value_cb($page, 'hostname') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
</div>
</div>
@ -93,7 +93,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="fieldinrow">
<label for="secure" class="flabel"><?php echo getlocal("page.gen_button.secure_links") ?></label>
<div class="fvaluenodesc">
<input id="secure" type="checkbox" name="secure" value="on"<?php echo form_value_cb('secure') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
<input id="secure" type="checkbox" name="secure" value="on"<?php echo form_value_cb($page, 'secure') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
</div>
</div>
<?php } ?>
@ -102,7 +102,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="field">
<label for="modsecurity" class="flabel"><?php echo getlocal("page.gen_button.modsecurity") ?></label>
<div class="fvaluenodesc">
<input id="modsecurity" type="checkbox" name="modsecurity" value="on"<?php echo form_value_cb('modsecurity') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
<input id="modsecurity" type="checkbox" name="modsecurity" value="on"<?php echo form_value_cb($page, 'modsecurity') ? " checked=\"checked\"" : "" ?> onchange="this.form.submit();"/>
</div>
</div>

View File

@ -61,7 +61,7 @@ require_once(dirname(__FILE__).'/inc_errors.php');
<div class="fleftlabel">&nbsp;</div>
<div class="fvalue">
<label>
<input type="checkbox" name="isRemember" value="on"<?php echo form_value_cb('isRemember') ? " checked=\"checked\"" : "" ?> />
<input type="checkbox" name="isRemember" value="on"<?php echo form_value_cb($page, 'isRemember') ? " checked=\"checked\"" : "" ?> />
<?php echo getlocal("page_login.remember") ?></label>
</div>
<br clear="all"/>