part 2
/**
Blocks member to use modules
@ mixed $ID User identifier. Should be member ID if $IsAdmin is 0 or admin name if $IsAdmin is 1
@ string $ModuleType If not equal to empty string, only specified type of modules will be processed
@return int Count of processed modules
/
function modules_block($ID, $ModuleType = '')
{
if (! (int)$ID)
{
modules_err("modules_block(): invalid member ID (\$ID = '{$ID}')");
}
$ProcessedModulesCount = CallModuleFunction('FuncBlock', '$UserIdentifier', array($ID), $ModuleType, '', $ErrorMessage);
if ($ProcessedModulesCount === false)
{
modules_err("modules_block() (CallModuleFunction error): ".$ErrorMessage);
}
return $ProcessedModulesCount;
}
/**
Allows member to use modules
@ mixed $ID User identifier. Should be member ID if $IsAdmin is 0 or admin name if $IsAdmin is 1
@ string $ModuleType If not equal to empty string, only specified type of modules will be processed
@return int Count of processed modules
/
function modules_unblock($ID, $ModuleType = '')
{
if (! (int)$ID)
{
modules_err("modules_unblock(): invalid member ID (\$ID = '{$ID}')");
}
$ProcessedModulesCount = CallModuleFunction('FuncUnblock', '$UserIdentifier', array($ID), $ModuleType, '', $ErrorMessage );
if ($ProcessedModulesCount === false)
{
modules_err("modules_unblock() (CallModuleFunction error): ".$ErrorMessage);
}
return $ProcessedModulesCount;
}
/**
Updates member's or admin's information
@ mixed $ID User identifier. Should be member ID if $IsAdmin is 0 or admin name if $IsAdmin is 1
@ string $ModuleType If not equal to empty string, only specified type of modules will be processed
@ string $PreviousNickname If not empty, denotes that nickname of member was changed
@ int $IsAdmin Defines, how to interpret $ID parameter.
@return int Count of processed modules
/
function modules_update($ID, $ModuleType = '', $PreviousNickname = '', $IsAdmin = 0)
{
if (strlen(trim($ID)) <= 0)
{
modules_err("modules_update(): invalid user identifier (\$ID = '{$ID}', \$IsAdmin = '{$IsAdmin}')");
}
$ProcessedModulesCount = CallModuleFunction('FuncUpdate', '$UserIdentifier, $IsAdmin, $PreviousNickname',
array($ID, $IsAdmin, $PreviousNickname), $ModuleType, '', $ErrorMessage);
if ($ProcessedModulesCount === false)
{
modules_err("modules_update() (CallModuleFunction error): ".$ErrorMessage);
}
return $ProcessedModulesCount;
}
/**
Logs member or admin into module
@ mixed $ID User identifier. Should be member ID if $IsAdmin is 0 or admin name if $IsAdmin is 1
@ string $ModuleName Defines, which module to log in. Cannot be empty
@ int $IsAdmin Defines, how to interpret $ID parameter
/
function modules_login($ID, $ModuleName, $IsAdmin)
{
if (strlen(trim($ID)) <= 0)
{
modules_err("modules_login(): invalid user identifier (\$ID = '{$ID}', \$IsAdmin = '{$IsAdmin}')");
}
if (strlen(trim($ModuleName)) <= 0)
{
modules_err("modules_login(): module name was not specified");
}
$ProcessedModulesCount = CallModuleFunction('Login', '$UserIdentifier, $IsAdmin', array($ID, $IsAdmin), '',
$ModuleName, $ErrorMessage);
if ($ProcessedModulesCount === false)
{
modules_err("modules_login() (CallModuleFunction error): ".$ErrorMessage);
}
if ($ProcessedModulesCount === 0)
{
modules_err("modules_login(): no module with such name (\$ModuleName = '{$ModuleName}')");
}
}
/**
Raises module error. Calls exit() function (finishes PHP code interperting)
For internal use only
@ string $ErrorMessage Message to display
*/
function modules_err($ErrorMessage)
{
global $site;
mail($site['bugReportMail'], "{$site['title']} : error in module", $ErrorMessage);
echo "Module error: $ErrorMessage";
exit;
}
/**
Evaluates FuncConf procedure of modules (fills $mods array)
For internal use only
*/
function modules_read_config()
{
global $mods;
$ResModulesConfig = db_res("SELECT `Conf` FROM `Modules`");
while ($ArrModuleConfig = mysql_fetch_array($ResModulesConfig))
{
eval($ArrModuleConfig['Conf']);
}
}
/**
Synchronyzes certain profiles with modules users set
*/
function synchronizeProfiles($idList, $isAdmin)
{
global $PHPBIN;
$CommandLineArgs = new CCommandLineArgs;
$CommandLineArgs->AddArgument((int)$isAdmin);
foreach ($idList as $id)
{
$CommandLineArgs->AddArgument($id);
}
if (chdir(BX_DIRECTORY_PATH_ROOT.'modules/'))
{
$scriptReturnValue = 'value was not set';
echo "exec({$PHPBIN} -f refresh.php ".$CommandLineArgs->GetCommandLine().")";
// ($scriptOutput, $scriptReturnValue);
echo "<br />Return value = ".$scriptReturnValue."<br >";
// if ($scriptReturnValue !== 1)
// {
// echo "refresh.php returned: <br />\n";
foreach ($scriptOutput as $outputLine)
{
echo $outputLine.'<br />';
}
echo '------------------------------------------ <br /><br />';
// modules_err("synchronizeProfiles(): exec({$PHPBIN} -f refresh.php ".$CommandLineArgs->GetCommandLine().") returned ".$scriptReturnValue);
}
}
// else
// {
// modules_err("synchronizeProfiles(): chdir(" . BX_DIRECTORY_PATH_ROOT . "modules/) returned false");
// }
/* DEBUG
echo "exec({$PHPBIN} -f refresh.php ".$CommandLineArgs->GetCommandLine().")";
echo "<br />Return value = ".$scriptReturnValue."<br >";
foreach ($scriptOutput as $outputLine)
{
echo $outputLine.'<br />';
}
echo '------------------------------------------ <br /><br />';
//*/
//}
/
Synchronyzes all profiles with modules users set. Synchronization is performed
part-by-part to avoid execution time limit exceeding
/
function modulesRefresh($partSize = 20)
{
/
Splits list of profiles into parts and calls synchronizeProfiles function for each part
/
function splitAndSynchronize($idList, $isAdmin, $partSize)
{
if (! is_array($idList))
{
$idList = array($idList);
}
$fullPartsCount = intval(count($idList) / $partSize);
for ($partIndex = 0; $partIndex <= $fullPartsCount - 1; $partIndex++)
{
$part = array();
for ($idIndex = 0; $idIndex <= $partSize - 1; $idIndex++)
{
$part[] = $idList[$partIndex $partSize + $idIndex];
}
synchronizeProfiles($part, $isAdmin);
}
$restSize = count($idList) % $partSize;
if ($restSize)
{
$part = array();
for ($idIndex = 0; $idIndex <= $restSize - 1; $idIndex++)
{
$part[] = $idList[$fullPartsCount * $partSize + $idIndex];
}
synchronizeProfiles($part, $isAdmin);
}
} /* function splitAndSynchronize */
// Synchronize admins
$resAdmins = db_res("SELECT `Name` FROM `Admins`");
while ($adminInfo = mysql_fetch_array($resAdmins))
{
$admins[] = $adminInfo['Name'];
}
splitAndSynchronize($admins, 1, $partSize);
// Synchronize members
$resMembers = db_res("SELECT `ID`, `NickName` FROM `Profiles`");
while ($arrMember = mysql_fetch_array($resMembers))
{
if (! in_array($arrMember['NickName'], $admins))
{
$members[] = $arrMember['ID'];
}
}
splitAndSynchronize($members, 0, $partSize);
}
modules_read_config();
?>
please guide me what to do.. to fix the error
thanks and regards..
adi
indonesia