Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Thu, Jun 19, 9:36 AM

in-portal

Index: branches/unlabeled/unlabeled-1.1.2/core/install/upgrades.sql
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/install/upgrades.sql (nonexistent)
+++ branches/unlabeled/unlabeled-1.1.2/core/install/upgrades.sql (revision 7525)
@@ -0,0 +1,13 @@
+# ===== v 3.0.10 =====
+SELECT * FROM Modules;
+SELECT Name FROM Modules;
+
+# ===== v 4.0.1 =====
+ALTER TABLE Modules ADD COLUMN NotCool VARCHAR(255);
+
+# ===== v 4.0.12 =====
+# multiline
+ALTER TABLE Modules ADD COLUMN SuperCool VARCHAR(255);
+
+# ===== v 4.0.15 =====
+UPDATE Modules SET Version = '4.0.5' WHERE Name = 'Core';
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/install/upgrades.sql
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1.2.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/install_setup.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/install_setup.tpl (revision 7524)
+++ branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/install_setup.tpl (revision 7525)
@@ -1,51 +1,56 @@
<tr class="table_color2">
<td colspan="2">
In order to use the installation tool, please provide your Intechnic account information:
</td>
</tr>
<tr class="table_color2">
<td class="text">
<b>Username<span class="error">*</span>:</b>
</td>
<td width="80%">
- <input type="text" name="user_name" value="<?php $this->GetVar('user_name'); ?>" class="text" />
+ <input type="text" name="login" value="" class="text" />
</td>
</tr>
<tr class="table_color2">
<td class="text">
<b>Password<span class="error">*</span>:</b>
</td>
<td>
- <input type="password" name="user_password" class="text" />
+ <input type="password" name="password" class="text" />
</td>
</tr>
<?php
ob_start();
?>
<tr class="%4$s">
<td colspan="2">
- <input type="radio" value="%1$s" name="inp_opt" id="inp_opt_%1$s"%2$s><label for="inp_opt_%1$s">%3$s</label></span>
+ <input type="radio" value="%1$s" name="next_preset" id="next_preset_%1$s"%2$s><label for="next_preset_%1$s">%3$s</label></span>
</td>
</tr>
<?php
$option_tpl = ob_get_clean();
$options = Array (
- 6 => 'Upgrade In-Portal',
- 1 => 'Clean out the In-Portal database and reinstall',
- 4 => 'Clean out the In-Portal database and reinstall from backup',
- 2 => 'Install to a new database',
- 3 => 'Update License Information',
- 5 => 'Change Database Configuration',
- 7 => 'Fix Paths',
+ 'upgrade' => 'Upgrade In-Portal',
+ 1 => 'Clean out the In-Portal database and reinstall',
+ 4 => 'Clean out the In-Portal database and reinstall from backup',
+ 2 => 'Install to a new database',
+ 3 => 'Update License Information',
+ 'db_reconfig' => 'Change Database Configuration',
+ 'fix_paths' => 'Fix Paths',
);
+ $upgradable_modules = $this->GetUpgradableModules();
+ if (!$upgradable_modules) {
+ unset($options['upgrade']);
+ }
+
$td_class = 'table_color1';
foreach ($options as $option_key => $option_title) {
- $checked = $this->GetVar('inp_opt') == $option_key ? ' checked' : '';
+ $checked = $this->GetVar('next_preset') == $option_key ? ' checked' : '';
echo sprintf($option_tpl, $option_key, $checked, $option_title, $td_class);
$td_class = ($td_class == 'table_color1') ? 'table_color2' : 'table_color1';
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/install_setup.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.1.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/choose_modules.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/choose_modules.tpl (revision 7524)
+++ branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/choose_modules.tpl (revision 7525)
@@ -1,16 +1,21 @@
<?php
ob_start();
?>
<tr class="table_color2">
<td class="text" colspan="2" valign="middle">
- <input type="checkbox" name="modules[]" id="module_%1$s" value="%1$s"/><label for="module_%1$s">%1$s</label>
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input type="checkbox" name="modules[]" id="module_%1$s" value="%1$s"/></td>
+ <td><label for="module_%1$s">%1$s</label></td>
+ </tr>
+ </table>
</td>
</tr>
<?php
$module_tpl = ob_get_clean();
$modules = $this->ScanModules();
foreach ($modules as $module) {
echo sprintf($module_tpl, $module);
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/choose_modules.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.1.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/upgrade_modules.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/upgrade_modules.tpl (nonexistent)
+++ branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/upgrade_modules.tpl (revision 7525)
@@ -0,0 +1,31 @@
+<?php
+ ob_start();
+?>
+<tr class="table_color2">
+ <td class="text" colspan="2" valign="middle">
+ <table cellpadding="0" cellspacing="0">
+ <tr>
+ <td><input type="checkbox" name="modules[]" id="module_%1$s" value="%1$s"/></td>
+ <td><label for="module_%1$s">%2$s</label></td>
+ </tr>
+ </table>
+ </td>
+</tr>
+<?php
+ $module_tpl = ob_get_clean();
+
+ $modules = $this->GetUpgradableModules();
+ foreach ($modules as $module_name => $module_params) {
+ $module_title = $module_name.' ('.$module_params['Version'].' to '.$module_params['ToVersion'].')';
+ if ($this->Application->isDebugMode()) {
+ $module_title .= ' [from: '.$module_params['FromVersion'].']';
+ }
+ echo sprintf($module_tpl, $module_name, $module_title);
+ }
+?>
+<tr class="table_color1">
+ <td class="hint" colspan="2" valign="middle">
+ <img src="incs/img/icon_warning.gif" width="14" height="14" align="absmiddle" />
+ Your data will be modified during the upgrade. We strongly recommend that you make a backup of your database. Proceed with the upgrade ?
+ </td>
+</tr>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/install/step_templates/upgrade_modules.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1.2.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.1.2/core/install/incs/style.css
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/install/incs/style.css (revision 7524)
+++ branches/unlabeled/unlabeled-1.1.2/core/install/incs/style.css (revision 7525)
@@ -1,206 +1,213 @@
html, body {
margin: 0;
padding: 0;
background: #FFFFFF;
color: #333333;
}
ol.install-steps {
font: bold 12px verdana, sans-serif;
color: #fff;
line-height: 20px
}
.install-steps li.current-step {
color: #005786
}
/*#nav {
margin-left: -1px;
text-align: center;
float: left
}
#content {
padding: 10px;
color: darkblue;
float: right
}
#header {
background-color: #fff;
color: #006;
border-bottom: 1px solid #006;
margin-bottom: 0px
}
*/
.footer {
background-color: #FFFFFF;
color: #006;
border-top: 1px solid #006;
font-size: 11px;
text-align: right;
padding: 2px 10px 0 0;
clear: both;
}
p {
padding: 0;
margin-top: 0px;
font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif;
}
/*
.spacer {clear: both}
dd, dt {
font: 0.95em 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif;
}
*/
.head_version {
padding-right: 5px;
font-weight: normal;
font-size: 10px;
color: white;
font-family: verdana, arial;
text-decoration: none;
}
.admintitle, .admintitle-white {
font-weight: bold;
font-size: 20px;
color: #009FF0;
font-family: verdana, arial;
text-decoration: none;
}
.admintitle-white {
color: #fff
}
.subsectiontitle {
font-weight: bold;
font-size: 14px;
color: white;
font-family: verdana, arial;
background-color: #999999;
text-decoration: none;
height: 24px;
}
.subsectiontitle:hover {
font-weight: bold;
font-size: 14px;
color: #ffcc00;
font-family: verdana, arial;
background-color: #999999;
text-decoration: none;
}
.text {
font-weight: normal;
font-size: 12px;
font-family: verdana, arial;
text-decoration: none;
}
.toolbar {
border-right: #000000 1px solid;
border-top: #000000 0px solid;
font-size: 10pt;
border-left: #000000 1px solid;
border-bottom: #000000 1px solid;
font-family: Arial, Helvetica, sans-serif;
background-color: #F0F1EB;
}
.tableborder {
border-right: #000000 1px solid;
border-top: #000000 0px solid;
font-size: 10pt;
border-left: #000000 1px solid;
border-bottom: #000000 1px solid;
font-family: Arial, Helvetica, sans-serif;
}
.tableborder_full {
border-right: #000000 1px solid;
border-top: #000000 1px solid;
font-size: 10pt;
border-left: #000000 1px solid;
border-bottom: #000000 1px solid;
font-family: Arial, Helvetica, sans-serif;
background-image: url(img/tab_middle.gif);
background-repeat: repeat-x;
}
.tablenav {
font-weight: bold;
font-size: 14px;
color: white;
font-family: verdana, arial;
background-color: #73C4F5;
text-decoration: none;
}
.tablenav_link {
font-weight: bold;
font-size: 14px;
color: white;
font-family: verdana, arial;
text-decoration: none;
}
.tablenav_link:hover {
font-weight: bold;
font-size: 14px;
color: #FFCC00;
font-family: verdana, arial;
text-decoration: none;
}
/*.table_color1 {
font-weight: normal;
font-size: 14px;
color: black;
font-family: verdana, arial;
background-color: #F6F6F6;
text-decoration: none;
}*/
.table_color2 {
font-weight: normal;
font-size: 14px;
color: black;
font-family: verdana, arial;
background-color: #EBEBEB;
text-decoration: none;
}
.error {
font-weight: bold;
font-size: 9pt;
color: #ff0000;
font-family: Arial, Helvetica, sans-serif;
}
.button {
font-weight: normal;
font-size: 12px;
background: url(img/button_back.gif) #F9EEAE repeat-x;
color: black;
font-family: Arial, Verdana;
text-decoration: none;
}
td {
font-size: 10pt;
font-family: Verdana, Helvetica;
text-decoration: none;
}
.link {
cursor: pointer;
}
+
+.hint {
+ font-size: 12px;
+ color: #666666;
+ font-style: normal;
+ font-family: Arial, Helvetica, sans-serif;
+}
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/install/incs/style.css
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.1.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.1.2/core/install/incs/img/icon_warning.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/install/incs/img/icon_warning.gif
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1.2.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.2.2/core/install/steps_db.xml
===================================================================
--- branches/unlabeled/unlabeled-1.2.2/core/install/steps_db.xml (revision 7524)
+++ branches/unlabeled/unlabeled-1.2.2/core/install/steps_db.xml (revision 7525)
@@ -1,43 +1,46 @@
<steps>
<step name="db_config" title="Database Configuration">
<![CDATA[Host name (<i>normally "localhost"</i>), Database user name, and database Password.
These fields are required to connect to the database.</p><p>If you would like In-Portal
to use a table prefix, enter it in the field provided. This prefix can be any
text which can be used in the names of tables on your system. The characters entered in this field
are placed <i>before</i> the names of the tables used by In-Portal. For example, if you enter "inp_"
into the prefix field, the table named Category will be named inp_Category.</p>]]>
</step>
<step name="root_password" title="Set Root Password" help_title="Set Admin Root Password">
<![CDATA[<p>The Root Password is initially required to access the admin sections of In-Portal.
The root user cannot be used to access the front-end of the system, so it is recommended that you
create additional users with admin privlidges.</p>]]>
</step>
<step name="choose_modules" title="Select Modules to Install">
<![CDATA[<p>Select the In-Portal modules you wish to install. The modules listed to the right
are all modules included in this installation that are licensed to run on this server. </p>]]>
</step>
<step name="check_paths" title="Filesystem Check">
<![CDATA[<b>Write</b><br />Shows folder and files, that write permissions should be adjusted
to allow web server to write data into them.]]>
</step>
<step name="finish" title="Installation Complete" help_title="Thank You!">
<![CDATA[<p>Thanks for using In-Portal! Be sure to visit <a target="_new" href="http://www.in-portal.net">www.in-portal.net</a>
for the latest news, module releases and support. </p>
<p>*Make sure to clean your browser' cache after upgrading In-portal version</p>]]>
</step>
<step name="install_setup" title="Installation Maintenance">
<![CDATA[<p>A Configuration file has been detected on your system and it appears In-Portal is correctly installed.
In order to work with the maintenance functions provided to the left you must provide the Intechnic
Username and Password you used when obtaining the license file residing on the server, or your admin Root password.
<i>(Use Username 'root' if using your root password)</i></p>
<p>To removing your existing database and start with a fresh installation, select the first option
provided. Note that this operation cannot be undone and no backups are made! Use at your own risk.</p>
<p>If you wish to scrap your current installation and install to a new location, choose the second option.
If this option is selected you will be prompted for new database configuration information.</p>
<p>The <i>Update License Information</i> option is used to update your In-Portal license data. Select this option if you have
modified your licensing status with Intechnic, or you have received new license data via email</p>
<p>The <i>Fix Paths</i> option should be used when the location of the In-portal files has changed.
For example, if you moved them from one folder to another. It will update all settings and ensure the
program is operational at the new location.</p>]]>
</step>
+ <step name="upgrade_modules" title="Select Modules to Upgrade">
+ <![CDATA[help missing]]>
+ </step>
</steps>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.2.2/core/install/steps_db.xml
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.2.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.2.2/core/install/incs/install.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.2.2/core/install/incs/install.tpl (revision 7524)
+++ branches/unlabeled/unlabeled-1.2.2/core/install/incs/install.tpl (revision 7525)
@@ -1,153 +1,153 @@
<html>
<head>
<title>In-Portal Installation</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<base href="<?php echo $this->baseURL; ?>"/>
<link rel="stylesheet" type="text/css" href="incs/style.css" />
<script type="text/javascript" src="incs/script.js"></script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" style="height: 100%">
<form enctype="multipart/form-data" id="install_form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
<!-- header: begin -->
<tr>
<td height="90">
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="90">
<tr>
<td rowspan="3" valign="top"><a href="http://www.in-portal.net" target="_top"><img title="In-portal" src="incs/img/globe.gif" width="84" height="91" border="0" alt="In-Portal"/></a></td>
<td rowspan="3" valign="top"><a href="http://www.in-portal.net" target="_top"><img title="In-portal" src="incs/img/logo.gif" width="150" height="91" border="0" alt="In-Portal"/></a></td>
<td rowspan="3" width="100%" align="right">&nbsp;</td>
<td width="400"><img title="" src="incs/img/blocks.gif" width="400" height="73" alt="blocks" /></td>
</tr>
- <tr><td align="right" background="incs/img/version_bg.gif" class="head_version" valign="top"><img title="" src="incs/img/spacer.gif" width="1" height="14" alt=""/>In-Portal Version <?php echo $this->GetModuleVersion('In-Portal'); ?>: English US</td></tr>
+ <tr><td align="right" background="incs/img/version_bg.gif" class="head_version" valign="top"><img title="" src="incs/img/spacer.gif" width="1" height="14" alt=""/>In-Portal Version <?php echo $this->GetModuleVersion('Core'); ?>: English US</td></tr>
<tr><td><img title="" src="incs/img/blocks2.gif" width="400" height="2" alt="blocks2"/><br /></td></tr>
<tr><td bgcolor="black" colspan="4"><img title="" src="incs/img/spacer.gif" width="1" height="1" alt=""/><br /></td></tr>
</table>
</td>
</tr>
<!-- header: end -->
<tr height="100%">
<td valign="top">
<table cellpadding=10 cellspacing=0 border=0 width="100%" height="100%">
<tr valign="top">
<td style="width: 200px; background: #009ff0 url(incs/img/bg_install_menu.gif) no-repeat bottom right; border-right: 1px solid #000">
<img src="incs/img/spacer.gif" width="180" height="1" border="0" alt="" /><br />
<span class="admintitle-white">Installation</span>
<ol class="install-steps">
<?php
echo $this->PrintSteps('<li class="current-step">%s</li>', '<li>%s</li>');
?>
</ol>
</td>
<td>
<img src="incs/img/icon_install.gif" width="46" height="46" alt="" align="absmiddle" />&nbsp;<span class="admintitle"><?php echo $this->GetStepInfo('step_title'); ?></span><br /><br />
<!-- section header: begin -->
<table border="0" cellpadding="2" cellspacing="0" class="tableborder_full" width="100%" height="30">
<tr>
<td class="tablenav" width="580" nowrap background="incs/img/tabnav_left.jpg">
<span class="tablenav_link"><?php echo 'Step '.$this->GetStepNumber().' - '.$this->GetStepInfo('step_title'); ?></span>
</td>
<td align="right" class="tablenav" background="incs/img/tabnav_back.jpg" width="100%">
<a class="link" onclick="ShowHelp('in-portal:install');">
<img src="incs/img/blue_bar_help.gif" border="0">
</a>
</td>
</tr>
</table>
<!-- section header: end -->
<!-- toolbar: begin -->
<table border=0 cellpadding=0 cellspacing=0 width="100%" class="toolbar">
<tr>
<td>
<a href="javascript:continue_install();">
<img border="0" src="incs/img/toolbar/tool_select.gif" id="img_Save" width="32" height="32" border="0" alt="Save" onmouseout="swap_image('img_Save', 'toolbar/tool_select.gif');" onmouseover="swap_image('img_Save','toolbar/tool_select_f2.gif');" /><br />
</a>
</td>
<td>
<img src="incs/img/toolbar/tool_cancel.gif" id="img_Cancel" width="32" height="32" border="0" alt="Cancel" onmouseout="swap_image('img_Cancel', 'toolbar/tool_cancel.gif');" onmouseover="swap_image('img_Cancel','toolbar/tool_cancel_f2.gif');" onclick="history.go(-1);" /><br />
</td>
<td width="100%">&nbsp;</td>
</tr>
</table>
<!-- toolbar: end -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableborder">
<tr valign="top">
<td width="60%" bgcolor="#F0F0F0">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="4">
<!-- step body: begin -->
<?php echo $this->GetStepBody(); ?>
<!-- step body: end -->
<!-- step error message: begin -->
<tr class="table_color2">
<td colspan="2">
<p class="error">
<?php echo $this->errorMessage; ?>
</p>
<br/>
</td>
</tr>
<!-- step error message: end -->
<!-- next, prev buttons: begin -->
<tr>
<td colspan="2">
<br />
<input type="submit" name="submit_form" value="Continue" class="button" />
<?php
if ($this->GetStepNumber() > 1 && $this->GetNextStep() != -1) {
echo '<input type="reset" name="cancel" value="Cancel" class="button" onclick="history.go(-1);" />';
}
?>
<input type="hidden" name="step" value="<?php echo $this->currentStep; ?>"/>
<input type="hidden" name="preset" value="<?php echo $this->stepsPreset; ?>"/>
</td>
</tr>
<!-- next, prev buttons: end -->
</table>
</td>
<td width="40%" style="border-left: 1px solid #000; background: #f0f0f0">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td class="subsectiontitle" style="border-bottom: 1px solid #000000; background-color: #999"><?php echo $this->GetStepInfo('help_title'); ?></td>
</tr>
<tr>
<td class="text"><?php echo $this->GetStepInfo('help_body'); ?></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
</td>
</tr>
<tr>
<td class="footer">
Powered by In-portal &copy; 1997-<?php echo date('Y'); ?>, Intechnic Corporation. All rights reserved.
<br /><img src="incs/img/spacer.gif" width="1" height="10" alt="" />
</td>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.2.2/core/install/incs/install.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.2.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.6.2/core/units/general/helpers/modules.php
===================================================================
--- branches/unlabeled/unlabeled-1.6.2/core/units/general/helpers/modules.php (revision 7524)
+++ branches/unlabeled/unlabeled-1.6.2/core/units/general/helpers/modules.php (revision 7525)
@@ -1,370 +1,370 @@
<?php
class kModulesHelper extends kHelper {
function checkLogin()
{
return $this->_GetModules();
}
function getWhereClause()
{
$where_clause = Array('Loaded = 1');
if (!$this->Application->IsAdmin()) return implode(' AND ', $where_clause);
$modules = $this->_GetModules();
if ($modules) {
foreach ($modules as $module_index => $module) {
$modules[$module_index] = $this->Conn->qstr($module);
}
$where_clause[] = 'Name IN ('.implode(',', $modules).')';
}
return implode(' AND ', $where_clause);
}
function _EnableCookieSID()
{
$session =& $this->Application->recallObject('Session');
return $session->CookiesEnabled;
}
function _IsSpider($UserAgent)
{
global $robots;
$lines = file(FULL_PATH.'/robots_list.txt');
if (!is_array($robots)) {
$robots = Array();
for($i = 0; $i < count($lines); $i++) {
$l = $lines[$i];
$p = explode("\t", $l, 3);
$robots[] = $p[2];
}
}
return in_array($UserAgent, $robots);
}
function _MatchIp($ip1, $ip2)
{
$matched = TRUE;
$ip = explode('.', $ip1);
$MatchIp = explode('.', $ip2);
for ($i = 0; $i < count($ip); $i++) {
if($i == count($MatchIp)) break;
if (trim($ip[$i]) != trim($MatchIp[$i]) || trim($ip[$i]) == '*') {
$matched = FALSE;
break;
}
}
return $matched;
}
function _IpAccess($IpAddress, $AllowList, $DenyList)
{
$allowed = explode(',', $AllowList);
$denied = explode(',', $DenyList);
$MatchAllowed = FALSE;
for ($x = 0; $x < count($allowed); $x++) {
$ip = explode('.', $allowed[$x]);
$MatchAllowed = $this->_MatchIp($IpAddress, $allowed[$x]);
if ($MatchAllowed)
break;
}
$MatchDenied = FALSE;
for ($x = 0; $x < count($denied); $x++) {
$ip = explode('.', $denied[$x]);
$MatchDenied = $this->_MatchIp($IpAddress, $denied[$x]);
if ($MatchDenied)
break;
}
$Result = (($MatchAllowed && !$MatchDenied) || (!$MatchAllowed && !$MatchDenied) ||
($MatchAllowed && $MatchDenied));
return $Result;
}
/**
* Reads config.php file and parses it
*
*/
function _readConfig()
{
$vars = parse_portal_ini(FULL_PATH.'/config.php');
foreach ($vars as $config_key => $config_value) {
$GLOBALS['g_'.$config_key] = $config_value;
}
}
/**
* Leaves only domain part from hostname (e.g. extract "intechnic.lv" from "test.intechnic.lv")
* Used for admin login license check
*
* @param string $d
* @return string
*/
function _StripDomainHost($d)
{
$IsIp = false;
$dotcount = substr_count($d, '.');
if ($dotcount == 3) {
$IsIp = true;
for ($x = 0; $x < strlen($d); $x++) {
if (!is_numeric(substr($d, $x, 1)) && substr($d, $x, 1) != '.')
{
$IsIp = false;
break;
}
}
}
if ($dotcount > 1 && !$IsIp) {
$p = explode('.', $d);
$ret = $p[count($p) - 2].'.'.$p[count($p) - 1];
}
else {
$ret = $d;
}
return $ret;
}
/**
* When logging into admin then check only last 2 parts of host name VS domain in license
*
* @param string $user_domain
* @param string $license_domain
* @return int
*/
function _CheckDomain($user_domain, $license_domain)
{
if ($this->Application->IsAdmin()) {
$user_domain = $this->_StripDomainHost($user_domain);
return preg_match('/(.*)'.preg_quote($user_domain, '/').'$/', $license_domain);
}
else {
return preg_match('/(.*)'.preg_quote($license_domain, '/').'$/', $user_domain);
}
}
/**
* Returns modules list, that are in license
*
* @return Array
*/
function _GetModules()
{
global $i_Keys;
static $modules = null;
if (isset($modules)) return $modules;
$this->_readConfig();
$license = base64_decode($GLOBALS['g_License']);
$this->_ParseLicense($license);
$modules = Array();
$domain = $this->_GetDomain();
if (!$this->_IsLocalSite($domain)) {
for ($x = 0; $x < count($i_Keys); $x++) {
$key = $i_Keys[$x];
if ($this->_CheckDomain($domain, $key['domain'])) {
// used hostname is subdomain or matches domain from license
$modules = explode(',', $key['mod']);
}
}
}
else {
$modules = array_keys($this->Application->ModuleInfo);
}
- array_push($modules, 'Proj-base', 'Proj-CMS', 'Custom');
+ array_push($modules, 'Core', 'Proj-base', 'Proj-CMS', 'Custom');
return $modules;
}
/**
* Allows to determine if module is licensed
*
* @param string $name
* @return bool
*/
function _ModuleLicensed($name)
{
$modules = $this->_GetModules();
return in_array($name, $modules);
}
/**
* Returns domain from licences (and direct in case of install script)
*
* @return string
*/
function _GetDomain()
{
return $this->Application->ConfigValue('DomainDetect') ? $_SERVER['HTTP_HOST'] : $GLOBALS['g_Domain'];
}
function _keyED($txt, $encrypt_key)
{
$encrypt_key = md5($encrypt_key);
$ctr = 0;
$tmp = '';
for ($i = 0; $i < strlen($txt); $i++) {
if ($ctr == strlen($encrypt_key)) $ctr = 0;
$tmp .= substr($txt, $i, 1) ^ substr($encrypt_key, $ctr, 1);
$ctr++;
}
return $tmp;
}
function _decrypt($txt, $key)
{
$txt = $this->_keyED($txt,$key);
$tmp = '';
for ($i = 0; $i < strlen($txt); $i++) {
$md5 = substr($txt, $i, 1);
$i++;
$tmp .= (substr($txt, $i, 1) ^ $md5);
}
return $tmp;
}
function LoadFromRemote()
{
return '';
}
function DLid()
{
die($GLOBALS['lid']."\n");
}
function _LoadLicense($LoadRemote = false)
{
$f = FULL_PATH.'/intechnic.php';
if ($this->_falseIsLocalSite($f)) $ret = true;
if (file_exists($f)) {
$contents = file($f);
$data = base64_decode($contents[1]);
}
else {
if ($LoadRemote) return $LoadFromRemote;
}
return $data;
}
function _VerifyKey($domain, $k)
{
$key = md5($domain);
$lkey = substr($key, 0, strlen($key) / 2);
$rkey = substr($key, strlen($key) / 2);
$r = $rkey.$lkey;
if ($k == $r) return true;
return false;
}
function _ParseLicense($txt)
{
global $i_User, $i_Pswd, $i_Keys;
if (!$this->_falseIsLocalSite($txt)) $nah = false;
$data = $this->_decrypt($txt, 'beagle');
$i_Keys = Array();
$lines = explode("\n", $data);
for ($x = 0; $x < count($lines); $x++) {
$l = $lines[$x];
$p = explode('=', $l, 2);
switch($p[0]) {
case 'Username':
$i_User = $p[1];
break;
case 'UserPass':
$i_Pswd = $p[1];
break;
default:
if (substr($p[0], 0, 3) == 'key') {
$parts = explode('|', $p[1]);
if ($this->_VerifyKey($parts[0], $parts[1])) {
unset($K);
$k['domain'] = $parts[0];
$k['key'] = $parts[1];
$k['desc'] = $parts[2];
$k['mod'] = $parts[3];
$i_Keys[] = $k;
}
}
break;
}
}
}
function _GetObscureValue($i)
{
if ($i == 'x') return 0254; $z = '';
if ($i == 'z') return 0x7F.'.';
if ($i == 'c') return '--code--';
if ($i >= 5 && $i < 7) return $this->_GetObscureValue($z)*$this->_GetObscureValue('e');
if ($i > 30) return Array(0x6c,0x6f,0x63,0x61,0x6c,0x68,0x6f,0x73,0x74);
if ($i > 20) return 99;
if ($i > 10) return '.'.($this->_GetObscureValue(6.5)+1);
if ($i == 'a') return 0xa;
}
function _Chr($val)
{
$x = $this->_GetObscureValue(25);
$f = chr($x).chr($x+5).chr($x+15);
return $f($val);
}
function _IsLocalSite($domain)
{
$ee = $this->_GetObscureValue(35); $yy = '';
foreach ($ee as $e) $yy .= $this->_Chr($e);
$localb = FALSE;
if(substr($domain,0,3)==$this->_GetObscureValue('x'))
{
$b = substr($domain,0,6);
$p = explode(".",$domain);
$subnet = $p[1];
if($p[1]>15 && $p[1]<32)
$localb=TRUE;
}
$zz = $this->_GetObscureValue('z').$this->_GetObscureValue(5).'.'.(int)$this->_GetObscureValue(7).$this->_GetObscureValue(12);
$ff = $this->_GetObscureValue('z')+65;
$hh = $ff-0x18;
if($domain==$yy || $domain==$zz || substr($domain,0,7)==$ff.$this->_Chr(46).$hh ||
substr($domain,0,3)==$this->_GetObscureValue('a').$this->_Chr(46) || $localb || strpos($domain,".")==0)
{
return TRUE;
}
return FALSE;
}
function _falseIsLocalSite($domain)
{
$localb = FALSE;
if(substr($domain,0,3)=="172")
{
$b = substr($domain,0,6);
$p = explode(".",$domain);
$subnet = $p[1];
if($p[1]>15 && $p[1]<32)
$localb=TRUE;
}
if($domain=="localhost" || $domain=="127.0.0.1" || substr($domain,0,7)=="192.168" ||
substr($domain,0,3)=="10." || $localb || strpos($domain,".")==0)
{
return TRUE;
}
return FALSE;
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.6.2/core/units/general/helpers/modules.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6.2.2
\ No newline at end of property
+1.6.2.3
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.6.2/core/install.php
===================================================================
--- branches/unlabeled/unlabeled-1.6.2/core/install.php (revision 7524)
+++ branches/unlabeled/unlabeled-1.6.2/core/install.php (revision 7525)
@@ -1,902 +1,1078 @@
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
define('IS_INSTALL', 1);
define('ADMIN', 1);
define('FULL_PATH', realpath(dirname(__FILE__).'/..') );
define('REL_PATH', '/core');
+ /**
+ * Upgrade sqls are located using this mask
+ *
+ */
+ define('UPGRADES_FILE', FULL_PATH.'/%sinstall/upgrades.sql');
+
// print_pre($_POST);
$install_engine = new kInstallator();
$install_engine->Init();
$install_engine->Run();
$install_engine->Done();
class kInstallator {
/**
* Reference to kApplication class object
*
* @var kApplication
*/
var $Application = null;
/**
* Connection to database
*
* @var kDBConnection
*/
var $Conn = null;
/**
* Path to config.php
*
* @var string
*/
var $INIFile = '';
/**
* XML file containing steps information
*
* @var string
*/
var $StepDBFile = '';
/**
* Parsed data from config.php
*
* @var Array
*/
var $systemConfig = Array ();
/**
* Step name, that currently being processed
*
* @var string
*/
var $currentStep = '';
/**
* Steps list (preset) to use for current installation
*
* @var string
*/
var $stepsPreset = '';
/**
* Installtion steps to be done
*
* @var Array
*/
var $steps = Array(
'fresh_install' => Array ('check_paths', 'db_config', 'root_password', 'choose_modules', 'finish'),
'already_installed' => Array ('install_setup'),
- 'upgrade' => Array ('install_setup',/* ..., */ 'finish'),
+ 'upgrade' => Array ('install_setup', 'upgrade_modules', /* ..., */ 'finish'),
'db_reconfig' => Array ('install_setup',/* ..., */ 'finish'),
'fix_paths' => Array ('install_setup',/* ..., */ 'finish'),
);
/**
+ * Steps, that doesn't required admin to be logged-in to proceed
+ *
+ * @var Array
+ */
+ var $skipLoginSteps = Array ('root_password', 'choose_modules', 'finish', -1);
+
+ /**
* Steps, on which kApplication should not be initialized, because of missing correct db table structure
*
* @var Array
*/
-
- var $skipApplicationSteps = Array ('check_paths', 'db_config', 'install_setup'); // remove install_setup when application will work separately from install
+ var $skipApplicationSteps = Array ('check_paths', 'db_config'/*, 'install_setup'*/); // remove install_setup when application will work separately from install
/**
* Folders that should be writeable to continue installation
*
* @var Array
*/
var $writeableFolders = Array ('/system');
/**
* Contains last error message text
*
* @var string
*/
var $errorMessage = '';
/**
* Base path for includes in templates
*
* @var string
*/
var $baseURL = '';
function Init()
{
$this->INIFile = FULL_PATH.'/config.php';
$this->StepDBFile = FULL_PATH.'/'.REL_PATH.'/install/steps_db.xml';
$base_path = rtrim(preg_replace('/'.preg_quote(rtrim(REL_PATH, '/'), '/').'$/', '', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']))), '/');
$this->baseURL = 'http://'.$_SERVER['HTTP_HOST'].$base_path.'/core/install/';
set_error_handler( Array(&$this, 'ErrorHandler') );
if (file_exists($this->INIFile)) {
// if config.php found, then check his write permission too
$this->writeableFolders[] = '/config.php';
}
else {
$this->writeableFolders[] = '/';
}
$this->systemConfig = $this->ParseConfig(true);
$this->systemConfig['Misc']['WriteablePath'] = '/system'; // for development purposes
$this->currentStep = $this->GetVar('step');
+ // can't check login on steps where no application present anyways :)
+ $this->skipLoginSteps = array_unique(array_merge($this->skipLoginSteps, $this->skipApplicationSteps));
+
$this->SelectPreset();
if (!$this->currentStep) {
- // first step of current preset
- reset($this->steps[$this->stepsPreset]);
- $this->currentStep = current($this->steps[$this->stepsPreset]);
+ $this->SetFirstStep(); // sets first step of current preset
}
$this->InitStep();
}
+ function SetFirstStep()
+ {
+ reset($this->steps[$this->stepsPreset]);
+ $this->currentStep = current($this->steps[$this->stepsPreset]);
+ }
+
/**
* Selects preset to proceed based on various criteria
*
*/
function SelectPreset()
{
$preset = $this->GetVar('preset');
if (file_exists($this->INIFile) && $this->systemConfig) {
// only at installation first step
$status = $this->CheckDatabase(false);
if ($status && $this->AlreadyInstalled()) {
- $preset = 'already_installed';
- $this->currentStep = '';
+ // if already installed, then all future actions need login to work
+ $this->skipLoginSteps = Array (-1);
+ if (!$preset) {
+ $preset = 'already_installed';
+ $this->currentStep = '';
+ }
}
}
if ($preset === false) {
$preset = 'fresh_install'; // default preset
}
$this->stepsPreset = $preset;
}
-
+
function GetVar($name)
{
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : false;
}
/**
* Performs needed intialization of data, that step requires
*
*/
function InitStep()
{
- $this->InitApplication();
+ $require_login = !in_array($this->currentStep, $this->skipLoginSteps);
+ $this->InitApplication($require_login);
+ if ($require_login) {
+ // step require login to proceed
+ if (!$this->Application->LoggedIn()) {
+ $this->stepsPreset = 'already_installed';
+ $this->SetFirstStep();
+ }
+ }
+
switch ($this->currentStep) {
case 'check_paths':
foreach ($this->writeableFolders as $folder_path) {
$file_path = FULL_PATH.$folder_path;
if (!is_writable($file_path)) {
$this->errorMessage = 'Install cannot write to specified folder in the root directory of your installation';
break;
}
}
break;
case 'db_config':
$section_name = 'Database';
$fields = Array ('DBType', 'DBHost', 'DBName', 'DBUser', 'DBUserPassword', 'TablePrefix');
if (!isset($this->systemConfig[$section_name])) {
$this->systemConfig[$section_name] = Array ();
}
// set fields
foreach ($fields as $field_name) {
$submit_value = $this->GetVar($field_name);
if ($submit_value !== false) {
$this->systemConfig[$section_name][$field_name] = $submit_value;
}
elseif (!isset($this->systemConfig[$section_name][$field_name])) {
$this->systemConfig[$section_name][$field_name] = '';
}
}
break;
case 'choose_modules':
// if no modules found, then proceed to next step
$modules = $this->ScanModules();
if (!$modules) {
$this->currentStep = $this->GetNextStep();
}
break;
- case 'install_setup':
- if ($this->stepsPreset == 'already_installed') {
- // if preset was not choosen, then raise error
- $this->errorMessage = 'Please select action to perform';
+ case 'upgrade_modules':
+ // get installed modules from db and compare their versions to upgrade script
+ $modules = $this->GetUpgradableModules();
+ if (!$modules) {
+ $this->currentStep = $this->GetNextStep();
}
- else {
- // if preset was choosen, then check root password entered
- $user_name = $this->GetVar('user_name');
- $user_password = $this->GetVar('user_password');
-
- if ($user_name == 'root') {
- $sql = 'SELECT VariableValue
- FROM '.$this->systemConfig['Database']['TablePrefix'].'
- WHERE VariableName = "RootPass"';
- $root_password = $this->Conn->GetOne($sql);
- $user_password = md5( md5($user_password) . 'b38');
- if ($user_password != $root_password) {
- $this->errorMessage = 'Invalid User Name or Password. If you don\'t know your username or password, contact Intechnic Support';
+ break;
+
+ case 'install_setup':
+ $next_preset = $this->Application->GetVar('next_preset');
+ if ($next_preset !== false && $this->Application->GetVar('login') == 'root') {
+ // option was choosen, then verify password & login user
+ $login_event = new kEvent('u.current:OnLogin');
+ $this->Application->HandleEvent($login_event);
+
+ if ($login_event->status == erSUCCESS) {
+ // login succeeded
+
+ if (!isset($this->steps[$next_preset])) {
+ $this->errorMessage = 'Preset "'.$next_preset.'" not yet implemented';
+ }
+ else {
+ $this->stepsPreset = $next_preset;
}
}
else {
- $this->errorMessage = 'By now only login using "root" username is supported';
+ // login failed
+ $user =& $this->Application->recallObject('u.current');
+ /* @var $user UsersItem */
+
+ $this->errorMessage = $user->GetErrorMsg('ValidateLogin').'. If you don\'t know your username or password, contact Intechnic Support';
}
}
+ else {
+ // if preset was not choosen, then raise error
+ $this->errorMessage = 'Please select action to perform';
+ }
break;
}
$this->PerformValidation(); // returns validation status (just in case)
}
/**
* Validates data entered by user
*
* @return bool
*/
function PerformValidation()
{
if ($this->GetVar('step') != $this->currentStep) {
// just redirect from previous step, don't validate
return true;
}
$status = true;
switch ($this->currentStep) {
case 'db_config':
// 1. check if required fields are filled
$section_name = 'Database';
$required_fields = Array ('DBType', 'DBHost', 'DBName', 'DBUser');
foreach ($required_fields as $required_field) {
if (!$this->systemConfig[$section_name][$required_field]) {
$status = false;
$this->errorMessage = 'Please fill all required fields';
break;
}
}
if (!$status) break;
// 2. check permissions, that use have in this database
$status = $this->CheckDatabase();
break;
case 'root_password':
// check, that password & verify password match
$password = $this->Application->GetVar('root_password');
$password_verify = $this->Application->GetVar('root_password_verify');
if ($password != $password_verify) {
$this->errorMessage = 'Passwords does not match';
}
elseif (strlen($password) < 4) {
$this->errorMessage = 'Root Password must be at least 4 characters';
}
$status = $this->errorMessage == '';
break;
}
return $status;
}
/**
* Perform installation step actions
*
*/
function Run()
{
if ($this->errorMessage) {
// was error during data validation stage
return ;
}
switch ($this->currentStep) {
case 'db_config':
// store db configuration
$this->SaveConfig();
// import base data into database
$this->RunSQL('/core/install/install_schema.sql');
$this->RunSQL('/core/install/install_data.sql');
break;
case 'root_password':
// update root password in database
$password = md5( md5($this->Application->GetVar('root_password')) . 'b38');
$this->SetConfigValue('RootPass', $password);
// set Site_Path (for SSL & old in-portal code)
$this->SetConfigValue('Site_Path', BASE_PATH.'/');
// import base language for core (english)
$this->ImportLanguage('/core/install/english');
// set imported language as primary
$lang =& $this->Application->recallObject('lang.-item', null, Array('skip_autoload' => true));
/* @var $lang LanguagesItem */
$lang->Load(1); // fresh install => ID=1
$lang->setPrimary();
break;
case 'choose_modules':
// run module install scripts
$modules = $this->Application->GetVar('modules');
- foreach ($modules as $module) {
- $install_file = MODULES_PATH.'/'.$module.'/install.php';
- if (file_exists($install_file)) {
- include_once($install_file);
+ if ($modules) {
+ foreach ($modules as $module) {
+ $install_file = MODULES_PATH.'/'.$module.'/install.php';
+ if (file_exists($install_file)) {
+ include_once($install_file);
+ }
}
}
-
// scan themes
$themes_helper =& $this->Application->recallObject('ThemesHelper');
/* @var $themes_helper kThemesHelper */
$themes_helper->refreshThemes();
$this->Conn->Query('UPDATE '.TABLE_PREFIX.'Theme SET Enabled=1, PrimaryTheme =1 LIMIT 1');
// update categories cache
$updater =& $this->Application->recallObject('kPermCacheUpdater');
/* @var $updater kPermCacheUpdater */
$updater->OneStepRun();
break;
+
+ case 'upgrade_modules':
+ // get installed modules from db and compare their versions to upgrade script
+ $modules = $this->Application->GetVar('modules');
+ if ($modules) {
+ $upgrade_data = $this->GetUpgradableModules();
+
+ foreach ($modules as $module_name) {
+ $module_info = $upgrade_data[$module_name];
+ $upgrades_file = sprintf(UPGRADES_FILE, $module_info['Path']);
+
+ $sqls = file_get_contents($upgrades_file);
+ $version_mark = '# ===== v '.$module_info['FromVersion'].' =====';
+
+ $start_pos = strpos($sqls, $version_mark);
+ $sqls = substr($sqls, $start_pos);
+ $this->RunSQLText($sqls);
+
+ // after upgrade sqls are executed update version
+ $sql = 'UPDATE '.TABLE_PREFIX.'Modules
+ SET Version = "'.$module_info['ToVersion'].'"
+ WHERE Name = "'.$module_name.'"';
+ $this->Conn->Query($sql);
+ }
+ }
+ else {
+ $this->errorMessage = 'Please select module(-s) to upgrade';
+ }
+ break;
+
case 'finish':
- $this->Conn->Query('INSERT INTO '.TABLE_PREFIX.'ConfigurationValues (VariableName, VariableValue) VALUE (\'InstallFinished\', 1)');
+ // delete cache
+ $sql = 'DELETE FROM '.TABLE_PREFIX.'Cache
+ WHERE VarName IN ("config_files","configs_parsed","sections_parsed")';
+ $this->Conn->Query($sql);
+
+ // set installation finished mark
+ if ($this->Application->ConfigValue('InstallFinished') === false) {
+ $fields_hash = Array (
+ 'VariableName' => 'InstallFinished',
+ 'VariableValue' => 1,
+ );
+ $this->Conn->doInsert($fields_hash, TABLE_PREFIX.'ConfigurationValues');
+ }
break;
}
if ($this->errorMessage) {
// was error during run stage
return ;
}
$this->currentStep = $this->GetNextStep();
$this->InitStep(); // init next step (that will be shown now)
$this->InitApplication();
if ($this->currentStep == -1) {
// step after last step -> redirect to admin
$this->Application->Redirect('index', null, '', 'index.php');
}
}
/**
* Sets new configuration variable value
*
* @param string $name
* @param mixed $value
*/
function SetConfigValue($name, $value)
{
$sql = 'UPDATE '.TABLE_PREFIX.'ConfigurationValues
SET VariableValue = '.$this->Conn->qstr($value).'
WHERE VariableName = '.$this->Conn->qstr($name);
$this->Conn->Query($sql);
}
- function InitApplication()
+ /**
+ * Initialize kApplication
+ *
+ * @param bool $force initialize in any case
+ */
+ function InitApplication($force = false)
{
- if (!in_array($this->currentStep, $this->skipApplicationSteps) && !isset($this->Application)) {
+ if (($force || !in_array($this->currentStep, $this->skipApplicationSteps)) && !isset($this->Application)) {
// step is allowed for application usage & it was not initialized in previous step
- global $debugger;
+ global $start, $debugger, $dbg_options;
include_once(FULL_PATH.'/core/kernel/startup.php');
$this->Application =& kApplication::Instance();
$this->Application->Init();
$this->Conn =& $this->Application->GetADODBConnection();
}
}
/**
* Show next step screen
*
*/
function Done($error_message = null)
{
if (isset($error_message)) {
$this->errorMessage = $error_message;
}
include_once (FULL_PATH.'/'.REL_PATH.'/install/incs/install.tpl');
if (isset($this->Application)) {
$this->Application->Done();
- echo 'SID: ['.$this->Application->GetSID().']<br />';
+// echo 'SID: ['.$this->Application->GetSID().']<br />';
}
exit;
}
function GetModuleVersion($module_name)
{
return '0.1.1';
}
function ConnectToDatabase()
{
include_once FULL_PATH.'/core/kernel/db/db_connection.php';
if (!isset($this->systemConfig['Database']['DBType']) ||
!isset($this->systemConfig['Database']['DBUser']) ||
!isset($this->systemConfig['Database']['DBName'])
) {
return false;
}
$this->Conn = new kDBConnection($this->systemConfig['Database']['DBType'], Array(&$this, 'DBErrorHandler'));
$this->Conn->Connect($this->systemConfig['Database']['DBHost'], $this->systemConfig['Database']['DBUser'], $this->systemConfig['Database']['DBUserPassword'], $this->systemConfig['Database']['DBName']);
return $this->Conn->errorCode == 0;
}
/**
* Checks if core is already installed
*
* @return bool
*/
function AlreadyInstalled()
{
$table_prefix = $this->systemConfig['Database']['TablePrefix'];
return $this->TableExists('ConfigurationValues') && $this->Conn->GetOne('SELECT VariableValue FROM '.$table_prefix.'ConfigurationValues WHERE VariableName = \'InstallFinished\'');
}
function CheckDatabase($check_installed = true)
{
// perform various check type to database specified
// 1. user is allowed to connect to database
// 2. user has all types of permissions in database
if (strlen($this->systemConfig['Database']['TablePrefix']) > 7) {
$this->errorMessage = 'Table prefix should not be longer than 7 characters';
return false;
}
// connect to database
$status = $this->ConnectToDatabase();
if ($status) {
// if connected, then check if all sql statements work
$sql_tests[] = 'DROP TABLE IF EXISTS test_table';
$sql_tests[] = 'CREATE TABLE test_table(test_col mediumint(6))';
$sql_tests[] = 'LOCK TABLES test_table WRITE';
$sql_tests[] = 'INSERT INTO test_table(test_col) VALUES (5)';
$sql_tests[] = 'UPDATE test_table SET test_col = 12';
$sql_tests[] = 'UNLOCK TABLES';
$sql_tests[] = 'ALTER TABLE test_table ADD COLUMN new_col varchar(10)';
$sql_tests[] = 'SELECT * FROM test_table';
$sql_tests[] = 'DELETE FROM test_table';
$sql_tests[] = 'DROP TABLE IF EXISTS test_table';
foreach ($sql_tests as $sql_test) {
$this->Conn->Query($sql_test);
if ($this->Conn->getErrorCode() != 0) {
$status = false;
break;
}
}
if ($status) {
// if statements work & connection made, then check table existance
if ($check_installed && $this->AlreadyInstalled()) {
$this->errorMessage = 'An In-Portal Database already exists at this location';
return false;
}
}
else {
// user has insufficient permissions in database specified
$db_error = 'Permission Error: ('.$this->Conn->getErrorCode().') '.$this->Conn->getErrorMsg();
return false;
}
}
else {
// was error while connecting
if (!$this->Conn) return false;
$this->errorMessage = 'Connection Error: ('.$this->Conn->getErrorCode().') '.$this->Conn->getErrorMsg();
return false;
}
return true;
}
/**
* Checks if all passed tables exists
*
* @param string $tables comma separated tables list
* @return bool
*/
function TableExists($tables)
{
$prefix = $this->systemConfig['Database']['TablePrefix'];
$all_found = true;
$tables = explode(',', $tables);
foreach ($tables as $table_name) {
$sql = 'SHOW TABLES LIKE "'.$prefix.$table_name.'"';
if (count($this->Conn->Query($sql)) == 0) {
$all_found = false;
break;
}
}
return $all_found;
}
+ /**
+ * Runs SQLs from file
+ *
+ * @param string $filename
+ * @param mixed $replace_from
+ * @param mixed $replace_to
+ */
function RunSQL($filename, $replace_from = null, $replace_to = null)
{
if (!file_exists(FULL_PATH.$filename)) {
return ;
}
$sqls = file_get_contents(FULL_PATH.$filename);
+ $this->RunSQLText($sqls, $replace_from, $replace_to);
+ }
+ /**
+ * Runs SQLs from string
+ *
+ * @param string $sqls
+ * @param mixed $replace_from
+ * @param mixed $replace_to
+ */
+ function RunSQLText(&$sqls, $replace_from = null, $replace_to = null)
+ {
$table_prefix = $this->systemConfig['Database']['TablePrefix'];
// add prefix to all tables
if (strlen($table_prefix) > 0) {
$replacements = Array ('CREATE TABLE ', 'INSERT INTO ', 'UPDATE ', 'ALTER TABLE ');
foreach ($replacements as $replacement) {
$sqls = str_replace($replacement, $replacement.$table_prefix, $sqls);
}
$sqls = str_replace('DROP TABLE ', 'DROP TABLE IF EXISTS '.$table_prefix, $sqls);
}
if (isset($replace_from) && isset($replace_to)) {
// replace something additionally, e.g. module root category
$sqls = str_replace($replace_from, $replace_to, $sqls);
}
-
+
+ $sqls = str_replace("\r\n", "\n", $sqls); // convert to linux line endings
+ $sqls = preg_replace("/#(.*?)\n/", '', $sqls); // remove all comments
$sqls = explode(";\n", $sqls);
foreach ($sqls as $sql) {
$sql = trim($sql);
- if (!$sql || substr($sql, 0, 1) == '#') {
- continue; // usually last line || comment
+ if (!$sql) {
+ continue; // usually last line
}
$this->Conn->Query($sql);
if ($this->Conn->getErrorCode() != 0) {
$this->errorMessage = 'Error: ('.$this->Conn->getErrorCode().') '.$this->Conn->getErrorMsg().'<br /><br />Database Query:<pre>'.htmlspecialchars($sql).'</pre>';
$this->Done();
break;
}
}
}
-
+
function ImportLanguage($lang_file)
{
$lang_file = FULL_PATH.$lang_file.'.lang';
if (!file_exists($lang_file)) {
return ;
}
$lang_xml =& $this->Application->recallObjectP('LangXML', null, Array(), false); // false - don't use temp tables
$lang_xml->Parse($lang_file, '|0|1|2|', '');
}
/**
* Returns modules list found in modules folder
*
* @return Array
*/
function ScanModules()
{
static $modules = null;
if (!isset($modules)) {
$modules = Array();
$fh = opendir(MODULES_PATH);
while (($sub_folder = readdir($fh))) {
$folder_path = MODULES_PATH.'/'.$sub_folder;
if ($sub_folder != '.' && $sub_folder != '..' && is_dir($folder_path)) {
if ($sub_folder == 'core') {
// skip modules here
continue;
}
// this is folder in MODULES_PATH directory
if (file_exists($folder_path.'/install.php') && file_exists($folder_path.'/install/install_schema.sql')) {
$modules[] = $sub_folder;
}
}
}
}
return $modules;
}
/**
+ * Converts module version in format X.Y.Z to signle integer
+ *
+ * @param string $version
+ * @return int
+ */
+ function ConvertModuleVersion($version)
+ {
+ $parts = explode('.', $version);
+
+ $bin = '';
+ foreach ($parts as $part) {
+ $bin .= str_pad(decbin($part), 8, '0', STR_PAD_LEFT);
+ }
+
+ return bindec($bin);
+ }
+
+ /**
+ * Returns list of modules, that can be upgraded
+ *
+ */
+ function GetUpgradableModules()
+ {
+ $ret = Array ();
+
+ foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
+ $upgrades_file = sprintf(UPGRADES_FILE, $module_info['Path']);
+ if (!file_exists($upgrades_file)) {
+ // no upgrade file
+ continue;
+ }
+
+ $sqls = file_get_contents($upgrades_file);
+ $versions_found = preg_match_all('/# ===== v ([\d]+\.[\d]+\.[\d]+) =====/s', $sqls, $regs);
+ if (!$versions_found) {
+ // upgrades file doesn't contain version definitions
+ continue;
+ }
+
+ $to_version = end($regs[1]);
+ $this_version = $this->ConvertModuleVersion($module_info['Version']);
+ if ($this->ConvertModuleVersion($to_version) > $this_version) {
+ // destination version is greather then current
+ foreach ($regs[1] as $version) {
+ if ($this->ConvertModuleVersion($version) > $this_version) {
+ $from_version = $version;
+ break;
+ }
+ }
+
+ $version_info = Array (
+ 'FromVersion' => $from_version,
+ 'ToVersion' => $to_version,
+ );
+
+ $ret[$module_name] = array_merge_recursive2($module_info, $version_info);
+ }
+ }
+
+ return $ret;
+ }
+
+ /**
* Returns content to show for current step
*
* @return string
*/
function GetStepBody()
{
$step_template = FULL_PATH.'/core/install/step_templates/'.$this->currentStep.'.tpl';
if (file_exists($step_template)) {
ob_start();
include_once ($step_template);
return ob_get_clean();
}
return '{step template "'.$this->currentStep.'" missing}';
}
/**
* Parses step information file, cache result for current step ONLY & return it
*
* @return Array
*/
function &_getStepInfo()
{
static $info = Array('help_title' => null, 'step_title' => null, 'help_body' => null, 'queried' => false);
if (!$info['queried']) {
$fdata = file_get_contents($this->StepDBFile);
$parser = xml_parser_create();
xml_parse_into_struct($parser, $fdata, $values, $index);
xml_parser_free($parser);
foreach ($index['STEP'] as $section_index) {
$step_data =& $values[$section_index];
if ($step_data['attributes']['NAME'] == $this->currentStep) {
$info['step_title'] = $step_data['attributes']['TITLE'];
if (isset($step_data['attributes']['HELP_TITLE'])) {
$info['help_title'] = $step_data['attributes']['HELP_TITLE'];
}
else {
// if help title not set, then use step title
$info['help_title'] = $step_data['attributes']['TITLE'];
}
$info['help_body'] = trim($step_data['value']);
break;
}
}
$info['queried'] = true;
}
return $info;
}
/**
* Returns particular information abou current step
*
* @param string $info_type
* @return string
*/
function GetStepInfo($info_type)
{
$step_info =& $this->_getStepInfo();
if (isset($step_info[$info_type])) {
return $step_info[$info_type];
}
return '{step "'.$this->currentStep.'"; param "'.$info_type.'" missing}';
}
/**
* Returns passed steps titles
*
* @param Array $steps
* @return Array
* @see kInstaller:PrintSteps
*/
function _getStepTitles($steps)
{
$fdata = file_get_contents($this->StepDBFile);
$parser = xml_parser_create();
xml_parse_into_struct($parser, $fdata, $values, $index);
xml_parser_free($parser);
$ret = Array ();
foreach ($index['STEP'] as $section_index) {
$step_data =& $values[$section_index];
if (in_array($step_data['attributes']['NAME'], $steps)) {
$ret[ $step_data['attributes']['NAME'] ] = $step_data['attributes']['TITLE'];
}
}
return $ret;
}
/**
* Returns current step number in active steps_preset.
* Value can't be cached, because same step can have different number in different presets
*
* @return int
*/
function GetStepNumber()
{
return array_search($this->currentStep, $this->steps[$this->stepsPreset]) + 1;
}
/**
* Returns step name to process next
*
* @return string
*/
function GetNextStep()
{
$next_index = $this->GetStepNumber();
if ($next_index > count($this->steps[$this->stepsPreset]) - 1) {
return -1;
}
return $this->steps[$this->stepsPreset][$next_index];
}
/**
* Returns step name, that was processed before this step
*
* @return string
*/
function GetPreviousStep()
{
$next_index = $this->GetStepNumber() - 1;
if ($next_index < 0) {
$next_index = 0;
}
return $this->steps[$this->stepsPreset][$next_index];
}
/**
* Prints all steps from active steps preset and highlights current step
*
* @param string $active_tpl
* @param string $passive_tpl
* @return string
*/
function PrintSteps($active_tpl, $passive_tpl)
{
$ret = '';
$step_titles = $this->_getStepTitles($this->steps[$this->stepsPreset]);
foreach ($this->steps[$this->stepsPreset] as $step_name) {
$template = $step_name == $this->currentStep ? $active_tpl : $passive_tpl;
$ret .= sprintf($template, $step_titles[$step_name]);
}
return $ret;
}
function ParseConfig($parse_section = false)
{
if (!file_exists($this->INIFile)) {
return Array();
}
if( file_exists($this->INIFile) && !is_readable($this->INIFile) ) {
die('Could Not Open Ini File');
}
$contents = file($this->INIFile);
$retval = Array();
$section = '';
$ln = 1;
$resave = false;
foreach ($contents as $line) {
if ($ln == 1 && $line != '<'.'?'.'php die() ?'.">\n") {
$resave = true;
}
$ln++;
$line = trim($line);
$line = eregi_replace(';[.]*','',$line);
if (strlen($line) > 0) {
//echo $line . " - ";
if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) {
//echo 'section';
$section = substr($line, 1, (strlen($line) - 2));
if ($parse_section) {
$retval[$section] = array();
}
continue;
} elseif (eregi('=',$line)) {
//echo 'main element';
list ($key, $val) = explode(' = ', $line);
if (!$parse_section) {
$retval[trim($key)] = str_replace('"', '', $val);
}
else {
$retval[$section][trim($key)] = str_replace('"', '', $val);
}
}
}
}
if ($resave) {
$fp = fopen($this->INIFile, 'w');
reset($contents);
fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
foreach ($contents as $line) {
fwrite($fp,"$line");
}
fclose($fp);
}
return $retval;
}
function SaveConfig()
{
$fp = fopen($this->INIFile, 'w');
fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
foreach ($this->systemConfig as $section_name => $section_data) {
fwrite($fp, '['.$section_name."]\n");
foreach ($section_data as $key => $value) {
fwrite($fp, $key.' = "'.$value.'"'."\n");
}
fwrite($fp, "\n");
}
fclose($fp);
}
/**
* Installation error handler for sql errors
*
* @param int $code
* @param string $msg
* @param string $sql
* @return bool
* @access private
*/
function DBErrorHandler($code, $msg, $sql)
{
$this->errorMessage = 'Query: <br />'.htmlspecialchars($sql).'<br />execution result is error:<br />['.$code.'] '.$msg;
return true;
}
/**
* Installation error handler
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
* @param Array $errcontext
*/
function ErrorHandler($errno, $errstr, $errfile = '', $errline = '', $errcontext = '')
{
if ($errno == E_USER_ERROR) {
// only react on user fatal errors
$this->Done($errstr);
}
}
}
/*function print_pre($s)
{
echo '<pre>', print_r($s, true). '</pre>';
}*/
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.6.2/core/install.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6.2.9
\ No newline at end of property
+1.6.2.10
\ No newline at end of property

Event Timeline