Beispiel #1
0
function sql_connect_maintenance()
{
    global $tpl, $db, $opt;
    sql_connect($opt['db']['maintenance_user'], $opt['db']['maintenance_password'], false);
    if ($db['dblink'] === false) {
        sql_disconnect();
        sql_connect();
        if ($db['connected'] == false) {
            $tpl->error(ERROR_DB_COULD_NOT_RECONNECT);
        }
        return false;
    }
    return true;
}
function db_update($table, $fields, $pk = '', $show_query = 0)
{
    // ej: $err=db_update('users',array('pass','user_name'),('id','id2'),1);
    // include("conexion.php");
    if ($pk != '') {
        $query = 'update ' . $table . ' set ';
        $total_fields_pk = count($pk);
        $cant_fields_pk = 1;
    } else {
        $query = 'insert ignore into ' . $table . ' set ';
    }
    $total_fields = count($fields);
    $cant_fields = 1;
    foreach ($fields as $field => $field_value) {
        if ($field == 'pass' || $field == 'password') {
            $query .= $field . " = '" . md5(cleanQuery($field_value)) . "' ";
        } else {
            $query .= $field . " = '" . cleanQuery($field_value) . "' ";
        }
        if ($total_fields != $cant_fields) {
            $query .= ' , ';
        }
        $cant_fields++;
    }
    if ($pk != '') {
        $query .= ' where ';
        foreach ($pk as $field => $field_value) {
            $query .= $field . " = '" . cleanQuery($field_value) . "' ";
            if ($total_fields_pk != $cant_fields_pk) {
                $query .= ' and ';
            }
            $cant_fields_pk++;
        }
    }
    if ($show_query != 0) {
        echo $query . '<br />';
    }
    //file_put_contents('request.txt', $query, FILE_APPEND);
    sql_connect();
    if (mysql_query($query)) {
        return mysql_insert_id();
        sql_disconnect();
    } else {
        return mysql_insert_id();
        sql_disconnect();
    }
}
Beispiel #3
0
function showInstallForm()
{
    // 0. pre check if all necessary files exist
    doCheckFiles();
    ?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
		<title><?php 
    echo _TITLE;
    ?>
</title>
		<style type="text/css"><!--
			@import url('../nucleus/documentation/styles/manual.css');
		--></style>
		<script type="text/javascript"><!--
			var submitcount = 0;

			// function to make sure the submit button only gets pressed once
			function checkSubmit() {
				if (submitcount == 0) {
					submitcount++;
					return true;
				} else {
					return false;
				}
			}
		--></script>
	</head>
	<body>
		<div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php 
    echo _ALT_NUCLEUS_CMS_LOGO;
    ?>
" /></div> <!-- Nucleus logo -->
		<form method="post" action="index.php">
		
		<h1><?php 
    echo _HEADER1;
    ?>
</h1>
		
		<?php 
    echo _TEXT1;
    ?>
		
		<h1><?php 
    echo _HEADER1_2;
    ?>
</h1>
		
		<?php 
    echo _TEXT1_2;
    ?>
		
		<fieldset>
			<legend><?php 
    echo _TEXT1_2_TAB_HEAD;
    ?>
</legend>
			<table>
				<tr>
					<td><?php 
    echo _TEXT1_2_TAB_FIELD1;
    ?>
</td>
					<td>
						<select name="charset" tabindex="10000">
							<option value="utf8" selected="selected">UTF-8</option>
							<option value="ujis" >EUC-JP</option>
						</select>
					</td>
				</tr>
			</table>
		</fieldset>
		
		<h1><?php 
    echo _HEADER2;
    ?>
</h1>
		
		<?php 
    echo _TEXT2;
    ?>
		
		<ul>
			<li>PHP:
<?php 
    echo phpversion();
    ?>
			</li>
			<li>MySQL:
<?php 
    // Turn on output buffer
    // Needed to repress the output of the sql function that are
    // not part of php (in this case the @ operator doesn't work)
    ob_start();
    // note: this piece of code is taken from phpMyAdmin
    $conn = sql_connect_args('localhost', '', '');
    $result = @sql_query('SELECT VERSION() AS version', $conn);
    if ($result != FALSE && sql_num_rows($result) > 0) {
        $row = sql_fetch_array($result);
        $match = explode('.', $row['version']);
    } else {
        $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);
        if ($result != FALSE && @sql_num_rows($result) > 0) {
            $row = sql_fetch_row($result);
            $match = explode('.', $row[1]);
        } else {
            $output = function_exists('shell_exec') ? @shell_exec('mysql -V') : '0.0.0';
            preg_match('#[0-9]+\\.[0-9]+\\.[0-9]+#', $output, $version);
            $match = explode('.', $version[0]);
            if ($match[0] == '') {
                $match[0] = '0';
                $match[1] = '0';
                $match[2] = '0';
            }
        }
    }
    @sql_disconnect($conn);
    //End and clean output buffer
    ob_end_clean();
    $mySqlVersion = implode($match, '.');
    $minVersion = '3.23';
    if (version_compare($mySqlVersion, '0.0.0', '==')) {
        echo _NOTIFICATION1;
    } else {
        echo $mySqlVersion;
    }
    if (version_compare($mySqlVersion, $minVersion, '<')) {
        echo ' <span class="warning" style="display:block">' . sprintf(_TEXT2_WARN1, $minVersion) . '</span>';
    }
    ?>
			</li>
		</ul>
