|
From: mhewitson <mhe...@us...> - 2007-06-07 22:01:35
|
Update of /cvsroot/mxbb/mx_blogs/admin In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv721/mx_blogs/admin Added Files: admin_weblog_action.php admin_weblog_cfg.php admin_weblog_mood.php admin_weblog_templates.php admin_weblog_tools.php Log Message: mx_blogs, Initial checkin --- NEW FILE: admin_weblog_action.php --- <?php /*************************************************************************** * admin_weblog_action.php * ----------------------------- * begin : Monday, September 5, 2004 * copyright : (C) 2005 Hyperion * email : vi...@ho... * * $Id: admin_weblog_action.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. * ***************************************************************************/ define('IN_PORTAL', 1); // // First we do the setmodules stuff for the admin cp. // if( !empty($setmodules) ) { $filename = basename(__FILE__); $module['Blog_admin']['Action_choices'] = 'modules/mx_blogs/admin/' .$filename; return; } $mx_root_path = "./../../../"; $module_root_path ="./../"; //include($mx_root_path . 'extension.inc'); $phpEx = substr(strrchr(__FILE__, '.'), 1); include($mx_root_path . 'admin/pagestart.' . $phpEx); include($module_root_path . 'includes/weblogs_constants.'.$phpEx); include($module_root_path . 'includes/weblogs_common.'.$phpEx); include($module_root_path . 'language/lang_' . $use_lang . '/lang_weblog_admin.' . $phpEx); // // Get the actions data // $sql = "SELECT * FROM " . WEBLOG_ACTIONS_TABLE . " ORDER BY action_text"; if( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Couldn't obtain action data from database", "", __LINE__, __FILE__, $sql); } $action_data = $db->sql_fetchrowset($result); // // Check to see what mode we should operate in. // if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) { $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; } else { $mode = ""; } // // Read a listing of uploaded currently icons for use in the add or edit smliey code... // $dir = @opendir($module_root_path . 'images/weblogs/'); while($file = @readdir($dir)) { if( !@is_dir(phpbb_realpath($module_root_path . 'images/weblogs/' . $file)) ) { $img_size = @getimagesize($module_root_path . 'images/weblogs/' . $file); if( $img_size[0] && $img_size[1] ) { $currently_images[] = $file; } } } @closedir($dir); // // Select main mode // if( isset($HTTP_POST_VARS['add']) || isset($HTTP_GET_VARS['add']) ) { // // Admin has selected to add a "currently". // $template->set_filenames(array( "body" => "admin/weblog_action_edit_body.tpl") ); $filename_list = ""; for( $i = 0; $i < count($currently_images); $i++ ) { $filename_list .= '<option value="' . $currently_images[$i] . '">' . $currently_images[$i] . '</option>'; } $s_hidden_fields = '<input type="hidden" name="mode" value="savenew" />'; $template->assign_vars(array( "L_CURRENTLY_TITLE" => $lang['Weblog_currently_title'], "L_CURRENTLY_CONFIG" => $lang['Weblog_currently_config'], "L_CURRENTLY_EXPLAIN" => $lang['Weblog_currently_explain'], "L_CURRENTLY_URL" => $lang['Weblog_currently_url'], "L_CURRENTLY_CURRENTLY" => $lang['Weblog_currently_currently'], "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], "CURRENTLY_IMG" => $module_root_path . 'images/weblogs/' . $currently_images[0], "S_CURRENTLY_ACTION" => append_sid("admin_weblog_action.$phpEx"), "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_FILENAME_OPTIONS" => $filename_list) ); $template->pparse("body"); } else if ( $mode != "" ) { switch( $mode ) { case 'delete': // // Admin has selected to delete a currently. // $currently_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; $sql = "DELETE FROM " . WEBLOG_ACTIONS_TABLE . " WHERE action_id = " . $currently_id; $result = $db->sql_query($sql); if( !$result ) { message_die(GENERAL_ERROR, "Couldn't delete action", "", __LINE__, __FILE__, $sql); } $message = $lang['Weblog_currently_del_success'] . "<br /><br />" . sprintf($lang['Click_return_currentlyadmin'], "<a href=\"" . append_sid("admin_weblog_action.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); break; case 'edit': // // Admin has selected to edit a currently. // $currently_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; $sql = "SELECT * FROM " . WEBLOG_ACTIONS_TABLE . " WHERE action_id = " . $currently_id; $result = $db->sql_query($sql); if( !$result ) { message_die(GENERAL_ERROR, 'Could not obtain emoticon information', "", __LINE__, __FILE__, $sql); } $currently_data = $db->sql_fetchrow($result); $filename_list = ""; for( $i = 0; $i < count($currently_images); $i++ ) { if( $currently_images[$i] == $currently_data['action_url'] ) { $currently_selected = "selected=\"selected\""; $currently_edit_img = $currently_images[$i]; } else { $currently_selected = ""; } $filename_list .= '<option value="' . $currently_images[$i] . '"' . $currently_selected . '>' . $currently_images[$i] . '</option>'; } $template->set_filenames(array( "body" => "admin/weblog_action_edit_body.tpl") ); $s_hidden_fields = '<input type="hidden" name="mode" value="save" /><input type="hidden" name="currently_id" value="' . $currently_data['action_id'] . '" />'; $template->assign_vars(array( "L_CURRENTLY_TITLE" => $lang['Weblog_currently_title'], "L_CURRENTLY_CONFIG" => $lang['Weblog_currently_config'], "L_CURRENTLY_EXPLAIN" => $lang['Weblog_currently_explain'], "L_CURRENTLY_URL" => $lang['Weblog_currently_url'], "L_CURRENTLY_CURRENTLY" => $lang['Weblog_currently_currently'], "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], "CURRENTLY_IMG" => $module_root_path . 'images/weblogs/' . $currently_edit_img, "CURRENTLY_CURRENTLY" => $currently_data['action_text'], "S_CURRENTLY_ACTION" => append_sid("admin_weblog_action.$phpEx"), "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_FILENAME_OPTIONS" => $filename_list) ); $template->pparse("body"); break; case "save": // // Admin has submitted changes while editing a currently. // // // Get the submitted data, being careful to ensure that we only // accept the data we are looking for. // $currently_url = ( isset($HTTP_POST_VARS['currently_url']) ) ? trim($HTTP_POST_VARS['currently_url']) : trim($HTTP_GET_VARS['currently_url']); $currently_currently = ( isset($HTTP_POST_VARS['currently_currently']) ) ? trim($HTTP_POST_VARS['currently_currently']) : trim($HTTP_GET_VARS['currently_currently']); $currently_id = ( isset($HTTP_POST_VARS['currently_id']) ) ? intval($HTTP_POST_VARS['currently_id']) : intval($HTTP_GET_VARS['currently_id']); // If no code was entered complain ... if ( $currently_url == '') { message_die(MESSAGE, $lang['Fields_empty']); } // // Proceed with updating the currently table. // $sql = "UPDATE " . WEBLOG_ACTIONS_TABLE . " SET action_url = '" . str_replace("\'", "''", $currently_url) . "', action_text = '" . str_replace("\'", "''", $currently_currently) . "' WHERE action_id = $currently_id"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't update action info", "", __LINE__, __FILE__, $sql); } $message = $lang['Weblog_currently_edit_success'] . "<br /><br />" . sprintf($lang['Click_return_currentlyadmin'], "<a href=\"" . append_sid("admin_weblog_action.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); break; case "savenew": // // Admin has submitted changes while adding a new currently. // // // Get the submitted data being careful to ensure the the data // we recieve and process is only the data we are looking for. // $currently_url = ( isset($HTTP_POST_VARS['currently_url']) ) ? $HTTP_POST_VARS['currently_url'] : $HTTP_GET_VARS['currently_url']; $currently_currently = ( isset($HTTP_POST_VARS['currently_currently']) ) ? $HTTP_POST_VARS['currently_currently'] : $HTTP_GET_VARS['currently_currently']; // If no code was entered complain ... if ($currently_url == '') { message_die(MESSAGE, $lang['Fields_empty']); } // // Save the data to the currently table. // $sql = "INSERT INTO " . WEBLOG_ACTIONS_TABLE . " (action_url, action_text) VALUES ('" . str_replace("\'", "''", $currently_url) . "', '" . str_replace("\'", "''", $currently_currently) . "')"; if( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Couldn't insert new action", "", __LINE__, __FILE__, $sql); } $message = $lang['Weblog_currently_add_success'] . "<br /><br />" . sprintf($lang['Click_return_currentlyadmin'], "<a href=\"" . append_sid("admin_weblog_action.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); break; } } else { // // This is the main display of the page before the admin has selected // any options. // $template->set_filenames(array( "body" => "admin/weblog_action_list_body.tpl") ); $template->assign_vars(array( "L_ACTION" => $lang['Action'], "L_CURRENTLY_TITLE" => $lang['Weblog_currently_title'], "L_CURRENTLY_TEXT" => $lang['Weblog_currently_explain'], "L_DELETE" => $lang['Delete'], "L_EDIT" => $lang['Edit'], "L_CURRENTLY_ADD" => $lang['Weblog_currently_add'], "L_IMAGE" => $lang['Weblog_image'], "L_CURRENTLY" => $lang['Weblog_currently'], "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_CURRENTLY_ACTION" => append_sid("admin_weblog_action.$phpEx")) ); // // Loop throuh the rows of currentlys setting block vars for the template. // for($i = 0; $i < count($action_data); $i++) { $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars("currently", array( "ROW_COLOR" => "#" . $row_color, "ROW_CLASS" => $row_class, "CURRENTLY_IMG" => $module_root_path . 'images/weblogs/' . $action_data[$i]['action_url'], "CURRENTLY" => $action_data[$i]['action_text'], "U_CURRENTLY_EDIT" => append_sid("admin_weblog_action.$phpEx?mode=edit&id=" . $action_data[$i]['action_id']), "U_CURRENTLY_DELETE" => append_sid("admin_weblog_action.$phpEx?mode=delete&id=" . $action_data[$i]['action_id'])) ); } // // Spit out the page. // $template->pparse("body"); } // // Page Footer // include($mx_root_path . 'admin/page_footer_admin.'.$phpEx); ?> --- NEW FILE: admin_weblog_templates.php --- <?php /*************************************************************************** * admin_weblog_templates.php * -------------------------------- * begin : Monday, September 5, 2004 * copyright : (C) 2005 Hyperion * email : vi...@ho... * * $Id: admin_weblog_templates.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. * ***************************************************************************/ define('IN_PORTAL', 1); // // First we do the setmodules stuff for the admin cp. // if( !empty($setmodules) ) { $filename = basename(__FILE__); $module['Blog_admin']['Templates'] = 'modules/mx_blogs/admin/' . $filename; return; } $mx_root_path = "./../../../"; $module_root_path = "./../"; //include($mx_root_path . 'extension.inc'); $phpEx = substr(strrchr(__FILE__, '.'), 1); include($mx_root_path . 'admin/pagestart.' . $phpEx); include($module_root_path . 'includes/weblogs_constants.'.$phpEx); include($module_root_path . 'includes/weblogs_common.'.$phpEx); include($module_root_path . 'language/lang_' . $use_lang . '/lang_weblog_admin.' . $phpEx); // // Check to see what mode we should operate in. // if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) { $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; } else { $mode = ""; } if ( !file_exists($module_root_path . 'weblogs/templates/') ) { @mkdir($module_root_path . 'weblogs/templates/', 0755); } @chmod ($module_root_path . 'weblogs/templates/', 0755); if( $dir = @opendir($module_root_path . "weblogs/templates/") ) { $dir_select = '<select name="template_dir" onchange="update_preview(this.form.template_dir.options[this.form.template_dir.selectedIndex].value)">'; $selected = ($template_data['template_dir'] == $sub_dir ) ? ' selected="selected"' : ''; while( $sub_dir = @readdir($dir) ) { if ( !is_file($module_root_path. "weblogs/templates/" . $sub_dir) && $sub_dir != '.' && $sub_dir != '..' ) { $dir_select .= '<option value="' . $sub_dir . '"' . $selected . '>' . $sub_dir . '</option>'; } } $dir_select .= '</select>'; } // // Select main mode // if( isset($HTTP_POST_VARS['add']) || isset($HTTP_GET_VARS['add']) ) { // // Admin has selected to add a template. // $template->set_filenames(array( "body" => "admin/weblog_template_edit_body.tpl") ); $template->assign_vars(array( "L_TEMPLATE_TITLE" => $lang['Weblog_template_title'], "L_TEMPLATE_CONFIG" => $lang['Weblog_template_config'], "L_TEMPLATE_EXPLAIN" => $lang['Weblog_template_explain'], "L_TEMPLATE_NAME" => $lang['Weblog_template_name'], "L_TEMPLATE_DIR" => $lang['Weblog_template_dir'], "L_TEMPLATE_PRIVATE" => $lang['Template_private'], "L_YES" => $lang['Yes'], "L_NO" => $lang['No'], "L_TEMPLATE_PREVIEW" => $lang['Weblog_template_preview'], "TEMPLATE_DIR" => $dir_select, "PREVIEW_IMG" => ( $template_data['template_dir'] ) ? $phpbb_root_path . 'weblogs/templates/' . $template_data['template_dir'] . '/weblog_preview.gif' : $phpbb_root_path . 'images/spacer.gif', "TEMPLATE_PRIVATE_CHECKED" => '', "TEMPLATE_NOT_PRIVATE_CHECKED" => ' checked="checked"', "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], "S_TEMPLATE_ACTION" => append_sid("admin_weblog_templates.$phpEx?mode=savenew"), "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_FILENAME_OPTIONS" => $filename_list) ); $template->pparse("body"); } else if ( $mode != "" ) { switch( $mode ) { case 'delete': // // Admin has selected to delete a template. // $template_id = ( !empty($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : intval($HTTP_GET_VARS['id']); $sql = "DELETE FROM " . WEBLOG_TEMPLATES_TABLE . " WHERE template_id = " . $template_id; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't delete template", "", __LINE__, __FILE__, $sql); } // // Let's move all the users using that deleted style to the very first style // $sql = "SELECT MIN(template_id) AS min_id FROM " . WEBLOG_TEMPLATES_TABLE; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't get minimum template id", "", __LINE__, __FILE__, $sql); } if ( $row = $db->sql_fetchrow($result) ) { $id = $row['min_id']; } $sql = "UPDATE " . WEBLOGS_TABLE . " SET template_id = $id WHERE template_id = $template_id"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't set users to use another template", "", __LINE__, __FILE__, $sql); } $message = $lang['Weblog_template_del_success'] . "<br /><br />" . sprintf($lang['Click_return_templateadmin'], "<a href=\"" . append_sid("admin_weblog_templates.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); mx_message_die(GENERAL_MESSAGE, $message); break; case 'edit': // // Admin has selected to edit a template. // $template_id = ( !empty($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : intval($HTTP_GET_VARS['id']); $sql = "SELECT * FROM " . WEBLOG_TEMPLATES_TABLE . " WHERE template_id = " . $template_id; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not obtain template information', "", __LINE__, __FILE__, $sql); } $templates_data = array(); if ( $row = $db->sql_fetchrow($result) ) { $templates_data = $row; } $template->set_filenames(array( "body" => "admin/weblog_template_edit_body.tpl") ); $s_hidden_fields = '<input type="hidden" name="mode" value="save" /><input type="hidden" name="template_id" value="' . $template_data['template_id'] . '" />'; $template->assign_vars(array( "L_TEMPLATE_TITLE" => $lang['Weblog_template_title'], "L_TEMPLATE_CONFIG" => $lang['Weblog_template_config'], "L_TEMPLATE_EXPLAIN" => $lang['Weblog_template_explain'], "L_TEMPLATE_NAME" => $lang['Weblog_template_name'], "L_TEMPLATE_PREVIEW" => $lang['Weblog_template_preview'], "L_TEMPLATE_DIR" => $lang['Weblog_template_dir'], "L_TEMPLATE_PRIVATE" => $lang['Template_private'], "L_YES" => $lang['Yes'], "L_NO" => $lang['No'], "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], "TEMPLATE_NAME" => $templates_data['template_name'], "TEMPLATE_DIR" => $dir_select, "PREVIEW_IMG" => ( $templates_data['template_dir'] ) ? $module_root_path . 'weblogs/templates/' . $templates_data['template_dir'] . '/preview_img.gif' : $phpbb_root_path . 'images/spacer.gif', "TEMPLATE_PRIVATE_CHECKED" => ( $templates_data['template_private'] ) ? ' checked="checked"' : '', "TEMPLATE_NOT_PRIVATE_CHECKED" => ( !$templates_data['template_private'] ) ? ' checked="checked"' : '', "S_TEMPLATE_ACTION" => append_sid("admin_weblog_templates.$phpEx?mode=edit&id=$template_id"), "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_FILENAME_OPTIONS" => $filename_list) ); $template->pparse("body"); break; case "save": // // Admin has submitted changes while editing a template. // $template_id = ( !empty($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : intval($HTTP_GET_VARS['id']); // // Get the submitted data, being careful to ensure that we only // accept the data we are looking for. // $template_name = ( isset($HTTP_POST_VARS['template_name']) ) ? trim($HTTP_POST_VARS['template_name']) : trim($HTTP_GET_VARS['template_name']); $template_dir = ( isset($HTTP_POST_VARS['template_dir']) ) ? trim($HTTP_POST_VARS['template_dir']) : trim($HTTP_GET_VARS['template_dir']); $template_private = ( isset($HTTP_POST_VARS['private_template']) ) ? intval($HTTP_POST_VARS['private_template']) : intval($HTTP_GET_VARS['private_template']); // If no code was entered complain ... if ( $template_name == '' ) { mx_message_die(MESSAGE, $lang['Fields_empty']); } // // Proceed with updating the templates table. // $sql = "UPDATE " . WEBLOG_TEMPLATES_TABLE . " SET template_name = '" . str_replace("\'", "''", $template_name) . "', template_dir = '" . str_replace("\'", "''", $template_dir) . "', template_private = $template_private WHERE template_id = $template_id"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, "Couldn't update template info", "", __LINE__, __FILE__, $sql); } $message = $lang['Weblog_template_edit_success'] . "<br /><br />" . sprintf($lang['Click_return_templateadmin'], "<a href=\"" . append_sid("admin_weblog_templates.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); mx_message_die(GENERAL_MESSAGE, $message); break; case "savenew": // // Admin has submitted changes while adding a new template // // // Get the submitted data being careful to ensure the the data // we recieve and process is only the data we are looking for. // $template_name = ( isset($HTTP_POST_VARS['template_name']) ) ? trim($HTTP_POST_VARS['template_name']) : trim($HTTP_GET_VARS['template_name']); $template_dir = ( isset($HTTP_POST_VARS['template_dir']) ) ? trim($HTTP_POST_VARS['template_dir']) : trim($HTTP_GET_VARS['template_dir']); $template_private = ( isset($HTTP_POST_VARS['private_template']) ) ? intval($HTTP_POST_VARS['private_template']) : intval($HTTP_GET_VARS['private_template']); // If no code was entered complain ... if ( !$template_name ) { mx_message_die(GENERAL_ERROR, $lang['Fields_empty']); } // // Verify the template directory exists and can be read // // Chmod so we'll have no problems @chmod($module_root_path . 'weblogs/templates/' . $template_dir, 0755); @chmod($module_root_path . 'weblogs/templates/' . $template_dir . '/' . $template_dir . '.cfg', 0755); if ( !file_exists($module_root_path . 'weblogs/templates/' . $template_dir . '/' . $template_dir . '.cfg') ) { mx_message_die(GENERAL_ERROR, $lang['Template_missing']); } // // Get max template id // $sql = "SELECT MAX(template_id) AS maximum FROM " . WEBLOG_TEMPLATES_TABLE; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, "Couldn't get maximum template id", "", __LINE__, __FILE__, $sql); } if ( $row = $db->sql_fetchrow($result) ) { $next_id = $row['maximum'] + 1; } // // Save the data to the weblog templates table. // $sql = "INSERT INTO " . WEBLOG_TEMPLATES_TABLE . " (template_id, template_name, template_dir, template_private) VALUES ($next_id, '" . str_replace("\'", "''", $template_name) . "', '" . str_replace("\'", "''", $template_dir) . "', $template_private)"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't insert new template", "", __LINE__, __FILE__, $sql); } $message = $lang['Weblog_template_add_success'] . "<br /><br />" . sprintf($lang['Click_return_templateadmin'], "<a href=\"" . append_sid("admin_weblog_templates.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); mx_message_die(GENERAL_MESSAGE, $message); break; } } else { // // This is the main display of the page before the admin has selected // any options. // $template->set_filenames(array( "body" => "admin/weblog_template_list_body.tpl") ); $template->assign_vars(array( "L_ACTION" => $lang['Action'], "L_TEMPLATE_TITLE" => $lang['Weblog_template_title'], "L_TEMPLATE_TEXT" => $lang['Weblog_template_explain'], "L_DELETE" => $lang['Delete'], "L_EDIT" => $lang['Edit'], "L_TEMPLATE_ADD" => $lang['Weblog_template_add'], "L_TEMPLATE_NAME" => $lang['Weblog_template'], "L_PREVIEW_IMAGE" => $lang['Preview_image'], "L_PRIVATE" => $lang['Template_private'], "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_TEMPLATE_ACTION" => append_sid("admin_weblog_templates.$phpEx")) ); // // Loop throuh the rows of templates setting block vars for the template. // for($i = 0; $i < count($template_data); $i++) { $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars('template_row', array( "ROW_COLOR" => "#" . $row_color, "ROW_CLASS" => $row_class, "TEMPLATE" => $template_data[$i]['template_name'], "TEMPLATE_IMAGE" => '<img src="' . $module_root_path . 'weblogs/templates/' . $template_data[$i]['template_dir'] . '/preview_img.gif" border="0">', "TEMPLATE_PRIVATE" => ( $template_data[$i]['template_private'] ) ? $lang['Yes'] : $lang['No'], "U_TEMPLATE_EDIT" => append_sid("admin_weblog_templates.$phpEx?mode=edit&id=" . $template_data[$i]['template_id']), "U_TEMPLATE_DELETE" => append_sid("admin_weblog_templates.$phpEx?mode=delete&id=" . $template_data[$i]['template_id'])) ); } // // Spit out the page. // $template->pparse("body"); } // // Page Footer // include($mx_root_path . 'admin/page_footer_admin.'.$phpEx); ?> --- NEW FILE: admin_weblog_tools.php --- <?php /*************************************************************************** * admin_weblog_tools.php * ---------------------------- * begin : Monday, September 5, 2004 * copyright : (C) 2005 Hyperion * email : vi...@ho... * * $Id: admin_weblog_tools.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. * ***************************************************************************/ define('IN_PORTAL',1); define('IN_PHPBB', 1); if( !empty($setmodules) ) { $filename = basename(__FILE__); $module['Blog_admin']['Weblog_tools'] = 'modules/mx_blogs/admin/' . $filename; return; } $mx_root_path = './../../../'; $module_root_path = "./../"; //include($mx_root_path . 'extension.inc'); $phpEx = substr(strrchr(__FILE__, '.'), 1); include($mx_root_path . 'common.'.$phpEx); include($mx_root_path . 'admin/pagestart.' . $phpEx); //include($phpbb_root_path . 'includes/functions_selects.'.$phpEx); include($module_root_path . 'includes/weblogs_constants.'.$phpEx); include($module_root_path . 'includes/weblogs_common.'.$phpEx); include($module_root_path . 'language/lang_' . $use_lang . '/lang_weblog_admin.' . $phpEx); $html_entities_match = array('#<#', '#>#'); $html_entities_replace = array('<', '>'); // // Set mode // if( isset( $HTTP_POST_VARS['mode'] ) || isset( $HTTP_GET_VARS['mode'] ) ) { $mode = ( isset( $HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; $mode = htmlspecialchars($mode); } else { $mode = ''; } if ( isset($HTTP_POST_VARS['user_admin']) ) { // // Default user selection box // $template->set_filenames(array( 'body' => 'admin/user_select_body.tpl') ); $template->assign_vars(array( 'L_USER_TITLE' => $lang['Weblog_user_admin'], 'L_USER_EXPLAIN' => $lang['Weblog_user_admin_explain'], 'L_USER_SELECT' => $lang['Select_a_User'], 'L_LOOK_UP' => $lang['Look_up_user'], 'L_FIND_USERNAME' => $lang['Find_username'], 'U_SEARCH_USER' => append_sid($phpbb_root_path . "search.$phpEx?mode=searchuser"), 'S_USER_ACTION' => append_sid("admin_weblog_tools.$phpEx?mode=user_admin"), 'S_USER_SELECT' => $select_list) ); } else if ( isset($HTTP_POST_VARS['weblog_admin']) ) { // // Default user selection box // $template->set_filenames(array( 'body' => 'admin/user_select_body.tpl') ); $template->assign_vars(array( 'L_USER_TITLE' => $lang['Weblog_admin'], 'L_USER_EXPLAIN' => $lang['Weblog_admin_explain'], 'L_USER_SELECT' => $lang['Select_a_weblog'], 'L_LOOK_UP' => $lang['Look_up_weblog'], 'S_USER_ACTION' => append_sid("admin_weblog_tools.$phpEx?mode=weblog_admin"), 'S_USER_SELECT' => $select_list) ); }else if ( isset($HTTP_POST_VARS['purge']) ) { // // Find the deleted weblogs and the deleted entries // $sql = "SELECT w.*, u.user_id, u.username FROM " . WEBLOGS_TABLE . " w, " . USERS_TABLE . " u WHERE u.user_weblog = w.weblog_id AND w.deleted = 1"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not retrieve deleted weblogs information', '', __LINE__, __FILE__, $sql); } while ( $row = $db->sql_fetchrow($result) ) { $del_weblogs[] = $row; } $sql = "SELECT e.*, w.*, u.user_id, u.username FROM " . WEBLOGS_TABLE . " w, " . USERS_TABLE . " u, " . WEBLOG_ENTRIES_TABLE . " e WHERE u.user_weblog = w.weblog_id AND e.weblog_id = w.weblog_id AND e.entry_deleted = 1"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not retrieve deleted entries information', '', __LINE__, __FILE__, $sql); } while ( $row = $db->sql_fetchrow($result) ) { $del_entries[] = $row; } if ( isset($HTTP_POST_VARS['purge_weblogs']) ) { // // Remove all weblogs with the "deleted" flag in the database // $sql = "DELETE FROM " . WEBLOGS_TABLE . " WHERE deleted = 1"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not delete "deleted" weblogs information', '', __LINE__, __FILE__, $sql); } // // Remove all entries with the "deleted" flag in the database // $sql = "DELETE FROM " . WEBLOG_ENTRIES_TABLE . " WHERE entry_deleted = 1"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not delete "deleted" entries', '', __LINE__, __FILE__, $sql); } // That's all, Folks! $message = $lang['Weblogs_purged'] . "<br /><br />" . sprintf($lang['Click_return_weblog_tools'], '<a href="' . append_sid("admin_weblog_tools.$phpEx") . '">', '</a>') . "<br /><br />" . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid($mx_root_path . "admin/index.$phpEx?pane=right") . '">', '</a>'); mx_message_die(GENERAL_MESSAGE, $message); } else if ( isset($HTTP_POST_VARS['purge_entries']) ) { // // Remove all entries with the "deleted" flag in the database // $sql = "DELETE FROM " . WEBLOG_ENTRIES_TABLE . " WHERE entry_deleted = 1"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Could not delete "deleted" entries', '', __LINE__, __FILE__, $sql); } // That's all, Folks! $message = $lang['Entries_purged'] . "<br /><br />" . sprintf($lang['Click_return_weblog_tools'], '<a href="' . append_sid("admin_weblog_tools.$phpEx") . '">', '</a>') . "<br /><br />" . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid($mx_root_path . "admin/index.$phpEx?pane=right") . '">', '</a>'); mx_message_die(GENERAL_MESSAGE, $message); } else if ( isset($HTTP_POST_VARS['weblogs_restore']) ) { $sql = ''; for ( $i = 0; $i < count($del_weblogs); $i++ ) { $weblog_id = $del_weblogs[$i]['weblog_id']; if ( !empty($HTTP_POST_VARS[$weblog_id]) ) { $sql .= "UPDATE " . WEBLOGS_TABLE . " SET deleted = 0 WHERE weblog_id = $weblog_id;"; } } if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Error updating weblogs information', '', __LINE__, __FILE__, $sql); } $message = $lang['Weblogs_restored'] . "<br /><br />" . sprintf($lang['Click_return_weblog_tools'], '<a href="' . append_sid("admin_weblog_tools.$phpEx") . '">', '</a>') . "<br /><br />" . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid($mx_root_path . "admin/index.$phpEx?pane=right") . '">', '</a>'); mx_message_die(GENERAL_MESSAGE, $message); } else if ( isset($HTTP_POST_VARS['entries_restore']) ) { $sql = ''; for ( $i = 0; $i < count($del_entries); $i++ ) { $entry_id = $del_entries[$i]['entry_id']; if ( !empty($HTTP_POST_VARS[$entry_id]) ) { $sql .= "UPDATE " . WEBLOG_ENTRIES_TABLE . " SET entry_deleted = 0 WHERE entry_id = $entry_id;"; } } if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Error updating entry information', '', __LINE__, __FILE__, $sql); } $message = $lang['Entries_restored'] . "<br /><br />" . sprintf($lang['Click_return_weblog_tools'], '<a href="' . append_sid("admin_weblog_tools.$phpEx") . '">', '</a>') . "<br /><br />" . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid($mx_root_path . "admin/index.$phpEx?pane=right") . '">', '</a>'); mx_message_die(GENERAL_MESSAGE, $message); } else if ( isset($HTTP_POST_VARS['weblogs_purge']) ) { $sql = ''; for ( $i = 0; $i < count($del_weblogs); $i++ ) { $weblog_id = $del_weblogs[$i]['weblog_id']; if ( !empty($HTTP_POST_VARS[$weblog_id]) ) { $sql .= "DELETE FROM " . WEBLOGS_TABLE . " WHERE weblog_id = $weblog_id;"; } } if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Error deleting weblog information', '', __LINE__, __FILE__, $sql); } $message = $lang['Weblogs_purged'] . "<br /><br />" . sprintf($lang['Click_return_weblog_tools'], '<a href="' . append_sid("admin_weblog_tools.$phpEx") . '">', '</a>') . "<br /><br />" . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid($mx_root_path . "admin/index.$phpEx?pane=right") . '">', '</a>'); mx_message_die(GENERAL_MESSAGE, $message); } else if ( isset($HTTP_POST_VARS['entries_purge']) ) { $sql = ''; for ( $i = 0; $i < count($del_entries); $i++ ) { $entry_id = $del_entries[$i]['entry_id']; if ( !empty($HTTP_POST_VARS[$entry_id]) ) { $sql .= "DELETE FROM " . WEBLOG_ENTRIES_TABLE . " WHERE entry_id = $entry_id;"; } } if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Error deleting entry information', '', __LINE__, __FILE__, $sql); } $message = $lang['Entries_purged'] . "<br /><br />" . sprintf($lang['Click_return_weblog_tools'], '<a href="' . append_sid("admin_weblog_tools.$phpEx") . '">', '</a>') . "<br /><br />" . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid($mx_root_path . "admin/index.$phpEx?pane=right") . '">', '</a>'); mx_message_die(GENERAL_MESSAGE, $message); } for ( $i = 0; $i < count($del_weblogs); $i++ ) { $row_class = ( !($i % 2) ) ? 'row1' : 'row2'; $template->assign_block_vars('weblogrow', array( 'ROW_CLASS' => $row_class, 'WEBLOG' => $del_weblogs[$i]['weblog_name'], 'U_PROFILE' => append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $del_weblogs[$i]['user_id']), 'OWNER' => $del_weblogs[$i]['username'], 'WEBLOG_DESC' => $del_weblogs[$i]['weblog_desc'], 'STARTED_DATE' => create_date($board_config['default_dateformat'], $del_weblogs[$i]['weblog_create_date'], $board_config['board_timezone']), 'INPUT_NAME' => $del_weblogs[$i]['weblog_id']) ); } for ( $i = 0; $i < count($del_entries); $i++ ) { $row_class = ( !($i % 2) ) ? 'row1' : 'row2'; $template->assign_block_vars('entryrow', array( 'ROW_CLASS' => $row_class, 'ENTRY' => $del_entries[$i]['entry_subject'], 'WEBLOG' => $del_entries[$i]['weblog_name'], 'U_PROFILE' => append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $del_entries[$i]['user_id']), 'U_WEBLOG' => append_sid($module_root_path . "weblog.$phpEx?" . POST_WEBLOG_URL . "=" . $del_entries[$i]['weblog_id']), 'OWNER' => $del_entries[$i]['username'], 'WEBLOG_DESC' => $del_entries[$i]['weblog_desc'], 'INPUT_NAME' => $del_entries[$i]['entry_id']) ); } // // Default user selection box // $template->set_filenames(array( 'body' => 'admin/weblog_purge_body.tpl') ); $template->assign_vars(array( 'L_USER_TITLE' => $lang['Weblog_user_admin'], 'L_USER_EXPLAIN' => $lang['Weblog_user_admin_explain'], 'L_USER_SELECT' => $lang['Select_a_User'], 'L_LOOK_UP' => $lang['Look_up_user'], 'L_FIND_USERNAME' => $lang['Find_username'], 'U_SEARCH_USER' => append_sid($phpbb_root_path . "search.$phpEx?mode=searchuser"), 'S_PURGE_ACTION' => append_sid("admin_weblog_tools.$phpEx?mode=purge"), 'S_USER_SELECT' => $select_list) ); } else if ( $mode == 'edit' ) { if ( isset($HTTP_POST_VARS['submit']) ) { if ( isset($HTTP_POST_VARS['ban_user']) ) { $user_allowweblog = 0; } else { $user_allowweblog = 1; } $allow_adv_weblogs = ( isset($HTTP_POST_VARS['allow_adv_weblogs']) ) ? intval($HTTP_POST_VARS['allow_adv_weblogs']) : 0; $user_id = ( isset($HTTP_POST_VARS['user_id']) ) ? intval($HTTP_POST_VARS['user_id']) : 0; $sql = "UPDATE " . USERS_TABLE . " SET user_allowweblog = $user_allowweblog, user_allowadvweblog = $allow_adv_weblogs WHERE user_id = $user_id"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Error updating user information', '', __LINE__, __FILE__, $sql); } mx_message_die (GENERAL_MESSAGE, 'User updated Successfully'); } $username = ( isset($HTTP_POST_VARS['username']) ) ? $HTTP_POST_VARS['username'] : ''; $sql = "SELECT * FROM " . USERS_TABLE . " WHERE username = '" . str_replace("\'", "''", $username) . "'"; if ( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, 'Error querying to find weblog user information', '', __LINE__, __FILE__, $sql); } if ( $row = $db->sql_fetchrow($result) ) { $weblog_user_data = $row; } else { mx_message_die(GENERAL_MESSAGE, $lang['User_not_exist']); } $template->set_filenames(array( 'body' => 'admin/weblog_users_body.tpl') ); $template->assign_vars(array( 'L_CONFIGURATION_TITLE' => $lang['Weblog_user_admin'], 'L_CONFIGURATION_EXPLAIN' => $lang['Weblog_user_admin_explain'], 'L_BAN_THIS_USER_WEBLOG' => $lang['Ban_this_user_weblog'], 'L_ALLOW_ADV_WEBLOG' => $lang['Allow_adv_weblog'], 'L_ALLOW_ADV_WEBLOG_EXPLAIN' => $lang['Allow_adv_weblog_explain'], 'S_BAN_USER_CHECKED' => ( !$weblog_user_data['user_allowweblog'] ) ? ' checked="checked"' : '', 'S_ALLOW_ADV_WEBLOGS_YES' => ( $weblog_user_data['user_allowadvweblog'] ) ? ' checked="checked"' : '', 'S_ALLOW_ADV_WEBLOGS_NO' => ( !$weblog_user_data['user_allowadvweblog'] ) ? ' checked="checked"' : '', 'USERNAME' => $username, 'S_HIDDEN_FIELDS' => '<input type="hidden" name="user_id" value="' . $weblog_user_data['user_id'] . '" />', 'S_CONFIG_ACTION' => append_sid("admin_weblog_tools.$phpEx?mode=edit")) ); } else { // // Default user selection box // $template->set_filenames(array( 'body' => 'admin/weblog_tools_body.tpl') ); $template->assign_vars(array( 'L_PICK_A_TOOL' => $lang['Pick_a_tool'], 'L_WEBLOG_ADMIN' => $lang['Weblog_admin'], 'L_WEBLOG_ADMIN_EXPLAIN' => $lang['Weblog_admin_explain'], 'L_WEBLOG_USER_ADMIN' => $lang['Weblog_user_admin'], 'L_WEBLOG_USER_ADMIN_EXPLAIN' => $lang['Weblog_user_admin_explain'], 'L_CONFIGURATION_TITLE' => $lang['Weblog_tools'], 'L_CONFIGURATION_EXPLAIN' => $lang['Weblog_tools_explain'], 'L_WEBLOG_PURGING' => $lang['Weblog_purging'], 'L_WEBLOG_PURGING_EXPLAIN' => $lang['Weblog_purging_explain'] ) ); $template->assign_vars(array( 'S_SELECT_ACTION' => append_sid("admin_weblog_tools.$phpEx")) ); } $template->assign_vars(array( 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No']) ); $template->pparse('body'); include($mx_root_path . 'admin/page_footer_admin.'.$phpEx); ?> --- NEW FILE: admin_weblog_cfg.php --- <?php /*************************************************************************** * admin_weblog_config.php * ----------------------------- * begin : Monday, September 5, 2004 * copyright : (C) 2005 Hyperion * email : vi...@ho... * * $Id: admin_weblog_config.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. * ***************************************************************************/ define('IN_PORTAL', 1); if( !empty($setmodules) ) { $file = basename(__FILE__); $module['Blog_admin']['Configuration'] = "modules/mx_blogs/admin/" . "$file"; return; } // // Let's set the root dir for phpBB // //$phpbb_root_path = "./../"; $mx_root_path = '../../../'; $module_root_path = './../'; //include($mx_root_path . 'extension.inc'); $phpEx = substr(strrchr(__FILE__, '.'), 1); include($mx_root_path . 'admin/pagestart.' . $phpEx); //include($phpbb_root_path . 'includes/functions_selects.'.$phpEx); include($module_root_path . 'includes/weblogs_constants.'.$phpEx); include($module_root_path . 'includes/weblogs_common.'.$phpEx); include($module_root_path . 'language/lang_' . $use_lang . '/lang_weblog_admin.' . $phpEx); // // Pull all config data // $sql = "SELECT * FROM " . WEBLOG_CONFIG_TABLE; if(!$result = $db->sql_query($sql)) { mx_message_die(CRITICAL_ERROR, "Could not query config information in admin_weblog_config", "", __LINE__, __FILE__, $sql); } else { while( $row = $db->sql_fetchrow($result) ) { $config_name = $row['config_name']; $config_value = $row['config_value']; $default_config[$config_name] = isset($HTTP_POST_VARS['submit']) ? str_replace("'", "\'", $config_value) : $config_value; $new[$config_name] = ( isset($HTTP_POST_VARS[$config_name]) ) ? $HTTP_POST_VARS[$config_name] : $default_config[$config_name]; if ($config_name == 'cookie_name') { $cookie_name = str_replace('.', '_', $new['cookie_name']); } if( isset($HTTP_POST_VARS['submit']) ) { $sql = "UPDATE " . WEBLOG_CONFIG_TABLE . " SET config_value = '" . str_replace("\'", "''", $new[$config_name]) . "' WHERE config_name = '$config_name'"; if( !$db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Failed to update weblog configuration for $config_name", "", __LINE__, __FILE__, $sql); } } } if( isset($HTTP_POST_VARS['submit']) ) { $message = $lang['Weblog_config_updated'] . "<br /><br />" . sprintf($lang['Click_return_weblog_config'], "<a href=\"" . append_sid("admin_weblog_config.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); mx_message_die(GENERAL_MESSAGE, $message); } } $template->set_filenames(array( "body" => "admin/weblog_config_body.tpl") ); $enable_mod_yes = ( $new['enable_mod'] ) ? ' checked="checked"' : ''; $enable_mod_no = ( !$new['enable_mod'] ) ? ' checked="checked"' : ''; $condense_index_yes = ( $new['condense_index'] ) ? ' checked="checked"' : ''; $condense_index_no = ( !$new['condense_index'] ) ? ' checked="checked"' : ''; $censor_weblogs_yes = ( $new['censor_weblog'] ) ? ' checked="checked"' : ''; $censor_weblogs_no = ( !$new['censor_weblog'] ) ? ' checked="checked"' : ''; $require_auth_yes = ( $new['require_auth'] ) ? ' checked="checked"' : ''; $require_auth_no = ( !$new['require_auth'] ) ? ' checked="checked"' : ''; $index_list_by_username_yes = ( $new['index_list_by_username'] ) ? ' checked="checked"' : ''; $index_list_by_username_no = ( !$new['index_list_by_username'] ) ? ' checked="checked"' : ''; $pic_uploading_enabled_yes = ( $new['pic_upload_enabled'] ) ? ' checked="checked"' : ''; $pic_uploading_enabled_no = ( !$new['pic_upload_enabled'] ) ? ' checked="checked"' : ''; $use_default_faceplates_yes = ( $new['use_default_faceplates'] ) ? ' checked="checked"' : ''; $use_default_faceplates_no = ( !$new['use_default_faceplates'] ) ? ' checked="checked"' : ''; $num_weblogs = array(1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 100); $select_num_weblogs = '<select name="main_blogsperpage">'; for($i = 0; $i < count($num_weblogs); $i++) { $selected = ( $num_weblogs[$i] == $new['main_blogsperpage'] ) ? ' selected="selected"' : ''; $select_num_weblogs .= '<option value="' . $num_weblogs[$i] . '"' . $selected . '>' . $num_weblogs[$i] . '</option>'; } $select_num_weblogs .= '</select>'; $sort_method = array(SORT_NEWEST_ENTRIES, SORT_WEBLOG_NAME, SORT_NUM_ENTRIES, SORT_WEBLOG_START_DATE, SORT_WEBLOG_VIEWS); $sort_method_text = array($lang['Sort_newest_entries'], $lang['Sort_weblog_name'], $lang['Sort_num_entries'], $lang['Sort_weblog_start_date'], $lang['Sort_weblog_views']); $select_sort = '<select name="main_sorttype">'; for($i = 0; $i < count($sort_method); $i++) { $selected = ( $sort_method[$i] == $new['main_sorttype'] ) ? ' selected="selected"' : ''; $select_sort .= '<option value="' . $sort_method[$i] . '"' . $selected . '>' . $sort_method_text[$i] . '</option>'; } $select_sort .= '</select>'; $sort_order = array('desc', 'asc'); $sort_order_text = array($lang['Sort_Descending'], $lang['Sort_Ascending']); $select_asc_desc = '<select name="main_sortorder">'; for($i = 0; $i < count($sort_order); $i++) { $selected = ($sort_order[$i] == $new['main_sortorder'] ) ? ' selected="selected"' : ''; $select_asc_desc .= '<option value="' . $sort_order[$i] . '"' . $selected . '>' . $sort_order_text[$i] . '</option>'; } $select_asc_desc .= '</select>'; $select_auth = make_weblog_auth_select ( $new['default_auth'], 'default_auth' ); $select_reply_auth = make_weblog_auth_select ( $new['default_reply_auth'], 'default_reply_auth' ); // // Escape any quotes in the site description for proper display in the text // box on the admin page // $template->assign_vars(array( 'S_CONFIG_ACTION' => append_sid("admin_weblog_cfg.$phpEx"), 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_CONFIGURATION_TITLE' => $lang['Weblog_configuration'], 'L_CONFIGURATION_EXPLAIN' => $lang['Weblog_configuration_explain'], 'L_GENERAL_SETTINGS' => $lang['General_settings'], 'L_ENABLE_BLOG_MOD' => $lang['Enable_blog_mod'], 'L_INDEX_BLOGS_PER_PAGE' => $lang['Index_weblogs_per_page'], 'L_CONDENSE_INDEX' => $lang['Condense_index'], 'L_CONDENSE_INDEX_EXPLAIN' => $lang['Condense_index_explain'], 'L_CENSOR_WEBLOGS' => $lang['Censor_weblogs'], 'L_CENSOR_WEBLOGS_EXPLAIN' => $lang['Censor_weblogs_explain'], 'L_REQUIRE_AUTH' => $lang['Require_authentication'], 'L_REQUIRE_AUTH_EXPLAIN' => $lang['Require_authentication_explain'], 'L_DEFAULT_SETTINGS' => $lang['Default_settings'], 'L_DEFAULT_WEBLOG_NAME' => $lang['Default_weblog_name'], 'L_DEFAULT_WEBLOG_NAME_EXPLAIN' => $lang['Default_weblog_name_explain'], 'L_DEFAULT_WEBLOG_DESC' => $lang['Default_weblog_desc'], 'L_INDEX_SORT_TYPE' => $lang['Index_sort_type'], 'L_INDEX_SORT_ORDER' => $lang['Index_sort_order'], 'L_WEBLOG_AUTH_DEFAULT' => $lang['Default_accessibility'], 'L_WEBLOG_REPLY_AUTH_DEFAULT' => $lang['Default_reply_auth'], 'L_ENTRIES_PER_PAGE' => $lang['Default_entries_per_page'], 'L_POST_REPLY_TEXT' => $lang['Default_post_reply_text'], 'L_REPLIES_TEXT' => $lang['Default_replies_text'], 'L_INDEX_LIST_BY_USERNAME' => $lang['Index_list_by_username'], 'L_BY_WEBLOG_NAME' => $lang['By_weblog_name'], 'L_BY_OWNER_NAME' => $lang['By_owner_name'], 'L_SHOUTBOX_FLOOD_DELAY' => $lang['Shoutbox_flood_delay'], 'L_PICTURE_UPLOADING' => $lang['Picture_uploading'], 'L_PICTURE_UPLOAD_ENABLED' => $lang['Picture_uploading_enabled'], 'L_MAXIMUM_PIC_SIZE' => $lang['Maximum_pic_size'], 'L_MAX_PIC_WIDTH' => $lang['Maximum_pic_width'], 'L_MAX_PIC_HEIGHT' => $lang['Maximum_pic_height'], 'L_USE_DEFAULT_FACEPLATES' => $lang['Use_default_faceplates'], 'L_USE_DEFAULT_FACEPLATES_EXPLAIN' => $lang['Use_default_faceplates_explain'], //for mx_blogs to find the pages 'L_WEBLOG_CONFIG_PAGE' => $lang['mx_weblog_config_page'], 'L_WEBLOG_LISTS_PAGE' => $lang['mx_weblog_list'], 'SHOUTBOX_FLOOD_DELAY' => intval($new['shoutbox_flood_delay']), 'BLOGS_PER_PAGE_SELECT' => $select_num_weblogs, 'INDEX_SORT_TYPE_SELECT' => $select_sort, 'INDEX_SORT_ORDER_SELECT' => $select_asc_desc, 'WEBLOG_AUTH_SELECT' => $select_auth, 'WEBLOG_REPLY_AUTH_SELECT' => $select_reply_auth, 'DEFAULT_WEBLOG_NAME' => $weblog_config['default_name'], 'DEFAULT_WEBLOG_DESC' => $weblog_config['default_desc'], 'ENTRIES_PER_PAGE' => $weblog_config['default_entries_perpage'], 'POST_REPLY_TEXT' => $weblog_config['default_post_reply_text'], 'REPLIES_TEXT' => $weblog_config['default_replies_text'], 'MAX_PIC_SIZE' => $weblog_config['max_pic_size'], 'MAX_PIC_HEIGHT' => $weblog_config['max_pic_height'], 'MAX_PIC_WIDTH' => $weblog_config['max_pic_width'], 'WEBLOG_CONFIG_PAGE' => $weblog_config['mx_weblog_config_page'], 'WEBLOG_LIST_PAGE' => $weblog_config['mx_weblog_list'], 'S_USE_DEFAULT_FACEPLATES_YES' => $use_default_faceplates_yes, 'S_USE_DEFAULT_FACEPLATES_NO' => $use_default_faceplates_no, 'S_PIC_UPLOAD_ENABLED_YES' => $pic_uploading_enabled_yes, 'S_PIC_UPLOAD_ENABLED_NO' => $pic_uploading_enabled_no, 'S_ENABLE_BLOG_MOD_YES' => $enable_mod_yes, 'S_ENABLE_BLOG_MOD_NO' => $enable_mod_no, 'S_CONDENSE_INDEX_YES' => $condense_index_yes, 'S_CONDENSE_INDEX_NO' => $condense_index_no, 'S_CENSOR_WEBLOGS_YES' => $censor_weblogs_yes, 'S_CENSOR_WEBLOGS_NO' => $censor_weblogs_no, 'S_INDEX_LIST_BY_USERNAME_YES' => $index_list_by_username_yes, 'S_INDEX_LIST_BY_USERNAME_NO' => $index_list_by_username_no, 'S_REQUIRE_AUTH_YES' => $require_auth_yes, 'S_REQUIRE_AUTH_NO' => $require_auth_no) ); $template->pparse("body"); include($mx_root_path . 'admin/page_footer_admin.'.$phpEx); ?> --- NEW FILE: admin_weblog_mood.php --- <?php /*************************************************************************** * admin_weblog_mood.php * --------------------------- * begin : Monday, September 5, 2004 * copyright : (C) 2005 Hyperion * email : vi...@ho... * * $Id: admin_weblog_mood.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. * ***************************************************************************/ define('IN_PORTAL', 1); // // First we do the setmodules stuff for the admin cp. // if( !empty($setmodules) ) { $filename = basename(__FILE__); $module['Blog_admin']['Mood_choices'] = 'modules/mx_blogs/admin/' . $filename; return; } $mx_root_path = "./../../../"; $module_root_path = "./../"; //include($mx_root_path . 'extension.inc'); $phpEx = substr(strrchr(__FILE__, '.'), 1); include($mx_root_path . 'admin/pagestart.' . $phpEx); include($module_root_path . 'includes/weblogs_constants.'.$phpEx); include($module_root_path . 'includes/weblogs_common.'.$phpEx); include($module_root_path . 'language/lang_' . $use_lang . '/lang_weblog_admin.' . $phpEx); // // Get the moods data // $sql = "SELECT * FROM " . WEBLOG_MOODS_TABLE . " ORDER BY mood_text"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't obtain mood data from database", "", __LINE__, __FILE__, $sql); } $mood_data = $db->sql_fetchrowset($result); $sql = "SELECT * FROM " . WEBLOG_MOOD_SETS_TABLE . " ORDER BY set_id"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't obtain mood set data from database", "", __LINE__, __FILE__, $sql); } $mood_set_data = $db->sql_fetchrowset($result); // // Check to see what mode we should operate in. // if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) { $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; } else { $mode = ""; } // // Read a listing of uploaded mood icons for use in the add or edit smliey code... // $dir = @opendir($module_root_path . 'images/weblogs/'); while($file = @readdir($dir)) { if( !@is_dir(phpbb_realpath($module_root_path . 'images/weblogs/' . $file)) ) { $img_size = @getimagesize($module_root_path . 'images/weblogs/' . $file); if( $img_size[0] && $img_size[1] ) { $mood_images[] = $file; } } } @closedir($dir); if ( isset($HTTP_POST_VARS['id']) ) { $id = intval($HTTP_POST_VARS['id']); } else if ( isset($HTTP_GET_VARS['id']) ) { $id = intval($HTTP_GET_VARS['id']); } // // Select main mode // switch( $mode ) { case 'addmood': // // Admin has selected to add a mood. // $template->set_filenames(array( "body" => "admin/weblog_mood_edit_body.tpl") ); $filename_list = ""; for( $i = 0; $i < count($mood_images); $i++ ) { $filename_list .= '<option value="' . $mood_images[$i] . '">' . $mood_images[$i] . '</option>'; } $s_hidden_fields = '<input type="hidden" name="mode" value="savenewmood" /><input type="hidden" name="id" value="' . $id . '" />'; $template->assign_vars(array( "L_MOOD_TITLE" => $lang['Weblog_mood_title'], "L_MOOD_CONFIG" => $lang['Weblog_mood_config'], "L_MOOD_EXPLAIN" => $lang['Weblog_mood_explain'], "L_MOOD_URL" => $lang['Weblog_mood_url'], "L_MOOD_MOOD" => $lang['Weblog_mood_mood'], "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], "MOOD_IMG" => $module_root_path . 'images/weblogs/' . $mood_images[0], "S_MOOD_ACTION" => append_sid("admin_weblog_mood.$phpEx"), "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_FILENAME_OPTIONS" => $filename_list) ); $template->pparse("body"); break; case 'addset': // // Admin has selected to add a new set. // $template->set_filenames(array( "body" => "admin/weblog_mood_set_edit_body.tpl") ); $s_hidden_fields = '<input type="hidden" name="mode" value="savenewset" />'; $template->assign_vars(array( "L_MOOD_TITLE" => $lang['Weblog_mood_set_title'], "L_MOOD_CONFIG" => $lang['Weblog_mood_set_config'], "L_MOOD_EXPLAIN" => $lang['Weblog_mood_set_explain'], "L_MOOD_SET" => $lang['Mood_set'], "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], "MOOD_SET" => '', "S_MOOD_SET_ACTION" => append_sid("admin_weblog_mood.$phpEx"), "S_HIDDEN_FIELDS" => $s_hidden_fields) ); $template->pparse("body"); break; case 'deletemood': // // Admin has selected to delete a mood. // $mood_id = $id; $sql = "DELETE FROM " . WEBLOG_MOODS_TABLE . " WHERE mood_id = " . $mood_id; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't delete mood", "", __LINE__, __FILE__, $sql); } $message = $lang['Weblog_mood_del_success'] . "<br /><br />" . sprintf($lang['Click_return_moodadmin'], "<a href=\"" . append_sid("admin_weblog_mood.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); mx_message_die(GENERAL_MESSAGE, $message); break; case 'deleteset': // // Admin has selected to delete an entire mood set. // $set_id = $id; // Find all moods under this set $sql = "DELETE FROM " . WEBLOG_MOODS_TABLE . " WHERE mood_set = $set_id"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't delete moods under this mood set", "", __LINE__, __FILE__, $sql); } $sql = "DELETE FROM " . WEBLOG_MOOD_SETS_TABLE . " WHERE set_id = $set_id"; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, "Couldn't delete moods under this mood set", "", __LINE__, __FILE__, $sql); } $message = $lang['Weblog_mood_set_del_success'] . "<br /><br />" . sprintf($lang['Click_return_moodadmin'], "<a href=\"" . append_sid("admin_weblog_mood.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); mx_message_die(GENERAL_MESSAGE, $message); break; case 'editmood': // // Admin has selected to edit a mood. // $mood_id = $id; $sql = "SELECT * FROM " . WEBLOG_MOODS_TABLE . " WHERE mood_id = " . $mood_id; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not obtain mood information', "", __LINE__, __FILE__, $sql); } $mood_data = $db->sql_fetchrow($result); $filename_list = ""; for( $i = 0; $i < count($mood_images); $i++ ) { if( $mood_images[$i] == $mood_data['mood_url'] ) { $mood_selected = "selected=\"selected\""; $mood_edit_img = $mood_images[$i]; } else { $mood_selected = ""; } $filename_list .= '<option value="' . $mood_images[$i] . '"' . $mood_selected . '>' . $mood_images[$i] . '</option>'; } $template->set_filenames(array( "body" => "admin/weblog_mood_edit_body.tpl") ); $s_hidden_fields = '<input type="hidden" name="mode" value="savemood" /><input type="hidden" name="mood_id" value="' . $mood_data['mood_id'] . '" />'; $template->assign_vars(array( "L_MOOD_TITLE" => $lang['Weblog_mood_title'], "L_MOOD_CONFIG" => $lang['Weblog_mood_config'], "L_MOOD_EXPLAIN" => $lang['Weblog_mood_explain'], "L_MOOD_URL" => $lang['Weblog_mood_url'], "L_MOOD_MOOD" => $lang['Weblog_mood_mood'], "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], "MOOD_IMG" => $module_root_path . 'images/weblogs/' . $mood_edit_img, "MOOD_MOOD" => $mood_data['mood_text'], "S_MOOD_ACTION" => append_sid("admin_weblog_mood.$phpEx"), "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_FILENAME_OPTIONS" => $filename_list) ); $template->pparse("body"); break; case 'editset': // // Admin has selected to edit a mood set. // $set_id = $id; $sql = "SELECT * FROM " . WEBLOG_MOOD_SETS_TABLE . " WHERE set_id = " . $set_id; if( !$result = $db->sql_query($sql) ) { mx_message_die(GENERAL_ERROR, 'Could not obtain mood set information', "", __LINE__, __FILE__, $sql); } $mood_set_data = $db->sql_fetchrow($result); $template->set_filenames(array( "body" => "admin/weblog_mood_set_edit_body.tpl") ); $s_hidden_fields = '<input type="hidden" name="mode" value="saveset" /><input type="hidden" name="id" value="' . $mood_set_data['set_id'] . '" />'; $template->assign_vars(array( "L_MOOD_TITLE" => $lang['Weblog_mood_set_title'], "L_MOOD_CONFIG" => $lang['Weblog_mood_set_config'], "L_MOOD_EXPLAIN" => $lang['Weblog_mood_set_explain'], "L_MOOD_SET" => $lang['Mood_set'], "L_SUBMIT" => $lang['Submit'], "L_RESET" => $lang['Reset'], "MOOD_SET" => $mood_set_data['set_name'], "S_MOOD_SET_ACTION" => append_sid("admin_weblog_mood.$phpEx"), "S_HIDDEN_FIELDS" => $s_hidden_fields, "S_FILENAME_OPTIONS" => $filename_list) ); $template->pparse("body"); break; case 'savemood': // // Admin has submitted changes while editing a mood. // // // Get the submitted data, being careful to ensure that we only // accept the data we are looking for. // $mood_url = ( isset($HTTP_POST_VARS['mood_url']) ) ? trim($HTTP_POST_VARS['mood_url']) : trim($HTTP_GET_VARS['mood_url']); $mood_mood = ( isset($HTTP_POST_VARS['mood_mood']) ) ? trim($HTTP_POST_VARS['mood_mood']) : trim($HTTP_GET_VARS['mood_mood']); $mood_id = ( isset($HTTP_POST_VARS['mood_id']) ) ? intval($HTTP_POST_VARS['mood_id']) : intval($HTTP_GET_VARS['mood_id']); // If no code was entered complain ... if ( $mood_url == '') { mx_message_die(MESSAGE, $lang['Fields_empty']); } // // Proceed with updating the mood table. // $sql = "UPDATE " . WEBLOG_MOODS_TABLE . " SET mood_url = '" . str_replace("\'", "''", $mood_url) . "', mood_text = '" . str_replace("\'", "''", $mood_mood) . "' WHERE mood_id = $mood_id"; if( !($result = $db->sql_query($sql)) ) { mx_message_die(GENERAL_ERROR, "Couldn't update mood info", "", __LINE__, __FILE__, $sql); } $message = $lang['Weblog_mood_edit_success'] . "<br /><br... [truncated message content] |