0) {
require_once WT_ROOT.'blocks/'.$f;
}
}
closedir($d);
/**
* End loading list of Blocks in blocks directory
*
* Load List of Blocks in modules/XX/blocks directories
*/
if (file_exists(WT_ROOT.'modules')) {
$dir=dir(WT_ROOT.'modules');
while (false !== ($entry = $dir->read())) {
if (!strstr($entry,'.') && ($entry!='..') && ($entry!='CVS')&& !strstr($entry, 'svn')) {
$path = WT_ROOT.'modules/' . $entry.'/blocks';
if (is_readable($path)) {
$d=dir($path);
while (false !== ($entry = $d->read())) {
if (($entry!='.') && ($entry!='..') && ($entry!='CVS')&& !strstr($entry, 'svn')&&(preg_match('/\.php$/', $entry)>0)) {
$p=$path.'/'.$entry;
require_once $p;
}
}
}
}
}
}
/**
* End loading list of Blocks in modules/XX/blocks directories
*/
$time = client_time();
if (!isset($action)) $action='';
// Visitors should see any links to a user page, but they may be
// following a link after an inactivity logout.
if (!WT_USER_ID) {
if (!empty($ctype) && $ctype=='user') {
header('Location: login.php&url=index.php?ctype=user');
exit;
} else {
$ctype = 'gedcom';
}
}
if (empty($ctype)) {
if ($PAGE_AFTER_LOGIN == 'welcome') $ctype = 'gedcom';
else $ctype = 'user';
}
if (WT_USER_ID) {
//-- add favorites action
if ($action=='addfav' && !empty($gid)) {
$gid = strtoupper($gid);
$indirec = find_gedcom_record($gid, WT_GED_ID);
$ct = preg_match('/0 @(.*)@ (.*)/', $indirec, $match);
if ($indirec && $ct>0) {
$favorite = array();
if (empty($favtype)) {
if ($ctype=='user') $favtype = 'user';
else $favtype = 'gedcom';
}
if ($favtype=='gedcom') {
$favtype = $GEDCOM;
$_SESSION['clearcache'] = true;
}
else $favtype=WT_USER_NAME;
$favorite['username'] = $favtype;
$favorite['gid'] = $gid;
$favorite['type'] = trim($match[2]);
$favorite['file'] = $GEDCOM;
$favorite['url'] = '';
$favorite['note'] = $favnote;
$favorite['title'] = '';
addFavorite($favorite);
}
}
if (($action=='addfav')&&(!empty($url))) {
if (empty($favtitle)) $favtitle = $url;
$favorite = array();
if (!isset($favtype)) {
if ($ctype=='user') $favtype = 'user';
else $favtype = 'gedcom';
}
if ($favtype=='gedcom') {
$favtype = $GEDCOM;
$_SESSION['clearcache'] = true;
}
else $favtype=WT_USER_NAME;
$favorite['username'] = $favtype;
$favorite['gid'] = '';
$favorite['type'] = 'URL';
$favorite['file'] = $GEDCOM;
$favorite['url'] = $url;
$favorite['note'] = $favnote;
$favorite['title'] = $favtitle;
addFavorite($favorite);
}
if (($action=='deletefav')&&(!empty($fv_id))) {
deleteFavorite($fv_id);
if ($ctype=='gedcom') $_SESSION['clearcache'] = true;
}
else if ($action=='deletemessage') {
if (isset($message_id)) {
if (!is_array($message_id)) deleteMessage($message_id);
else {
foreach($message_id as $indexval => $mid) {
if (isset($mid)) deleteMessage($mid);
}
}
if ($ctype=='gedcom') $_SESSION['clearcache'] = true;
}
}
else if (($action=='deletenews')&&(isset($news_id))) {
deleteNews($news_id);
if ($ctype=='gedcom') $_SESSION['clearcache'] = true;
}
}
//-- get the blocks list
if ($ctype=='user') {
$ublocks = getBlocks(WT_USER_NAME);
if ((count($ublocks['main'])==0) && (count($ublocks['right'])==0)) {
$ublocks['main'][] = array('print_todays_events', '');
$ublocks['main'][] = array('print_user_messages', '');
$ublocks['main'][] = array('print_user_favorites', '');
$ublocks['right'][] = array('print_welcome_block', '');
$ublocks['right'][] = array('print_random_media', '');
$ublocks['right'][] = array('print_upcoming_events', '');
$ublocks['right'][] = array('print_logged_in_users', '');
}
}
else {
$ublocks = getBlocks($GEDCOM);
if ((count($ublocks['main'])==0) && (count($ublocks['right'])==0)) {
$ublocks['main'][] = array('print_gedcom_stats', '');
$ublocks['main'][] = array('print_gedcom_news', '');
$ublocks['main'][] = array('print_gedcom_favorites', '');
$ublocks['main'][] = array('review_changes_block', '');
$ublocks['right'][] = array('print_gedcom_block', '');
$ublocks['right'][] = array('print_random_media', '');
$ublocks['right'][] = array('print_todays_events', '');
$ublocks['right'][] = array('print_logged_in_users', '');
}
}
//-- Set some behaviour controls that depend on which blocks are selected
$welcome_block_present = false;
$gedcom_block_present = false;
$top10_block_present = false;
$login_block_present = false;
foreach($ublocks['right'] as $block) {
if ($block[0]=='print_welcome_block') $welcome_block_present = true;
if ($block[0]=='print_gedcom_block') $gedcom_block_present = true;
if ($block[0]=='print_block_name_top10') $top10_block_present = true;
if ($block[0]=='print_login_block') $login_block_present = true;
}
foreach($ublocks['main'] as $block) {
if ($block[0]=='print_welcome_block') $welcome_block_present = true;
if ($block[0]=='print_gedcom_block') $gedcom_block_present = true;
if ($block[0]=='print_block_name_top10') $top10_block_present = true;
if ($block[0]=='print_login_block') $login_block_present = true;
}
//-- clear the GEDCOM cache files
if (!empty($_SESSION['clearcache'])) {
$_SESSION['clearcache'] = false;
clearCache();
}
// We have finished writing to $_SESSION, so release the lock
session_write_close();
//-- handle block AJAX calls
/**
* In order for a block to make an AJAX call the following request parameters must be set
* block = the method name of the block to call (e.g. 'print_random_media')
* side = the side of the page the block is on (e.g. 'main' or 'right')
* bindex = the number of the block on that side, first block = 0
*/
if ($action=='ajax') {
header('Content-Type: text/html; charset=UTF-8');
//-- if a block wasn't sent then exit with nothing
if (!isset($_REQUEST['block'])) {
echo 'Block not sent';
exit;
}
$block = $_REQUEST['block'];
//-- set which side the block is on
$side = 'main';
if (isset($_REQUEST['side'])) $side = $_REQUEST['side'];
//-- get the block number
if (isset($_REQUEST['bindex'])) {
if (isset($ublocks[$side][$_REQUEST['bindex']])) {
$blockval = $ublocks[$side][$_REQUEST['bindex']];
if ($blockval[0]==$block && array_key_exists($blockval[0], $WT_BLOCKS)) {
if ($side=='main') {
$param1 = 'false';
} else {
$param1 = 'true';
}
if (array_key_exists($blockval[0], $WT_BLOCKS) && !loadCachedBlock($blockval, $side.$_REQUEST['bindex'])) {
ob_start();
eval($blockval[0]."($param1, \$blockval[1], \"$side\", ".$_REQUEST['bindex'].");");
$content = ob_get_contents();
saveCachedBlock($blockval, $side.$_REQUEST['bindex'], $content);
ob_end_flush();
}
if (WT_DEBUG) {
echo execution_stats();
}
if (WT_DEBUG_SQL) {
echo WT_DB::getQueryLog();
}
exit;
}
}
}
//-- not sure which block to call so call the first one we find
foreach($ublocks['main'] as $bindex=>$blockval) {
if ($blockval[0]==$block && array_key_exists($blockval[0], $WT_BLOCKS)) {
eval($blockval[0]."(false, \$blockval[1], \"main\", $bindex);");
}
}
foreach($ublocks['right'] as $bindex=>$blockval) {
if ($blockval[0]==$block && array_key_exists($blockval[0], $WT_BLOCKS)) {
eval($blockval[0]."(true, \$blockval[1], \"right\", $bindex);");
}
}
exit;
}
//-- end of ajax call handler
if ($ctype=='user') {
$helpindex = 'index_myged_help';
print_header(i18n::translate('My Page'));
} else {
print_header(get_gedcom_setting(WT_GED_ID, 'title'));
}
if (WT_USE_LIGHTBOX) {
require WT_ROOT.'modules/lightbox/lb_defaultconfig.php';
require WT_ROOT.'modules/lightbox/functions/lb_call_js.php';
}
echo WT_JS_START;
?>
function refreshpage() {
window.location = 'index.php?ctype=';
}
function addnews(uname) {
window.open('editnews.php?username='+uname, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1');
}
function editnews(news_id) {
window.open('editnews.php?news_id='+news_id, '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1');
}
var pastefield;
function paste_id(value) {
pastefield.value=value;
}
/**
* blocks may use this JS function to update themselves using AJAX technology
* @param string targetId the id of the block to target the results too
* @param string block the method name of the block to call (e.g. 'print_random_media')
* @param string side the side of the page the block is on (e.g. 'main' or 'right')
* @param int bindex the number of the block on that side, first block = 0
* @param string ctype shows whether block is on Welcome or My Page ('gedcom' or 'user')
* @param boolean loading Whether or not to show the loading message
*/
function ajaxBlock(targetId, block, side, bindex, ctype, loading) {
target = document.getElementById(targetId);
if (!target) return false;
target.style.height = (target.offsetHeight) + "px";
if (loading) target.innerHTML = "
";
var oXmlHttp = createXMLHttp();
link = "index.php?action=ajax&block="+block+"&side="+side+"&bindex="+bindex+"&ctype="+ctype;
oXmlHttp.open("get", link, true);
oXmlHttp.onreadystatechange=function()
{
if (oXmlHttp.readyState==4)
{
target.innerHTML = oXmlHttp.responseText;
target.style.height = 'auto';
}
};
oXmlHttp.send(null);
return false;
}