<?php 
    if (phpversion() < '5.0.0') {
        echo ' <p class="deprecated">' . _TEXT2_WARN2 . '</p>';
        ?>
</form>
</body>
</html>
<?php 
        exit;
    }
    // tell people how they can have their config file filled out automatically
    if (@file_exists('../config.php') && @(!is_writable('../config.php'))) {
        ?>

		<h1><?php 
        echo _HEADER3;
        ?>
</h1>

		<?php 
        echo _TEXT3;
    }
    ?>

		<h1><?php 
    echo _HEADER4;
    ?>
</h1>

		<?php 
    echo _TEXT4;
    ?>

		<fieldset>
			<legend><?php 
    echo _TEXT4_TAB_HEAD;
    ?>
</legend>
			<table>
				<tr>
					<td><label for="if_mySQL_host"><?php 
    echo _TEXT4_TAB_FIELD1;
    ?>
:</label></td>
					<td><input id="if_mySQL_host" name="mySQL_host" value="DUMMY_DB_HOST" tabindex="10010" /></td>
				</tr>
				<tr>
					<td><label for="if_mySQL_user"><?php 
    echo _TEXT4_TAB_FIELD2;
    ?>
:</label></td>
					<td><input id="if_mySQL_user" name="mySQL_user" value="DUMMY_PROJECT_NAME" tabindex="10020" /></td>
				</tr>
				<tr>
					<td><label for="if_mySQL_password"><?php 
    echo _TEXT4_TAB_FIELD3;
    ?>
:</label></td>
					<td><input id="if_mySQL_password" name="mySQL_password" value="DUMMY_DB_PASSWORD" type="password" tabindex="10030" /></td>
				</tr>
				<tr>
					<td><label for="if_mySQL_database"><?php 
    echo _TEXT4_TAB_FIELD4;
    ?>
:</label></td>
					<td><input id="if_mySQL_database" name="mySQL_database" value="DUMMY_PROJECT_NAME" tabindex="10040" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create" tabindex="10050" /><label for="mySQL_create"><?php 
    echo _TEXT4_TAB_FIELD4_ADD;
    ?>
</label>)</td>
				</tr>
			</table>
		</fieldset>

		<fieldset>
			<legend><?php 
    echo _TEXT4_TAB2_HEAD;
    ?>
</legend>
			<table>
				<tr>
					<td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix" tabindex="10060" /><label for="mySQL_usePrefix"><?php 
    echo _TEXT4_TAB2_FIELD;
    ?>
:</label></td>
					<td><input name="mySQL_tablePrefix" value="" tabindex="10070" /></td>
				</tr>
			</table>

			<?php 
    echo _TEXT4_TAB2_ADD;
    ?>

		</fieldset>

	<h1><?php 
    echo _HEADER5;
    ?>
</h1>

	<?php 
    echo _TEXT5;
    ?>

<?php 
    // no need to this all! dirname(__FILE__) is all we need -- moraes
    /*
    // discover full path
    $fullPath = serverVar('PATH_TRANSLATED');
    
    if ($fullPath == '') {
    	$fullPath = serverVar('SCRIPT_FILENAME');
    }
    
    $basePath = str_replace('install.php', '', $fullPath);
    $basePath = replaceDoubleBackslash($basePath);
    $basePath = replaceDoubleBackslash($basePath);
    
    // add slash at end if necessary
    if (!endsWithSlash($basePath) ) {
    	$basePath .= '/';
    }
    */
    $basePath = str_replace('install', '', dirname(__FILE__));
    ?>

		<fieldset>
			<legend><?php 
    echo _TEXT5_TAB_HEAD;
    ?>
</legend>
			<table>
				<tr>
					<td><label for="if_IndexURL"><?php 
    echo _TEXT5_TAB_FIELD1;
    ?>
