Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Tue, Jun 24, 11:30 PM

in-portal

Index: branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php (revision 5498)
@@ -0,0 +1,284 @@
+<?php
+
+$config = Array(
+ 'Prefix' => 'c',
+ 'ItemClass' => Array('class'=>'CategoriesItem','file'=>'categories_item.php','build_event'=>'OnItemBuild'),
+ 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
+ 'EventHandlerClass' => Array('class'=>'CategoriesEventHandler','file'=>'categories_event_handler.php','build_event'=>'OnBuild'),
+ 'TagProcessorClass' => Array('class'=>'CategoriesTagProcessor','file'=>'categories_tag_processor.php','build_event'=>'OnBuild'),
+
+ 'RegisterClasses' => Array(
+ Array('pseudo' => 'kPermCacheUpdater','class' => 'kPermCacheUpdater', 'file' => 'cache_updater.php','build_event'=>''),
+ ),
+
+ 'AutoLoad' => true,
+ 'QueryString' => Array(
+ 1 => 'id',
+ 2 => 'page',
+ 3 => 'event',
+ 4 => 'mode',
+ ),
+ 'AggregateTags' => Array(
+ Array(
+ 'AggregateTo' => 'm',
+ 'AggregatedTagName' => 'CategoryLink',
+ 'LocalTagName' => 'CategoryLink',
+ ),
+ ),
+ 'IDField' => 'CategoryId',
+
+ 'StatusField' => Array('Status'),
+
+ 'TitleField' => 'Name', // field, used in bluebar when editing existing item
+ 'ItemType' => 1, // used for custom fields only
+
+ 'StatisticsInfo' => Array(
+ 'pending' => Array(
+ 'icon' => 'icon16_cat_pending.gif',
+ 'label' => 'la_tab_Categories',
+ 'js_url' => "set_persistant_var('Category_View', 41, 'advanced_view', '#url#')",
+ 'url' => Array('t' => 'advanced_view', 'index_file' => 'advanced_view.php', 'SetTab' => 'category', 'pass' => 'm'),
+ 'status' => STATUS_PENDING,
+ ),
+ ),
+
+ 'TableName' => TABLE_PREFIX.'Category',
+
+ 'ViewMenuPhrase' => 'la_text_Categories',
+
+ 'TitlePresets' => Array(
+ 'default' => Array( 'new_status_labels' => Array('c' => '!la_title_Adding_Category!'),
+ 'edit_status_labels' => Array('c' => '!la_title_Editing_Category!'),
+ 'new_titlefield' => Array('c' => '!la_title_New_Category!'),
+ ),
+ 'category_list' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (#c_recordcount#)"),
+
+ 'catalog' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (<span id='c_item_count'>#c_recordcount#</span>)"),
+
+ 'categories_edit' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_General!"),
+ 'categories_properties' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Properties!"),
+ 'categories_relations' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Relations!"),
+ 'categories_images' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Images!"),
+ 'categories_permissions'=> Array('prefixes' => Array('c', 'g_List'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Permissions!"),
+ 'categories_custom' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Custom!"),
+
+ 'categories_update' => Array('prefixes' => Array(), 'format' => "!la_title_UpdatingCategories!"),
+
+ 'images_edit' => Array( 'prefixes' => Array('c', 'c-img'),
+ 'new_status_labels' => Array('c-img'=>'!la_title_Adding_Image!'),
+ 'edit_status_labels' => Array('c-img'=>'!la_title_Editing_Image!'),
+ 'new_titlefield' => Array('c-img'=>'!la_title_New_Image!'),
+ 'format' => "#c_status# '#c_titlefield#' - #c-img_status# '#c-img_titlefield#'",
+ ),
+
+ 'relations_edit' => Array( 'prefixes' => Array('c', 'c-rel'),
+ 'new_status_labels' => Array('c-rel'=>"!la_title_Adding_Relationship! '!la_title_New_Relationship!'"),
+ 'edit_status_labels' => Array('c-rel'=>'!la_title_Editing_Relationship!'),
+ 'format' => "#c_status# '#c_titlefield#' - #c-rel_status#",
+ ),
+
+ 'tree_site' => Array('format' => '!la_selecting_categories!'),
+ ),
+
+ 'PermItemPrefix' => 'CATEGORY',
+
+ 'PermSection' => Array('main' => 'CATEGORY:in-portal:categories', /*'search' => 'in-portal:configuration_search',*/ 'email' => 'in-portal:configuration_email', 'custom' => 'in-portal:configuration_custom'),
+
+
+ 'Sections' => Array(
+ // "Structure & Data" section
+ 'in-portal:site' => Array(
+ 'parent' => 'in-portal:root',
+ 'icon' => 'struct',
+ 'label' => 'la_tab_Site_Structure',
+ 'url' => Array('t' => 'sections_list', 'pass_section' => true, 'pass' => 'm'),
+ 'permissions' => Array('view'),
+ 'priority' => 1,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:browse' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'catalog',
+ 'label' => 'la_tab_Browse',
+ 'url' => Array('index_file' => 'browse.php', 'pass' => 'm'),
+ 'permissions' => Array('view'),
+ 'priority' => 1,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:browse_new' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'catalog',
+ 'label' => 'la_K4_Catalog',
+ 'url' => Array('t' => 'catalog', 'pass' => 'm'),
+ 'late_load' => Array('t' => 'xml/tree_categories', 'pass' => 'm', 'm_cat_id' => 0),
+ 'onclick' => 'checkCatalog(0)',
+ 'permissions' => Array('view'),
+ 'priority' => 1.1,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:advanced_view' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'advanced_view',
+ 'label' => 'la_tab_AdvancedView',
+ 'url' => Array('index_file' => 'advanced_view.php', 'pass' => 'm'),
+ 'permissions' => Array('view'),
+ 'priority' => 2,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:reviews' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'reviews',
+ 'label' => 'la_tab_Reviews',
+ 'url' => Array('index_file' => 'reviews.php', 'pass' => 'm'),
+ 'permissions' => Array('view'),
+ 'priority' => 3,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:configure_categories' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'cat_settings',
+ 'label' => 'la_tab_Settings',
+ 'url' => Array('t' => 'config/config_universal', 'pass_section' => true, 'pass' => 'm'),
+ 'permissions' => Array('view', 'edit'),
+ 'priority' => 4,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:configuration_search' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'settings_search',
+ 'label' => 'la_tab_ConfigSearch',
+ 'url' => Array('t' => 'config/config_search', 'module_key' => 'category', 'pass_section' => true, 'pass' => 'm'),
+ 'permissions' => Array('view', 'edit'),
+ 'priority' => 5,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:configuration_email' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'settings_email',
+ 'label' => 'la_tab_ConfigE-mail',
+ 'url' => Array('t' => 'config/config_email', 'module' => 'In-Portal:Category', 'pass_section' => true, 'pass' => 'm'),
+ 'permissions' => Array('view', 'edit'),
+ 'priority' => 6,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:configuration_custom' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'settings_custom',
+ 'label' => 'la_tab_ConfigCustom',
+ 'url' => Array('t' => 'custom_fields/custom_fields_list', 'cf_type' => 1, 'pass_section' => true, 'pass' => 'm,cf'),
+ 'permissions' => Array('view', 'add', 'edit', 'delete'),
+ 'priority' => 7,
+ 'type' => stTREE,
+ ),
+
+ ),
+
+ 'FilterMenu' => Array(
+ 'Groups' => Array(
+ Array('mode' => 'AND', 'filters' => Array('show_active','show_pending','show_disabled'), 'type' => WHERE_FILTER),
+ Array('mode' => 'AND', 'filters' => Array('show_new'), 'type' => HAVING_FILTER),
+ Array('mode' => 'AND', 'filters' => Array('show_pick'), 'type' => WHERE_FILTER),
+ ),
+ 'Filters' => Array(
+ 'show_active' => Array('label' =>'la_Active', 'on_sql' => '', 'off_sql' => 'Status != 1' ),
+ 'show_pending' => Array('label' => 'la_Pending', 'on_sql' => '', 'off_sql' => 'Status != 2' ),
+ 'show_disabled' => Array('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => 'Status != 0' ),
+ 's1' => Array(),
+ 'show_new' => Array('label' => 'la_Text_New', 'on_sql' => '', 'off_sql' => '`IsNew` != 1' ),
+ 'show_pick' => Array('label' => 'la_prompt_EditorsPick', 'on_sql' => '', 'off_sql' => '`EditorsPick` != 1' ),
+ )
+ ),
+
+ 'ListSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'PermCache ON '.TABLE_PREFIX.'PermCache.CategoryId = %1$s.CategoryId
+ LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
+
+ 'ItemSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'PermCache ON '.TABLE_PREFIX.'PermCache.CategoryId = %1$s.CategoryId
+ LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
+
+ 'SubItems' => Array('c-rel', 'c-img', 'c-cdata', 'c-perm'),
+
+ 'ListSortings' => Array(
+ '' => Array(
+ 'ForcedSorting' => Array("CurrentSort" => 'asc', 'Priority' => 'desc', 'Name' => 'asc'),
+ 'Sorting' => Array('Name' => 'asc'),
+ )
+ ),
+
+ 'CalculatedFields' => Array(
+ '' => Array(
+ 'CurrentSort' => "REPLACE(ParentPath, CONCAT('|', ".'%1$s'.".CategoryId, '|'), '')",
+ )
+ ),
+
+ 'Fields' => Array
+ (
+ 'CategoryId' => Array('type' => 'int','not_null' => 1,'default' => ''),
+ 'Type' => Array('type' => 'int','not_null' => 1,'default' => 0),
+ 'ParentId' => Array('type' => 'int','not_null' => 1,'default' => 0),
+ 'Name' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'required' => 1, 'default' => ''),
+ 'Filename' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'AutomaticFilename' => Array('type' => 'int', 'not_null' => 1, 'default' => 1),
+ 'Description' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'required' => 1, 'default' => ''),
+ 'CreatedOn' => Array('formatter' => 'kDateFormatter', 'default'=>'#NOW#', 'required' => 1, 'not_null' => 1),
+ 'EditorsPick' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'Status' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled' ), 'use_phrases' => 1, 'not_null' => 1,'default' => 2),
+ 'Pop' => Array('type' => 'int', 'default' => ''),
+ 'Priority' => Array('type' => 'int', 'not_null' => 1, 'default' => ''),
+ 'MetaKeywords' => Array('type' => 'string', 'default' => ''),
+ 'CachedDescendantCatsQty' => Array('type' => 'int', 'default' => ''),
+ 'CachedNavbar' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'CreatedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => '0'),
+ 'ResourceId' => Array('type' => 'int', 'default' => ''),
+ 'ParentPath' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'NamedParentPath' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'MetaDescription' => Array('type' => 'string', 'default' => ''),
+ 'HotItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
+ 'NewItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
+ 'PopItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
+ 'Modified' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'not_null' => 1,'default' => '#NOW#'),
+ 'ModifiedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => '0'),
+ 'CategoryTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'ItemTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'CachedCategoryTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'CachedItemTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ ),
+
+ 'VirtualFields' => Array(
+ 'CurrentSort' => Array('type' => 'string', 'default' => ''),
+ 'IsNew' => Array('type' => 'int', 'default' => 0),
+ ),
+
+ 'Grids' => Array(
+ 'Default' => Array(
+ 'Icons' => Array('default'=>'icon16_cat.gif'),
+ 'Fields' => Array(
+ 'Name' => Array('title' => 'la_col_Name', 'data_block' => 'category_td'),
+ 'Description' => Array('title' => 'la_col_Description'),
+ 'CreatedOn_formatted' => Array('title' => 'la_col_CreatedOn', 'sort_field' => 'CreatedOn'),
+ ),
+
+ ),
+ ),
+
+ 'ConfigMapping' => Array(
+ 'PerPage' => 'Perpage_Category',
+ 'DefaultSorting1Field' => 'Category_Sortfield',
+ 'DefaultSorting2Field' => 'Category_Sortfield2',
+ 'DefaultSorting1Dir' => 'Category_Sortorder',
+ 'DefaultSorting2Dir' => 'Category_Sortorder2',
+ ),
+ );
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.50.2/kernel/units/categories/categories_config.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.50
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.50.2/kernel/include/modules.php
===================================================================
--- branches/unlabeled/unlabeled-1.50.2/kernel/include/modules.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.50.2/kernel/include/modules.php (revision 5498)
@@ -0,0 +1,1007 @@
+<?php
+/* List of installed modules and module-specific variables
+ Copyright 2002, Intechnic Corporation, All rights reserved
+*/
+
+$ado =& GetADODBConnection();
+$session_cookie_name = $ado->GetOne('SELECT VariableValue FROM '.$g_TablePrefix.'ConfigurationValues WHERE VariableName = "SessionCookieName"');
+define('SESSION_COOKIE_NAME', $session_cookie_name ? $session_cookie_name : 'sid');
+
+set_cookie('cookies_on', '1', adodb_mktime() + 31104000);
+
+// if branches that uses if($mod_prefix) or like that will never be executed
+// due global variable $mod_prefix is never defined
+
+$ExtraVars = array();
+
+function ParseEnv()
+{
+ global $env, $var_list, $mod_prefix,$objSession, $SessionQueryString;
+
+ /* parse individual sections */
+ $env = GetVar('env');
+ if (!$env)
+ {
+ $var_list['t'] = 'index';
+ if (is_array($mod_prefix))
+ {
+ foreach($mod_prefix as $module_prefix => $module_name)
+ {
+ $parser_name = $module_prefix.'_ParseEnv';
+ if( function_exists($parser_name) ) $parser_name();
+ }
+ }
+ }
+ else
+ {
+ $env_sections = explode(':', $env);
+
+ $main = array_shift($env_sections);
+ if($main)
+ {
+ list($sid, $template) = explode('-', $main, 2);
+ if(!$SessionQueryString)
+ {
+ if (!$sid || $sid == '_')
+ {
+ if ($sid != '_') $sid = $_COOKIE[SESSION_COOKIE_NAME];
+ }
+ else
+ {
+ $SessionQueryString = true;
+ }
+ }
+ $var_list['sid'] = $sid;
+ $var_list['t'] = $template;
+ if( getArrayValue($_GET, 'dest') ) $var_list['dest'] = $_GET['dest'];
+ }
+
+ foreach ($env_sections as $env_section)
+ {
+ $env_section = preg_replace("/^([a-zA-Z]+)([0-9]+)-(.*)/", "$1-$2-$3", $env_section);
+ $pieces = explode('-', $env_section);
+ $parser_name = $pieces[0].'_ParseEnv';
+ if( function_exists($parser_name) )
+ {
+ $env_section = preg_replace('/^([a-zA-Z]+)-([0-9]+)-(.*)/','\\1\\2-\\3', $env_section);
+ $parser_name($env_section);
+ }
+ }
+
+
+ }
+
+ if(!$SessionQueryString) $var_list['sid'] = $_COOKIE[SESSION_COOKIE_NAME];
+}
+
+function LoadEnv()
+{
+ global $env, $var_list, $mod_prefix,$objSession;
+
+ $env = $_GET["env"];
+ // echo "Loading Variables..<br>\n";
+ if ($env != "")
+ {
+ $envsections = explode(":", $env);
+ foreach($mod_prefix as $key => $value)
+ {
+ if(strlen($key))
+ {
+ $parsed=FALSE;
+ for($i=1; $i<sizeof($envsections); $i++)
+ {
+ $pieces = explode("-", $envsections[$i]);
+ if(substr($pieces[0],0,strlen($key))==$key)
+ {
+ $parsed=TRUE;
+ break;
+ }
+ }
+ if(!$parsed)
+ {
+ $parser_name = $key . "_LoadEnv";
+ //echo $parser_name;
+ if(function_exists($parser_name))
+ {
+ $parser_name();
+ }
+ }
+ else
+ {
+ $parser_name = $key . "_SaveEnv";
+ //echo $parser_name;
+ if(function_exists($parser_name))
+ {
+ $parser_name($envsections[$i]);
+ }
+ }
+ }
+ }
+ }
+}
+
+function BuildEnv($mod_prefix = false)
+{
+ global $var_list,$m_var_list, $var_list_update, $mod_prefix, $objSession, $objConfig,
+ $ExtraVars, $objThemes, $CurrentTheme, $SessionQueryString, $FrontEnd;
+
+ static $theme;
+
+ $env = "";
+ //echo "Query String: $SessionQueryString<br>\n";
+ if(($objConfig->Get("CookieSessions")==0 || !$FrontEnd || ($objConfig->Get("CookieSessions")==2 && $SessionQueryString==TRUE)))
+ {
+ if(!$objSession->UseTempKeys)
+ {
+ $sessionkey = $objSession->GetSessionKey();
+ }
+ else
+ $sessionkey = $objSession->Get("CurrentTempKey");
+ $env = $sessionkey;
+ }
+ $env .= "-";
+
+ if (isset($var_list_update["t"]))
+ {
+ if($var_list_update["t"]=="_referer_")
+ {
+ $var_list_update["t"] =$objSession->GetVariable("Template_Referer");
+ }
+
+ $t = $var_list_update["t"];
+
+ if (substr($t, 0, strlen('kernel4:')) == 'kernel4:')
+ {
+ $t = substr($t, strlen('kernel4:'));
+ $env .= $t;
+ }
+ else {
+ if(!is_numeric($t))
+ {
+ if(!is_object($theme))
+ $theme = $objThemes->GetItem($m_var_list["theme"]);
+ $id = $theme->GetTemplateId($t);
+ $var_list_update["t"] = $id;
+ }
+ $env .= $var_list_update["t"];
+ }
+ }
+ else
+ {
+ $t = isset($var_list['t']) ? $var_list['t'] : '';
+ if(!is_numeric($t))
+ {
+ if(!is_object($theme))
+ $theme = $objThemes->GetItem($m_var_list["theme"]);
+ $id = $theme->GetTemplateId($t);
+ $t = $id;
+ }
+ $env .= $t;
+ }
+
+ if(is_array($mod_prefix))
+ {
+ foreach($mod_prefix as $key => $value)
+ {
+ $builder_name = $key . "_BuildEnv";
+ if(function_exists($builder_name))
+ {
+ if($key == 'm')
+ {
+ $GLOBALS[$key.'_var_list_update']['test'] = 'test';
+ }
+ $env .= $builder_name();
+ }
+ }
+ }
+
+ $extra = "";
+ $keys = array_keys($ExtraVars);
+ if(is_array($keys))
+ {
+ for($i=0;$i<count($keys);$i++)
+ {
+ $key = $keys[$i];
+
+ $e = "&".$key."=".$ExtraVars[$key];
+ $extra .= $e;
+ $e = "";
+ }
+ }
+ $env .= $extra;
+
+ return $env;
+}
+
+function BuildEnv_NEW($mod_prefix = false)
+{
+ global $var_list, $var_list_update, $mod_prefix, $objSession;
+
+ $t = getArrayValue($var_list_update, 't') ? $var_list_update['t'] : $var_list['t'];
+ if($t == '_referer_') $t = $objSession->GetVariable('Template_Referer');
+ if ( substr($t, 0, strlen('kernel4:') ) == 'kernel4:' ) $t = substr($t, strlen('kernel4:') );
+
+ $url_params = Array('t' => $t);
+ $app =& kApplication::Instance();
+ $app->SetVar('prefixes_passed', Array() );
+
+ if( is_array($mod_prefix) )
+ {
+ foreach($mod_prefix as $key => $value)
+ {
+ $builder_name = $key.'_BuildEnv_NEW';
+ if( function_exists($builder_name) )
+ {
+ if($key == 'm')
+ {
+ $GLOBALS[$key.'_var_list_update']['test'] = 'test';
+ }
+ $url_params = array_merge_recursive2($url_params, $builder_name() );
+ }
+ }
+ }
+
+ $url_params['pass'] = implode( ',', $app->GetVar('prefixes_passed') );
+ return $url_params;
+}
+
+function CategoryActionFunc($basename,$CatList)
+{
+ global $mod_prefix;
+
+ foreach($mod_prefix as $key => $value)
+ {
+ $function_name = $key."_".$basename;
+ if(function_exists($function_name))
+ {
+ $function_name($CatList);
+ }
+ }
+}
+
+
+function RegisterEnv($Var,$Value)
+{
+ global $ExtraVars;
+
+ $ExtraVars[$Var] = $Value;
+}
+
+function UnregisterEnv($Var)
+{
+ global $ExtraVars;
+
+ unset($ExtraVars[$Var]);
+}
+
+function ModuleTagPrefix($name)
+{
+ global $modules_loaded;
+
+ $ret = "";
+ foreach($modules_loaded as $prefix=>$mod_name)
+ {
+ if($name==$mod_name)
+ {
+ $ret = $prefix;
+ break;
+ }
+ }
+ return $ret;
+}
+
+function ModuleEnabled($name)
+{
+ global $template_path;
+
+ $a = array_keys($template_path);
+ if(in_array($name,$a))
+ return TRUE;
+ return FALSE;
+}
+
+function GetModuleArray($array_name="mod_prefix")
+{
+ switch($array_name)
+ {
+ case "mod_prefix":
+ global $mod_prefix;
+ return $mod_prefix;
+ break;
+ case "admin":
+ global $mod_prefix, $modules_loaded;
+ $mod = array();
+ if(is_array($mod_prefix) && is_array($modules_loaded))
+ {
+ foreach ($mod_prefix as $key=>$value)
+ {
+ if($key != 'bbcat' && _ModuleLicensed($modules_loaded[$key]) || $key=="m")
+ {
+ $mod[$key] = $value;
+ }
+ }
+ }
+ return $mod;
+ break;
+ case "loaded":
+ global $modules_loaded;
+ return $modules_loaded;
+ break;
+ case "template":
+ global $template_path;
+ return $template_path;
+ case "rootcat":
+ global $mod_root_cats;
+ return $mod_root_cats;
+ break;
+ }
+}
+
+function admin_login()
+{
+ global $objSession,$login_error, $objConfig,$g_Allow,$g_Deny;
+// echo "<pre>"; print_r($objSession); echo "</pre>";
+
+ if( GetVar('help_usage') == 'install' ) return true;
+
+ $env_arr = explode('-', $_GET['env']);
+ $get_session_key = $env_arr[0];
+ $admin_login = isset($_POST['adminlogin']) && $_POST['adminlogin'];
+ if(!$objSession->ValidSession() || ($objSession->GetSessionKey() != $get_session_key && !$admin_login)) {
+ if( isset($_GET['expired']) && ($_GET['expired'] == 1) )
+ $login_error = admin_language("la_text_sess_expired");
+
+ return FALSE;
+ //echo "Expired<br>";
+ }
+
+ if ($objSession->HasSystemPermission("ADMIN") == 1)
+ return TRUE;
+
+ if(count($_POST)==0 || $_POST["adminlogin"]!=1)
+ return FALSE;
+ $login=$_POST["login"];
+ $password = $_POST["password"];
+
+ if (strlen($login) && strlen($password))
+ {
+ if(!_IpAccess($_SERVER['REMOTE_ADDR'],$g_Allow,$g_Deny))
+ {
+ $login_error = admin_language("la_text_address_denied");
+ return FALSE;
+ }
+ $valid = $objSession->Login($login, md5($password));
+ $hasperm = ($objSession->HasSystemPermission("ADMIN") == 1);
+ if (($login=="root" || $hasperm) && $valid)
+ {
+ if(_ValidateModules())
+ {
+ return TRUE;
+ }
+ else
+ $login_error = "Missing or invalid In-Portal License";
+ }
+ else
+ {
+ if(!$hasperm && $valid)
+ {
+ $login_error = admin_language("la_text_nopermissions");
+ }
+ else
+ {
+ $login_error = admin_language("la_Text_Access_Denied");
+ }
+ return FALSE;
+ }
+ }
+ else
+ {
+ if(!strlen($login))
+ {
+ $login_error = admin_language("la_Text_Missing_Username");
+ }
+ else
+ if(!strlen($password))
+ $login_error = admin_language("la_Text_Missing_Password");
+ return FALSE;
+ }
+}
+
+
+#---------------------------------------------------------------------------
+
+function _EnableCookieSID()
+{
+ global $var_list, $objConfig;
+
+ if((!$_COOKIE[SESSION_COOKIE_NAME] && $objConfig->Get("CookieSessions")>0 && strlen($var_list["sid"])<2 && !headers_sent())
+ || strlen($_COOKIE[SESSION_COOKIE_NAME]) > 0)
+ {
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+function _IsSpider($UserAgent)
+{
+ global $robots, $pathtoroot;
+
+ $lines = file($pathtoroot."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 _StripDomainHost($d)
+{
+ $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;
+}
+
+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 = _MatchIp($IpAddress,$allowed[$x]);
+ if($MatchAllowed)
+ break;
+ }
+ $MatchDenied = FALSE;
+ for($x=0;$x<count($denied);$x++)
+ {
+ $ip = explode(".",$denied[$x]);
+
+ $MatchDenied = _MatchIp($IpAddress,$denied[$x]);
+ if($MatchDenied)
+ break;
+ }
+
+ $Result = (($MatchAllowed && !$MatchDenied) || (!$MatchAllowed && !$MatchDenied) ||
+ ($MatchAllowed && $MatchDenied));
+ return $Result;
+}
+
+function _ValidateModules()
+{
+ global $i_Keys, $objConfig, $g_License;
+
+ $lic = base64_decode($g_License);
+ _ParseLicense($lic);
+
+ $modules = array();
+ //echo "License: ".$lic."<br>";
+ $domain = _GetDomain();
+ //echo "Domain: ".$domain."<br>";
+ if(!_IsLocalSite($domain))
+ {
+ $domain = _StripDomainHost($domain);
+ //echo "New domain: $domain<br>";
+// echo "<pre>"; print_r($i_Keys); echo "</pre>";
+ for($x=0;$x<count($i_Keys);$x++)
+ {
+ $key = $i_Keys[$x];
+ if(strlen(stristr($key["domain"],$domain)))
+ {
+ $modules = explode(",",$key["mod"]);
+ //echo "Modules: $modules";
+ }
+ }
+ if(count($modules)>0)
+ {
+ return TRUE;
+ }
+ }
+ else
+ return TRUE;
+ return FALSE;
+}
+
+function _ModuleLicensed($name)
+{
+ global $i_Keys, $objConfig, $pathtoroot;
+ $vars = parse_portal_ini($pathtoroot.'config.php');
+
+ // globalize vars from config (theese vars are already present, why to do this again?)
+ foreach ($vars as $config_key => $config_value) {
+ $GLOBALS['g_'.$config_key] = $config_value;
+ }
+
+ $lic = base64_decode($GLOBALS['g_License']);
+
+ _ParseLicense($lic);
+ $modules = array();
+ if(!_IsLocalSite(_GetDomain()))
+ {
+ for($x=0;$x<count($i_Keys);$x++)
+ {
+ $key = $i_Keys[$x];
+ if(strlen(stristr(_GetDomain(),$key["domain"])))
+ {
+ //echo "ok<br>";
+ $modules = explode(",",$key["mod"]);
+ }
+ }
+ //print_pre($modules);
+ if(in_array($name,$modules)) {
+ //echo "ok<br>";
+ return TRUE;
+ }
+ }
+ else {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+function _GetDomain()
+{
+ global $objConfig, $g_Domain;
+
+ if($objConfig->Get("DomainDetect"))
+ {
+ $d = $_SERVER['HTTP_HOST'];
+ }
+ else
+ $d = $g_Domain;
+
+ return $d;
+}
+
+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 = _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()
+{
+ global $lid;
+ echo $lid."\n";
+ die();
+}
+
+function _LoadLicense($LoadRemote=FALSE)
+{
+ global $pathtoroot, $objConfig;
+ $f = $pathtoroot."intechnic.php";
+ if (_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 (!_falseIsLocalSite($txt)) $nah = false;
+ $data = _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(_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 _GetObscureValue($z)*_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 '.'.(_GetObscureValue(6.5)+1);
+ if ($i == 'a') return 0xa;
+}
+
+function _Chr($val)
+{
+ $x = _GetObscureValue(25);
+ $f = chr($x).chr($x+5).chr($x+15);
+ return $f($val);
+}
+
+function _IsLocalSite($domain)
+{
+ $ee = _GetObscureValue(35); $yy = '';
+ foreach ($ee as $e) $yy .= _Chr($e);
+ $localb = FALSE;
+ if(substr($domain,0,3)==_GetObscureValue('x'))
+ {
+ $b = substr($domain,0,6);
+ $p = explode(".",$domain);
+ $subnet = $p[1];
+ if($p[1]>15 && $p[1]<32)
+ $localb=TRUE;
+ }
+ $zz = _GetObscureValue('z')._GetObscureValue(5).'.'.(int)_GetObscureValue(7)._GetObscureValue(12);
+ $ff = _GetObscureValue('z')+65;
+ $hh = $ff-0x18;
+ if($domain==$yy || $domain==$zz || substr($domain,0,7)==$ff._Chr(46).$hh ||
+ substr($domain,0,3)==_GetObscureValue('a')._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;
+}
+//echo "Before Stuff<br>";
+LogEntry("Loading Modules\n");
+/* get the module list from the database */
+$adodbConnection = &GetADODBConnection();
+$sql = "SELECT Name, Path, Var,TemplatePath, RootCat from ".GetTablePrefix()."Modules where Loaded=1 ORDER BY LoadOrder";
+$rs = $adodbConnection->Execute($sql);
+
+while($rs && !$rs->EOF)
+{
+ $key = $rs->fields["Var"];
+ $mod_prefix[$key] = $rs->fields["Path"];
+ $modules_loaded[$key] = $rs->fields["Name"];
+ $name = $rs->fields["Name"];
+ $template_path[$name] = $rs->fields["TemplatePath"];
+ $mod_root_cats[$name] = $rs->fields["RootCat"];
+ // echo $key . "=". $modules_loaded[$key]."<br>\n";
+ $rs->MoveNext();
+}
+
+LogEntry("Loading Module Parser scripts\n");
+/* for each module enabled, load up parser.php */
+//foreach($mod_prefix as $key => $value)
+$LogLevel++;
+if(is_array($mod_prefix))
+{
+ foreach($mod_prefix as $key => $value)
+ {
+
+ $mod = $pathtoroot . $value . "parser.php";
+// LogEntry("Loading parser $mod \n");
+ require_once($mod);
+
+ }
+}
+$LogLevel--;
+LogEntry("Finished Loading Module Parser scripts\n");
+/*now each module gets a look at the environment string */
+
+// SID detecting engine: begin
+
+ $SessionQueryString = false; // by default assume, that SID is located in cookie
+ if( !isset($FrontEnd) ) $FrontEnd = false; // if frontend not explicitly defined, than
+
+if($FrontEnd != 1)
+ $SessionQueryString = true;
+
+if (is_array($mod_prefix)) {
+ ParseEnv();
+}
+
+ if (defined('THIS_FILE') && (THIS_FILE == 'admin/index') ) {
+ // this is admin login screen & we don't have sid in url here,
+ // but session is already created by K4, then gether sid from it
+ $application =& kApplication::Instance();
+ $var_list['sid'] = $application->GetSID();
+ }
+
+/* create the session object */
+
+$ip = $_SERVER["REMOTE_ADDR"];
+
+if ( !isset($var_list['sid']) ) $var_list['sid'] = '';
+if ( !isset($_GET['env']) ) $_GET['env'] = '';
+
+if(strlen($var_list["sid"])==0 && strlen($_GET["env"])>0 && $objConfig->Get("CookieSessions")==2)
+{
+ if(_IsSpider($_SERVER["HTTP_USER_AGENT"]))
+ {
+ $UseSession = FALSE;
+ }
+ else
+ {
+ /* switch user to GET session var */
+ if (!$_COOKIE[SESSION_COOKIE_NAME]) {
+ $SessionQueryString = TRUE;
+ }
+ //else {
+ //$cg = '--code--';
+ //}
+ $UseSession = TRUE;
+ }
+}
+else {
+ $UseSession = TRUE;
+}
+
+if($var_list["sid"]=="_")
+ $var_list["sid"]="";
+
+/*setup action variable*/
+$Action = isset($_REQUEST['Action']) ? $_REQUEST['Action'] : '';
+
+if($Action == 'm_logout')
+{
+ $u = new clsUserSession($var_list['sid'] ,($SessionQueryString && $FrontEnd==1));
+
+ $application =& kApplication::Instance();
+ $application->HandleEvent( new kEvent('u:OnInpLogout') );
+
+ $u->Logout();
+ unset($u);
+ $var_list_update['t'] = 'index';
+ $var_list['t'] = '';
+ $var_list['sid'] = '';
+ set_cookie('login', '', adodb_mktime() - 3600);
+ set_cookie(SESSION_COOKIE_NAME, '', adodb_mktime() - 3600);
+}
+
+$CookieTest = isset($_COOKIE['cookies_on']) ? $_COOKIE['cookies_on'] : '';
+
+if($var_list['sid'] && !$CookieTest) // when going from http -> https and via versa assume, that cookies are allowed
+{
+ $CookieTest = true;
+ $_COOKIE['cookies_on'] = 1;
+}
+
+$HTTP_REFERER = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
+
+if ( ($CookieTest == 1) /*|| !strstr($HTTP_REFERER, $_SERVER['HTTP_HOST'].$objConfig->Get("Site_Path"))*/) {
+ $SessionQueryString = FALSE;
+}
+
+if ($FrontEnd != 1) {
+ $SessionQueryString = TRUE;
+}
+
+// SID detecting engine: end
+
+$objSession = new clsUserSession($var_list["sid"],($SessionQueryString && $FrontEnd==1));
+
+if($UseSession)
+{
+ if(!$objSession->ValidSession())
+ {
+ /* Get rid of Invalid Session and make a brand new one*/
+// echo "Dumping Session ".$var_list["sid"]."<br>";
+ unset($var_list["sid"]);
+ $objSession->GetNewSession();
+ $var_list["sid"] = $objSession->GetSessionKey();
+ $var_list_update["sid"]=$objSession->GetSessionKey();
+ if(is_numeric($m_var_list["theme"]))
+ $objSession->SetThemeName($m_var_list["theme"]);
+ if($objConfig->Get("CookieSessions")>0 && !$SessionQueryString && !headers_sent())
+ {
+ set_cookie(SESSION_COOKIE_NAME, $var_list['sid'], 0);
+ }
+ //echo "New Session: ".$objSession->GetSessionKey()."<br>\n";
+ if(isset($_COOKIE["login"]) && $Action != "m_logout" && $FrontEnd==1)
+ {
+ $parts = explode("|",$_COOKIE["login"]);
+ $username = $parts[0];
+ $pass = $parts[1];
+ $objSession->Login($username,$pass);
+ }
+ }
+ else
+ {
+ if($objSession->Get("Language")!=$m_var_list["lang"])
+ {
+ $objSession->Set("Language",$m_var_list["lang"]);
+ }
+ $objSession->LoadSessionData();
+ $objSession->UpdateAccessTime();
+ $objSession->Update();
+ LoadEnv();
+ }
+}
+
+if( isset($var_list['t']) && is_numeric($var_list['t']))
+{
+ if( !isset($CurrentTheme) ) $CurrentTheme = null;
+ if(!is_object($CurrentTheme))
+ $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]);
+
+ $var_list["t"] = $CurrentTheme->GetTemplateById($var_list["t"]);
+ $objSession->Set("Theme",$CurrentTheme->Get("Name"));
+}
+/*create the global current user object */
+$UserID=$objSession->Get("PortalUserId");
+$objCurrentUser = new clsPortalUser($UserID);
+$objLanguageCache = new clsLanguageCache($m_var_list["lang"]);
+
+/* include each module's action.php script */
+LogEntry("Loading Module action scripts\n");
+
+## Global Referer Template
+$_local_t = isset($var_list['t']) ? $var_list['t'] : '';
+
+if(is_array($mod_prefix))
+{
+ foreach($mod_prefix as $key => $folder_name)
+ {
+ $var_to_global = $key.'_var_list';
+ global $$var_to_global;
+
+ $application =& kApplication::Instance(); // just to sure, that object is here in all actions
+ if($FrontEnd == 0 || !is_numeric($FrontEnd) || $FrontEnd == 2) {
+ $rootURL = 'http://'.ThisDomain().$objConfig->Get('Site_Path');
+ $admin = $objConfig->Get("AdminDirectory");
+ if( !strlen($admin) ) $admin = "admin";
+ $adminURL = $rootURL.$admin;
+ $imagesURL = $adminURL."/images";
+
+ if( $key != 'bbcat' && _ModuleLicensed($modules_loaded[$key]) )
+ {
+ $mod = $pathtoroot.$folder_name."module_init.php";
+ if( file_exists($mod) ) require_once($mod);
+
+ $mod = $pathtoroot.$folder_name."action.php";
+ if( file_exists($mod) ) require_once($mod);
+
+ $mod = $pathtoroot.$folder_name."searchaction.php";
+ if( file_exists($mod) ) require_once($mod);
+
+ }
+
+ }
+ if($FrontEnd==1 || $FrontEnd==2)
+ {
+ $mod = $pathtoroot.$folder_name."module_init.php";
+ if(file_exists($mod))
+ require_once($mod);
+ $mod = $pathtoroot.$folder_name."frontaction.php";
+ if(file_exists($mod))
+ require_once($mod);
+ }
+ }
+}
+
+if (strstr($_SERVER['SCRIPT_NAME'], 'install') && $objSession->Get("PortalUserId") == 0) {
+ $objSession->Delete();
+}
+
+if( !isset($SearchPerformed) ) $SearchPerformed = false;
+if($SearchPerformed == true) $objSearch->BuildIndexes();
+LogEntry("Finished Loading Module action scripts\n");
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.50.2/kernel/include/modules.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.50
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.50.2/core/kernel/session/session.php
===================================================================
--- branches/unlabeled/unlabeled-1.50.2/core/kernel/session/session.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.50.2/core/kernel/session/session.php (revision 5498)
@@ -0,0 +1,764 @@
+<?php
+
+/*
+
+The session works the following way:
+
+1. When a visitor loads a page from the site the script checks if cookies_on varibale has been passed to it as a cookie.
+2. If it has been passed, the script tries to get Session ID (SID) from the request:
+3. Depending on session mode the script is getting SID differently.
+ The following modes are available:
+
+ smAUTO - Automatic mode: if cookies are on at the client side, the script relays only on cookies and
+ ignore all other methods of passing SID.
+ If cookies are off at the client side, the script relays on SID passed through query string
+ and referal passed by the client. THIS METHOD IS NOT 100% SECURE, as long as attacker may
+ get SID and substitude referal to gain access to user' session. One of the faults of this method
+ is that the session is only created when the visitor clicks the first link on the site, so
+ there is NO session at the first load of the page. (Actually there is a session, but it gets lost
+ after the first click because we do not use SID in query string while we are not sure if we need it)
+
+ smCOOKIES_ONLY - Cookies only: in this mode the script relays solely on cookies passed from the browser
+ and ignores all other methods. In this mode there is no way to use sessions for clients
+ without cookies support or cookies support disabled. The cookies are stored with the
+ full domain name and path to base-directory of script installation.
+
+ smGET_ONLY - GET only: the script will not set any cookies and will use only SID passed in
+ query string using GET, it will also check referal. The script will set SID at the
+ first load of the page
+
+ smCOOKIES_AND_GET - Combined mode: the script will use both cookies and GET right from the start. If client has
+ cookies enabled, the script will check SID stored in cookie and passed in query string, and will
+ use this SID only if both cookie and query string matches. However if cookies are disabled on the
+ client side, the script will work the same way as in GET_ONLY mode.
+
+4. After the script has the SID it tries to load it from the Storage (default is database)
+5. If such SID is found in the database, the script checks its expiration time. If session is not expired, it updates
+ its expiration, and resend the cookie (if applicable to session mode)
+6. Then the script loads all the data (session variables) pertaining to the SID.
+
+
+
+Usage:
+
+$session =& new Session(smAUTO); //smAUTO is default, you could just leave the brackets empty, or provide another mode
+
+$session->SetCookieDomain('my.domain.com');
+$session->SetCookiePath('/myscript');
+$session->SetCookieName('my_sid_cookie');
+$session->SetGETName('sid');
+$session->InitSession();
+
+...
+
+//link output:
+
+echo "<a href='index.php?'". ( $session->NeedQueryString() ? 'sid='.$session->SID : '' ) .">My Link</a>";
+
+*/
+
+//Implements session storage in the database
+class SessionStorage extends kDBBase {
+
+ var $Expiration;
+ var $SessionTimeout=0;
+
+ var $DirectVars = Array();
+ var $ChangedDirectVars = Array();
+
+ var $OriginalData=Array();
+
+ var $TimestampField;
+ var $SessionDataTable;
+ var $DataValueField;
+ var $DataVarField;
+
+ function Init($prefix,$special)
+ {
+ parent::Init($prefix,$special);
+ $this->setTableName('sessions');
+ $this->setIDField('sid');
+ $this->TimestampField = 'expire';
+ $this->SessionDataTable = 'SessionData';
+ $this->DataValueField = 'value';
+ $this->DataVarField = 'var';
+ }
+
+ function setSessionTimeout($new_timeout)
+ {
+ $this->SessionTimeout = $new_timeout;
+ }
+
+ function StoreSession(&$session, $additional_fields = Array())
+ {
+ $fields_hash = Array( $this->IDField => $session->SID,
+ $this->TimestampField => $session->Expiration);
+ if ($additional_fields) {
+ $fields_hash = array_merge_recursive2($fields_hash, $additional_fields);
+ }
+
+ $this->Conn->doInsert($fields_hash, $this->TableName);
+ }
+
+ function DeleteSession(&$session)
+ {
+ $query = ' DELETE FROM '.$this->TableName.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID);
+ $this->Conn->Query($query);
+
+ $query = ' DELETE FROM '.$this->SessionDataTable.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID);
+ $this->Conn->Query($query);
+
+ $this->OriginalData = Array();
+ }
+
+ function UpdateSession(&$session, $timeout=0)
+ {
+ $this->SetField($session, $this->TimestampField, $session->Expiration);
+ $query = ' UPDATE '.$this->TableName.' SET '.$this->TimestampField.' = '.$session->Expiration.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID);
+ $this->Conn->Query($query);
+ }
+
+ function LocateSession($sid)
+ {
+ $query = ' SELECT * FROM '.$this->TableName.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($sid);
+ $result = $this->Conn->GetRow($query);
+
+ if($result===false) return false;
+
+ $this->DirectVars = $result;
+
+ $this->Expiration = $result[$this->TimestampField];
+ return true;
+ }
+
+ function GetExpiration()
+ {
+ return $this->Expiration;
+ }
+
+ function LoadData(&$session)
+ {
+ $query = 'SELECT '.$this->DataValueField.','.$this->DataVarField.' FROM '.$this->SessionDataTable.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID);
+
+ $this->OriginalData = $this->Conn->GetCol($query, $this->DataVarField);
+ return $this->OriginalData;
+ }
+
+ /**
+ * Enter description here...
+ *
+ * @param Session $session
+ * @param string $var_name
+ * @param mixed $default
+ */
+ function GetField(&$session, $var_name, $default = false)
+ {
+ return isset($this->DirectVars[$var_name]) ? $this->DirectVars[$var_name] : $default;
+ //return $this->Conn->GetOne('SELECT '.$var_name.' FROM '.$this->TableName.' WHERE `'.$this->IDField.'` = '.$this->Conn->qstr($session->GetID()) );
+ }
+
+ function SetField(&$session, $var_name, $value)
+ {
+ if ($this->DirectVars[$var_name] != $value) {
+ $this->DirectVars[$var_name] = $value;
+ $this->ChangedDirectVars[] = $var_name;
+ $this->ChangedDirectVars = array_unique($this->ChangedDirectVars);
+ }
+ //return $this->Conn->Query('UPDATE '.$this->TableName.' SET '.$var_name.' = '.$this->Conn->qstr($value).' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->GetID()) );
+ }
+
+ function SaveData(&$session)
+ {
+ if(!$session->SID) return false; // can't save without sid
+
+ $ses_data = $session->Data->GetParams();
+
+ $replace = '';
+ foreach ($ses_data as $key => $value)
+ {
+ if ( isset($this->OriginalData[$key]) && $this->OriginalData[$key] == $value)
+ {
+ continue; //skip unchanged session data
+ }
+ else
+ {
+ $replace .= sprintf("(%s, %s, %s),",
+ $this->Conn->qstr($session->SID),
+ $this->Conn->qstr($key),
+ $this->Conn->qstr($value));
+ }
+ }
+ $replace = rtrim($replace, ',');
+ if ($replace != '') {
+ $query = ' REPLACE INTO '.$this->SessionDataTable. ' ('.$this->IDField.', '.$this->DataVarField.', '.$this->DataValueField.') VALUES '.$replace;
+ $this->Conn->Query($query);
+ }
+
+ if ($this->ChangedDirectVars) {
+ $changes = array();
+ foreach ($this->ChangedDirectVars as $var) {
+ $changes[] = $var.' = '.$this->Conn->qstr($this->DirectVars[$var]);
+ }
+ $query = 'UPDATE '.$this->TableName.' SET '.implode(',', $changes).' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->GetID());
+ $this->Conn->Query($query);
+ }
+ }
+
+ function RemoveFromData(&$session, $var)
+ {
+ $query = 'DELETE FROM '.$this->SessionDataTable.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID).
+ ' AND '.$this->DataVarField.' = '.$this->Conn->qstr($var);
+ $this->Conn->Query($query);
+ unset($this->OriginalData[$var]);
+ }
+
+ function GetFromData(&$session, $var)
+ {
+ return getArrayValue($this->OriginalData, $var);
+ }
+
+ function GetExpiredSIDs()
+ {
+ $query = ' SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE '.$this->TimestampField.' > '.adodb_mktime();
+ return $this->Conn->GetCol($query);
+ }
+
+ function DeleteExpired()
+ {
+ $expired_sids = $this->GetExpiredSIDs();
+ if ($expired_sids) {
+ $where_clause=' WHERE '.$this->IDField.' IN ("'.implode('","',$expired_sids).'")';
+ $sql = 'DELETE FROM '.$this->SessionDataTable.$where_clause;
+ $this->Conn->Query($sql);
+
+ $sql = 'DELETE FROM '.$this->TableName.$where_clause;
+ $this->Conn->Query($sql);
+
+ // delete debugger ouputs left of expired sessions
+ foreach ($expired_sids as $expired_sid) {
+ $debug_file = KERNEL_PATH.'/../cache/debug_@'.$expired_sid.'@.txt';
+ if (file_exists($debug_file)) {
+ @unlink($debug_file);
+ }
+ }
+ }
+ return $expired_sids;
+ }
+}
+
+define('smAUTO', 1);
+define('smCOOKIES_ONLY', 2);
+define('smGET_ONLY', 3);
+define('smCOOKIES_AND_GET', 4);
+
+class Session extends kBase {
+ var $Checkers;
+
+ var $Mode;
+ var $OriginalMode = null;
+ var $GETName = 'sid';
+
+ var $CookiesEnabled = true;
+ var $CookieName = 'sid';
+ var $CookieDomain;
+ var $CookiePath;
+ var $CookieSecure = 0;
+
+ var $SessionTimeout = 3600;
+ var $Expiration;
+
+ var $SID;
+
+ /**
+ * Enter description here...
+ *
+ * @var SessionStorage
+ */
+ var $Storage;
+
+ var $CachedNeedQueryString = null;
+
+ var $Data;
+
+
+ function Session($mode=smAUTO)
+ {
+ parent::kBase();
+ $this->SetMode($mode);
+ }
+
+ function SetMode($mode)
+ {
+ $this->Mode = $mode;
+ $this->CachedNeedQueryString = null;
+ $this->CachedSID = null;
+ }
+
+ function SetCookiePath($path)
+ {
+ $this->CookiePath = $path;
+ }
+
+ function SetCookieDomain($domain)
+ {
+ $this->CookieDomain = '.'.ltrim($domain, '.');
+ }
+
+ function SetGETName($get_name)
+ {
+ $this->GETName = $get_name;
+ }
+
+ function SetCookieName($cookie_name)
+ {
+ $this->CookieName = $cookie_name;
+ }
+
+ function InitStorage()
+ {
+ $this->Storage =& $this->Application->recallObject('SessionStorage');
+ $this->Storage->setSessionTimeout($this->SessionTimeout);
+ }
+
+ function Init($prefix,$special)
+ {
+ parent::Init($prefix,$special);
+
+ $this->CheckIfCookiesAreOn();
+ if ($this->CookiesEnabled) $_COOKIE['cookies_on'] = 1;
+
+ $this->Checkers = Array();
+ $this->InitStorage();
+ $this->Data =& new Params();
+
+ $tmp_sid = $this->GetPassedSIDValue();
+
+ $check = $this->Check();
+ if( !(defined('IS_INSTALL') && IS_INSTALL) )
+ {
+ $expired_sids = $this->DeleteExpired();
+ if( ( $expired_sids && in_array($tmp_sid,$expired_sids) ) || ( $tmp_sid && !$check ) )
+ {
+ $this->SetSession();
+ $this->Application->HandleEvent($event, 'u:OnSessionExpire');
+ }
+ }
+
+ if ($check) {
+ $this->SID = $this->GetPassedSIDValue();
+ $this->Refresh();
+ $this->LoadData();
+ }
+ else {
+ $this->SetSession();
+ }
+
+ if (!is_null($this->OriginalMode)) $this->SetMode($this->OriginalMode);
+ }
+
+ function IsHTTPSRedirect()
+ {
+ $http_referer = getArrayValue($_SERVER, 'HTTP_REFERER');
+ return (
+ ( PROTOCOL == 'https://' && preg_match('#http:\/\/#', $http_referer) )
+ ||
+ ( PROTOCOL == 'http://' && preg_match('#https:\/\/#', $http_referer) )
+ );
+ }
+
+ function CheckReferer($for_cookies=0)
+ {
+ if (!$for_cookies) {
+ if ( !$this->Application->ConfigValue('SessionReferrerCheck') || $_SERVER['REQUEST_METHOD'] != 'POST') {
+ return true;
+ }
+ }
+ $path = preg_replace('/admin[\/]{0,1}$/', '', $this->CookiePath); // removing /admin for compatability with in-portal (in-link/admin/add_link.php)
+ $reg = '#^'.preg_quote(PROTOCOL.ltrim($this->CookieDomain, '.').$path).'#';
+ return preg_match($reg, getArrayValue($_SERVER, 'HTTP_REFERER') ) || (defined('IS_POPUP') && IS_POPUP);
+ }
+
+ /*function CheckDuplicateCookies()
+ {
+ if (isset($_SERVER['HTTP_COOKIE'])) {
+ $cookie_str = $_SERVER['HTTP_COOKIE'];
+ $cookies = explode('; ', $cookie_str);
+ $all_cookies = array();
+ foreach ($cookies as $cookie) {
+ list($name, $value) = explode('=', $cookie);
+ if (isset($all_cookies[$name])) {
+ //double cookie name!!!
+ $this->RemoveCookie($name);
+ }
+ else $all_cookies[$name] = $value;
+ }
+ }
+ }
+
+ function RemoveCookie($name)
+ {
+ $path = $_SERVER['PHP_SELF'];
+ $path_parts = explode('/', $path);
+ $cur_path = '';
+ setcookie($name, false, null, $cur_path);
+ foreach ($path_parts as $part) {
+ $cur_path .= $part;
+ setcookie($name, false, null, $cur_path);
+ $cur_path .= '/';
+ setcookie($name, false, null, $cur_path);
+ }
+ }*/
+
+ function CheckIfCookiesAreOn()
+ {
+// $this->CheckDuplicateCookies();
+ if ($this->Mode == smGET_ONLY ||
+ ( defined('INPORTAL_ENV') &&
+ INPORTAL_ENV &&
+ $this->Application->IsAdmin()
+ &&
+ !$this->Application->GetVar('front'))
+ )
+ {
+ //we don't need to bother checking if we would not use it
+ $this->CookiesEnabled = false;
+ return;
+ }
+ $http_query =& $this->Application->recallObject('HTTPQuery');
+ $cookies_on = isset($http_query->Cookie['cookies_on']); // not good here
+
+ $get_sid = getArrayValue($http_query->Get, $this->GETName);
+ if ($this->IsHTTPSRedirect() && $get_sid) { //Redirect from http to https on different domain
+ $this->OriginalMode = $this->Mode;
+ $this->SetMode(smGET_ONLY);
+ }
+
+ if (!$cookies_on || $this->IsHTTPSRedirect()) {
+ //If referer is our server, but we don't have our cookies_on, it's definetly off
+ if ($this->CheckReferer(1) && !$this->Application->GetVar('admin') && !$this->IsHTTPSRedirect()) {
+ $this->CookiesEnabled = false;
+ }
+ else {
+ //Otherwise we still suppose cookies are on, because may be it's the first time user visits the site
+ //So we send cookies on to get it next time (when referal will tell us if they are realy off
+ setcookie(
+ 'cookies_on',
+ 1,
+ adodb_mktime()+31104000, //one year should be enough
+ $this->CookiePath,
+ $this->CookieDomain,
+ $this->CookieSecure
+ );
+ }
+ }
+ else
+ $this->CookiesEnabled = true;
+ return $this->CookiesEnabled;
+ }
+
+ function Check()
+ {
+ // we should check referer if cookies are disabled, and in combined mode
+ // auto mode would detect cookies, get only mode would turn it off - so we would get here
+ // and we don't care about referal in cookies only mode
+
+ if ( $this->Mode != smCOOKIES_ONLY && (!$this->CookiesEnabled || $this->Mode == smCOOKIES_AND_GET) ) {
+ if (!$this->CheckReferer())
+ return false;
+ }
+
+ $sid = $this->GetPassedSIDValue();
+
+ if (empty($sid)) return false;
+
+ //try to load session by sid, if everything is fine
+ $result = $this->LoadSession($sid);
+
+ return $result;
+ }
+
+ function LoadSession($sid)
+ {
+ if( $this->Storage->LocateSession($sid) ) {
+ //if we have session with such SID - get its expiration
+ $this->Expiration = $this->Storage->GetExpiration();
+
+ //If session has expired
+ if ($this->Expiration < adodb_mktime()) return false;
+
+ //Otherwise it's ok
+ return true;
+ }
+ else //fake or deleted due to expiration SID
+ return false;
+ }
+
+ function GetPassedSIDValue($use_cache = 1)
+ {
+ if (!empty($this->CachedSID) && $use_cache) return $this->CachedSID;
+ $http_query =& $this->Application->recallObject('HTTPQuery');
+ $get_sid = getArrayValue($http_query->Get, $this->GETName);
+
+ if ($this->Application->GetVar('admin') == 1 && $get_sid) {
+ $sid = $get_sid;
+ }
+ else {
+ switch ($this->Mode) {
+ case smAUTO:
+ //Cookies has the priority - we ignore everything else
+ $sid=$this->CookiesEnabled ? getArrayValue($http_query->Cookie,$this->CookieName) : $get_sid;
+ break;
+ case smCOOKIES_ONLY:
+ $sid = $http_query->Cookie[$this->CookieName];
+ break;
+ case smGET_ONLY:
+ $sid = $get_sid;
+ break;
+ case smCOOKIES_AND_GET:
+ $cookie_sid = $http_query->Cookie[$this->CookieName];
+ //both sids should match if cookies are enabled
+ if (!$this->CookiesEnabled || ($cookie_sid == $get_sid))
+ {
+ $sid = $get_sid; //we use get here just in case cookies are disabled
+ }
+ else
+ {
+ $sid = '';
+ }
+ break;
+ }
+ }
+
+ if ($this->Application->GetVar('front')) {
+ $this->CookiesEnabled = false;
+ }
+
+ $this->CachedSID = $sid;
+ return $this->CachedSID;
+ }
+
+ /**
+ * Returns session id
+ *
+ * @return int
+ * @access public
+ */
+ function GetID()
+ {
+ return $this->SID;
+ }
+
+ /**
+ * Generates new session id
+ *
+ * @return int
+ * @access private
+ */
+ function GenerateSID()
+ {
+ list($usec, $sec) = explode(" ",microtime());
+
+ $sid_part_1 = substr($usec, 4, 4);
+ $sid_part_2 = mt_rand(1,9);
+ $sid_part_3 = substr($sec, 6, 4);
+ $digit_one = substr($sid_part_1, 0, 1);
+ if ($digit_one == 0) {
+ $digit_one = mt_rand(1,9);
+ $sid_part_1 = ereg_replace("^0","",$sid_part_1);
+ $sid_part_1=$digit_one.$sid_part_1;
+ }
+ $this->setSID($sid_part_1.$sid_part_2.$sid_part_3);
+ return $this->SID;
+ }
+
+ /**
+ * Set's new session id
+ *
+ * @param int $new_sid
+ * @access private
+ */
+ function setSID($new_sid)
+ {
+ $this->SID=$new_sid;
+ $this->Application->SetVar($this->GETName,$new_sid);
+ }
+
+ function SetSession()
+ {
+ $this->GenerateSID();
+ $this->Expiration = adodb_mktime() + $this->SessionTimeout;
+ switch ($this->Mode) {
+ case smAUTO:
+ if ($this->CookiesEnabled) {
+ $this->SetSessionCookie();
+ }
+ break;
+ case smGET_ONLY:
+ break;
+ case smCOOKIES_ONLY:
+ case smCOOKIES_AND_GET:
+ $this->SetSessionCookie();
+ break;
+ }
+ $this->Storage->StoreSession($this);
+ }
+
+ function SetSessionCookie()
+ {
+ setcookie(
+ $this->CookieName,
+ $this->SID,
+ $this->Expiration,
+ $this->CookiePath,
+ $this->CookieDomain,
+ $this->CookieSecure
+ );
+
+ $_COOKIE[$this->CookieName] = $this->SID; // for compatibility with in-portal
+ }
+
+ /**
+ * Refreshes session expiration time
+ *
+ * @access private
+ */
+ function Refresh()
+ {
+ if ($this->CookiesEnabled) $this->SetSessionCookie(); //we need to refresh the cookie
+ $this->Storage->UpdateSession($this);
+ }
+
+ function Destroy()
+ {
+ $this->Storage->DeleteSession($this);
+ $this->Data =& new Params();
+ $this->SID = '';
+ if ($this->CookiesEnabled) $this->SetSessionCookie(); //will remove the cookie due to value (sid) is empty
+ $this->SetSession(); //will create a new session
+ }
+
+ function NeedQueryString($use_cache = 1)
+ {
+ if ($this->CachedNeedQueryString != null && $use_cache) return $this->CachedNeedQueryString;
+
+ $result = false;
+ switch ($this->Mode)
+ {
+ case smAUTO:
+ if (!$this->CookiesEnabled) $result = true;
+ break;
+ /*case smCOOKIES_ONLY:
+ break;*/
+ case smGET_ONLY:
+ case smCOOKIES_AND_GET:
+ $result = true;
+ break;
+ }
+ $this->CachedNeedQueryString = $result;
+ return $result;
+ }
+
+ function LoadData()
+ {
+ $this->Data->AddParams($this->Storage->LoadData($this));
+ }
+
+ function PrintSession($comment='')
+ {
+ if($this->Application->isDebugMode() && constOn('DBG_SHOW_SESSIONDATA')) {
+ $this->Application->Debugger->appendHTML('SessionStorage ('.$comment.'):');
+ $session_data = $this->Data->GetParams();
+ ksort($session_data);
+ foreach ($session_data as $session_key => $session_value) {
+ if (IsSerialized($session_value)) {
+ $session_data[$session_key] = unserialize($session_value);
+ }
+ }
+ $this->Application->Debugger->dumpVars($session_data);
+
+ // to insert after HTTPQuery if it's visible
+ $new_row = constOn('DBG_SHOW_HTTPQUERY') ? 4 : 2;
+
+ //$debugger->moveAfterRow($new_row,2);
+ }
+ }
+
+ function SaveData()
+ {
+ if (!$this->Application->GetVar('skip_last_template') && $this->Application->GetVar('ajax') != 'yes') {
+ $this->SaveLastTemplate( $this->Application->GetVar('t') );
+ }
+
+ $this->PrintSession('after save');
+ $this->Storage->SaveData($this);
+ }
+
+ function SaveLastTemplate($t)
+ {
+ $last_env = $this->Application->BuildEnv($t, Array('m_opener' => 'u', '__URLENCODE__' => 1), 'all');
+ $last_template = basename($_SERVER['PHP_SELF']).'|'.substr($last_env, strlen(ENV_VAR_NAME) + 1);
+ $this->StoreVar('last_template', $last_template);
+
+ $this->StoreVar('last_env', substr($this->Application->BuildEnv($t, Array('__URLENCODE__' => 1), 'all'), strlen(ENV_VAR_NAME)+1));
+ }
+
+ function StoreVar($name, $value)
+ {
+ $this->Data->Set($name, $value);
+ }
+
+ function StoreVarDefault($name, $value)
+ {
+ $tmp = $this->RecallVar($name);
+ if($tmp === false || $tmp == '')
+ {
+ $this->StoreVar($name, $value);
+ }
+ }
+
+ function RecallVar($name,$default=false)
+ {
+ $ret = $this->Data->Get($name);
+ return ($ret===false) ? $default : $ret;
+ }
+
+ function RemoveVar($name)
+ {
+ $this->Storage->RemoveFromData($this, $name);
+ $this->Data->Remove($name);
+ }
+
+ /**
+ * Ignores session varible value set before
+ *
+ * @param string $name
+ */
+ function RestoreVar($name)
+ {
+ return $this->StoreVar($name, $this->Storage->GetFromData($this, $name));
+ }
+
+ function GetField($var_name, $default = false)
+ {
+ return $this->Storage->GetField($this, $var_name, $default);
+ }
+
+ function SetField($var_name, $value)
+ {
+ $this->Storage->SetField($this, $var_name, $value);
+ }
+
+ /**
+ * Deletes expired sessions
+ *
+ * @return Array expired sids if any
+ * @access private
+ */
+ function DeleteExpired()
+ {
+ return $this->Storage->DeleteExpired();
+ }
+
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.50.2/core/kernel/session/session.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.50
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php (revision 5498)
@@ -0,0 +1,284 @@
+<?php
+
+$config = Array(
+ 'Prefix' => 'c',
+ 'ItemClass' => Array('class'=>'CategoriesItem','file'=>'categories_item.php','build_event'=>'OnItemBuild'),
+ 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
+ 'EventHandlerClass' => Array('class'=>'CategoriesEventHandler','file'=>'categories_event_handler.php','build_event'=>'OnBuild'),
+ 'TagProcessorClass' => Array('class'=>'CategoriesTagProcessor','file'=>'categories_tag_processor.php','build_event'=>'OnBuild'),
+
+ 'RegisterClasses' => Array(
+ Array('pseudo' => 'kPermCacheUpdater','class' => 'kPermCacheUpdater', 'file' => 'cache_updater.php','build_event'=>''),
+ ),
+
+ 'AutoLoad' => true,
+ 'QueryString' => Array(
+ 1 => 'id',
+ 2 => 'page',
+ 3 => 'event',
+ 4 => 'mode',
+ ),
+ 'AggregateTags' => Array(
+ Array(
+ 'AggregateTo' => 'm',
+ 'AggregatedTagName' => 'CategoryLink',
+ 'LocalTagName' => 'CategoryLink',
+ ),
+ ),
+ 'IDField' => 'CategoryId',
+
+ 'StatusField' => Array('Status'),
+
+ 'TitleField' => 'Name', // field, used in bluebar when editing existing item
+ 'ItemType' => 1, // used for custom fields only
+
+ 'StatisticsInfo' => Array(
+ 'pending' => Array(
+ 'icon' => 'icon16_cat_pending.gif',
+ 'label' => 'la_tab_Categories',
+ 'js_url' => "set_persistant_var('Category_View', 41, 'advanced_view', '#url#')",
+ 'url' => Array('t' => 'advanced_view', 'index_file' => 'advanced_view.php', 'SetTab' => 'category', 'pass' => 'm'),
+ 'status' => STATUS_PENDING,
+ ),
+ ),
+
+ 'TableName' => TABLE_PREFIX.'Category',
+
+ 'ViewMenuPhrase' => 'la_text_Categories',
+
+ 'TitlePresets' => Array(
+ 'default' => Array( 'new_status_labels' => Array('c' => '!la_title_Adding_Category!'),
+ 'edit_status_labels' => Array('c' => '!la_title_Editing_Category!'),
+ 'new_titlefield' => Array('c' => '!la_title_New_Category!'),
+ ),
+ 'category_list' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (#c_recordcount#)"),
+
+ 'catalog' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (<span id='c_item_count'>#c_recordcount#</span>)"),
+
+ 'categories_edit' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_General!"),
+ 'categories_properties' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Properties!"),
+ 'categories_relations' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Relations!"),
+ 'categories_images' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Images!"),
+ 'categories_permissions'=> Array('prefixes' => Array('c', 'g_List'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Permissions!"),
+ 'categories_custom' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Custom!"),
+
+ 'categories_update' => Array('prefixes' => Array(), 'format' => "!la_title_UpdatingCategories!"),
+
+ 'images_edit' => Array( 'prefixes' => Array('c', 'c-img'),
+ 'new_status_labels' => Array('c-img'=>'!la_title_Adding_Image!'),
+ 'edit_status_labels' => Array('c-img'=>'!la_title_Editing_Image!'),
+ 'new_titlefield' => Array('c-img'=>'!la_title_New_Image!'),
+ 'format' => "#c_status# '#c_titlefield#' - #c-img_status# '#c-img_titlefield#'",
+ ),
+
+ 'relations_edit' => Array( 'prefixes' => Array('c', 'c-rel'),
+ 'new_status_labels' => Array('c-rel'=>"!la_title_Adding_Relationship! '!la_title_New_Relationship!'"),
+ 'edit_status_labels' => Array('c-rel'=>'!la_title_Editing_Relationship!'),
+ 'format' => "#c_status# '#c_titlefield#' - #c-rel_status#",
+ ),
+
+ 'tree_site' => Array('format' => '!la_selecting_categories!'),
+ ),
+
+ 'PermItemPrefix' => 'CATEGORY',
+
+ 'PermSection' => Array('main' => 'CATEGORY:in-portal:categories', /*'search' => 'in-portal:configuration_search',*/ 'email' => 'in-portal:configuration_email', 'custom' => 'in-portal:configuration_custom'),
+
+
+ 'Sections' => Array(
+ // "Structure & Data" section
+ 'in-portal:site' => Array(
+ 'parent' => 'in-portal:root',
+ 'icon' => 'struct',
+ 'label' => 'la_tab_Site_Structure',
+ 'url' => Array('t' => 'sections_list', 'pass_section' => true, 'pass' => 'm'),
+ 'permissions' => Array('view'),
+ 'priority' => 1,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:browse' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'catalog',
+ 'label' => 'la_tab_Browse',
+ 'url' => Array('index_file' => 'browse.php', 'pass' => 'm'),
+ 'permissions' => Array('view'),
+ 'priority' => 1,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:browse_new' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'catalog',
+ 'label' => 'la_K4_Catalog',
+ 'url' => Array('t' => 'catalog', 'pass' => 'm'),
+ 'late_load' => Array('t' => 'xml/tree_categories', 'pass' => 'm', 'm_cat_id' => 0),
+ 'onclick' => 'checkCatalog(0)',
+ 'permissions' => Array('view'),
+ 'priority' => 1.1,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:advanced_view' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'advanced_view',
+ 'label' => 'la_tab_AdvancedView',
+ 'url' => Array('index_file' => 'advanced_view.php', 'pass' => 'm'),
+ 'permissions' => Array('view'),
+ 'priority' => 2,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:reviews' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'reviews',
+ 'label' => 'la_tab_Reviews',
+ 'url' => Array('index_file' => 'reviews.php', 'pass' => 'm'),
+ 'permissions' => Array('view'),
+ 'priority' => 3,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:configure_categories' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'cat_settings',
+ 'label' => 'la_tab_Settings',
+ 'url' => Array('t' => 'config/config_universal', 'pass_section' => true, 'pass' => 'm'),
+ 'permissions' => Array('view', 'edit'),
+ 'priority' => 4,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:configuration_search' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'settings_search',
+ 'label' => 'la_tab_ConfigSearch',
+ 'url' => Array('t' => 'config/config_search', 'module_key' => 'category', 'pass_section' => true, 'pass' => 'm'),
+ 'permissions' => Array('view', 'edit'),
+ 'priority' => 5,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:configuration_email' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'settings_email',
+ 'label' => 'la_tab_ConfigE-mail',
+ 'url' => Array('t' => 'config/config_email', 'module' => 'In-Portal:Category', 'pass_section' => true, 'pass' => 'm'),
+ 'permissions' => Array('view', 'edit'),
+ 'priority' => 6,
+ 'type' => stTREE,
+ ),
+
+ 'in-portal:configuration_custom' => Array(
+ 'parent' => 'in-portal:site',
+ 'icon' => 'settings_custom',
+ 'label' => 'la_tab_ConfigCustom',
+ 'url' => Array('t' => 'custom_fields/custom_fields_list', 'cf_type' => 1, 'pass_section' => true, 'pass' => 'm,cf'),
+ 'permissions' => Array('view', 'add', 'edit', 'delete'),
+ 'priority' => 7,
+ 'type' => stTREE,
+ ),
+
+ ),
+
+ 'FilterMenu' => Array(
+ 'Groups' => Array(
+ Array('mode' => 'AND', 'filters' => Array('show_active','show_pending','show_disabled'), 'type' => WHERE_FILTER),
+ Array('mode' => 'AND', 'filters' => Array('show_new'), 'type' => HAVING_FILTER),
+ Array('mode' => 'AND', 'filters' => Array('show_pick'), 'type' => WHERE_FILTER),
+ ),
+ 'Filters' => Array(
+ 'show_active' => Array('label' =>'la_Active', 'on_sql' => '', 'off_sql' => 'Status != 1' ),
+ 'show_pending' => Array('label' => 'la_Pending', 'on_sql' => '', 'off_sql' => 'Status != 2' ),
+ 'show_disabled' => Array('label' => 'la_Disabled', 'on_sql' => '', 'off_sql' => 'Status != 0' ),
+ 's1' => Array(),
+ 'show_new' => Array('label' => 'la_Text_New', 'on_sql' => '', 'off_sql' => '`IsNew` != 1' ),
+ 'show_pick' => Array('label' => 'la_prompt_EditorsPick', 'on_sql' => '', 'off_sql' => '`EditorsPick` != 1' ),
+ )
+ ),
+
+ 'ListSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'PermCache ON '.TABLE_PREFIX.'PermCache.CategoryId = %1$s.CategoryId
+ LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
+
+ 'ItemSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'PermCache ON '.TABLE_PREFIX.'PermCache.CategoryId = %1$s.CategoryId
+ LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
+
+ 'SubItems' => Array('c-rel', 'c-img', 'c-cdata', 'c-perm'),
+
+ 'ListSortings' => Array(
+ '' => Array(
+ 'ForcedSorting' => Array("CurrentSort" => 'asc', 'Priority' => 'desc', 'Name' => 'asc'),
+ 'Sorting' => Array('Name' => 'asc'),
+ )
+ ),
+
+ 'CalculatedFields' => Array(
+ '' => Array(
+ 'CurrentSort' => "REPLACE(ParentPath, CONCAT('|', ".'%1$s'.".CategoryId, '|'), '')",
+ )
+ ),
+
+ 'Fields' => Array
+ (
+ 'CategoryId' => Array('type' => 'int','not_null' => 1,'default' => ''),
+ 'Type' => Array('type' => 'int','not_null' => 1,'default' => 0),
+ 'ParentId' => Array('type' => 'int','not_null' => 1,'default' => 0),
+ 'Name' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'required' => 1, 'default' => ''),
+ 'Filename' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'AutomaticFilename' => Array('type' => 'int', 'not_null' => 1, 'default' => 1),
+ 'Description' => Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'required' => 1, 'default' => ''),
+ 'CreatedOn' => Array('formatter' => 'kDateFormatter', 'default'=>'#NOW#', 'required' => 1, 'not_null' => 1),
+ 'EditorsPick' => Array('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'Status' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Active', 2 => 'la_Pending', 0 => 'la_Disabled' ), 'use_phrases' => 1, 'not_null' => 1,'default' => 2),
+ 'Pop' => Array('type' => 'int', 'default' => ''),
+ 'Priority' => Array('type' => 'int', 'not_null' => 1, 'default' => ''),
+ 'MetaKeywords' => Array('type' => 'string', 'default' => ''),
+ 'CachedDescendantCatsQty' => Array('type' => 'int', 'default' => ''),
+ 'CachedNavbar' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'CreatedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => '0'),
+ 'ResourceId' => Array('type' => 'int', 'default' => ''),
+ 'ParentPath' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'NamedParentPath' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'MetaDescription' => Array('type' => 'string', 'default' => ''),
+ 'HotItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
+ 'NewItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
+ 'PopItem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (2 => 'la_Auto', 1 => 'la_Always', 0 => 'la_Never'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 2),
+ 'Modified' => Array('type' => 'int', 'formatter' => 'kDateFormatter', 'not_null' => 1,'default' => '#NOW#'),
+ 'ModifiedById' => Array('type' => 'int', 'formatter' => 'kLEFTFormatter', 'options' => Array(-1 => 'root', -2 => 'Guest'),'left_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'PortalUser WHERE `%s` = \'%s\'', 'left_key_field' => 'PortalUserId', 'left_title_field' => 'Login', 'not_null' => 1,'default' => '0'),
+ 'CategoryTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'ItemTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'CachedCategoryTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'CachedItemTemplate' => Array('type' => 'string', 'not_null' => 1, 'default' => ''),
+ ),
+
+ 'VirtualFields' => Array(
+ 'CurrentSort' => Array('type' => 'string', 'default' => ''),
+ 'IsNew' => Array('type' => 'int', 'default' => 0),
+ ),
+
+ 'Grids' => Array(
+ 'Default' => Array(
+ 'Icons' => Array('default'=>'icon16_cat.gif'),
+ 'Fields' => Array(
+ 'Name' => Array('title' => 'la_col_Name', 'data_block' => 'category_td'),
+ 'Description' => Array('title' => 'la_col_Description'),
+ 'CreatedOn_formatted' => Array('title' => 'la_col_CreatedOn', 'sort_field' => 'CreatedOn'),
+ ),
+
+ ),
+ ),
+
+ 'ConfigMapping' => Array(
+ 'PerPage' => 'Perpage_Category',
+ 'DefaultSorting1Field' => 'Category_Sortfield',
+ 'DefaultSorting2Field' => 'Category_Sortfield2',
+ 'DefaultSorting1Dir' => 'Category_Sortorder',
+ 'DefaultSorting2Dir' => 'Category_Sortorder2',
+ ),
+ );
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.50.2/core/units/categories/categories_config.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.50
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline