Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 6:56 PM

in-portal

Index: trunk/kernel/units/modules/modules_event_handler.php
===================================================================
--- trunk/kernel/units/modules/modules_event_handler.php (revision 1590)
+++ trunk/kernel/units/modules/modules_event_handler.php (revision 1591)
@@ -1,36 +1,36 @@
<?php
-class ModulesEventHandler extends InpDBEventHandler {
+ class ModulesEventHandler extends InpDBEventHandler {
/**
* Builds list
*
* @param kEvent $event
* @access protected
*/
function OnListBuild(&$event)
{
parent::OnListBuild($event);
}
/**
* Builds item
*
* @param kEvent $event
* @access protected
*/
function OnItemBuild(&$event)
{
- $this->Application->SetVar($this->Prefix."_".$event->Special."_id", $event->Special);
+ $this->Application->SetVar( $event->getPrefixSpecial(true).'_id', $event->Special);
parent::OnItemBuild($event);
}
- function SetCustomQuery(&$event){
- $object=&$event->getObject();
- $object->addFilter("current_module", "Name=".$event->Special);
-
- }
+ function SetCustomQuery(&$event)
+ {
+ $object=&$event->getObject();
+ $object->addFilter('current_module', 'Name='.$event->Special);
+ }
-}
+ }
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/modules/modules_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/admin/install/install_lib.php
===================================================================
--- trunk/admin/install/install_lib.php (revision 1590)
+++ trunk/admin/install/install_lib.php (revision 1591)
@@ -1,825 +1,825 @@
-<?php
-function minimum_php_version( $vercheck )
-{
- $minver = explode(".", $vercheck);
- $curver = explode(".", phpversion());
- if (($curver[0] < $minver[0])
- || (($curver[0] == $minver[0])
- && ($curver[1] < $minver[1]))
- || (($curver[0] == $minver[0]) && ($curver[1] == $minver[1])
- && ($curver[2][0] < $minver[2][0])))
- return false;
- else
- return true;
-}
-
-function VersionSort($a, $b)
-{
- if ($a == $b) {
- return 0;
- }
- else {
- $tmp_a = str_replace("inportal_upgrade_v", "", $a);
- $tmp_a = str_replace(".sql", "", $a);
-
- $tmp_b = str_replace("inportal_upgrade_v", "", $b);
- $tmp_b = str_replace(".sql", "", $b);
-
- return (ConvertVersion($a) < ConvertVersion($b)) ? -1 : 1;
- }
-}
-
-function GetMaxPortalVersion($admindirname)
-{
- $dir = @dir($admindirname.'/install/upgrades');
-
- $upgrades_arr = Array();
-
- $version = '';
- while ($file = $dir->read()) {
- if ($file != "." && $file != ".." && !is_dir($admindirname.$file)) {
- if (strstr($file, 'inportal_upgrade_v')) {
- $upgrades_arr[] = $file;
- }
- }
- }
-
- usort($upgrades_arr, "VersionSort");
-
- foreach($upgrades_arr as $file) {
- $file_tmp = str_replace("inportal_upgrade_v", "", $file);
- $file_tmp = str_replace(".sql", "", $file_tmp);
-
- if (ConvertVersion($file_tmp) > ConvertVersion($version)) {
- $version = $file_tmp;
- }
- }
-
- return $version;
-}
-
-function ConvertVersion($version)
-{
- $parts = explode('.', $version);
-
- $bin = '';
- foreach ($parts as $part) {
- $bin .= str_pad(decbin($part), 8, '0', STR_PAD_LEFT);
- }
-
- $dec = bindec($bin);
-
- return $dec;
-}
-
-function TableExists(&$ado, $tables)
-{
- global $g_TablePrefix;
-
- $t = explode(",",$tables);
-
- $i = $ado->MetaTables();
- for($x=0;$x<count($i);$x++)
- $i[$x] = strtolower($i[$x]);
-
- $AllFound = TRUE;
- for($tIndex=0;$tIndex<count($t);$tIndex++)
- {
- $table = $g_TablePrefix.$t[$tIndex];
- $table = strtolower($table);
- if(!in_array($table,$i))
- {
- $AllFound = FALSE;
- }
-
- }
- return $AllFound;
-}
-
-function set_ini_value($section, $key, $newvalue)
-{
- global $ini_vars;
- $ini_vars[$section][$key] = $newvalue;
-}
-
-function save_values()
-{
- // Should write something to somwere, but it doesn't :(
- global $ini_file,$ini_vars;
-
- //if( file_exists($ini_file) )
- //{
- $fp = fopen($ini_file, "w");
- fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
- foreach($ini_vars as $secname => $section)
- {
- fwrite($fp,"[".$secname."]\n");
- foreach($section as $key => $value) fwrite($fp,"$key = \"$value\"\n");
- fwrite($fp,"\n");
- }
- fclose($fp);
- //}
-}
-
-function getConnectionInterface($action, $dbo_type='adodb')
-{
- if($dbo_type == 'adodb')
- {
- switch($action)
- {
- case 'query': return 'Execute'; break;
- case 'errorno': return 'ErrorNo'; break;
- case 'errormsg': return 'ErrorMsg'; break;
- }
- }
-
- if($dbo_type == 'dbconnection')
- {
- switch($action)
- {
- case 'query': return 'Query'; break;
- case 'errorno': return 'getErrorCode'; break;
- case 'errormsg': return 'getErrorMsg'; break;
- }
-
- }
-}
-
-function RunSchemaFile(&$ado, $filename, $dbo_type='adodb')
-{
- if( file_exists($filename) )
- {
- $sql = file_get_contents($filename);
- if($sql) RunSchemaText($ado,$sql,$dbo_type);
- }
-}
-
-function RunSchemaText(&$ado, $sql, $dbo_type='adodb')
-{
- global $g_TablePrefix;
-
- if(strlen($g_TablePrefix))
- {
- $what = "CREATE TABLE ";
- $replace = "CREATE TABLE ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "DROP TABLE ";
- $replace = "DROP TABLE IF EXISTS ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "INSERT INTO ";
- $replace = "INSERT INTO ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "UPDATE ";
- $replace = "UPDATE ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "ALTER TABLE ";
- $replace = "ALTER TABLE ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
- }
-
- $commands = explode("# --------------------------------------------------------",$sql);
- if(count($commands)>0)
- {
- $query_func = getConnectionInterface('query',$dbo_type);
- $errorno_func = getConnectionInterface('errorno',$dbo_type);
- $errormsg_func = getConnectionInterface('errormsg',$dbo_type);
-
- for($i = 0; $i < count($commands); $i++)
- {
- $cmd = $commands[$i];
- $cmd = trim($cmd);
- if(strlen($cmd)>0)
- {
- $ado->$query_func($cmd);
- if($ado->$errorno_func() != 0)
- {
- $db_error = $ado->$errormsg_func()." COMMAND:<PRE>$cmd</PRE>";
- }
- }
- }
- }
-}
-
-function RunSQLText(&$ado, $allsql, $dbo_type='adodb')
-{
- global $g_TablePrefix;
-
- $line = 0;
- $query_func = getConnectionInterface('query',$dbo_type);
- $errorno_func = getConnectionInterface('errorno',$dbo_type);
- $errormsg_func = getConnectionInterface('errormsg',$dbo_type);
-
- while($line<count($allsql))
- {
- $sql = $allsql[$line];
- if(strlen(trim($sql))>0 && substr($sql,0,1)!="#")
- {
- if(strlen($g_TablePrefix))
- {
- $what = "CREATE TABLE ";
- $replace = "CREATE TABLE ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "DELETE FROM ";
- $replace = "DELETE FROM ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "DROP TABLE ";
- $replace = "DROP TABLE IF EXISTS ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "DROP TABLE IF EXISTS ";
- $replace = "DROP TABLE IF EXISTS ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "INSERT INTO ";
- $replace = "INSERT INTO ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "UPDATE ";
- $replace = "UPDATE ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
-
- $what = "ALTER TABLE ";
- $replace = "ALTER TABLE ".$g_TablePrefix;
- $sql = ereg_replace($what, $replace, $sql);
- }
- $sql = trim($sql);
- if(strlen($sql)>0)
- {
- $ado->$query_func($sql);
- if($ado->$errorno_func()!=0)
- {
- $db_error = $ado->$errormsg_func()." COMMAND:<PRE>$sql</PRE>";
- $error = TRUE;
- }
- }
- }
- $line++;
- }
-}
-
-function RunSQLFile(&$ado, $filename, $dbo_type='adodb')
-{
- if(file_exists($filename))
- {
- $allsql = file($filename);
- RunSQLText($ado,$allsql,$dbo_type);
- }
-}
-
-function RunRestoreFile($ado,$filename,$FileOffset,$MaxLines)
-{
- $size = filesize($filename);
-
- if($FileOffset > $size)
- return -2;
-
- $fp = fopen($filename,"r");
- if(!$fp)
- return -1;
-
- if($FileOffset>0)
- {
- fseek($fp,$FileOffset);
- }
- else
- {
- $EndOfSQL = FALSE;
- $sql = "";
- while(!feof($fp) && !$EndOfSQL)
- {
- $l = fgets($fp,16384);
- if(substr($l,0,11)=="INSERT INTO")
- {
- $EndOfSQL = TRUE;
- }
- else
- {
- $sql .= $l;
- $FileOffset = ftell($fp) - strlen($l);
- }
- }
- if(strlen($sql))
- {
- RunSchemaText($ado,$sql);
- }
- fseek($fp,$FileOffset);
- }
- $LinesRead = 0;
- $sql = "";
- $AllSql = array();
- while($LinesRead < $MaxLines && !feof($fp))
- {
- $sql = fgets($fp, 16384);
- if(strlen($sql))
- {
- $AllSql[] = $sql;
- $LinesRead++;
- }
- }
- if(!feof($fp))
- {
- $FileOffset = ftell($fp);
- }
- else
- {
- $FileOffset = $TotalSize;
- }
- fclose($fp);
- if(count($AllSql)>0)
- RunSQLText($ado,$AllSql);
- return (int)$FileOffset;
-}
-
-
-function _inst_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 _inst_decrypt($txt,$key)
-{
- $txt = _inst_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 inst_LoadFromRemote()
-{
- return "";
-}
-
-function mod_DLid()
-{
- global $DownloadId;
- echo $DownloadId."\n";
- die();
-}
-
-function ae666b1b8279502f4c4b570f133d513e($LoadRemote=FALSE,$file="")
-{
- return _inst_LoadLicense($LoadRemote,$file);
-}
-
-function _inst_LoadLicense($LoadRemote=FALSE,$file="")
-{
- global $path,$admin;
-
- $data = Array();
-
- if(!strlen($file))
- {
- $f = $path.$admin."/include/inportal.dat";
- }
- else
- $f = $file;
- if(file_exists($f))
- {
- $contents = file($f);
- $data[0] = base64_decode($contents[1]);
- $data[1] = $contents[2];
- }
- else
- if($LoadRemote)
- return $LoadFromRemote;
- return $data;
-}
-
-function inst_SaveLicense($data)
-{
-
-}
-
-function _inst_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 a83570933e44bc66b31dd7127cf3f23a($txt)
-{
- return _inst_ParseLicense($txt);
-}
-
-function _inst_ParseLicense($txt)
-{
- global $i_User, $i_Pswd, $i_Keys;
- $data = _inst_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(_inst_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 de3ec1b7a142cccd0d51f03d24280744($domain)
-{
- _inst_falseIsLocalSite($domain);
- return _inst_IsLocalSite($domain);
-}
-
-function _inst_GetObscureValue($i)
-{
- if ($i == 'x') return 0254;
- if ($i == 'z') return 0x7F.'.';
- if ($i >= 5 && $i < 7) return _inst_GetObscureValue($z)*_inst_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 '.'.(_inst_GetObscureValue(6.5)+1);
- if ($i == 'a') return 0xa;
-}
-
-function _inst_Chr($val)
-{
- $x = _inst_GetObscureValue(25);
- $f = chr($x).chr($x+5).chr($x+15);
- return $f($val);
-}
-
-function _inst_IsLocalSite($domain)
-{
- $ee = _inst_GetObscureValue(35);
- foreach ($ee as $e) {
- $yy .= _inst_Chr($e);
- }
- $localb = FALSE;
- if(substr($domain,0,3)==_inst_GetObscureValue('x'))
- {
- $b = substr($domain,0,6);
- $p = explode(".",$domain);
- $subnet = $p[1];
- if($p[1]>15 && $p[1]<32)
- $localb=TRUE;
- }
- $zz = _inst_GetObscureValue('z')._inst_GetObscureValue(5).'.'.(int)_inst_GetObscureValue(7)._inst_GetObscureValue(12);
- $ff = _inst_GetObscureValue('z')+65;
- $hh = $ff-0x18;
- if($domain==$yy || $domain==$zz || substr($domain,0,7)==$ff._inst_Chr(46).$hh ||
- substr($domain,0,3)==_inst_GetObscureValue('a')._inst_Chr(46) || $localb || strpos($domain,".")==0)
- {
- return TRUE;
- }
- return FALSE;
-}
-
-function _inst_falseIsLocalSite($domain)
-{
- $localb = FALSE;
- if(substr($domain,0,3)=="172" || $domain == '##code##')
- {
- $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;
-}
-
-function ed592fe427e1ce60e32ffcb0c82d8557($name)
-{
- return _inst_ModuleLicensed($name);
-}
-
-function _inst_ModuleLicensed($name)
-{
- global $i_Keys, $objConfig, $g_License, $g_Domain;
-
- $lic = base64_decode($g_License);
- _inst_ParseLicense($lic);
-
- $modules = array();
- if(!_inst_IsLocalSite($g_Domain))
- {
- for($x=0;$x<count($i_Keys);$x++)
- {
- $key = $i_Keys[$x];
- if (strlen(stristr($g_Domain,$key["domain"])))
- {
- $modules = explode(",",strtolower($key["mod"]));
- }
- }
- if(in_array(strtolower($name),$modules))
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- else
- return TRUE;
-
- return FALSE;
-}
-
-function inst_parse_portal_ini($file, $parse_section = false) {
- if(!file_exists($file) && !is_readable($file))
- die("Could Not Open Ini File $file");
-
- $contents = file($file);
-
- $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) {
- if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) {
- $section = substr($line,1,(strlen($line)-2));
- if ($parse_section) {
- $retval[$section] = array();
- }
- continue;
- } elseif(eregi('=',$line)) {
- list($key,$val) = explode(' = ',$line);
- if (!$parse_section) {
- $retval[trim($key)] = str_replace('"', '', $val);
- }
- else {
- $retval[$section][trim($key)] = str_replace('"', '', $val);
- }
- } //end if
- } //end if
- } //end foreach
- if ($resave) {
- $fp = fopen($file, "w");
- reset($contents);
- fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
- foreach($contents as $line) fwrite($fp,"$line");
- fclose($fp);
- }
-
- return $retval;
-}
-
-function a48d819089308a9aeb447e7248b2587f()
-{
- return _inst_GetModuleList();
-}
-
-function _inst_GetModuleList()
-{
- global $rootpath,$pathchar,$admin, $pathtoroot;
-
- $path = $pathtoroot;
-
- $new = array();
- if ($dir = @opendir($path))
- {
- while (($file = readdir($dir)) !== false)
- {
- if($file !="." && $file !=".." && substr($file,0,1)!="_")
- {
- if(is_dir($path."/".$file))
- {
- $ModuleAdminDir = $path.$file.'/admin/';
- $inst_file = $ModuleAdminDir.'install.php';
- if( file_exists($inst_file) && file_exists($ModuleAdminDir.'install/inportal_schema.sql') )
- {
- if(_inst_ModuleLicensed($file)) {
- $new[$file] = $inst_file;
- }
- }
- }
- }
- }
- closedir($dir);
- }
- return array_keys($new);
-}
-
-function GetDirList ($dirName)
-{
-
- $filedates = array();
- $d = dir($dirName);
-
- while($entry = $d->read())
- {
- if ($entry != "." && $entry != "..")
- {
- if (!is_dir($dirName."/".$entry))
- {
- $filedate[]=$entry;
- }
- }
- }
- $d->close();
- return $filedate;
-}
-
-function GetLanguageList()
-{
- global $pathtoroot, $admin;
-
- $packs = array();
- $dir = $pathtoroot.$admin."/install/langpacks";
- $files = GetDirList($dir);
-
- if(is_array($files))
- {
- foreach($files as $f)
- {
- $p = pathinfo($f);
- if($p["extension"]=="lang")
- {
- $packs[] = $f;
- }
- }
- }
- return $packs;
-}
-
-function section_header($title, $return_result = false)
-{
- $ret = '<table border="0" cellpadding="2" cellspacing="0" class="tableborder_full" width="100%" height="30">'.
- '<tr><td class="tablenav" width="580" nowrap background="images/tabnav_left.jpg"><span class="tablenav_link">&nbsp;'.$title.'</span>'.
- '</td><td align="right" class="tablenav" background="images/tabnav_back.jpg" width="100%">'.
- "<a class=\"link\" onclick=\"ShowHelp('in-portal:install');\"><img src=\"images/blue_bar_help.gif\" border=\"0\"></A>".
- '</td></tr></table>';
- if( $return_result )
- return $ret;
- else
- echo $ret;
-}
-
-function &VerifyDB($error_state, $next_state, $success_func = null, $db_must_exist = false)
-{
- // perform various check type to database specified
- // 1. user is allowed to connect to database
- // 2. user has all types of permissions in database
- global $state, $db_error;
-
- // enshure we use data from post & not from config
- $GLOBALS['g_DBType'] = $_POST["ServerType"];
- $GLOBALS['g_DBHost'] = $_POST["ServerHost"];
- $GLOBALS['g_DBName'] = $_POST["ServerDB"];
- $GLOBALS['g_DBUser'] = $_POST["ServerUser"];
- $GLOBALS['g_DBUserPassword'] = $_POST["ServerPass"];
-
- // connect to database
- $ado =& inst_GetADODBConnection();
- if($ado->ErrorNo() != 0)
- {
- // was error while connecting
- $db_error = "Connection Error: (".$ado->ErrorNo().") ".$ado->ErrorMsg();
- $state = $error_state;
-
- }
- elseif( $ado->ErrorNo() == 0 )
- {
- // if connected, then check if all sql statements work
- $test_result = 1;
-
- $sql_tests[] = 'DROP TABLE IF EXISTS test_table';
- $sql_tests[] = 'CREATE TABLE test_table(test_col mediumint(6))';
- $sql_tests[] = 'INSERT INTO test_table(test_col) VALUES (5)';
- $sql_tests[] = 'UPDATE test_table SET test_col = 12';
- $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)
- {
- $ado->Execute($sql_test);
- if( $ado->ErrorNo()!=0 )
- {
- $test_result = 0;
- break;
- }
- }
-
- if($test_result == 1)
- {
- // if statements work & connection made, then check table existance
- $db_exists = TableExists($ado,"ConfigurationAdmin,Category,Permissions");
- if($db_exists != $db_must_exist)
- {
- $state = $error_state;
- $db_error = $db_must_exist ? 'An In-Portal Database already exists at this location' : 'An In-Portal Database was not found at this location';
- }
- else
- {
- $state = $next_state;
- if( isset($success_func) ) $success_func();
- }
- }
- else
- {
- // user has insufficient permissions in database specified
- $db_error = "Permission Error: (".$ado->ErrorNo().") ".$ado->ErrorMsg();
- $state = $error_state;
- }
- }
- return $ado;
-}
-
-function SaveDBConfig()
-{
- // save new database configuration
- set_ini_value("Database", "DBType",$_POST["ServerType"]);
- set_ini_value("Database", "DBHost",$_POST["ServerHost"]);
- set_ini_value("Database", "DBName",$_POST["ServerDB"]);
- set_ini_value("Database", "DBUser",$_POST["ServerUser"]);
- set_ini_value("Database", "DBUserPassword",$_POST["ServerPass"]);
- set_ini_value("Database","TablePrefix",$_POST["TablePrefix"]);
- save_values();
- $GLOBALS['include_file'] = 'install/install_finish.php';
-}
-
-function ReSetVar($var)
-{
- // define varible if not defined before
- if( !isset($GLOBALS[$var]) ) $GLOBALS[$var] = '';
-}
-
-// if globals.php not yet included (1st steps of install),
-// then define GetVar function
-if( !function_exists('GetVar') )
-{
- function GetVar($name, $post_priority = false)
- {
- if(!$post_priority) // follow gpc_order in php.ini
- return isset($_REQUEST[$name]) ? $_REQUEST[$name] : false;
- else // get variable from post 1stly if not found then from get
- return isset($_POST[$name]) && $_POST[$name] ? $_POST[$name] : ( isset($_GET[$name]) && $_GET[$name] ? $_GET[$name] : false );
- }
-}
-
-function RadioChecked($name, $value)
-{
- // return " checked" word in case if radio is checked
- $submit_value = GetVar($name);
- return $submit_value == $value ? ' checked' : '';
-}
-
-?>
+<?php
+function minimum_php_version( $vercheck )
+{
+ $minver = explode(".", $vercheck);
+ $curver = explode(".", phpversion());
+ if (($curver[0] < $minver[0])
+ || (($curver[0] == $minver[0])
+ && ($curver[1] < $minver[1]))
+ || (($curver[0] == $minver[0]) && ($curver[1] == $minver[1])
+ && ($curver[2][0] < $minver[2][0])))
+ return false;
+ else
+ return true;
+}
+
+function VersionSort($a, $b)
+{
+ if ($a == $b) {
+ return 0;
+ }
+ else {
+ $tmp_a = str_replace("inportal_upgrade_v", "", $a);
+ $tmp_a = str_replace(".sql", "", $a);
+
+ $tmp_b = str_replace("inportal_upgrade_v", "", $b);
+ $tmp_b = str_replace(".sql", "", $b);
+
+ return (ConvertVersion($a) < ConvertVersion($b)) ? -1 : 1;
+ }
+}
+
+function GetMaxPortalVersion($admindirname)
+{
+ $dir = @dir($admindirname.'/install/upgrades');
+
+ $upgrades_arr = Array();
+
+ $version = '';
+ while ($file = $dir->read()) {
+ if ($file != "." && $file != ".." && !is_dir($admindirname.$file)) {
+ if (strstr($file, 'inportal_upgrade_v')) {
+ $upgrades_arr[] = $file;
+ }
+ }
+ }
+
+ usort($upgrades_arr, "VersionSort");
+
+ foreach($upgrades_arr as $file) {
+ $file_tmp = str_replace("inportal_upgrade_v", "", $file);
+ $file_tmp = str_replace(".sql", "", $file_tmp);
+
+ if (ConvertVersion($file_tmp) > ConvertVersion($version)) {
+ $version = $file_tmp;
+ }
+ }
+
+ return $version;
+}
+
+function ConvertVersion($version)
+{
+ $parts = explode('.', $version);
+
+ $bin = '';
+ foreach ($parts as $part) {
+ $bin .= str_pad(decbin($part), 8, '0', STR_PAD_LEFT);
+ }
+
+ $dec = bindec($bin);
+
+ return $dec;
+}
+
+function TableExists(&$ado, $tables)
+{
+ global $g_TablePrefix;
+
+ $t = explode(",",$tables);
+
+ $i = $ado->MetaTables();
+ for($x=0;$x<count($i);$x++)
+ $i[$x] = strtolower($i[$x]);
+
+ $AllFound = TRUE;
+ for($tIndex=0;$tIndex<count($t);$tIndex++)
+ {
+ $table = $g_TablePrefix.$t[$tIndex];
+ $table = strtolower($table);
+ if(!in_array($table,$i))
+ {
+ $AllFound = FALSE;
+ }
+
+ }
+ return $AllFound;
+}
+
+function set_ini_value($section, $key, $newvalue)
+{
+ global $ini_vars;
+ $ini_vars[$section][$key] = $newvalue;
+}
+
+function save_values()
+{
+ // Should write something to somwere, but it doesn't :(
+ global $ini_file,$ini_vars;
+
+ //if( file_exists($ini_file) )
+ //{
+ $fp = fopen($ini_file, "w");
+ fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
+ foreach($ini_vars as $secname => $section)
+ {
+ fwrite($fp,"[".$secname."]\n");
+ foreach($section as $key => $value) fwrite($fp,"$key = \"$value\"\n");
+ fwrite($fp,"\n");
+ }
+ fclose($fp);
+ //}
+}
+
+function getConnectionInterface($action, $dbo_type='adodb')
+{
+ if($dbo_type == 'adodb')
+ {
+ switch($action)
+ {
+ case 'query': return 'Execute'; break;
+ case 'errorno': return 'ErrorNo'; break;
+ case 'errormsg': return 'ErrorMsg'; break;
+ }
+ }
+
+ if($dbo_type == 'dbconnection')
+ {
+ switch($action)
+ {
+ case 'query': return 'Query'; break;
+ case 'errorno': return 'getErrorCode'; break;
+ case 'errormsg': return 'getErrorMsg'; break;
+ }
+
+ }
+}
+
+function RunSchemaFile(&$ado, $filename, $dbo_type='adodb')
+{
+ if( file_exists($filename) )
+ {
+ $sql = file_get_contents($filename);
+ if($sql) RunSchemaText($ado,$sql,$dbo_type);
+ }
+}
+
+function RunSchemaText(&$ado, $sql, $dbo_type='adodb')
+{
+ global $g_TablePrefix;
+
+ if(strlen($g_TablePrefix))
+ {
+ $what = "CREATE TABLE ";
+ $replace = "CREATE TABLE ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "DROP TABLE ";
+ $replace = "DROP TABLE IF EXISTS ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "INSERT INTO ";
+ $replace = "INSERT INTO ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "UPDATE ";
+ $replace = "UPDATE ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "ALTER TABLE ";
+ $replace = "ALTER TABLE ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+ }
+
+ $commands = explode("# --------------------------------------------------------",$sql);
+ if(count($commands)>0)
+ {
+ $query_func = getConnectionInterface('query',$dbo_type);
+ $errorno_func = getConnectionInterface('errorno',$dbo_type);
+ $errormsg_func = getConnectionInterface('errormsg',$dbo_type);
+
+ for($i = 0; $i < count($commands); $i++)
+ {
+ $cmd = $commands[$i];
+ $cmd = trim($cmd);
+ if(strlen($cmd)>0)
+ {
+ $ado->$query_func($cmd);
+ if($ado->$errorno_func() != 0)
+ {
+ $db_error = $ado->$errormsg_func()." COMMAND:<PRE>$cmd</PRE>";
+ }
+ }
+ }
+ }
+}
+
+function RunSQLText(&$ado, $allsql, $dbo_type='adodb')
+{
+ global $g_TablePrefix;
+
+ $line = 0;
+ $query_func = getConnectionInterface('query',$dbo_type);
+ $errorno_func = getConnectionInterface('errorno',$dbo_type);
+ $errormsg_func = getConnectionInterface('errormsg',$dbo_type);
+
+ while($line<count($allsql))
+ {
+ $sql = $allsql[$line];
+ if(strlen(trim($sql))>0 && substr($sql,0,1)!="#")
+ {
+ if(strlen($g_TablePrefix))
+ {
+ $what = "CREATE TABLE ";
+ $replace = "CREATE TABLE ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "DELETE FROM ";
+ $replace = "DELETE FROM ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "DROP TABLE ";
+ $replace = "DROP TABLE IF EXISTS ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "DROP TABLE IF EXISTS ";
+ $replace = "DROP TABLE IF EXISTS ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "INSERT INTO ";
+ $replace = "INSERT INTO ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "UPDATE ";
+ $replace = "UPDATE ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+
+ $what = "ALTER TABLE ";
+ $replace = "ALTER TABLE ".$g_TablePrefix;
+ $sql = ereg_replace($what, $replace, $sql);
+ }
+ $sql = trim($sql);
+ if(strlen($sql)>0)
+ {
+ $ado->$query_func($sql);
+ if($ado->$errorno_func()!=0)
+ {
+ $db_error = $ado->$errormsg_func()." COMMAND:<PRE>$sql</PRE>";
+ $error = TRUE;
+ }
+ }
+ }
+ $line++;
+ }
+}
+
+function RunSQLFile(&$ado, $filename, $dbo_type='adodb')
+{
+ if(file_exists($filename))
+ {
+ $allsql = file($filename);
+ RunSQLText($ado,$allsql,$dbo_type);
+ }
+}
+
+function RunRestoreFile($ado,$filename,$FileOffset,$MaxLines)
+{
+ $size = filesize($filename);
+
+ if($FileOffset > $size)
+ return -2;
+
+ $fp = fopen($filename,"r");
+ if(!$fp)
+ return -1;
+
+ if($FileOffset>0)
+ {
+ fseek($fp,$FileOffset);
+ }
+ else
+ {
+ $EndOfSQL = FALSE;
+ $sql = "";
+ while(!feof($fp) && !$EndOfSQL)
+ {
+ $l = fgets($fp,16384);
+ if(substr($l,0,11)=="INSERT INTO")
+ {
+ $EndOfSQL = TRUE;
+ }
+ else
+ {
+ $sql .= $l;
+ $FileOffset = ftell($fp) - strlen($l);
+ }
+ }
+ if(strlen($sql))
+ {
+ RunSchemaText($ado,$sql);
+ }
+ fseek($fp,$FileOffset);
+ }
+ $LinesRead = 0;
+ $sql = "";
+ $AllSql = array();
+ while($LinesRead < $MaxLines && !feof($fp))
+ {
+ $sql = fgets($fp, 16384);
+ if(strlen($sql))
+ {
+ $AllSql[] = $sql;
+ $LinesRead++;
+ }
+ }
+ if(!feof($fp))
+ {
+ $FileOffset = ftell($fp);
+ }
+ else
+ {
+ $FileOffset = $TotalSize;
+ }
+ fclose($fp);
+ if(count($AllSql)>0)
+ RunSQLText($ado,$AllSql);
+ return (int)$FileOffset;
+}
+
+
+function _inst_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 _inst_decrypt($txt,$key)
+{
+ $txt = _inst_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 inst_LoadFromRemote()
+{
+ return "";
+}
+
+function mod_DLid()
+{
+ global $DownloadId;
+ echo $DownloadId."\n";
+ die();
+}
+
+function ae666b1b8279502f4c4b570f133d513e($LoadRemote=FALSE,$file="")
+{
+ return _inst_LoadLicense($LoadRemote,$file);
+}
+
+function _inst_LoadLicense($LoadRemote=FALSE,$file="")
+{
+ global $path,$admin;
+
+ $data = Array();
+
+ if(!strlen($file))
+ {
+ $f = $path.$admin."/include/inportal.dat";
+ }
+ else
+ $f = $file;
+ if(file_exists($f))
+ {
+ $contents = file($f);
+ $data[0] = base64_decode($contents[1]);
+ $data[1] = $contents[2];
+ }
+ else
+ if($LoadRemote)
+ return $LoadFromRemote;
+ return $data;
+}
+
+function inst_SaveLicense($data)
+{
+
+}
+
+function _inst_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 a83570933e44bc66b31dd7127cf3f23a($txt)
+{
+ return _inst_ParseLicense($txt);
+}
+
+function _inst_ParseLicense($txt)
+{
+ global $i_User, $i_Pswd, $i_Keys;
+ $data = _inst_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(_inst_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 de3ec1b7a142cccd0d51f03d24280744($domain)
+{
+ _inst_falseIsLocalSite($domain);
+ return _inst_IsLocalSite($domain);
+}
+
+function _inst_GetObscureValue($i)
+{
+ if ($i == 'x') return 0254;
+ if ($i == 'z') return 0x7F.'.';
+ if ($i >= 5 && $i < 7) return _inst_GetObscureValue($z)*_inst_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 '.'.(_inst_GetObscureValue(6.5)+1);
+ if ($i == 'a') return 0xa;
+}
+
+function _inst_Chr($val)
+{
+ $x = _inst_GetObscureValue(25);
+ $f = chr($x).chr($x+5).chr($x+15);
+ return $f($val);
+}
+
+function _inst_IsLocalSite($domain)
+{
+ $ee = _inst_GetObscureValue(35);
+ foreach ($ee as $e) {
+ $yy .= _inst_Chr($e);
+ }
+ $localb = FALSE;
+ if(substr($domain,0,3)==_inst_GetObscureValue('x'))
+ {
+ $b = substr($domain,0,6);
+ $p = explode(".",$domain);
+ $subnet = $p[1];
+ if($p[1]>15 && $p[1]<32)
+ $localb=TRUE;
+ }
+ $zz = _inst_GetObscureValue('z')._inst_GetObscureValue(5).'.'.(int)_inst_GetObscureValue(7)._inst_GetObscureValue(12);
+ $ff = _inst_GetObscureValue('z')+65;
+ $hh = $ff-0x18;
+ if($domain==$yy || $domain==$zz || substr($domain,0,7)==$ff._inst_Chr(46).$hh ||
+ substr($domain,0,3)==_inst_GetObscureValue('a')._inst_Chr(46) || $localb || strpos($domain,".")==0)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+function _inst_falseIsLocalSite($domain)
+{
+ $localb = FALSE;
+ if(substr($domain,0,3)=="172" || $domain == '##code##')
+ {
+ $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;
+}
+
+function ed592fe427e1ce60e32ffcb0c82d8557($name)
+{
+ return _inst_ModuleLicensed($name);
+}
+
+function _inst_ModuleLicensed($name)
+{
+ global $i_Keys, $objConfig, $g_License, $g_Domain;
+
+ $lic = base64_decode($g_License);
+ _inst_ParseLicense($lic);
+
+ $modules = array();
+ if(!_inst_IsLocalSite($g_Domain))
+ {
+ for($x=0;$x<count($i_Keys);$x++)
+ {
+ $key = $i_Keys[$x];
+ if (strlen(stristr($g_Domain,$key["domain"])))
+ {
+ $modules = explode(",",strtolower($key["mod"]));
+ }
+ }
+ if(in_array(strtolower($name),$modules))
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ else
+ return TRUE;
+
+ return FALSE;
+}
+
+function inst_parse_portal_ini($file, $parse_section = false) {
+ if(!file_exists($file) && !is_readable($file))
+ die("Could Not Open Ini File $file");
+
+ $contents = file($file);
+
+ $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) {
+ if(eregi('^[[a-z]+]$',str_replace(' ', '', $line))) {
+ $section = substr($line,1,(strlen($line)-2));
+ if ($parse_section) {
+ $retval[$section] = array();
+ }
+ continue;
+ } elseif(eregi('=',$line)) {
+ list($key,$val) = explode(' = ',$line);
+ if (!$parse_section) {
+ $retval[trim($key)] = str_replace('"', '', $val);
+ }
+ else {
+ $retval[$section][trim($key)] = str_replace('"', '', $val);
+ }
+ } //end if
+ } //end if
+ } //end foreach
+ if ($resave) {
+ $fp = fopen($file, "w");
+ reset($contents);
+ fwrite($fp,'<'.'?'.'php die() ?'.">\n\n");
+ foreach($contents as $line) fwrite($fp,"$line");
+ fclose($fp);
+ }
+
+ return $retval;
+}
+
+function a48d819089308a9aeb447e7248b2587f()
+{
+ return _inst_GetModuleList();
+}
+
+function _inst_GetModuleList()
+{
+ global $rootpath,$pathchar,$admin, $pathtoroot;
+
+ $path = $pathtoroot;
+
+ $new = array();
+ if ($dir = @opendir($path))
+ {
+ while (($file = readdir($dir)) !== false)
+ {
+ if($file !="." && $file !=".." && substr($file,0,1)!="_")
+ {
+ if(is_dir($path."/".$file))
+ {
+ $ModuleAdminDir = $path.$file.'/admin/';
+ $inst_file = $ModuleAdminDir.'install.php';
+ if( file_exists($inst_file) && file_exists($ModuleAdminDir.'install/inportal_schema.sql') )
+ {
+ if(_inst_ModuleLicensed($file)) {
+ $new[$file] = $inst_file;
+ }
+ }
+ }
+ }
+ }
+ closedir($dir);
+ }
+ return array_keys($new);
+}
+
+function GetDirList ($dirName)
+{
+
+ $filedates = array();
+ $d = dir($dirName);
+
+ while($entry = $d->read())
+ {
+ if ($entry != "." && $entry != "..")
+ {
+ if (!is_dir($dirName."/".$entry))
+ {
+ $filedate[]=$entry;
+ }
+ }
+ }
+ $d->close();
+ return $filedate;
+}
+
+function GetLanguageList()
+{
+ global $pathtoroot, $admin;
+
+ $packs = array();
+ $dir = $pathtoroot.$admin."/install/langpacks";
+ $files = GetDirList($dir);
+
+ if(is_array($files))
+ {
+ foreach($files as $f)
+ {
+ $p = pathinfo($f);
+ if($p["extension"]=="lang")
+ {
+ $packs[] = $f;
+ }
+ }
+ }
+ return $packs;
+}
+
+function section_header($title, $return_result = false)
+{
+ $ret = '<table border="0" cellpadding="2" cellspacing="0" class="tableborder_full" width="100%" height="30">'.
+ '<tr><td class="tablenav" width="580" nowrap background="images/tabnav_left.jpg"><span class="tablenav_link">&nbsp;'.$title.'</span>'.
+ '</td><td align="right" class="tablenav" background="images/tabnav_back.jpg" width="100%">'.
+ "<a class=\"link\" onclick=\"ShowHelp('in-portal:install');\"><img src=\"images/blue_bar_help.gif\" border=\"0\"></A>".
+ '</td></tr></table>';
+ if( $return_result )
+ return $ret;
+ else
+ echo $ret;
+}
+
+function &VerifyDB($error_state, $next_state, $success_func = null, $db_must_exist = false)
+{
+ // perform various check type to database specified
+ // 1. user is allowed to connect to database
+ // 2. user has all types of permissions in database
+ global $state, $db_error;
+
+ // enshure we use data from post & not from config
+ $GLOBALS['g_DBType'] = $_POST["ServerType"];
+ $GLOBALS['g_DBHost'] = $_POST["ServerHost"];
+ $GLOBALS['g_DBName'] = $_POST["ServerDB"];
+ $GLOBALS['g_DBUser'] = $_POST["ServerUser"];
+ $GLOBALS['g_DBUserPassword'] = $_POST["ServerPass"];
+
+ // connect to database
+ $ado =& inst_GetADODBConnection();
+ if($ado->ErrorNo() != 0)
+ {
+ // was error while connecting
+ $db_error = "Connection Error: (".$ado->ErrorNo().") ".$ado->ErrorMsg();
+ $state = $error_state;
+
+ }
+ elseif( $ado->ErrorNo() == 0 )
+ {
+ // if connected, then check if all sql statements work
+ $test_result = 1;
+
+ $sql_tests[] = 'DROP TABLE IF EXISTS test_table';
+ $sql_tests[] = 'CREATE TABLE test_table(test_col mediumint(6))';
+ $sql_tests[] = 'INSERT INTO test_table(test_col) VALUES (5)';
+ $sql_tests[] = 'UPDATE test_table SET test_col = 12';
+ $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)
+ {
+ $ado->Execute($sql_test);
+ if( $ado->ErrorNo()!=0 )
+ {
+ $test_result = 0;
+ break;
+ }
+ }
+
+ if($test_result == 1)
+ {
+ // if statements work & connection made, then check table existance
+ $db_exists = TableExists($ado,"ConfigurationAdmin,Category,Permissions");
+ if($db_exists != $db_must_exist)
+ {
+ $state = $error_state;
+ $db_error = $db_must_exist ? 'An In-Portal Database already exists at this location' : 'An In-Portal Database was not found at this location';
+ }
+ else
+ {
+ $state = $next_state;
+ if( isset($success_func) ) $success_func();
+ }
+ }
+ else
+ {
+ // user has insufficient permissions in database specified
+ $db_error = "Permission Error: (".$ado->ErrorNo().") ".$ado->ErrorMsg();
+ $state = $error_state;
+ }
+ }
+ return $ado;
+}
+
+function SaveDBConfig()
+{
+ // save new database configuration
+ set_ini_value("Database", "DBType",$_POST["ServerType"]);
+ set_ini_value("Database", "DBHost",$_POST["ServerHost"]);
+ set_ini_value("Database", "DBName",$_POST["ServerDB"]);
+ set_ini_value("Database", "DBUser",$_POST["ServerUser"]);
+ set_ini_value("Database", "DBUserPassword",$_POST["ServerPass"]);
+ set_ini_value("Database","TablePrefix",$_POST["TablePrefix"]);
+ save_values();
+ $GLOBALS['include_file'] = 'install/install_finish.php';
+}
+
+function ReSetVar($var)
+{
+ // define varible if not defined before
+ if( !isset($GLOBALS[$var]) ) $GLOBALS[$var] = '';
+}
+
+// if globals.php not yet included (1st steps of install),
+// then define GetVar function
+if( !function_exists('GetVar') )
+{
+ function GetVar($name, $post_priority = false)
+ {
+ if(!$post_priority) // follow gpc_order in php.ini
+ return isset($_REQUEST[$name]) ? $_REQUEST[$name] : false;
+ else // get variable from post 1stly if not found then from get
+ return isset($_POST[$name]) && $_POST[$name] ? $_POST[$name] : ( isset($_GET[$name]) && $_GET[$name] ? $_GET[$name] : false );
+ }
+}
+
+function RadioChecked($name, $value)
+{
+ // return " checked" word in case if radio is checked
+ $submit_value = GetVar($name);
+ return $submit_value == $value ? ' checked' : '';
+}
+
+?>
Property changes on: trunk/admin/install/install_lib.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.27
\ No newline at end of property
+1.28
\ No newline at end of property
Index: trunk/core/kernel/application.php
===================================================================
--- trunk/core/kernel/application.php (revision 1590)
+++ trunk/core/kernel/application.php (revision 1591)
@@ -1,1280 +1,1291 @@
<?php
/**
* Basic class for Kernel3-based Application
*
* This class is a Facade for any other class which needs to deal with Kernel3 framework.<br>
* The class incapsulates the main run-cycle of the script, provide access to all other objects in the framework.<br>
* <br>
* The class is a singleton, which means that there could be only one instance of KernelApplication in the script.<br>
* This could be guranteed by NOT calling the class constuctor directly, but rather calling KernelApplication::Instance() method,
* which returns an instance of the application. The method gurantees that it will return exactly the same instance for any call.<br>
* See singleton pattern by GOF.
* @package kernel4
*/
class kApplication {
/**
* Holds internal TemplateParser object
* @access private
* @var TemplateParser
*/
var $Parser;
var $Profiler;
/**
* Holds parser output buffer
* @access private
* @var string
*/
var $HTML;
var $DocRoot;
var $BasePath;
var $KernelPath;
var $Server;
/**
* Prevents request from beeing proceeded twice in case if application init is called mere then one time
*
* @var bool
* @todo This is not good anyway (by Alex)
*/
var $RequestProcessed = false;
/**
* The main Factory used to create
* almost any class of kernel and
* modules
*
* @access private
* @var kFactory
*/
var $Factory;
var $XMLFactory; // in use?
/**
* Holds all phrases used
* in code and template
*
* @var PhrasesCache
*/
var $Phrases;
/**
* Holds DBConnection
*
* @var kDBConnection
*/
var $DB;
/**
* Constucts KernelApplication - constructor is PRIVATE
*
* The constuructor of KernelApplication should NOT be called directly
* To create KernelApplication, call its Instance() method
* @see KerenelApplication::Instance
* @access private
*/
function kApplication()
{
global $doc_root, $base_path, $kernel_path, $protocol, $server;
$this->DocRoot = $doc_root;
$this->BasePath = $base_path;
$this->KernelPath = $kernel_path;
$this->Protocol = $protocol;
$this->Server = $server;
}
/**
* Returns kApplication instance anywhere in the script.
*
* This method should be used to get single kApplication object instance anywhere in the
* Kernel-based application. The method is guranteed to return the SAME instance of kApplication.
* Anywhere in the script you could write:
* <code>
* $application =& kApplication::Instance();
* </code>
* or in an object:
* <code>
* $this->Application =& kApplication::Instance();
* </code>
* to get the instance of kApplication. Note that we call the Instance method as STATIC - directly from the class.
* To use descendand of standard kApplication class in your project you would need to define APPLICATION_CLASS constant
* BEFORE calling kApplication::Instance() for the first time. If APPLICATION_CLASS is not defined the method would
* create and return default KernelApplication instance.
* @static
* @access public
* @return kApplication
*/
function &Instance()
{
static $instance = false;
if (!$instance) {
if (!defined('APPLICATION_CLASS')) define('APPLICATION_CLASS', 'kApplication');
$class = APPLICATION_CLASS;
$instance = new $class();
}
return $instance;
}
/**
* Initializes the Application
*
* Creates Utilites instance, HTTPQuery, Session, Profiler, TemplatesCache, Parser
* @access public
* @see HTTPQuery
* @see Session
* @see TemplatesCache
* @return void
*/
function Init()
{
if (defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_PROFILE_MEMORY') ) {
global $debugger;
$debugger->appendMemoryUsage('Application before Init:');
}
if( !$this->isDebugMode() ) set_error_handler( Array(&$this,'handleError') );
$this->DB = new kDBConnection(SQL_TYPE, Array(&$this,'handleSQLError') );
$this->DB->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB);
$this->DB->debugMode = $this->isDebugMode();
$this->SetDefaultConstants();
$this->Factory = new kFactory();
$this->registerDefaultClasses();
// 1. to read configs before doing any recallObject
$config_reader =& $this->recallObject('kUnitConfigReader');
if( !$this->GetVar('m_lang') ) $this->SetVar('m_lang', $this->GetDefaultLanguageId() );
if( !$this->GetVar('m_theme') ) $this->SetVar('m_theme', $this->GetDefaultThemeId());
$this->Phrases = new PhrasesCache( $this->GetVar('m_lang') );
$this->SetVar('lang.current_id', $this->GetVar('m_lang') );
$language =& $this->recallObject('lang.current', null, Array('live_table'=>true) );
if( !$this->GetVar('m_theme') ) $this->SetVar('m_theme', $this->GetDefaultThemeId() );
$this->SetVar('theme.current_id', $this->GetVar('m_theme') );
if ( $this->GetVar('m_cat_id') === false ) $this->SetVar('m_cat_id', 2); //need to rewrite
if( !$this->RecallVar('UserGroups') )
{
$this->StoreVar('UserGroups', $this->ConfigValue('User_GuestGroup'));
}
if( !$this->RecallVar('curr_iso') ) $this->StoreVar('curr_iso', $this->GetPrimaryCurrency() );
$this->ValidateLogin(); // TODO: write that method
if( $this->isDebugMode() )
{
global $debugger;
$debugger->profileFinish('kernel4_startup');
}
}
function GetDefaultLanguageId()
{
$table = $this->getUnitOption('lang','TableName');
$id_field = $this->getUnitOption('lang','IDField');
return $this->DB->GetOne('SELECT '.$id_field.' FROM '.$table.' WHERE PrimaryLang = 1');
}
function GetDefaultThemeId()
{
if (defined('DBG_FORCE_THEME') && DBG_FORCE_THEME){
return DBG_FORCE_THEME;
}
$table = $this->getUnitOption('theme','TableName');
$id_field = $this->getUnitOption('theme','IDField');
return $this->DB->GetOne('SELECT '.$id_field.' FROM '.$table.' WHERE PrimaryTheme = 1');
}
function GetPrimaryCurrency()
{
- $table = $this->getUnitOption('curr','TableName');
- return $this->DB->GetOne('SELECT ISO FROM '.$table.' WHERE IsPrimary = 1');
+ $this->setUnitOption('mod','AutoLoad',false);
+ $module =& $this->recallObject('mod');
+ $this->setUnitOption('mod','AutoLoad',true);
+
+ if( $module->Load('In-Commerce') )
+ {
+ $table = $this->getUnitOption('curr','TableName');
+ return $this->DB->GetOne('SELECT ISO FROM '.$table.' WHERE IsPrimary = 1');
+ }
+ else
+ {
+ return 'USD';
+ }
}
/**
* Registers default classes such as ItemController, GridController and LoginController
*
* Called automatically while initializing Application
* @access private
* @return void
*/
function RegisterDefaultClasses()
{
//$this->registerClass('Utilites',KERNEL_PATH.'/utility/utilities.php');
$this->registerClass('HTTPQuery',KERNEL_PATH.'/utility/http_query.php');
$this->registerClass('Session',KERNEL_PATH.'/session/session.php');
$this->registerClass('SessionStorage',KERNEL_PATH.'/session/session.php');
$this->registerClass('LoginEventHandler',KERNEL_PATH.'/session/login_event_handler.php','login_EventHandler');
$this->registerClass('kEventManager',KERNEL_PATH.'/event_manager.php','EventManager');
$this->registerClass('kUnitConfigReader',KERNEL_PATH.'/utility/unit_config_reader.php');
$this->registerClass('Params',KERNEL_PATH.'/utility/params.php','kActions');
$this->registerClass('kArray',KERNEL_PATH.'/utility/params.php','kArray');
$this->registerClass('kFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kOptionsFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kPictureFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kDateFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kLEFTFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kMultiLanguage', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kPasswordFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kCCDateFormatter', KERNEL_PATH.'/utility/formatters.php');
$this->registerClass('kTempTablesHandler', KERNEL_PATH.'/utility/temp_handler.php');
$event_manager =& $this->recallObject('EventManager');
$event_manager->registerBuildEvent('kTempTablesHandler','OnTempHandlerBuild');
//$this->registerClass('Configuration',KERNEL_PATH.'/utility/configuration.php');
$this->registerClass('TemplatesCache',KERNEL_PATH.'/parser/template.php');
$this->registerClass('Template',KERNEL_PATH.'/parser/template.php');
$this->registerClass('TemplateParser',KERNEL_PATH.'/parser/template_parser.php');
$this->registerClass('MainProcessor', KERNEL_PATH.'/processors/main_processor.php','m_TagProcessor');
$this->registerClass('kMultipleFilter', KERNEL_PATH.'/utility/filters.php');
$this->registerClass('kDBList', KERNEL_PATH.'/db/dblist.php');
$this->registerClass('kDBItem', KERNEL_PATH.'/db/dbitem.php');
$this->registerClass('kDBEventHandler', KERNEL_PATH.'/db/db_event_handler.php');
$this->registerClass('kDBTagProcessor', KERNEL_PATH.'/db/db_tag_processor.php');
$this->registerClass('kTagProcessor', KERNEL_PATH.'/processors/tag_processor.php');
$this->registerClass('kEmailMessage',KERNEL_PATH.'/utility/email.php');
$this->registerClass('kSmtpClient',KERNEL_PATH.'/utility/smtp_client.php');
if (file_exists(MODULES_PATH.'/in-commerce/units/rates/currency_rates.php')) {
$this->registerClass('kCurrencyRates',MODULES_PATH.'/in-commerce/units/rates/currency_rates.php');
}
/*$this->RegisterClass('LoginController', KERNEL_PATH.'/users/login_controller.php');*/
}
/**
* Defines default constants if it's not defined before - in config.php
*
* Called automatically while initializing Application and defines:
* LOGIN_CONTROLLER, XML_FACTORY etc.
* @access private
* @return void
*/
function SetDefaultConstants()
{
if (!defined('SERVER_NAME')) define('SERVER_NAME', $_SERVER['SERVER_NAME']);
if (!defined('LOGIN_CONTROLLER')) define('LOGIN_CONTROLLER', 'LoginController');
if (!defined('XML_FACTORY')) define('XML_FACTORY', 'XMLFactory');
if (!defined('ADMINS_LIST')) define('ADMINS_LIST', '/users/users.php');
if (!defined('USER_MODEL')) define('USER_MODEL', 'Users');
if (!defined('DEFAULT_LANGUAGE_ID')) define('DEFAULT_LANGUAGE_ID', 1);
}
function ProcessRequest()
{
$event_manager =& $this->recallObject('EventManager');
if( $this->isDebugMode() && dbg_ConstOn('DBG_SHOW_HTTPQUERY') )
{
global $debugger;
$http_query =& $this->recallObject('HTTPQuery');
$debugger->appendHTML('HTTPQuery:');
$debugger->dumpVars($http_query->_Params);
}
$event_manager->ProcessRequest();
$this->RequestProcessed = true;
}
/**
* Actually runs the parser against current template and stores parsing result
*
* This method gets t variable passed to the script, loads the template given in t variable and
* parses it. The result is store in {@link $this->HTML} property.
* @access public
* @return void
*/
function Run()
{
if (defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_PROFILE_MEMORY') ) {
global $debugger;
$debugger->appendMemoryUsage('Application before Run:');
}
if (!$this->RequestProcessed) $this->ProcessRequest();
$this->InitParser();
$template_cache =& $this->recallObject('TemplatesCache');
$t = $this->GetVar('t');
if (defined('CMS') && CMS) {
if (!$template_cache->TemplateExists($t)) {
$cms_handler =& $this->recallObject('cms_EventHandler');
$t = $cms_handler->GetDesignTemplate();
}
}
if (defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_PROFILE_MEMORY') ) {
global $debugger;
$debugger->appendMemoryUsage('Application before Parsing:');
}
$this->HTML = $this->Parser->Parse( $template_cache->GetTemplateBody($t), $t );
if (defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_PROFILE_MEMORY') ) {
global $debugger;
$debugger->appendMemoryUsage('Application after Parsing:');
}
}
function InitParser()
{
if( !is_object($this->Parser) ) $this->Parser =& $this->recallObject('TemplateParser');
}
/**
* Send the parser results to browser
*
* Actually send everything stored in {@link $this->HTML}, to the browser by echoing it.
* @access public
* @return void
*/
function Done()
{
if (defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_PROFILE_MEMORY') ) {
global $debugger;
$debugger->appendMemoryUsage('Application before Done:');
}
//eval("?".">".$this->HTML);
echo $this->HTML;
$this->Phrases->UpdateCache();
$session =& $this->recallObject('Session');
$session->SaveData();
//$this->SaveBlocksCache();
}
function SaveBlocksCache()
{
if (defined('EXPERIMENTAL_PRE_PARSE')) {
$data = serialize($this->PreParsedCache);
$this->DB->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("blocks_cache", '.$this->DB->qstr($data).', '.time().')');
}
}
// Facade
/**
* Returns current session id (SID)
* @access public
* @return longint
*/
function GetSID()
{
$session =& $this->recallObject('Session');
return $session->GetID();
}
function DestroySession()
{
$session =& $this->recallObject('Session');
$session->Destroy();
}
/**
* Returns variable passed to the script as GET/POST/COOKIE
*
* @access public
* @param string $var Variable name
* @return mixed
*/
function GetVar($var,$mode=FALSE_ON_NULL)
{
$http_query =& $this->recallObject('HTTPQuery');
return $http_query->Get($var,$mode);
}
/**
* Returns ALL variables passed to the script as GET/POST/COOKIE
*
* @access public
* @return array
*/
function GetVars()
{
$http_query =& $this->recallObject('HTTPQuery');
return $http_query->GetParams();
}
/**
* Set the variable 'as it was passed to the script through GET/POST/COOKIE'
*
* This could be useful to set the variable when you know that
* other objects would relay on variable passed from GET/POST/COOKIE
* or you could use SetVar() / GetVar() pairs to pass the values between different objects.<br>
*
* This method is formerly known as $this->Session->SetProperty.
* @param string $var Variable name to set
* @param mixed $val Variable value
* @access public
* @return void
*/
function SetVar($var,$val)
{
$http_query =& $this->recallObject('HTTPQuery');
$http_query->Set($var,$val);
}
/**
* Deletes Session variable
*
* @param string $var
*/
function RemoveVar($var)
{
$session =& $this->recallObject('Session');
return $session->RemoveVar($var);
}
/**
* Deletes HTTPQuery variable
*
* @param string $var
* @todo think about method name
*/
function DeleteVar($var)
{
$http_query =& $this->recallObject('HTTPQuery');
return $http_query->Remove($var);
}
/**
* Returns session variable value
*
* Return value of $var variable stored in Session. An optional default value could be passed as second parameter.
*
* @see SimpleSession
* @access public
* @param string $var Variable name
* @param mixed $default Default value to return if no $var variable found in session
* @return mixed
*/
function RecallVar($var,$default=false)
{
$session =& $this->recallObject('Session');
return $session->RecallVar($var,$default);
}
/**
* Stores variable $val in session under name $var
*
* Use this method to store variable in session. Later this variable could be recalled.
* @see RecallVar
* @access public
* @param string $var Variable name
* @param mixed $val Variable value
*/
function StoreVar($var, $val)
{
$session =& $this->recallObject('Session');
$session->StoreVar($var, $val);
}
function StoreVarDefault($var, $val)
{
$session =& $this->recallObject('Session');
$session->StoreVarDefault($var, $val);
}
/**
* Links HTTP Query variable with session variable
*
* If variable $var is passed in HTTP Query it is stored in session for later use. If it's not passed it's recalled from session.
* This method could be used for making sure that GetVar will return query or session value for given
* variable, when query variable should overwrite session (and be stored there for later use).<br>
* This could be used for passing item's ID into popup with multiple tab -
* in popup script you just need to call LinkVar('id', 'current_id') before first use of GetVar('id').
* After that you can be sure that GetVar('id') will return passed id or id passed earlier and stored in session
* @access public
* @param string $var HTTP Query (GPC) variable name
* @param mixed $ses_var Session variable name
* @param mixed $default Default variable value
*/
function LinkVar($var, $ses_var=null, $default='')
{
if (!isset($ses_var)) $ses_var = $var;
if ($this->GetVar($var) !== false)
{
$this->StoreVar($ses_var, $this->GetVar($var));
}
else
{
$this->SetVar($var, $this->RecallVar($ses_var, $default));
}
}
/**
* Returns variable from HTTP Query, or from session if not passed in HTTP Query
*
* The same as LinkVar, but also returns the variable value taken from HTTP Query if passed, or from session if not passed.
* Returns the default value if variable does not exist in session and was not passed in HTTP Query
*
* @see LinkVar
* @access public
* @param string $var HTTP Query (GPC) variable name
* @param mixed $ses_var Session variable name
* @param mixed $default Default variable value
* @return mixed
*/
function GetLinkedVar($var, $ses_var=null, $default='')
{
if (!isset($ses_var)) $ses_var = $var;
$this->LinkVar($var, $ses_var, $default);
return $this->GetVar($var);
}
/*function ExtractByMask($array, $mask, $key_id=1, $ret_mode=1)
{
$utils =& $this->recallObject('Utilities');
return $utils->ExtractByMask($array, $mask, $key_id, $ret_mode);
}
function GetSelectedIDs($mask, $format)
{
$http_query =& $this->recallObject('HTTPQuery');
return $http_query->GetSelectedIDs($mask, $format);
}
function GetSelectedIDsArray($mask, $value_mask="%s,")
{
$http_query =& $this->recallObject('HTTPQuery');
return $http_query->GetSelectedIDsArray($mask, $value_mask);
}*/
/**
* Returns configurtion option
*
* @param string $option
* @return string
* @access public
*/
/*function ConfigOption($option)
{
$config =& $this->recallObject('Configuration');
return $config->Get($option);
}*/
/**
* Sets configuration option
*
* @param string $option
* @param string $value
* @return bool
* @access public
*/
/*function SetConfigOption($option,$value)
{
$config =& $this->recallObject('Configuration');
return $config->Set($option, $value);
}*/
function AddBlock($name, $tpl)
{
$this->cache[$name] = $tpl;
}
function SetTemplateBody($title,$body)
{
$templates_cache =& $this->recallObject('TemplatesCache');
$templates_cache->SetTemplateBody($title,$body);
}
function ProcessTag($tag_data)
{
$a_tag = new Tag($tag_data,$this->Parser);
return $a_tag->DoProcessTag();
}
function ProcessParsedTag($prefix, $tag, $params)
{
$a_tag = new Tag('',$this->Parser);
$a_tag->Tag = $tag;
$a_tag->Processor = $prefix;
$a_tag->NamedParams = $params;
return $a_tag->DoProcessTag();
}
/* DEFINETLY NEEDS TO BE MOVED AWAY!!!!! */
/*var $email_body;
function Email($params)
{
$this->email_body = $this->ParseBlock($params);
$from = $this->GetVar('email_from');
$to = $this->GetVar('email_to');
$replay = $this->GetVar('email_replay');
if ( $replay == "" ) $replay = $from;
$subject = $this->GetVar('email_subject');
$charset = $this->GetVar('email_charset');
// $display = $this->GetVar('email_display');
$display = 0;
if (!isset($charset) || $charset == '') $charset = 'US-ASCII';
$mime = $this->GetVar('email_mime');
if ($mime == 'yes') {
$mime_mail = new MIMEMail($to, $from, $subject, $charset);
$mime_mail->mailbody($this->email_body);
if ($f_name = $this->GetVar('email_attach')) {
$full_path = DOC_ROOT.BASE_PATH.'/'.$f_name;
$data = '';
if(file_exists($full_path)) {
$fd = fopen($full_path, "r");
$data = fread($fd, filesize($full_path));
fclose($fd);
}
else exit;
$filename = $this->GetVar('email_attach_filename');
$type = $this->GetVar('email_attach_type');
$mime_mail->attachfile_raw($data, $filename, $type);
$mime_mail->send();
}
}
else {
$headers.="From: $from\n";
$headers.="Reply-To: $replay\n";
$headers.="Content-Type: text/html; charset=\"$charset\"\n";
if ( $display == 1 ) {
echo "<pre>";
echo " from : $from <br>";
echo " to : $to <br>";
echo " replay : $replay <br>";
echo " subject : $subject <br>";
echo " this->email_body : $this->email_body <br>";
echo " headers : $headers <br>";
echo "</pre>";
}
mail($to, $subject, $this->email_body, $headers);
}
}*/
/**
* Return ADODB Connection object
*
* Returns ADODB Connection object already connected to the project database, configurable in config.php
* @access public
* @return ADODBConnection
*/
function &GetADODBConnection()
{
return $this->DB;
}
function ParseBlock($params,$pass_params=0,$as_template=false)
{
if (substr($params['name'], 0, 5) == 'html:') return substr($params['name'], 6);
return $this->Parser->ParseBlock($params, $pass_params, $as_template);
}
function &GetXMLFactory()
{
return $this->XMLFactory;
}
/**
* Return href for template
*
* @access public
* @param string $t Template path
* @var string $prefix index.php prefix - could be blank, 'admin'
*/
function HREF($t, $prefix='', $params=null, $index_file=null)
{
global $HTTP_SERVER_VARS;
if (defined('ADMIN') && $prefix == '') $prefix='/admin';
if (defined('ADMIN') && $prefix == '_FRONT_END_') $prefix = '';
$index_file = isset($index_file) ? $index_file : (defined('INDEX_FILE') ? INDEX_FILE : basename($_SERVER['PHP_SELF']));
if( isset($params['index_file']) ) $index_file = $params['index_file'];
if (getArrayValue($params, 'opener') == 'u') {
$opener_stack=$this->RecallVar('opener_stack');
if($opener_stack) {
$opener_stack=unserialize($opener_stack);
if (count($opener_stack) > 0) {
list($index_file, $env) = explode('|', $opener_stack[count($opener_stack)-1]);
$ret = $this->BaseURL($prefix).$index_file.'?'.ENV_VAR_NAME.'='.$env;
if( getArrayValue($params,'escape') ) $ret = addslashes($ret);
return $ret;
}
else {
//define('DBG_REDIRECT', 1);
$t = $this->GetVar('t');
}
}
else {
//define('DBG_REDIRECT', 1);
$t = $this->GetVar('t');
}
}
$pass = isset($params['pass']) ? $params['pass'] : '';
$pass_events = isset($params['pass_events']) ? $params['pass_events'] : false; // pass events with url
if (defined('MOD_REWRITE') && MOD_REWRITE) {
$env = $this->BuildEnv('', $params, $pass, $pass_events, false);
$env = ltrim($env, ':-');
$session =& $this->recallObject('Session');
$sid = $session->NeedQueryString() ? '?sid='.$this->GetSID() : '';
// $env = str_replace(':', '/', $env);
$ret = $this->BaseURL($prefix).$t.'.html/'.$env.'/'.$sid;
}
else {
$env = $this->BuildEnv($t, $params, $pass, $pass_events);
$ret = $this->BaseURL($prefix).$index_file.'?'.$env;
}
return $ret;
}
function BuildEnv($t, $params, $pass='all', $pass_events=false, $env_var=true)
{
$session =& $this->recallObject('Session');
$sid = $session->NeedQueryString() && !(defined('MOD_REWRITE') && MOD_REWRITE) ? $this->GetSID() : '';
$ret = '';
if ($env_var) {
$ret = ENV_VAR_NAME.'=';
}
$ret .= defined('INPORTAL_ENV') ? $sid.'-'.$t : $sid.':'.$t;
$pass = str_replace('all', trim($this->GetVar('passed'), ','), $pass);
if(strlen($pass) > 0)
{
$pass_info = array_unique( explode(',',$pass) ); // array( prefix[.special], prefix[.special] ...
foreach($pass_info as $pass_element)
{
$ret.=':';
list($prefix)=explode('.',$pass_element);
$query_vars = $this->getUnitOption($prefix,'QueryString');
//if pass events is off and event is not implicity passed
if(!$pass_events && !isset($params[$pass_element.'_event'])) {
$params[$pass_element.'_event'] = ''; // remove event from url if requested
//otherwise it will use value from get_var
}
if($query_vars)
{
$tmp_string=Array(0=>$pass_element);
foreach($query_vars as $index => $var_name)
{
//if value passed in params use it, otherwise use current from application
$tmp_string[$index] = isset( $params[$pass_element.'_'.$var_name] ) ? $params[$pass_element.'_'.$var_name] : $this->GetVar($pass_element.'_'.$var_name);
if ( isset($params[$pass_element.'_'.$var_name]) ) {
unset( $params[$pass_element.'_'.$var_name] );
}
}
$escaped = array();
foreach ($tmp_string as $tmp_val) {
$escaped[] = str_replace(Array('-',':'), Array('\-','\:'), $tmp_val);
}
if ($this->getUnitOption($prefix, 'PortalStyleEnv') == true) {
$ret.= array_shift($escaped).array_shift($escaped).'-'.implode('-',$escaped);
}
else {
$ret.=implode('-',$escaped);
}
}
}
}
unset($params['pass']);
unset($params['opener']);
unset($params['m_event']);
if ($this->GetVar('admin') && !isset($params['admin'])) {
$params['admin'] = 1;
}
foreach ($params as $param => $value)
{
$ret .= '&'.$param.'='.$value;
}
if( getArrayValue($params,'escape') ) $ret = addslashes($ret);
return $ret;
}
function BaseURL($prefix='')
{
return PROTOCOL.SERVER_NAME.(defined('PORT')?':'.PORT : '').BASE_PATH.$prefix.'/';
}
function Redirect($t='', $params=null, $prefix='', $index_file=null)
{
if ($t == '' || $t === true) $t = $this->GetVar('t');
// pass prefixes and special from previous url
if (!isset($params['pass'])) $params['pass'] = 'all';
$location = $this->HREF($t, $prefix, $params, $index_file);
$a_location = $location;
$location = "Location: $location";
//echo " location : $location <br>";
if (headers_sent() != '' || ($this->isDebugMode() && dbg_ConstOn('DBG_REDIRECT')) ) {
/*$GLOBALS['debugger']->appendTrace();
echo "<b>Debug output above!!!</b> Proceed to redirect: <a href=\"$a_location\">$a_location</a><br>";*/
echo '<script language="javascript" type="text/javascript">window.location.href = \''.$a_location.'\';</script>';
}
else {
header("$location");
}
$session =& $this->recallObject('Session');
$session->SaveData();
$this->SaveBlocksCache();
exit;
}
function Phrase($label)
{
return $this->Phrases->GetPhrase($label);
}
/**
* Replace language tags in exclamation marks found in text
*
* @param string $text
* @param bool $force_escape force escaping, not escaping of resulting string
* @return string
* @access public
*/
function ReplaceLanguageTags($text, $force_escape=null)
{
return $this->Phrases->ReplaceLanguageTags($text,$force_escape);
}
/**
* Validtates user in session if required
*
*/
function ValidateLogin()
{
if (defined('LOGIN_REQUIRED'))
{
// Original Kostja call
//$login_controller =& $this->Factory->MakeClass(LOGIN_CONTROLLER, Array('model' => USER_MODEL, 'prefix' => 'login'));
// Call proposed by Alex
//$login_controller =& $this->RecallObject(LOGIN_CONTROLLER, Array('model' => USER_MODEL, 'prefix' => 'login'));
//$login_controller->CheckLogin();
}
}
/**
* Returns configuration option value by name
*
* @param string $name
* @return string
*/
function ConfigValue($name)
{
return $this->DB->GetOne('SELECT VariableValue FROM '.TABLE_PREFIX.'ConfigurationValues WHERE VariableName = '.$this->DB->qstr($name) );
}
/**
* Allows to process any type of event
*
* @param kEvent $event
* @access public
* @author Alex
*/
function HandleEvent(&$event, $params=null, $specificParams=null)
{
if ( isset($params) ) {
$event = new kEvent( $params, $specificParams );
}
$event_manager =& $this->recallObject('EventManager');
$event_manager->HandleEvent($event);
}
/**
* Registers new class in the factory
*
* @param string $real_class
* @param string $file
* @param string $pseudo_class
* @access public
* @author Alex
*/
function registerClass($real_class,$file,$pseudo_class=null)
{
$this->Factory->registerClass($real_class,$file,$pseudo_class);
}
/**
* Registers Hook from subprefix event to master prefix event
*
* @param string $hookto_prefix
* @param string $hookto_special
* @param string $hookto_event
* @param string $mode
* @param string $do_prefix
* @param string $do_special
* @param string $do_event
* @param string $conditional
* @access public
* @todo take care of a lot parameters passed
* @author Kostja
*/
function registerHook($hookto_prefix, $hookto_special, $hookto_event, $mode, $do_prefix, $do_special, $do_event, $conditional)
{
$event_manager =& $this->recallObject('EventManager');
$event_manager->registerHook($hookto_prefix, $hookto_special, $hookto_event, $mode, $do_prefix, $do_special, $do_event, $conditional);
}
/**
* Allows one TagProcessor tag act as other TagProcessor tag
*
* @param Array $tag_info
* @author Kostja
*/
function registerAggregateTag($tag_info)
{
$aggregator =& $this->recallObject('TagsAggregator', 'kArray');
$aggregator->SetArrayValue($tag_info['AggregateTo'], $tag_info['AggregatedTagName'], Array($tag_info['LocalPrefix'], $tag_info['LocalTagName']));
}
/**
* Returns object using params specified,
* creates it if is required
*
* @param string $name
* @param string $pseudo_class
* @param Array $event_params
* @return Object
* @author Alex
*/
function &recallObject($name,$pseudo_class=null,$event_params=Array())
{
$o1 =& $this->Factory->getObject($name,$pseudo_class,$event_params);
//$o1->param1 = 'one';
/*$func_args = func_get_args();
$factory =& $this->Factory;
$o2 =& call_user_func_array( Array(&$factory, 'getObject'), $func_args );*/
//$o2->param1 = 'two';
return $o1;
}
/**
* Checks if object with prefix passes was already created in factory
*
* @param string $name object presudo_class, prefix
* @return bool
* @author Kostja
*/
function hasObject($name)
{
return isset($this->Factory->Storage[$name]);
}
/**
* Removes object from storage by given name
*
* @param string $name Object's name in the Storage
* @author Kostja
*/
function removeObject($name)
{
$this->Factory->DestroyObject($name);
}
/**
* Get's real class name for pseudo class,
* includes class file and creates class
* instance
*
* @param string $pseudo_class
* @return Object
* @access public
* @author Alex
*/
function &makeClass($pseudo_class)
{
$func_args = func_get_args();
return call_user_func_array( Array(&$this->Factory, 'makeClass'), $func_args);
}
/**
* Checks if application is in debug mode
*
* @return bool
* @access public
* @author Alex
*/
function isDebugMode()
{
return defined('DEBUG_MODE') && DEBUG_MODE;
}
/**
* Checks if it is admin
*
* @return bool
* @author Alex
*/
function IsAdmin()
{
return defined('ADMIN') && ADMIN;
}
/**
* Reads unit (specified by $prefix)
* option specified by $option
*
* @param string $prefix
* @param string $option
* @return string
* @access public
* @author Alex
*/
function getUnitOption($prefix,$option)
{
$unit_config_reader =& $this->recallObject('kUnitConfigReader');
return $unit_config_reader->getUnitOption($prefix,$option);
}
/**
* Set's new unit option value
*
* @param string $prefix
* @param string $name
* @param string $value
* @author Alex
* @access public
*/
function setUnitOption($prefix,$option,$value)
{
$unit_config_reader =& $this->recallObject('kUnitConfigReader');
return $unit_config_reader->setUnitOption($prefix,$option,$value);
}
/**
* Read all unit with $prefix options
*
* @param string $prefix
* @return Array
* @access public
* @author Alex
*/
function getUnitOptions($prefix)
{
$unit_config_reader =& $this->recallObject('kUnitConfigReader');
return $unit_config_reader->getUnitOptions($prefix);
}
/**
* Splits any mixing of prefix and
* special into correct ones
*
* @param string $prefix_special
* @return Array
* @access public
* @author Alex
*/
function processPrefix($prefix_special)
{
return $this->Factory->processPrefix($prefix_special);
}
/**
* Set's new event for $prefix_special
* passed
*
* @param string $prefix_special
* @param string $event_name
* @access public
*/
function setEvent($prefix_special,$event_name)
{
$event_manager =& $this->recallObject('EventManager');
$event_manager->setEvent($prefix_special,$event_name);
}
/**
* SQL Error Handler
*
* @param int $code
* @param string $msg
* @param string $sql
* @return bool
* @access private
* @author Alex
*/
function handleSQLError($code,$msg,$sql)
{
global $debugger;
if($debugger)
{
$errorLevel=defined('DBG_SQL_FAILURE') && DBG_SQL_FAILURE ? E_USER_ERROR : E_USER_WARNING;
$debugger->dumpVars($_REQUEST);
$debugger->appendTrace();
$error_msg = '<span class="debug_error">'.$msg.' ('.$code.')</span><br><a href="javascript:SetClipboard(\''.htmlspecialchars($sql).'\');"><b>SQL</b></a>: '.$debugger->formatSQL($sql);
$long_id=$debugger->mapLongError($error_msg);
trigger_error( substr($msg.' ('.$code.') ['.$sql.']',0,1000).' #'.$long_id, $errorLevel);
return true;
}
else
{
$errorLevel = defined('IS_INSTALL') && IS_INSTALL ? E_USER_WARNING : E_USER_ERROR;
trigger_error('<b>SQL Error</b> in sql: '.$sql.', code <b>'.$code.'</b> ('.$msg.')', $errorLevel);
/*echo '<b>xProcessing SQL</b>: '.$sql.'<br>';
echo '<b>Error ('.$code.'):</b> '.$msg.'<br>';*/
return $errorLevel == E_USER_ERROR ? false : true;
}
}
/**
* Default error handler
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
* @param Array $errcontext
*/
function handleError($errno, $errstr, $errfile = '', $errline = '', $errcontext = '')
{
$fp = fopen(DOC_ROOT.BASE_PATH.'/silent_log.txt','a');
$time = date('d/m/Y H:i:s');
fwrite($fp, '['.$time.'] #'.$errno.': '.strip_tags($errstr).' in ['.$errfile.'] on line '.$errline."\n");
fclose($fp);
}
/**
* Returns & blocks next ResourceId available in system
*
* @return int
* @access public
* @author Eduard
*/
function NextResourceId()
{
$this->DB->Query('LOCK TABLES '.TABLE_PREFIX.'IdGenerator WRITE');
$this->DB->Query('UPDATE '.TABLE_PREFIX.'IdGenerator SET lastid = lastid+1');
$id = $this->DB->GetOne("SELECT lastid FROM ".TABLE_PREFIX."IdGenerator");
$this->DB->Query('UNLOCK TABLES');
return $id;
}
/**
* Returns main prefix for subtable prefix passes
*
* @param string $current_prefix
* @return string
* @access public
* @author Kostja
*/
function GetTopmostPrefix($current_prefix)
{
while ( $parent_prefix = $this->getUnitOption($current_prefix, 'ParentPrefix') )
{
$current_prefix = $parent_prefix;
}
return $current_prefix;
}
function EmailEventAdmin($email_event_name, $to_user_id = -1, $send_params = false)
{
return $this->EmailEvent($email_event_name, 1, $to_user_id, $send_params);
}
function EmailEventUser($email_event_name, $to_user_id = -1, $send_params = false)
{
return $this->EmailEvent($email_event_name, 0, $to_user_id, $send_params);
}
function EmailEvent($email_event_name, $email_event_type, $to_user_id = -1, $send_params = false)
{
$event = new kEvent('emailevents:OnEmailEvent');
$event->setEventParam('EmailEventName', $email_event_name);
$event->setEventParam('EmailEventToUserId', $to_user_id);
$event->setEventParam('EmailEventType', $email_event_type);
if ($send_params){
$event->setEventParam('DirectSendParams', $send_params);
}
$this->HandleEvent($event);
return $event;
}
function LoggedIn()
{
$user =& $this->recallObject('u');
return ($user->GetDBField('PortalUserId') > 0);
}
function CheckPermission($name, $cat_id = null)
{
if(!$cat_id)
{
$cat_id = $this->GetVar('m_cat_id');
}
$sql = 'SELECT ParentPath FROM '.$this->getUnitOption('c', 'TableName').'
WHERE CategoryId = '.$cat_id;
$cat_hierarchy = $this->DB->GetOne($sql);
$cat_hierarchy = explode('|', $cat_hierarchy);
array_shift($cat_hierarchy);
array_pop($cat_hierarchy);
$cat_hierarchy = array_reverse($cat_hierarchy);
$groups = $this->RecallVar('UserGroups');
foreach($cat_hierarchy as $category_id)
{
$sql = 'SELECT PermissionValue FROM '.TABLE_PREFIX.'Permissions
WHERE Permission = "'.$name.'"
AND CatId = '.$category_id.'
AND GroupId IN ('.$groups.')';
$res = $this->DB->GetOne($sql);
if( $res !== false )
{
return $res;
}
}
return 0;
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/kernel/application.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.13
\ No newline at end of property
+1.14
\ No newline at end of property
Index: trunk/core/units/modules/modules_event_handler.php
===================================================================
--- trunk/core/units/modules/modules_event_handler.php (revision 1590)
+++ trunk/core/units/modules/modules_event_handler.php (revision 1591)
@@ -1,36 +1,36 @@
<?php
-class ModulesEventHandler extends InpDBEventHandler {
+ class ModulesEventHandler extends InpDBEventHandler {
/**
* Builds list
*
* @param kEvent $event
* @access protected
*/
function OnListBuild(&$event)
{
parent::OnListBuild($event);
}
/**
* Builds item
*
* @param kEvent $event
* @access protected
*/
function OnItemBuild(&$event)
{
- $this->Application->SetVar($this->Prefix."_".$event->Special."_id", $event->Special);
+ $this->Application->SetVar( $event->getPrefixSpecial(true).'_id', $event->Special);
parent::OnItemBuild($event);
}
- function SetCustomQuery(&$event){
- $object=&$event->getObject();
- $object->addFilter("current_module", "Name=".$event->Special);
-
- }
+ function SetCustomQuery(&$event)
+ {
+ $object=&$event->getObject();
+ $object->addFilter('current_module', 'Name='.$event->Special);
+ }
-}
+ }
?>
\ No newline at end of file
Property changes on: trunk/core/units/modules/modules_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property

Event Timeline