:</label></td>
					<td><input id="if_IndexURL" name="IndexURL" size="60" value="<?php 
    $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
    $url = str_replace('install/index.php', '', $url);
    $url = replaceDoubleBackslash($url);
    // add slash at end if necessary
    if (!endsWithSlash($url)) {
        $url .= '/';
    }
    echo $url;
    ?>
" tabindex="10080" /></td>
				</tr>
				<tr>
					<td><label for="if_AdminURL"><?php 
    echo _TEXT5_TAB_FIELD2;
    ?>
:</label></td>
					<td><input id="if_AdminURL" name="AdminURL" size="60" value="<?php 
    if ($url) {
        echo $url . 'nucleus/';
    }
    ?>
" tabindex="10090" /></td>
				</tr>
				<tr>
					<td><label for="if_AdminPath"><?php 
    echo _TEXT5_TAB_FIELD3;
    ?>
:</label></td>
					<td><input id="if_AdminPath" name="AdminPath" size="60" value="<?php 
    if ($basePath) {
        echo $basePath . 'nucleus/';
    }
    ?>
" tabindex="10100" /></td>
				</tr>
				<tr>
					<td><label for="if_MediaURL"><?php 
    echo _TEXT5_TAB_FIELD4;
    ?>
:</label></td>
					<td><input id="if_MediaURL" name="MediaURL" size="60" value="<?php 
    if ($url) {
        echo $url . 'media/';
    }
    ?>
" tabindex="10110" /></td>
				</tr>
				<tr>
					<td><label for="if_MediaPath"><?php 
    echo _TEXT5_TAB_FIELD5;
    ?>
:</label></td>
					<td><input id="if_MediaPath" name="MediaPath" size="60" value="<?php 
    if ($basePath) {
        echo $basePath . 'media/';
    }
    ?>
" tabindex="10120" /></td>
				</tr>
				<tr>
					<td><label for="if_SkinsURL"><?php 
    echo _TEXT5_TAB_FIELD6;
    ?>
:</label></td>
					<td><input id="if_SkinsURL" name="SkinsURL" size="60" value="<?php 
    if ($url) {
        echo $url . 'skins/';
    }
    ?>
" tabindex="10130" />
						<br />(<?php 
    echo _TEXT5_TAB_FIELD7_2;
    ?>
)
					</td>
				</tr>
				<tr>
					<td><label for="if_SkinsPath"><?php 
    echo _TEXT5_TAB_FIELD7;
    ?>
:</label></td>
					<td><input id="if_SkinsPath" name="SkinsPath" size="60" value="<?php 
    if ($basePath) {
        echo $basePath . 'skins/';
    }
    ?>
" tabindex="10140" />
						<br />(<?php 
    echo _TEXT5_TAB_FIELD7_2;
    ?>
)
					</td>
				</tr>
				<tr>
					<td><label for="if_PluginURL"><?php 
    echo _TEXT5_TAB_FIELD8;
    ?>
:</label></td>
					<td><input id="if_PluginURL" name="PluginURL" size="60" value="<?php 
    if ($url) {
        echo $url . 'nucleus/plugins/';
    }
    ?>
" tabindex="10150" /></td>
				</tr>
				<tr>
					<td><label for="if_ActionURL"><?php 
    echo _TEXT5_TAB_FIELD9;
    ?>
:</label></td>
					<td><input id="if_ActionURL" name="ActionURL" size="60" value="<?php 
    if ($url) {
        echo $url . 'action.php';
    }
    ?>
" tabindex="10160" />
						<br />(<?php 
    echo _TEXT5_TAB_FIELD9_2;
    ?>
)
					</td>
				</tr>
			</table>
		</fieldset>

		<?php 
    echo _TEXT5_2;
    ?>

		<h1><?php 
    echo _HEADER6;
    ?>
</h1>

		<?php 
    echo _TEXT6;
    ?>

		<fieldset>
			<legend><?php 
    echo _TEXT6_TAB_HEAD;
    ?>
</legend>
			<table>
				<tr>
					<td><label for="if_User_name"><?php 
    echo _TEXT6_TAB_FIELD1;
    ?>
:</label></td>
					<td><input id="if_User_name" name="User_name" value="" tabindex="10170" /> <small>(<?php 
    echo _TEXT6_TAB_FIELD1_2;
    ?>
)</small></td>
				</tr>
				<tr>
					<td><label for="if_User_realname"><?php 
    echo _TEXT6_TAB_FIELD2;
    ?>
