Пример #1
0
function EchoTab()
{
    $tpl = new templates();
    switch ($_GET["tab"]) {
        case 0:
            return $tml = GeneralSettings();
            break;
        case 1:
            return $html = ReportSettings();
            break;
        case 2:
            return $html = read_conf();
            break;
        default:
            break;
    }
    echo $tpl->_ENGINE_parse_body($html);
}
Пример #2
0
function main()
{
    echo "In main\n";
    _make_conf();
    // read conf
    $conf_file = './my_first.conf';
    $conf = read_conf($conf_file);
    print "got conf\n";
    // db connect
    //$dbh = db_connect($conf['database']);
    $dbh = new DBHandler($conf['database']);
    if ($dbh) {
        print "Connected to " . $dbh->get_host() . "\n";
    }
    insert_department($dbh);
    get_all_departments($dbh);
    update_department($dbh);
    get_specific_departments($dbh);
    get_one_department($dbh);
    get_all_departments_two($dbh);
    delete_department($dbh);
    get_departments_keyed($dbh);
}
Пример #3
0
        foreach ($the_config as $key => $value) {
            if ($value == 'NULL') {
                $value = '';
            }
            if (is_int($value)) {
                $value = intval($value);
            }
            define($key, $value);
        }
    }
}
function filter($input)
{
    if (is_array($input)) {
        while (list($k, $v) = each($input)) {
            if (is_array($input[$k])) {
                while (list($k2, $v2) = each($input[$k])) {
                    $input[$k][$k2] = stripslashes($v2);
                }
                @reset($input[$k]);
            } else {
                $input[$k] = stripslashes($v);
            }
        }
        @reset($input);
    }
}
#读取配置
read_conf(array(PATH_EXTRA_CONF . 'dynamic.ini', PATH_EXTRA_CONF . 'private.ini'));
read_conf(array(PATH_CONF . 'public_' . PUBLIC_INI_FLAG . '.ini'));
function print_requirements_table()
{
    global $called_from_another_script, $path, $saurus_ver;
    $CONF = read_conf();
    # db connect data from config.php
    /*Assign required settings and their values*/
    $php_required_settings_to_check = array("register_globals", "file_uploads", "safe_mode");
    $php_setting_values_required = array(0, 1, 0);
    /*Assign recommended settings and their values*/
    $php_recommended_settings_to_check = array("post_max_size", "upload_max_filesize", "memory_limit");
    $php_setting_values_recommended = array(16, 16, 16);
    /* Directories to check (see also $saurus_ver) */
    $dirs = array($path . "classes/smarty/templates/", $path . "classes/smarty/templates_c/", $path . "classes/smarty/cache/");
    if ($saurus_ver == 3) {
        $dirs[] = $path . "failid/";
    }
    if ($saurus_ver == 4) {
        $dirs[] = $path . "public/";
        $dirs[] = $path . "shared/";
        $dirs[] = $path . "extensions/";
    }
    /* Get module information from phpinfo() */
    ob_start();
    phpinfo();
    $phpinfo = ob_get_contents();
    ob_end_clean();
    /* Find out if the webserver is running PHP asi CGI or as module 
    
    	Possible php_sapi_name() return values:
    
    	- aolserver
    	- activescript
    	- apache
    	- cgi-fcgi
    	- cgi
    	- isapi
    	- nsapi
    	- phttpd
    	- roxen
    	- java_servlet
    	- thttpd
    	- pi3web
    	- apache2filter
    	- caudium
    	- apache2handler
    	- tux
    	- webjames
    	- cli
    	- embed
    	- milter 
    
    	*/
    ## PHP running as CGI or FASTCGI
    if (php_sapi_name() == "cgi" || php_sapi_name() == "fcgi") {
        $mod_rewrite = -1;
        //mod_rewrite status unknown, because as CGI, phpinfo() doesn't show anything about loaded apache modules
    } else {
        //if PHP is running as module (php_sapi_name() == apache)
        /* Get module information from phpinfo() */
        if (strstr($phpinfo, "mod_rewrite")) {
            $mod_rewrite = 1;
        }
        //mod_rewrite exists
        //if $mod_rewrite doesn't exist up to this point, server is running PHP as module and it won't be shown by phpinfo()
    }
    ## if ISP==Zone then "mod_rewrite = YES"
    # (it's complicated to detect mod_rewrite module presence in PHP CGI mode)
    if ($_ENV['DZSP_CP_URL'] != '') {
        $mod_rewrite = 1;
        //mod_rewrite exists
    }
    /* Get PHP settings from php.ini */
    $ini = ini_get_all();
    /* Check if required and recommended settings and their value counts match */
    if (count($php_required_settings_to_check) != count($php_setting_values_required)) {
        die(" Count of php_required_settings_to_check and php_setting_values_required do not match!");
    }
    if (count($php_recommended_settings_to_check) != count($php_setting_values_recommended)) {
        die(" Count of php_recommended_settings_to_check and php_setting_values_recommended do not match!");
    }
    ############ styles
    ?>
	<style type="text/css">
	<!--
	/* Headline */
	<?php 
    if (!$path) {
        ?>
	.plk {font-size: 16px; font-family: Arial,Helvetica; color: #255AA6; font-weight: bold;}
	<?php 
    } else {
        ?>
	.plk { font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 14px; color: #333333; line-height: 16pt; font-weight: bold}
	<?php 
    }
    ?>
	/* Table */
	.scms_pane_header { font-family: Tahoma, Verdana, Helvetica; font-size: 13px; color: #FFFFFF; background-color: <?php 
    echo $path ? '#4040A9' : '#255AA6';
    ?>
; font-weight: bold; padding-right: 5px; padding-left: 8px; height: 30px}
	.scms_pane_header { font-family: Tahoma, Verdana, Helvetica; font-size: 11px; color: #333333; background-color: #CCCCCC; font-weight: bold; padding-right: 5px; padding-left: 6px; height: 22px }
	.r1 { height: 22px; font-family: Tahoma, Verdana, Helvetica; font-size: 11px; color: #333333; background-color: #FFFFFF; padding-right: 5px; padding-left: 6px; line-height: 16px; vertical-align: top}
	.r2 { height: 22px; font-family: Tahoma, Verdana, Helvetica; font-size: 11px; color: #333333; background-color: #F0F0F0; padding-right: 5px; padding-left: 6px; line-height: 16px; vertical-align: top }
	-->
	</style>
	<?php 
    ?>
<?php############ / styles?>

	<?php 
    ?>
<?php##################### HTML START #################?>
	<?php 
    if (!$called_from_another_script) {
        ?>
	<font class="plk">Server requirements</font>
	<br>
	<br>
	<?php 
    }
    ?>

	<table border="0" cellspacing="0" cellpadding="3" width="<?php 
    echo $called_from_another_script ? '580' : '100%';
    ?>
">
	<tr class="scms_tableheader"> 
		<td>Setting</td><td>Required value</td><td>Local value</td>
	</tr>
	<?php 
    ?>
<?php##################### DATABASE and WEBSERVER #################?>
	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">Database and Webserver</td>
	</tr>
	<?php 
    if (is_array($CONF)) {
        # conf file settings
        if (($conn = @mysql_connect($CONF['dbhost'] . ":" . $CONF['dbport'], $CONF['user'], $CONF['passwd'])) && $CONF['db']) {
            if ($dbh = @mysql_select_db($CONF['db'], $conn)) {
                $res = @mysql_fetch_array(@mysql_query("SELECT VERSION()"));
                $mysql_version = $res[0];
            }
            # dbh
        }
        # conn
    }
    if (!$mysql_version) {
        $word = 'Unknown (this value is OK during installation)';
    }
    ####### MYSQL version: 4.x - 5.1.35
    if (!$mysql_version || version_compare($mysql_version, "4.0") < 0 || version_compare($mysql_version, "5.6.20") > 0) {
        $color = "color='red'";
    } else {
        $color = "color='black'";
    }
    echo "<tr><td><font " . $color . ">MySQL version</font></td><td><font " . $color . ">4.x - 5.1.35</font></td><td><font " . $color . ">" . ($mysql_version ? $mysql_version : $word) . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ######## apache
    $tmp_arr = explode(")", $_SERVER['SERVER_SOFTWARE']);
    $webserver = $tmp_arr[0] . ($tmp_arr[1] ? ")" : "");
    if (!stristr(strtolower($webserver), 'apache')) {
        $color = "color='red'";
    }
    echo "<tr><td><font " . $color . ">Webserver software</font></td><td><font " . $color . ">Apache</font></td><td><font " . $color . ">" . ($webserver ? $webserver : 'Not found') . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ######## mod_rewrite
    if ($mod_rewrite == 1) {
        $color = "color='black'";
        $word = "Yes";
    } elseif ($mod_rewrite == -1) {
        $color = "color='red'";
        $word = "Unknown";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    echo "<tr><td><font " . $color . ">Apache module \"mod_rewrite\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ?>
	<?php 
    ?>
<?php##################### REQUIRED PHP #################?>

	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">Required PHP Settings</td>
	</tr>
	<?php 
    ####### PHP version: 5.0.0 - 5.6.3
    if (version_compare(phpversion(), "5.3.0") < 0 || version_compare(phpversion(), "5.6.2") > 0) {
        $color = "color='red'";
    }
    echo "<tr><td><font " . $color . ">PHP version</font></td><td><font " . $color . ">5.3.0 - 5.6.2</font></td><td><font " . $color . ">" . phpversion() . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ####### mysql support in php
    if (function_exists('mysql_connect')) {
        $word = "Yes";
        $color = "color='black'";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    echo "<tr><td><font " . $color . ">MySQL Support enabled</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    $color = "color='black'";
    //restore default color
    ####### php flags/values
    reset($php_required_settings_to_check);
    for ($i = 0; $i < count($php_required_settings_to_check); $i++) {
        //$current_setting = $php_required_settings_to_check[$i];
        if ($php_setting_values_required[$i] != (int) $ini[$php_required_settings_to_check[$i]][local_value]) {
            $color = "color='red'";
        }
        if ($ini[$php_required_settings_to_check[$i]][local_value] == 0) {
            $local_value = "Off";
        } else {
            $local_value = "On";
        }
        if ($php_setting_values_required[$i] == 0) {
            $required_value = "Off";
        } else {
            $required_value = "On";
        }
        echo "<tr><td><font " . $color . ">{$php_required_settings_to_check[$i]}</font></td><td><font " . $color . ">{$required_value}</font></td><td><font " . $color . ">{$local_value}</font></td></tr>";
        $color = "color='black'";
        //restore default color
    }
    /* Check for track_vars. track_vars is  always enabled since PHP 4.0.3 */
    if (version_compare(phpversion(), "4.0.3") < 0) {
        # If version is < 4.0.3 => then check, if phpinfo has "enable-track-vars". If not, then track_vars=OFF.
        if (!strstr($phpinfo, "enable-track-vars")) {
            $local_value = "Off";
            $color = "color='red'";
        } else {
            $local_value = "On";
            $color = "color='black'";
        }
    } else {
        $local_value = "On";
        $color = "color='black'";
    }
    echo "<tr><td><font " . $color . ">track_vars</font></td><td><font " . $color . ">On</font></td><td><font " . $color . ">{$local_value}</font></td></tr>";
    # check for mbstring
    if (!strstr($phpinfo, "mbstring")) {
        # mbstring not found
        $local_value = "No";
        $color = "color='red'";
    } else {
        # mbstring exists
        $local_value = "Yes";
        $color = "color='black'";
    }
    echo "<tr><td><font " . $color . ">mbstring support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $local_value . "</font></td></tr>";
    ?>

	<?php 
    ?>
<?php##################### RECOMMENDED PHP #################?>

	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">Recommended PHP Settings</td>
	</tr>
	<?php 
    reset($php_recommended_settings_to_check);
    for ($i = 0; $i < count($php_recommended_settings_to_check); $i++) {
        echo "<tr><td>{$php_recommended_settings_to_check[$i]}</td><td>{$php_setting_values_recommended[$i]}</td><td>" . (int) $ini[$php_recommended_settings_to_check[$i]][local_value] . "</td></tr>";
        $color = "color='black'";
        //restore default color
    }
    ?>

	<?php 
    ?>
<?php##################### GD library #################?>

	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">GD library</td>
	</tr>
	<?php 
    ######## GD
    #$gdinfo = gd_info();
    #printr($gdinfo['GD Version']);
    if (function_exists('imagetypes') && ImageTypes() & IMG_PNG) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PNG Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagetypes') && ImageTypes() & IMG_GIF) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: GIF Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagetypes') && ImageTypes() & IMG_JPG) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: JPG Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagetypes') && ImageTypes() & IMG_JPEG) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: JPEG Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagetypes') && ImageTypes() & IMG_WBMP) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: WBMP Support</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    ### GD functions:
    if (function_exists('getimagesize')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"getimagesize\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imageCreateTrueColor')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imageCreateTrueColor\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagecreatefromjpeg')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imagecreatefromjpeg\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagecopyresampled')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imagecopyresampled\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagesx')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imagesx\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    if (function_exists('imagesy')) {
        $color = "color='black'";
        $word = "Yes";
    } else {
        $color = "color='red'";
        $word = "No";
    }
    $i++;
    echo "<tr><td><font " . $color . ">GD: PHP function \"imagesy\"</font></td><td><font " . $color . ">Yes</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    ?>


	<?php 
    ?>
<?php##################### FILESYSTEM #################?>

	<tr class="scms_pane_header"> 
		<td nowrap colspan="4">Filesystem permissions</td>
	</tr>

	<?php 
    foreach ($dirs as $value) {
        # check if exists
        if (file_exists($value)) {
            if (is_writeable($value)) {
                $color = "color='black'";
                $word = "Writable";
            } else {
                $color = "color='red'";
                $word = "Not writable";
            }
        } else {
            $color = "color='red'";
            $word = "Not found";
        }
        # exists
        $i++;
        echo "<tr><td><font " . $color . ">" . $value . "</font></td><td><font " . $color . ">Writable</font></td><td><font " . $color . ">" . $word . "</font></td></tr>";
    }
    ?>
	</table>
	<?php 
}
Пример #5
0
<?php

define('TEMPLATE_DIR', dirname(__FILE__) . '/new_app_files');
$APP = array();
read_conf('NAME');
if (!preg_match('/^[a-z0-9-\\.]+$/i', $APP['NAME'])) {
    echo "Error: Invalid APP.NAME\n";
    die;
}
read_conf('DOMAIN');
read_conf('PHP_FPM.PORT');
$ret = generate();
if ($ret !== false) {
    echo "Done!\n";
    echo "\n";
}
function generate()
{
    global $APP;
    $app_dir = getcwd() . '/' . $APP['NAME'];
    if (file_exists($app_dir)) {
        echo "\n";
        echo "Warnning: App path[{$app_dir}] already exists!\n";
        echo "Overwrite?(n/y): ";
        $line = strtolower(trim(fgets(STDIN)));
        if ($line !== 'y') {
            die;
        }
    }
    echo "\n";
    echo "Generate app into: {$app_dir} ...\n";