|
From: mhewitson <mhe...@us...> - 2007-06-07 22:01:38
|
Update of /cvsroot/mxbb/mx_blogs/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv721/mx_blogs/includes Added Files: functions_trackback.php functions_weblog.php monofont.ttf weblogs_common.php weblogs_constants.php Log Message: mx_blogs, Initial checkin --- NEW FILE: weblogs_common.php --- <?php /*************************************************************************** * weblogs_common.php * ------------------------ * begin : Monday, September 5, 2004 * copyright : (C) 2005 Hyperion * email : vi...@ho... * * $Id: weblogs_common.php,v 1.0.0 2004/09/05, 13:17:43 Hyperion Exp $ * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ if ( !defined('IN_PHPBB') ) { die("Hacking attempt"); } if ( !isset($mx_root_path)) { $mx_root_path = '../../../'; } include($mx_root_path . 'modules/mx_blogs/includes/weblogs_constants.'.$phpEx); //include($phpbb_root_path . 'includes/functions_weblog.'.$phpEx); include($mx_root_path . 'modules/mx_blogs/includes/functions_weblog.'.$phpEx); //include($mx_root_path . 'includes/mx_functions.'.$phpEx); // The Blog Mod version 0.2.5 define('WEBLOGS_MOD_VERSION', '0.2.6'); // Weblog Constants (Constants used all over the place) define('SORT_NEWEST_ENTRIES', 0); define('SORT_WEBLOG_NAME', 1); define('SORT_NUM_ENTRIES', 2); define('SORT_WEBLOG_START_DATE', 3); define('SORT_WEBLOG_VIEWS', 4); define('SORT_WEBLOG_OWNER_NAME', 5); define('ACTION_DO_NOTHING', 0); define('ACTION_LOAD_TEMPLATE', 1); define('ACTION_SWITCH_MODE', 2); define('WEBLOG_AUTH_ALL', 0); define('WEBLOG_AUTH_REGISTERED', 1); define('WEBLOG_AUTH_FRIENDS', 2); define('WEBLOG_AUTH_OWNER', 3); // include the weblog language file $use_lang = ( !file_exists($mx_root_path . 'modules/mx_blogs/language/lang_' . $board_config['default_lang'] . '/lang_weblog_main.'.$phpEx) ) ? 'english' : $board_config['default_lang']; include($mx_root_path . 'modules/mx_blogs/language/lang_' . $use_lang . '/lang_weblog_main.' . $phpEx); // // Preload all Weblog Config data // $sql = "SELECT * FROM " . WEBLOG_CONFIG_TABLE; if( !($result = $db->sql_query($sql)) ) { if (function_exists('read_block_config')) { mx_message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql); } else { message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql); } } while ( $row = $db->sql_fetchrow($result) ) { $weblog_config[$row['config_name']] = $row['config_value']; } // // Preload the friends data (for determining if user is friend of weblog owner // $sql = "SELECT * FROM " . WEBLOG_FRIENDS_TABLE . " WHERE friend_id = " . $userdata['user_id']; if ( !($result = $db->sql_query($sql)) ) { if (function_exists('read_block_config')) { mx_message_die(GENERAL_ERROR, 'Error querying to find user weblog friends information', '', __LINE__, __FILE__, $sql); } else { message_die(GENERAL_ERROR, 'Error querying to find user weblog friends information', '', __LINE__, __FILE__, $sql); } } $friends_data = array(); while ( $row = $db->sql_fetchrow($result) ) { $friends_data[] = $row; } // // Preload the blocked users data (for determining if user is blocked in any weblog // $sql = "SELECT * FROM " . WEBLOG_BLOCKED_TABLE . " WHERE blocked_id = " . $userdata['user_id']; if ( !($result = $db->sql_query($sql)) ) { if (function_exists('read_block_config')) { mx_message_die(GENERAL_ERROR, 'Error querying to find user weblog blocked information', '', __LINE__, __FILE__, $sql); } else { message_die(GENERAL_ERROR, 'Error querying to find user weblog blocked information', '', __LINE__, __FILE__, $sql); } } $blocked_data = array(); while ( $row = $db->sql_fetchrow($result) ) { $blocked_data[] = $row; } // // Load the template data // // Get template data and check to see if there is at least one template installed. $sql = "SELECT * FROM " . WEBLOG_TEMPLATES_TABLE . " ORDER BY template_name"; if ( !($result = $db->sql_query($sql)) ) { if (function_exists('read_block_config')) { mx_message_die(GENERAL_ERROR, 'Error querying to find user weblog information', '', __LINE__, __FILE__, $sql); } else { message_die(GENERAL_ERROR, 'Error querying to find user weblog information', '', __LINE__, __FILE__, $sql); } } $template_data = array(); while ( $row = $db->sql_fetchrow($result) ) { $template_data[] = $row; } ?> --- NEW FILE: monofont.ttf --- (This appears to be a binary file; contents omitted.) --- NEW FILE: functions_weblog.php --- <?php /*************************************************************************** * functions_weblog.php * -------------------------- * begin : Monday, September 5, 2004 * copyright : (C) 2005 Hyperion * email : vi...@ho... * * $Id: functions_weblog.php,v 1.0.0 2004/09/05, 13:17:43 Hyperion Exp $ * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ function use_weblog_header ( $weblog_data, $template_dir, $parse = TRUE ) { global $board_config, $template, $template_data, $phpEx, $phpbb_root_path, $lang, $page_title, $userdata; global $module_root_path,$mx_root_path,$weblog_config; // // Start output of page // // include the weblog lang file $use_lang = ( !file_exists($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_weblog_main.'.$phpEx) ) ? 'english' : $board_config['default_lang']; // // Copied from includes/page_header.php // define('HEADER_INC', TRUE); // // gzip_compression // $do_gzip_compress = FALSE; if ( $board_config['gzip_compress'] ) { $phpver = phpversion(); $useragent = (isset($_SERVER["HTTP_USER_AGENT"]) ) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT; if ( $phpver >= '4.0.4pl1' && ( strstr($useragent,'compatible') || strstr($useragent,'Gecko') ) ) { if ( extension_loaded('zlib') ) { @ob_end_clean(); ob_start('ob_gzhandler'); } } else if ( $phpver > '4.0' ) { if ( strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') ) { if ( extension_loaded('zlib') ) { $do_gzip_compress = TRUE; ob_start(); ob_implicit_flush(0); header('Content-Encoding: gzip'); } } } } // Add no-cache control for cookies if they are set //$c_no_cache = (isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_data'])) ? 'no-cache="set-cookie", ' : ''; // Work around for "current" Apache 2 + PHP module which seems to not // cope with private cache control setting if (!empty($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache/2')) { header ('Cache-Control: no-cache, pre-check=0, post-check=0'); } else { header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0'); } header ('Expires: 0'); header ('Pragma: no-cache'); // Format Timezone. We are unable to use array_pop here, because of PHP3 compatibility $l_timezone = explode('.', $board_config['board_timezone']); $l_timezone = (count($l_timezone) > 1 && $l_timezone[count($l_timezone)-1] != 0) ? $lang[sprintf('%.1f', $board_config['board_timezone'])] : $lang[number_format($board_config['board_timezone'])]; if ( !$userdata['session_logged_in'] ) { $template->assign_block_vars('switch_user_logged_out', array()); } else { $template->assign_block_vars('switch_user_logged_in', array()); } // // End copy // if ( $parse ) { $template->set_filenames(array( 'header' => $module_root_path . 'weblogs/templates/' . $template_dir . '/weblog_header.htm') ); } if ( $weblog_data['font'] == '0' ) $font = 'Arial'; else if ( $weblog_data['font'] == '1' ) $font = 'Comic Sans MS'; else if ( $weblog_data['font'] == '2' ) $font = 'Courier New'; else if ( $weblog_data['font'] == '3' ) $font = 'Georgia'; else if ( $weblog_data['font'] == '4' ) $font = 'Verdana'; else if ( $weblog_data['font'] == '5' ) $font = 'Times New Roman'; else if ( $weblog_data['font'] == '6' ) $font = 'Trebuchet'; else $font = 'Verdana'; $template->assign_vars(array( 'SITENAME' => $board_config['sitename'], 'SITE_DESCRIPTION' => $board_config['site_desc'], 'PAGE_TITLE' => $page_title, 'BACKGROUND_COLOR' => $weblog_data['background_color'], 'ENTRY_BG_COLOR' => $weblog_data['entry_bg_color'], 'BORDER_COLOR' => $weblog_data['border_color'], 'BACKGROUND_IMAGE' => $weblog_data['background_image'], 'BACKGROUND_IMAGE_FIXED' => ( $weblog_data['background_image_fixed'] ) ? 'fixed' : 'scroll', 'BACKGROUND_REPEAT' => $weblog_data['tile_bg'], 'BACKGROUND_POSITION' => $weblog_data['bg_ypos'] . ' ' . $weblog_data['bg_xpos'], 'SB_FACE_COLOR' => $weblog_data['sb_face_color'], 'SB_HIGHLIGHT_COLOR' => $weblog_data['sb_highlight_color'], 'SB_SHADOW_COLOR' => $weblog_data['sb_shadow_color'], 'SB_3DLIGHT_COLOR' => $weblog_data['sb_3dlight_color'], 'SB_ARROW_COLOR' => $weblog_data['sb_arrow_color'], 'SB_TRACK_COLOR' => $weblog_data['sb_track_color'], 'SB_DARKSHADOW_COLOR' => $weblog_data['sb_darkshadow_color'], 'FONT' => $font, 'FONT_COLOR' => $weblog_data['font_color'], 'FONT_SIZE' => $weblog_data['font_size'], 'NORMAL_LINK_COLOR' => $weblog_data['normal_link_color'], 'NORMAL_LINK_UNDERLINED' => ( $weblog_data['normal_link_underline'] ) ? 'underline' : 'none', 'ACTIVE_LINK_COLOR' => $weblog_data['active_link_color'], 'ACTIVE_LINK_UNDERLINED' => ( $weblog_data['active_link_underline'] ) ? 'underline': 'none', 'HOVER_LINK_COLOR' => $weblog_data['hover_link_color'], 'HOVER_LINK_UNDERLINED' => ( $weblog_data['hover_link_underline'] ) ? 'underline': 'none', 'VISITED_LINK_COLOR' => $weblog_data['visited_link_color'], 'VISITED_LINK_UNDERLINED' => ( $weblog_data['visited_link_underline'] ) ? 'underline': 'none', 'WEBLOG_TITLE_COLOR' => $weblog_data['weblog_title_color'], 'WEBLOG_TITLE_FONT_SIZE' => $weblog_data['weblog_title_font_size'], 'ENTRY_TITLE_COLOR' => $weblog_data['entry_title_color'], 'ENTRY_TITLE_FONT_SIZE' => $weblog_data['entry_title_font_size'], 'DATE_TIME_COLOR' => $weblog_data['date_time_color'], 'DATE_TIME_FONT_SIZE' => $weblog_data['date_time_font_size'], 'BLOCK_TITLE_COLOR' => $weblog_data['block_title_color'], 'BLOCK_TITLE_FONT_SIZE' => $weblog_data['block_title_font_size'], 'BLOCK_BG_COLOR' => $weblog_data['block_bg_color'], 'BLOCK_BORDER_COLOR' => $weblog_data['block_border_color'], 'L_USERNAME' => $lang['Username'], 'L_PASSWORD' => $lang['Password'], 'L_LOGIN' => $lang['Login'], 'L_LOG_ME_IN' => $lang['Log_me_in'], 'L_AUTO_LOGIN' => $lang['Log_me_in'], 'L_INDEX' => sprintf($lang['Forum_Index'], $board_config['sitename']), 'L_REGISTER' => $lang['Register'], 'L_PROFILE' => $lang['Profile'], 'L_SEARCH' => $lang['Search'], 'L_PRIVATEMSGS' => $lang['Private_Messages'], 'L_WHO_IS_ONLINE' => $lang['Who_is_Online'], 'L_MEMBERLIST' => $lang['Memberlist'], 'L_FAQ' => $lang['FAQ'], 'L_USERGROUPS' => $lang['Usergroups'], 'L_SEARCH_NEW' => $lang['Search_new'], 'L_SEARCH_UNANSWERED' => $lang['Search_unanswered'], 'L_SEARCH_SELF' => $lang['Search_your_posts'], 'L_WEBLOGS' => $lang['Weblogs'], 'L_WEBLOG_CONFIG' => $lang['Weblog_CP'], 'L_MYWEBLOGS' => $lang['Weblog_MyWeblogs'], 'U_WEBLOGS' => append_sid($mx_root_path . "index.$phpEx?page=" . $weblog_config['mx_weblog_list']), 'U_MYWEBLOGS' => append_sid("myweblogs.$phpEx"), 'U_WEBLOG_CONFIG' => append_sid($mx_root_path . "index.$phpEx?page=" . $weblog_config['mx_weblog_config_page']), 'U_INDEX' => append_sid($mx_root_path . 'index.'.$phpEx), 'S_CONTENT_DIRECTION' => $lang['DIRECTION'], 'S_CONTENT_ENCODING' => $lang['ENCODING'], 'S_CONTENT_DIR_LEFT' => $lang['LEFT'], 'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'], 'S_TIMEZONE' => sprintf($lang['All_times'], $l_timezone), 'S_LOGIN_ACTION' => append_sid($mx_root_path . 'login.'.$phpEx)) ); if ( $parse ) { // // Parse the header // $template->pparse('header'); } return; } function use_weblog_footer ( $weblog_data, $template_dir, $parse = TRUE ) { global $do_gzip_compress, $template, $db; if ( $parse ) { $template->set_filenames(array( 'footer' => $module_root_path . 'weblogs/templates/' . $template_dir . '/weblog_footer.htm') ); // // Output the footer // $template->pparse('footer'); } // // Copied from includes/page_tail.php // // // Close our DB connection. // $db->sql_close(); // // Compress buffered output if required and send to browser // if ( $do_gzip_compress ) { // // Borrowed from php.net! // $gzip_contents = ob_get_contents(); @ob_end_clean(); $gzip_size = strlen($gzip_contents); $gzip_crc = crc32($gzip_contents); $gzip_contents = gzcompress($gzip_contents, 9); $gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4); echo "\x1f\x8b\x08\x00\x00\x00\x00\x00"; echo $gzip_contents; echo pack('V', $gzip_crc); echo pack('V', $gzip_size); } exit; // // End copy // } function make_template_select ( $selected, $select_name, $weblog_exists ) { global $template_data, $lang; $template_select = '<select id="' . $select_name . '" name="' . $select_name . '" onchange="update_preview(this.options[selectedIndex].id);">'; $found = false; for ($i = 0; $i < count($template_data); $i++) { if ( ($template_data[$i]['template_private'] && $selected == $template_data[$i]['template_id']) || !$template_data[$i]['template_private'] ) { $select = ( $selected == $template_data[$i]['template_id'] && $weblog_exists ) ? ' selected="selected"' : ''; $template_select .= '<option value="' . $template_data[$i]['template_name'] . '" id="' . $template_data[$i]['template_dir'] . '"' . $select . '>' . (( $template_data[$i]['template_private'] ) ? $lang['Private'] : '') . ' ' . $template_data[$i]['template_name'] . '</option>'; $found = ( $selected == $template_data[$i]['template_id'] ) ? true : $found; } $select = ''; } if ( !$found && $weblog_exists ) { $template_select .= '<option value="" name="" selected="selected">' . $lang['Unknown'] . '</option>'; } $template_select .= '</select>'; return $template_select; } function make_weblog_auth_select ( $selected, $select_name ) { global $lang; $weblog_auth_types = array($lang['Weblog_auth_all'], $lang['Weblog_auth_reg'], $lang['Weblog_auth_friends'], $lang['Weblog_auth_owner']); $weblog_auth_select = '<select id="' . $select_name . '" name="' . $select_name . '">'; for ($i = 0; $i < count($weblog_auth_types); $i++) { $select = ( $selected == $i ) ? ' selected="selected"' : ''; $weblog_auth_select .= '<option value="' . $i . '"' . $select . '>' . $weblog_auth_types[$i] . '</option>'; } $weblog_auth_select .= '</select>'; return $weblog_auth_select; } function make_mood_set_select ( $selected, $select_name ) { global $lang, $mood_set_data, $mood_data; $set_data = array(); // Find the data that corresponds with the selected set for ( $i = 0; $i < count($mood_set_data); $i++ ) { if ( $mood_set_data[$i]['set_id'] == $selected ) { $set_data = $mood_set_data[$i]; } } $set_select = '<select id="' . $select_name . '" name="' . $select_name . '" onchange="update_set_preview(this.options[selectedIndex].id);">'; for ( $i = 0; $i < count ($mood_set_data); $i++ ) { $preview = ''; for ( $j = 0; $j < count($mood_data) ; $j++) { $temp = 0; $temp = rand(0, count($mood_data)); if ( $mood_data[$j]['mood_set'] == $mood_set_data[$i]['set_id'] ) { $preview = $mood_data[$j]['mood_url']; break; } else if ( $mood_data[$temp]['mood_set'] == $mood_set_data[$i]['set_id'] ) { $preview = $mood_data[$temp]['mood_url']; break; } } if ( !$preview ) { $preview = 'mood_none.gif'; } $select = ( $selected == $mood_set_data[$i]['set_id'] ) ? ' selected="selected"' : ''; $set_select .= '<option value="' . $mood_set_data[$i]['set_id'] . '"' . $select . ' id="' . $preview . '">' . $mood_set_data[$i]['set_name'] . '</option>'; } $set_select .= '</select>'; return $set_select; } function make_mood_select ( $selected, $select_name, $set_id, $auto_change_img = FALSE ) { global $lang, $mood_data; $mood_select = '<select id="' . $select_name . '" name="' . $select_name . '"' . ( ( $auto_change_img ) ? ' onchange="update_mood(this.options[selectedIndex].id);"' : '') . ' tabindex="3">'; $mood_select .= '<optgroup label="' . $mood_data[0]['set_name'] . '"><option value="-1" id="mood_none.gif"' . (( $selected == -1 ) ? " selected=\"selected\"" : "") . '>' . $lang['None'] . '</option>'; for ($i = 0; $i < count($mood_data); $i++) { if ( $mood_data[$i]['mood_set'] == $set_id ) { $select = ( $selected == $mood_data[$i]['mood_id'] ) ? ' selected="selected"' : ''; $mood_select .= '<option value="' . $mood_data[$i]['mood_id'] . '" id="' . $mood_data[$i]['mood_url'] . '"' . $select . '>' . $mood_data[$i]['mood_text'] . '</option>'; } } $mood_select .= '</optgroup></select>'; return $mood_select; } function make_action_select ( $selected, $select_name, $auto_change_img = FALSE ) { global $lang, $action_data; $action_select = '<select id="' . $select_name . '" name="' . $select_name . '"' . ( ( $auto_change_img ) ? ' onchange="update_currently(this.options[selectedIndex].id);"' : '') . ' tabindex="4"><option value="-1" id="action_none.gif"' . (( $selected == -1 ) ? " selected=\"selected\"" : "") . '>' . $lang['None'] . '</option>'; for ($i = 0; $i < count($action_data); $i++) { $select = ( $selected == $action_data[$i]['action_id'] ) ? ' selected="selected"' : ''; $action_select .= '<option value="' . $action_data[$i]['action_id'] . '" id="' . $action_data[$i]['action_url'] . '"' . $select . '>' . $action_data[$i]['action_text'] . '</option>'; } $action_select .= '<option value="-2" id="action_custom.gif"' . (( $selected == -2 ) ? " selected=\"selected\"" : "") . '>' . $lang['Custom'] . '</option></select>'; return $action_select; } //ADDON Categories function make_category_select ( $selected, $select_name, $category_data, $auto_change = TRUE) { global $lang; $category_select = '<select id="' . $select_name . '" name="' . $select_name . '"' . ' onchange="update_category(this.options[selectedIndex].id);" tabindex="6">'; for ($i = 0; $i < count($category_data); $i++) { $select = ( $selected == $category_data[$i] ) ? ' selected="selected"' : ''; $category_select .= '<option value="' . $i . '" id="' . $category_data[$i] . '">' . $category_data[$i] . '</option>'; } $category_select .= '</select>'; return $category_select; } function load_template ( $template_dir, $weblog_id ) { global $lang,$mx_root_path; // Chmod so we'll have no problems @chmod($mx_root_path . 'modules/mx_blogs/weblogs', 0755); // CHMOD the template's files @chmod ($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_body.htm', 0755); @chmod ($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_header.htm', 0755); @chmod ($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_footer.htm', 0755); @chmod ($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_faceplate_body.htm', 0755); if ( file_exists($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_body.htm') ) { $weblog_body = file($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_body.htm'); } else { $weblog_body[] = sprintf($lang['Weblog_no_body'], $mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_body.htm'); } if ( file_exists($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_header.htm') ) { $weblog_header = file($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_header.htm'); } else { $weblog_header[] = sprintf($lang['Weblog_no_header'], $mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_header.htm'); } if ( file_exists($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_footer.htm') ) { $weblog_footer = file($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_footer.htm'); } else { $weblog_footer[] = sprintf($lang['Weblog_no_footer'], $mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_footer.htm'); } if ( file_exists($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_faceplate_body.htm') ) { $weblog_faceplate = file($mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_faceplate_body.htm'); } else { $weblog_faceplate[] = sprintf($lang['Weblog_no_faceplate'], $mx_root_path . 'modules/mx_blogs/weblogs/templates/' . $template_dir . '/weblog_faceplate_body.htm'); } $file_body = ''; $file_faceplate = ''; for ( $i = 0; $i < count($weblog_header); $i++) { $file_body .= $weblog_header[$i]; } for ( $i = 0; $i < count($weblog_body); $i++) { $file_body .= $weblog_body[$i]; } for ( $i = 0; $i < count($weblog_footer); $i++) { $file_body .= $weblog_footer[$i]; } for ( $i = 0; $i < count($weblog_faceplate); $i++) { $file_faceplate .= $weblog_faceplate[$i]; } $filename = $mx_root_path . 'modules/mx_blogs/weblogs/weblog_' . $weblog_id . '.htm'; // Delete the user's old file if present @unlink($filename); // Open for writing $f = @fopen($filename, 'w' ); // Write the stuff @fwrite( $f, $file_body ); // Close the file @fclose( $f ); // Do the same for the face plate $filename = $mx_root_path . 'modules/mx_blogs/weblogs/faceplate_' . $weblog_id . '.htm'; // Delete the user's old file if present @unlink($filename); // Open for writing $f = @fopen($filename, 'w' ); // Write the stuff @fwrite( $f, $file_faceplate ); // Close the file @fclose( $f ); } function save_template ( $weblog_body, $weblog_faceplate, $weblog_id ) { global $lang,$mx_root_path; // // Assumes html has been prepared already // // Chmod so we'll have no problems @chmod($mx_root_path . 'modules/mx_blogs/weblogs/', 0755); if ( !file_exists($mx_root_path . 'modules/mx_blogs/weblogs/faceplate_' . $weblog_id . '.htm') ) { mx_message_die (GENERAL_ERROR, sprintf($lang['No_faceplate_file'], $mx_root_path . 'modules/mx_blogs/weblogs/faceplate_' . $weblog_id . '.htm')); } $filename = $mx_root_path . 'modules/mx_blogs/weblogs/weblog_' . $weblog_id . '.htm'; // Chmod so we'll have no problems @chmod($filename, 0755); if ( !file_exists($filename) ) { mx_message_die (GENERAL_ERROR, sprintf($lang['No_weblog_file'], 'weblogs/weblog_' . $weblog_id . '.htm')); } // Delete the user's old file @unlink($filename); // Open for writing $f = @fopen($filename, 'w' ); // Write the stuff @fwrite( $f, $weblog_body ); // Close the file @fclose( $f ); // Do the same for the face plate $filename = $mx_root_path . 'modules/mx_blogs/weblogs/faceplate_' . $weblog_id . '.htm'; // Chmod so we'll have no problems @chmod($filename, 0755); if ( !file_exists($filename) ) { mx_message_die (GENERAL_ERROR, sprintf($lang['No_faceplate_file'], 'weblogs/faceplate_' . $weblog_id . '.htm')); } // Delete the user's old file @unlink($filename); // Open for writing $f = @fopen($filename, 'w' ); // Write the stuff @fwrite( $f, $weblog_faceplate ); // Close the file @fclose( $f ); } function get_auth_level ( $weblog_data, $friends_data, $blocked_data, $owner_id ) { global $userdata, $db; // // Get the authorization level of this user versus this weblog // $weblog_id = $weblog_data['weblog_id']; $auth_level = 0; // The user should at least belong to the 'all' category! if ( $userdata['session_logged_in'] ) { $auth_level = 1; for ( $i = 0; $i < count($friends_data); $i++ ) { if ( $friends_data[$i]['owner_id'] == $owner_id && $userdata['user_id'] == $friends_data[$i]['friend_id'] ) { $auth_level = 2; break; } } for ( $i = 0; $i < count($blocked_data); $i++ ) { if ( $blocked_data[$i]['owner_id'] == $owner_id && $userdata['user_id'] == $blocked_data[$i]['blocked_id'] ) { $auth_level = -1; break; } } if ( $weblog_data['weblog_id'] == $userdata['user_weblog'] ) { // Means full access. Can be any number higher than 2. $auth_level = 3; } } return $auth_level; } function get_weblog_faceplate ($weblog_id) { global $lang,$mx_root_path; $filename = $mx_root_path . 'modules/mx_blogs/weblogs/faceplate_' . $weblog_id . '.htm'; // CHMOD the template's files @chmod ($filename, 0755); if ( file_exists($filename) ) { $faceplate = file($filename); } else { $faceplate[] = sprintf($lang['No_faceplate_file'], $filename); } $file_faceplate = ''; for ( $i = 0; $i < count($faceplate); $i++) { $file_faceplate .= $faceplate[$i]; } return $file_faceplate; } function get_weblog_body ($weblog_id) { global $lang,$mx_root_path; $filename = $mx_root_path . 'modules/mx_blogs/weblogs/weblog_' . $weblog_id . '.htm'; // CHMOD the template's files @chmod ($filename, 0755); if ( file_exists($filename) ) { $body = file($filename); } else { $body[] = sprintf($lang['Weblog_no_body'], $filename); } $file_body = ''; for ( $i = 0; $i < count($body); $i++) { $file_body .= $body[$i]; } return $file_body; } function get_template_dir ( $template_id ) { global $template_data; for ( $i = 0; $i < count ($template_data); $i++) { if ( $template_data[$i]['template_id'] == $template_id ) { return $template_data[$i]['template_dir']; } } return -1; } function find_mood ( $mood_id ) { global $mood_data; for ( $i = 0; $i < count($mood_data); $i++ ) { if ( $mood_data[$i]['mood_id'] == $mood_id ) { return $mood_data[$i]; } } return -1; } function find_action ( $action_id ) { global $action_data; if ( $action_id == -2 ) { return -2; } for ( $i = 0; $i < count($action_data); $i++ ) { if ( $action_data[$i]['action_id'] == $action_id ) { return $action_data[$i]; } } return -1; } function make_date_select ( $select_year, $select_month, $select_day ) { global $lang, $board_config; $months = array($lang['datetime']['January'],$lang['datetime']['February'],$lang['datetime']['March'],$lang['datetime']['April'],$lang['datetime']['May'],$lang['datetime']['June'], $lang['datetime']['July'], $lang['datetime']['August'], $lang['datetime']['September'], $lang['datetime']['October'], $lang['datetime']['November'], $lang['datetime']['December']); $date_select = '<select id="month" name="month">'; $date_select .= '<option value="">---</option>'; for ($i = 1; $i <= 12 ; $i++) { $select = ( $select_month == $i ) ? ' selected="selected"' : ''; $date_select .= '<option value="' . $i . '"' . $select . '>' . $months[$i-1] . '</option>'; } $date_select .= '</select>'; $date_select .= '<select id="day" name="day">'; $date_select .= '<option value="">---</option>'; for ($i = 1; $i <= 31 ; $i++) { $select = ( $select_day == $i ) ? ' selected="selected"' : ''; $date_select .= '<option value="' . $i . '"' . $select . '>' . $i . '</option>'; } $date_select .= '</select>'; $date_select .= '<select id="year" name="year">'; for ($i = 1970; $i <= 2037; $i++) { $select = ( $select_year == $i ) ? ' selected="selected"' : ''; $date_select .= '<option value="' . $i . '"' . $select . '>' . $i . '</option>'; } $date_select .= '</select>'; return $date_select; } function search_array ( $needle, $haystack ) { for ( $i = 0; $i < count($haystack); $i++) { if ( $haystack[$i]['weblog_id'] == $needle ) { return true; } } return false; } function fetch_visible_weblogs ( $sort = 'entry_time', $order = 'desc' ) { global $db, $friends_data, $blocked_data, $template; // // Get Weblog Data // $sql = "SELECT w.*, u.*, e.* FROM " . USERS_TABLE . " u, " . WEBLOGS_TABLE . " w LEFT JOIN " . WEBLOG_ENTRIES_TABLE . " e ON e.weblog_id = w.weblog_id WHERE u.user_weblog = w.weblog_id AND w.deleted = 0 AND e.entry_deleted = 0 AND e.entry_time <= " . time() . " ORDER BY e.entry_time DESC"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not query weblogs information', '', __LINE__, __FILE__, $sql); } // // Build a new array, discarding weblogs with outdated entries or entries that cannot be viewed. // $weblog_data = array(); while( $row = $db->sql_fetchrow($result) ) { if ( !search_array( $row['weblog_id'], $weblog_data ) ) { $auth_level = get_auth_level( $row, $friends_data, $blocked_data, $row['user_id'] ); if ( $auth_level >= $row['weblog_auth'] && $auth_level >= $row['entry_access'] ) { $weblog_data[] = $row; } } } // // Now, do your own sorting for this special array. (Insertion sort) // $sorted_data = array(); for ( $i = 0; $i < count($weblog_data); $i++ ) { // Do it descending first, then if needed reverse the order for ascending. $high_index = 0; $high_value = ''; // Find highest value for ( $j = 0; $j < count($weblog_data); $j++ ) { if ( $weblog_data[$j][$sort] > $high_value ) { $high_index = $j; $high_value = $weblog_data[$j][$sort]; } } $sorted_data[] = $weblog_data[$high_index]; $weblog_data[$high_index][$sort] = ''; // Removes it so that it is always "less than or equal to" } if ( $order == 'asc' ) { $sorted_data = array_reverse ($sorted_data); } return $sorted_data; } ?> --- NEW FILE: weblogs_constants.php --- <?php if (!isset($mx_table_prefix)) { $mx_table_prefix = 'mx_'; } define('POST_WEBLOG_URL', 'w'); define('POST_ENTRY_URL', 'e'); define('POST_REPLY_URL', 'r'); define('WEBLOG_BLOCKED_TABLE', $mx_table_prefix.'weblog_blocked'); define('WEBLOG_CONFIG_TABLE', $mx_table_prefix.'weblog_config'); define('WEBLOG_ACTIONS_TABLE', $mx_table_prefix.'weblog_actions'); define('WEBLOG_ENTRIES_TABLE', $mx_table_prefix.'weblog_entries'); define('WEBLOG_FRIENDS_TABLE', $mx_table_prefix.'weblog_friends'); define('WEBLOG_MOODS_TABLE', $mx_table_prefix.'weblog_moods'); define('WEBLOG_MOOD_SETS_TABLE', $mx_table_prefix.'weblog_mood_sets'); define('WEBLOG_CONTRIBUTORS_TABLE', $mx_table_prefix.'weblog_contributors'); define('WEBLOG_REPLIES_TABLE', $mx_table_prefix.'weblog_replies'); define('WEBLOG_SHOUTBOX_TABLE', $mx_table_prefix.'weblog_shoutbox'); define('WEBLOG_TEMPLATES_TABLE', $mx_table_prefix.'weblog_templates'); define('WEBLOG_TRACKBACKS_TABLE', $mx_table_prefix.'weblog_trackbacks'); define('WEBLOGS_TABLE', $mx_table_prefix.'weblogs'); define('SORT_NEWEST_ENTRIES', 0); define('SORT_WEBLOG_NAME', 1); define('SORT_NUM_ENTRIES', 2); define('SORT_WEBLOG_START_DATE', 3); define('SORT_WEBLOG_VIEWS', 4); define('SORT_WEBLOG_OWNER_NAME', 5); define('ACTION_DO_NOTHING', 0); define('ACTION_LOAD_TEMPLATE', 1); define('ACTION_SWITCH_MODE', 2); define('WEBLOG_AUTH_ALL', 0); define('WEBLOG_AUTH_REGISTERED', 1); define('WEBLOG_AUTH_FRIENDS', 2); define('WEBLOG_AUTH_OWNER', 3); ?> --- NEW FILE: functions_trackback.php --- <?php /*************************************************************************** * functions_trackback.php * ----------------------------- * begin : Monday, September 5, 2004 * copyright : (C) 2005 Hyperion * email : vi...@ho... * * $Id: functions_trackback.php,v 1.0.0 2004/09/05, 13:17:43 Hyperion Exp $ * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ***************************************************************************/ if (!defined('IN_PHPBB')) { die('Hacking attempt'); } function do_trackback_pings ($tb_excerpt, $tb_urls, $weblog_name, $subject, $entry_id) { global $board_config, $phpEx; $tb_url = explode ("\n", $tb_urls); $server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://'; $server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['server_name'])); $server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) : ''; $script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['script_path'])); $script_name = ($script_name == '') ? $script_name : '/' . $script_name; $source_url = $server_protocol . $server_name . $server_port . $script_name . '/weblog_entry.' . $phpEx . '?e=' . $entry_id; $result = ''; $trackback = ''; for ($i = 0; $i < count($tb_url); $i++) { $trackback = trackback_ping($tb_url[$i], $weblog_name, $subject, $tb_excerpt, $source_url); $result .= '<br />' . $trackback; } return $result; } function trackback_ping ($target_url, $weblog_name, $title, $excerpt, $url) { global $lang; if (!preg_match('#^http[s]?:\/\/#i', $target_url)) { $target_url = 'http://' . $target_url; } // Split up the target url so that we can manage it $target = parse_url($target_url); // "?" is removed when the url is split up. This puts it back in. if ( isset($target['query']) && !empty($target['query']) ) { $target['query'] = '?' . $target['query']; } else { $target['query'] = ''; } if ( !isset($target['port']) || !is_numeric($target['port']) ) { $target['port'] = 80; } $excerpt = reduce_length($excerpt); // Connect to the target $target_sock = @fsockopen($target['host'], $target['port']); // If it can't connect.... if (!is_resource($target_sock)) { return sprintf($lang['Trackback_no_connect'], $target_url); } // Put together the things we want to send $target_send = 'url=' . rawurlencode($url) . '&title=' . rawurlencode($title) . '&blog_name=' . rawurlencode($weblog_name) . '&excerpt=' . rawurlencode($excerpt); // Send the trackback fputs($target_sock, "POST " . $target['path'] . $target['query'] . " HTTP/1.1\r\n"); fputs($target_sock, "Host: " . $target['host'] . "\r\n"); fputs($target_sock, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($target_sock, "Content-length: " . strlen($target_send) . "\r\n"); fputs($target_sock, "Connection: close\r\n\r\n"); fputs($target_sock, $target_send); // See what the server said while (!feof($target_sock)) { $response .= fgets($target_sock, 128); } // Close the connection fclose($target_sock); // send result return get_error_response($response, $target_url); } function get_error_response($response, $target_url) { global $lang; if ( strpos($response, '<error>0</error>') ) { return sprintf($lang['Trackback_successful'], $target_url); } $curr_pos = strpos($response, '<message>', $curr_pos); $end_pos = strpos($response, '</message>', $curr_pos); $error_msg = substr($response, $curr_pos, $end_pos - $curr_pos); return $error_msg; } function trackback_response($success, $err_response, $encoding) { // Start response to trackbacker... $return = '<?xml version="1.0" encoding="' . $encoding . '"?>'; $return .= '<response>'; // Send back response... if ($success) { // Trackback received successfully... $return .= ' <error>0</error>'; } else { // Something went wrong... $return .= ' <error>1</error>'; $return .= ' <message>' . htmlspecialchars($err_response) . '</message>'; } // End response to trackbacker... $return .= "</response>"; return $return; } function reduce_length($excerpt) { $excerpt = trim ($excerpt); if (strlen($excerpt) > 255) { $excerpt = substr($excerpt, 0, 252) . '...'; } return $excerpt; } ?> |