:</label></td>
					<td><input id="if_User_realname" name="User_realname" value="" tabindex="10180" /></td>
				</tr>
				<tr>
					<td><label for="if_User_password"><?php 
    echo _TEXT6_TAB_FIELD3;
    ?>
:</label></td>
					<td><input id="if_User_password" name="User_password" type="password" value="" tabindex="10190" /></td>
				</tr>
				<tr>
					<td><label for="if_User_password2"><?php 
    echo _TEXT6_TAB_FIELD4;
    ?>
:</label></td>
					<td><input id="if_User_password2" name="User_password2" type="password" value="" tabindex="10200" /></td>
				</tr>
				<tr>
					<td><label for="if_User_email"><?php 
    echo _TEXT6_TAB_FIELD5;
    ?>
:</label></td>
					<td><input id="if_User_email" name="User_email" value="" tabindex="10210" /> <small>(<?php 
    echo _TEXT6_TAB_FIELD5_2;
    ?>
)</small></td>
				</tr>
			</table>
		</fieldset>

		<h1><?php 
    echo _HEADER7;
    ?>
</h1>

		<?php 
    echo _TEXT7;
    ?>

		<fieldset>
			<legend><?php 
    echo _TEXT7_TAB_HEAD;
    ?>
</legend>
			<table>
				<tr>
					<td><label for="if_Blog_name"><?php 
    echo _TEXT7_TAB_FIELD1;
    ?>
:</label></td>
					<td><input id="if_Blog_name" name="Blog_name" size="60" value="My Nucleus CMS" tabindex="10220" /></td>
				</tr>
				<tr>
					<td><label for="if_Blog_shortname"><?php 
    echo _TEXT7_TAB_FIELD2;
    ?>
:</label></td>
					<td><input id="if_Blog_shortname" name="Blog_shortname" value="mynucleuscms" tabindex="10230" /> <small>(<?php 
    echo _TEXT7_TAB_FIELD2_2;
    ?>
)</small></td>
				</tr>
			</table>
		</fieldset>

		<h1><?php 
    echo _HEADER8;
    ?>
</h1>

		<fieldset>
			<legend><?php 
    echo _TEXT8_TAB_HEADER;
    ?>
</legend>
			<table>
				<tr>
					<td><input name="Weblog_ping" value="1" type="checkbox" id="Weblog_ping" tabindex="10240" /><label for="Weblog_ping"><?php 
    echo _TEXT8_TAB_FIELD1;
    ?>
</label></td>
				</tr>
			</table>
		</fieldset>
		
		<h1><?php 
    echo _HEADER9;
    ?>
</h1>
		
		<?php 
    echo _TEXT9;
    ?>
		
		<p>
		<input name="action" value="go" type="hidden" />
		<input type="submit" value="<?php 
    echo _BUTTON1;
    ?>
" onclick="return checkSubmit();" tabindex="10250" />
		</p>
		
		</form>
	</body>
</html>

<?php 
}
Beispiel #4
0
 function redirect($page)
 {
     global $cookie, $opt;
     $cookie->close();
     // close db-connection
     sql_disconnect();
     $this->header();
     if (strpos($page, "\n") !== false) {
         $page = substr($page, 0, strpos($page, "\n"));
     }
     // redirect
     if (substr($page, 0, 7) != 'http://') {
         if (substr($page, 0, 1) == '/') {
             $page = substr($page, 1);
         }
         $page = $opt['page']['absolute_url'] . $page;
     }
     if ($opt['session']['mode'] == SAVE_SESSION) {
         if (defined('SID') && SID != '' && session_id() != '') {
             if (strpos($page, '?') === false) {
                 header("Location: " . $page . '?' . urlencode(session_name()) . '=' . urlencode(session_id()));
             } else {
                 header("Location: " . $page . '&' . urlencode(session_name()) . '=' . urlencode(session_id()));
             }
         } else {
             header("Location: " . $page);
         }
     } else {
         header("Location: " . $page);
     }
     exit;
 }
Beispiel #5
0
function sql_connect_root()
{
    global $tpl, $db, $opt;
    if (file_exists($opt['rootpath'] . 'config2/sqlroot.inc.php')) {
        require $opt['rootpath'] . 'config2/sqlroot.inc.php';
    } else {
        return false;
    }
    sql_disconnect();
    sql_connect($opt['sqlroot']['username'], $opt['sqlroot']['password'], false);
    if ($db['dblink'] === false) {
        sql_disconnect();
        sql_connect();
        if ($db['connected'] == false) {
            $tpl->error(ERROR_DB_COULD_NOT_RECONNECT);
        }
        return false;
    }
    return true;
}