* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
// Still no luck or empty title?
if (empty($data['title'])) {
// No name found
- $data['title'] = sprintf("%s (%s)", getMessage('LANG_UNKNOWN_MODULE'), $module);
- if (SQL_NUMROWS($result) == '0') {
+ $data['title'] = getMaskedMessage('UNKNOWN_MODULE_DETECTED', $module);
+ if ((is_resource($result)) && (SQL_HASZERONUMS($result))) {
// Add module to database
$dummy = checkModulePermissions($module);
} // END - if
} // END - if
// Load SQL data and add the menu to the output stream...
- $result_main = SQL_QUERY_ESC("SELECT `title`, `action` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$ADD." ORDER BY `sort` ASC",
+ $result_main = SQL_QUERY_ESC("SELECT `title`, `action`, `visible`, `locked` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE (`what`='' OR `what` IS NULL)".$ADD." ORDER BY `sort` ASC",
array($mode), __FUNCTION__, __LINE__);
//* DEBUG: */ print(__LINE__.'/'.$main_cnt.':'.getWhat()."*<br />");
$GLOBALS['rows'] = '';
while ($content = SQL_FETCHARRAY($result_main)) {
//* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].':'.getWhat()."*<br />");
- // Init variables
+ // Init/"translate" variables
enableBlockMode(false);
- $action = $content['action'];
+ $content = translateMenuVisibleLocked($content);
// Load menu header template
$GLOBALS['rows'] .= loadTemplate($mode . '_menu_title', true, $content);
// Sub menu
- $result_sub = SQL_QUERY_ESC("SELECT `title` AS sub_title, `what` AS sub_what FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$ADD." ORDER BY `sort`",
+ $result_sub = SQL_QUERY_ESC("SELECT `title` AS sub_title, `what` AS sub_what, `visible` AS sub_visible, `locked` AS sub_locked FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ".$ADD." ORDER BY `sort` ASC",
array($mode, $content['action']), __FUNCTION__, __LINE__);
- // Get number of rows
- $totalWhats = SQL_NUMROWS($result_sub);
-
// Do we have some entries?
- if ($totalWhats > 0) {
+ if (SQL_NUMROWS($result_sub) > 0) {
// Init counter
$cnt = '0';
// Merge both arrays in one
$content = merge_array($content, $content2);
+ // Translate visible/locked again
+ $content = translateMenuVisibleLocked($content, 'sub_');
+
// Init content
$OUT = '';
// Full file name for checking menu
- //* DEBUG: */ print(__LINE__.":!!!!".$content['sub_what']."!!!<br />");
+ //* DEBUG: */ print(__LINE__ . ':!!!!' . $content['sub_what'] . '!!!<br />');
$inc = sprintf("inc/modules/%s/what-%s.php", $mode, $content['sub_what']);
if (isIncludeReadable($inc)) {
// Mark currently selected menu - open
// Rewrite array
$content = array(
- 'menu' => $OUT,
- 'what' => $content['sub_what']
+ 'menu' => $OUT,
+ 'what' => $content['sub_what'],
+ 'visible_css' => $content['sub_visible_css'],
+ 'locked_css' => $content['sub_locked_css']
);
// Add regular menu row or bottom row?
- if ($cnt < $totalWhats) {
+ if ($cnt < SQL_NUMROWS($result_sub)) {
$GLOBALS['rows'] .= loadTemplate($mode . '_menu_row', true, $content);
} else {
$GLOBALS['rows'] .= loadTemplate($mode . '_menu_bottom', true, $content);
}
- }
+ } // END - while
} else {
// This is a menu block... ;-)
enableBlockMode();
//* DEBUG: */ print(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat()."*<br />");
}
+ // Free result
+ SQL_FREERESULT($result_sub);
+
+ // Count one up
$main_cnt++;
//* DEBUG: */ print(__LINE__.'/'.$main_cnt.':'.getWhat()."*<br />");
// is the cache entry there?
if (isset($GLOBALS['is_member'])) {
// Then return it
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CACHED! (' . intval($GLOBALS['is_member']) . ')');
return $GLOBALS['is_member'];
- } elseif (getMemberId() == '0') {
+ } elseif ((!isSessionVariableSet('userid')) || (!isSessionVariableSet('u_hash'))) {
// No member
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'No member set in cookie/session.');
return false;
} else {
- // Transfer userid=>current
- setCurrentUserid(getMemberId());
+ // Get it secured from session
+ setMemberId(getSession('userid'));
+ setCurrentUserId(getMemberId());
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . getSession('userid') . ' used from cookie/session.');
}
// Init user data array
$ret = true;
} else {
// Maybe got locked etc.
- logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status'));
+ //* DEBUG */ logDebugMessage(__FUNCTION__, __LINE__, 'status=' . getUserData('status') . ',' . $valPass . '(' . strlen($valPass) . ')/' . getSession('u_hash') . '(' . strlen(getSession('u_hash')) . ')/' . getUserData('password') . '(' . strlen(getUserData('password')) . ')');
destroyMemberSession();
}
} else {
// Cookie data is invalid!
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cookie data invalid or user not found.');
destroyMemberSession();
}
} else {
// Cookie data is invalid!
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cookie data not complete.');
destroyMemberSession();
}
$GLOBALS['is_member'] = $ret;
// Return status
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret=' . intval($ret));
return $ret;
}
// Don't look for invalid userids...
if ($userid < 1) {
// Invalid, so abort here
- debug_report_bug('User id ' . $userid . ' is invalid.');
+ debug_report_bug(__FUNCTION__, __LINE__, 'User id ' . $userid . ' is invalid.');
} elseif (isUserDataValid()) {
// Use cache, so it is fine
return true;
// This patched function will reduce many SELECT queries for the specified or current admin login
function isAdmin ($adminLogin = '') {
+ // No admin in installation phase!
+ if ((isInstallationPhase()) || (!isAdminRegistered())) {
+ return false;
+ } // END - if
+
// Init variables
$ret = false;
$passCookie = '';
$valPass = '';
- //* DEBUG: */ print(__FUNCTION__.':'.$adminLogin.'<br />');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminLogin.'<br />');
// If admin login is not given take current from cookies...
if ((empty($adminLogin)) && (isSessionVariableSet('admin_login')) && (isSessionVariableSet('admin_md5'))) {
$adminLogin = getSession('admin_login');
$passCookie = getSession('admin_md5');
} // END - if
- //* DEBUG: */ print(__FUNCTION__.':'.$adminLogin.'/'.$passCookie.'<br />');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminLogin.'/'.$passCookie.'<br />');
// Do we have cache?
if (!isset($GLOBALS['is_admin'][$adminLogin])) {
if (!empty($valPass)) {
// Check if password is valid
- //* DEBUG: */ print(__FUNCTION__ . ':(' . $valPass . '==' . $passCookie . ')='.intval($valPass == $passCookie).'<br />');
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '(' . $valPass . '==' . $passCookie . ')='.intval($valPass == $passCookie));
$GLOBALS['is_admin'][$adminLogin] = (($valPass == $passCookie) || ((strlen($valPass) == 32) && ($valPass == md5($passCookie))) || (($valPass == '*FAILED*') && (!isExtensionActive('cache'))));
} // END - if
} // END - if
$OUT = loadTemplate(($mode . '_receive_table'), true, $OUT);
} else {
// Maybe the admin has to setup some maximum values?
- debug_report_bug('Nothing is being done here?');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Nothing is being done here?');
}
// Free result
array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__);
// Was it *not* found?
- if (SQL_NUMROWS($result) == '0') {
+ if (SQL_HASZERONUMS($result)) {
// So we add one!
SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`, `userid`, `link_type`) VALUES ('%s','%s','%s')",
array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__);
} // END - foreach
} else {
// Problem in request
- debug_report_bug('Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name));
+ debug_report_bug(__FUNCTION__, __LINE__, 'Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name));
}
} else {
// Data from database
} // END - if
// Exclude users in holiday?
- if (getExtensionVersion('holiday') >= '0.1.3') {
+ if (isExtensionInstalledAndNewer('holiday', '0.1.3')) {
// Add something for the holiday extension
$CAT_WHERE .= " AND d.`holiday_active`='N'";
} // END - if
return $receiverList;
}
-// Get timestamp for given stats type and data
-function getTimestampFromUserStats ($statsType, $statsData, $userid = '0') {
- // Default timestamp is zero
- $data['inserted'] = '0';
-
- // User id set?
- if ((isMemberIdSet()) && ($userid == '0')) {
- $userid = getMemberId();
- } // END - if
-
- // Is the extension installed and updated?
- if ((!isExtensionActive('sql_patches')) || (isExtensionOlder('sql_patches', '0.5.6'))) {
- // Return zero here
- return $data['inserted'];
- } // END - if
-
- // Try to find the entry
- $result = SQL_QUERY_ESC("SELECT
- UNIX_TIMESTAMP(`inserted`) AS inserted
-FROM
- `{?_MYSQL_PREFIX?}_user_stats_data`
-WHERE
- `userid`=%s AND
- `stats_type`='%s' AND
- `stats_data`='%s'
-LIMIT 1",
- array(
- bigintval($userid),
- $statsType,
- $statsData
- ), __FUNCTION__, __LINE__);
-
- // Is the entry there?
- if (SQL_NUMROWS($result) == 1) {
- // Get this stamp
- $data = SQL_FETCHARRAY($result);
- } // END - if
-
- // Free result
- SQL_FREERESULT($result);
-
- // Return stamp
- return $data['inserted'];
-}
-
-// Inserts user stats
-function insertUserStatsRecord ($userid, $statsType, $statsData) {
- // Is the extension installed and updated?
- if ((!isExtensionActive('sql_patches')) || (isExtensionOlder('sql_patches', '0.5.6'))) {
- // Return zero here
- return false;
- } // END - if
-
- // Does it exist?
- if ((!getTimestampFromUserStats($statsType, $statsData, $userid)) && (!is_array($statsData))) {
- // Then insert it!
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats_data` (`userid`,`stats_type`,`stats_data`) VALUES (%s,'%s','%s')",
- array(bigintval($userid), $statsType, $statsData), __FUNCTION__, __LINE__);
- } elseif (is_array($statsData)) {
- // Invalid data!
- logDebugMessage(__FUNCTION__, __LINE__, "userid={$userid},type={$statsType},data={".gettype($statsData).": Invalid statistics data type!");
- }
-}
-
// "Getter" for array for user refs and points in given level
function getUserReferalPoints ($userid, $level) {
//* DEBUG: */ print("----------------------- <font color=\"#00aa00\">".__FUNCTION__." - ENTRY</font> ------------------------<ul><li>\n");