function phorum_check_language($is_install = false) { global $PHORUM; $checked = array(); // Check for the default language file. if (!file_exists("./include/lang/{$PHORUM["default_forum_options"]["language"]}.php")) { return array(PHORUM_SANITY_WARN, "Your default language is set to\n \"" . htmlspecialchars($PHORUM["default_forum_options"]["language"]) . "\",\n but the language file \"include/lang/" . htmlspecialchars($PHORUM["default_forum_options"]["language"] . ".php") . "\" is\n not available on your system (anymore?).", "Install the specified language file to make this default\n language work or change the Default Language setting\n under General Settings."); } $checked[$PHORUM["default_forum_options"]["language"]] = true; // If this check is run at install time, we're done. if ($is_install) { return array(PHORUM_SANITY_OK, NULL, NULL); } // Check for the forum specific language file(s). require_once './include/api/forums.php'; $forums = phorum_api_forums_get(NULL, NULL, NULL, NULL, PHORUM_FLAG_INCLUDE_INACTIVE); foreach ($forums as $id => $forum) { if (!empty($forum["language"]) && !$checked[$forum["language"]] && !file_exists("./include/lang/{$forum["language"]}.php")) { $type = $forum['folder_flag'] ? 'folder' : 'forum'; return array(PHORUM_SANITY_WARN, "The language for {$type} \"" . htmlspecialchars($forum["name"]) . "\" is set to\n \"" . htmlspecialchars($forum["language"]) . "\",\n but the language file \"include/lang/" . htmlspecialchars($forum["language"] . ".php") . "\" is\n not available on your system (anymore?).", "Install the specified language file to make this language\n work or change the language setting for the forum."); } $checked[$forum["language"]] = true; } // All checks are OK. return array(PHORUM_SANITY_OK, NULL, NULL); }
function phorum_readable_permissions() { global $PHORUM; $newperms = array(); if (isset($PHORUM["user"]["permissions"])) { $forums = phorum_api_forums_get(array_keys($PHORUM["user"]["permissions"])); foreach ($PHORUM["user"]["permissions"] as $forum => $perms) { if (isset($forums[$forum])) { if ($perms & PHORUM_USER_ALLOW_MODERATE_MESSAGES) { $newperms[] = array('forum' => $forums[$forum]["name"], 'perm' => $PHORUM['DATA']['LANG']['PermModerator']); } if ($perms & PHORUM_USER_ALLOW_READ) { $newperms[] = array('forum' => $forums[$forum]["name"], 'perm' => $PHORUM['DATA']['LANG']['PermAllowRead']); } if ($perms & PHORUM_USER_ALLOW_REPLY) { $newperms[] = array('forum' => $forums[$forum]["name"], 'perm' => $PHORUM['DATA']['LANG']['PermAllowReply']); } if ($perms & PHORUM_USER_ALLOW_NEW_TOPIC) { $newperms[] = array('forum' => $forums[$forum]["name"], 'perm' => $PHORUM['DATA']['LANG']['PermAllowPost']); } } } } return $newperms; }
function phorum_check_upload_limits($is_install) { global $PHORUM; if ($is_install) { return array(PHORUM_SANITY_SKIP, NULL, NULL); } // Keep track if uploads are used. $upload_used = false; // Get the maximum file upload size for PHP. list($system_max_upload, $php_max_upload, $db_max_upload) = phorum_api_system_get_max_upload(); // Check limits for file uploading in personal profile. if ($PHORUM["file_uploads"] && $PHORUM["max_file_size"]) { $upload_used = true; $res = phorum_single_check_upload_limits($PHORUM["max_file_size"] * 1024, "the Max File Size option for user file uploads " . "(in their profile)", $php_max_upload, $db_max_upload); if ($res != NULL) { return $res; } } // Check limits for attachment uploading in forums. require_once './include/api/forums.php'; $forums = phorum_api_forums_get(NULL, NULL, NULL, NULL, PHORUM_FLAG_INCLUDE_INACTIVE | PHORUM_FLAG_FORUMS); foreach ($forums as $id => $forum) { if ($forum["max_attachments"] > 0 && $forum["max_attachment_size"]) { $upload_used = true; $res = phorum_single_check_upload_limits($forum["max_attachment_size"] * 1024, "the Max File Size option for uploading attachments\n in the forum \"{$forum['name']}\"", $php_max_upload, $db_max_upload); if ($res != NULL) { return $res; } } } // No upload functionality found so far? Then we're done. if (!$upload_used) { return array(PHORUM_SANITY_OK, NULL); } // Check if the upload temp directory can be written. $tmpdir = get_cfg_var('upload_tmp_dir'); if (!empty($tmpdir)) { $fp = @fopen("{$tmpdir}/sanity_checks_dummy_uploadtmpfile", "w"); if (!$fp) { return array(PHORUM_SANITY_CRIT, "The system is unable to write files\n to PHP's upload tmpdir \"" . htmlspecialchars($tmpdir) . "\".\n The system error was:<br/><br/>" . htmlspecialchars($php_errormsg) . ".", "Change the upload_tmp_dir setting in your php.ini file\n or give your webserver more permissions for the current\n upload directory."); } fclose($fp); unlink("{$tmpdir}/sanity_checks_dummy_uploadtmpfile"); } return array(PHORUM_SANITY_OK, NULL, NULL); }
$skipsession = FALSE; if (phorum_page == 'css' || phorum_page == 'javascript') { $skipsession = TRUE; } // If the Phorum is disabled, display a message. if (isset($PHORUM["status"]) && $PHORUM["status"] == PHORUM_MASTER_STATUS_DISABLED) { if (!empty($PHORUM["disabled_url"])) { phorum_api_redirect($PHORUM['disabled_url']); } else { echo "This Phorum is currently administratively disabled. Please " . "contact the web site owner at " . htmlspecialchars($PHORUM['system_email_from_address']) . " " . "for more information."; exit; } } if (!empty($PHORUM["forum_id"])) { // Load the settings for the currently active forum. $forum_settings = phorum_api_forums_get($PHORUM["forum_id"], null, null, null, PHORUM_FLAG_INCLUDE_INACTIVE); if ($forum_settings === NULL) { /* * [hook] * common_no_forum * * [description] * This hook is called in case a forum_id is requested for * an unknown or inaccessible forum. It can be used for * doing things like logging the bad requests or fully * overriding Phorum's default behavior for these cases * (which is redirecting the user back to the index page). * * [category] * Request initialization *
/** * Retrieve data for all forums inheriting their settings from a certain forum. * * @param integer $forum_id * The forum_id for which to check what forums inherit its setting. * * @return array * An array of forums, index by the their forum_id and sorted * by their display order. */ function phorum_api_forums_by_inheritance($forum_id = 0) { return phorum_api_forums_get(NULL, NULL, NULL, $forum_id); }
$forums[$forum_id] = $folder; // Keep track of folders that are shown below the starting node. $folders[$forum_id] = array(); } } // Loop over all the folders (flat view sections) that we will show and get // their child forums and folders. foreach ($folders as $folder_id => $dummy) { // These folders are level zero folders. To the child forums and folders, // level 1 will be assigned. The level value can be used in the template // to see where a new top level folder starts. $forums[$folder_id]['level'] = 0; // Retrieve the children for the current folder. For the (v)root folder, // we only retrieve the contained forums, since its folders will be shown // as separate sections in the flat index view instead. $children = phorum_api_forums_get(NULL, $folder_id, NULL, $PHORUM['vroot'], $PHORUM['vroot'] == $folder_id ? PHORUM_FLAG_FORUMS : 0); foreach ($children as $child_forum_id => $child_forum) { // If inaccessible forums should be hidden on the index, then check // if the current user has rights to access the current forum. if (!$child_forum['folder_flag'] && $PHORUM['hide_forums'] && !phorum_api_user_check_access(PHORUM_USER_ALLOW_READ, $child_forum_id)) { continue; } // These are level one forums and folders. $child_forum['level'] = 1; // Remember the data. $forums[$child_forum_id] = $child_forum; // Add the forum or folder to the child list for the current folder. $folders[$folder_id][$child_forum_id] = $child_forum_id; } } // --------------------------------------------------------------------
foreach ($files as $file_id => $data) { if (phorum_api_file_check_delete_access($file_id)) { phorum_api_file_delete($file_id); } } } // Run a hook for performing custom actions after cleanup. if (isset($PHORUM["hooks"]["delete"])) { phorum_api_hook("delete", array($msgthd_id)); } } } } $PHORUM['DATA']['PREPOST'] = array(); if ($gotforums) { $foruminfo = phorum_api_forums_get($mod_forums, NULL, NULL, $PHORUM['vroot']); } else { $foruminfo = array(); } foreach ($mod_forums as $forum => $rest) { $checkvar = 1; // Get the threads $rows = array(); // get the thread set started $rows = $PHORUM['DB']->get_unapproved_list($forum, $showwaiting, $moddays); // loop through and read all the data in. foreach ($rows as $key => $row) { $numunapproved++; $rows[$key]['forumname'] = $foruminfo[$forum]['name']; $rows[$key]['checkvar'] = $checkvar; if ($checkvar) {
} else { echo "Error Saving Group Forum Permissions"; } break; } } if ($error) { phorum_admin_error($error); } require_once './include/admin/PhorumInputForm.php'; $groups = $PHORUM['DB']->get_groups(0, TRUE); /** * @todo Add PHORUM_FLAG_FORUMS when the phorum_get_forum_info() call * from below is APIfied. */ $forums = phorum_api_forums_get(NULL, NULL, NULL, NULL, PHORUM_FLAG_INCLUDE_INACTIVE); if (isset($_REQUEST["edit"]) && !empty($_REQUEST['group_id'])) { $group_id_in = empty($_POST['group_id']) ? $_GET['group_id'] : $_POST['group_id']; $_GET['group_id'] = (int) $group_id_in; $group = $groups[$_GET["group_id"]]; $frm = new PhorumInputForm("", "post"); $frm->addbreak("Edit Group"); $frm->hidden("module", "groups"); $frm->hidden("section", "edit"); // for getting back to the edit-page $frm->hidden('edit', '1'); $frm->hidden("group_id", $_GET["group_id"]); $open_options = array(PHORUM_GROUP_CLOSED => "No", PHORUM_GROUP_OPEN => "Yes", PHORUM_GROUP_REQUIRE_APPROVAL => "Yes (require Group Moderator approval)"); $frm->addrow("Name:", $frm->text_box("name", $group["name"], 50)); $frm->addrow("Allow Membership Requests:", $frm->select_tag("open", $open_options, $group["open"], "")); $frm->show();
/** * @param integer $flag * $flag can be 0, 1, 2 or 3 * 0 = all forums / folders * 1 = all forums * 2 = only forums + vroot-folders (used in banlists) * 3 = only vroot-folders * * @param integer $vroot * This parameter can be -1, 0 or > 0 * -1 returns forums from all vroots * 0 returns only forums / folders from the root (vroot = 0) * > 0 returns only forums / folders within the given vroot */ function phorum_get_forum_info($flag = 0, $vroot = -1) { $folders = array(); $forums = phorum_api_forums_get(NULL, NULL, NULL, NULL, PHORUM_FLAG_INCLUDE_INACTIVE); foreach ($forums as $forum) { if (($flag == 0 || $forum['folder_flag'] == 0 && $flag != 3 || $flag == 2 && $forum['vroot'] > 0 && $forum['vroot'] == $forum['forum_id'] || $flag == 3 && $forum['vroot'] == $forum['forum_id']) && ($vroot == -1 || $vroot == $forum['vroot'])) { // Build a string path for the current forum record. $parts = $forum['forum_path']; array_shift($parts); $path = implode('::', $parts); // When we are not requesting vroot folders specifically, // then add an indication when the current forum record // is a vroot folder. if ($flag != 3 && $forum['vroot'] && $forum['vroot'] == $forum['forum_id']) { $path .= " (Virtual Root)"; } $folders[$forum["forum_id"]] = $path; } } asort($folders, SORT_STRING); return $folders; }
function phorum_build_forum_list() { $PHORUM = $GLOBALS["PHORUM"]; // Check what forums the current user can read. $allowed_forums = phorum_api_user_check_access(PHORUM_USER_ALLOW_READ, PHORUM_ACCESS_LIST); $forum_picker = array(); // build forum drop down data require_once './include/api/forums.php'; $forums = phorum_api_forums_get($allowed_forums); foreach ($forums as $forum) { $tmp_forums[$forum["forum_id"]]["forum_id"] = $forum["forum_id"]; $tmp_forums[$forum["forum_id"]]["parent"] = $forum["parent_id"]; $tmp_forums[$forum["parent_id"]]["children"][] = $forum["forum_id"]; if (empty($forums[$forum["parent_id"]]["childcount"])) { $forums[$forum["parent_id"]]["childcount"] = 1; } else { $forums[$forum["parent_id"]]["childcount"]++; } } $order = array(); $stack = array(); $curr_id = $PHORUM['vroot']; while (count($tmp_forums)) { if (empty($seen[$curr_id])) { if ($curr_id != $PHORUM['vroot']) { if ($forums[$curr_id]["active"]) { $order[$curr_id] = $forums[$curr_id]; } $seen[$curr_id] = true; } } array_unshift($stack, $curr_id); $data = $tmp_forums[$curr_id]; if (isset($data["children"])) { if (count($data["children"])) { $curr_id = array_shift($tmp_forums[$curr_id]["children"]); } else { unset($tmp_forums[$curr_id]); array_shift($stack); $curr_id = array_shift($stack); } } else { unset($tmp_forums[$curr_id]); array_shift($stack); $curr_id = array_shift($stack); } if (!is_numeric($curr_id)) { break; } } foreach ($order as $forum) { if ($forum["folder_flag"]) { // Skip empty folders. if (empty($forums[$forum['forum_id']]['childcount'])) { continue; } $url = phorum_get_url(PHORUM_INDEX_URL, $forum["forum_id"]); } else { $url = phorum_get_url(PHORUM_LIST_URL, $forum["forum_id"]); } $indent = count($forum["forum_path"]) - 2; if ($indent < 0) { $indent = 0; } $forum_picker[$forum["forum_id"]] = array("forum_id" => $forum["forum_id"], "parent_id" => $forum["parent_id"], "folder_flag" => $forum["folder_flag"], "name" => $forum["name"], "stripped_name" => strip_tags($forum["name"]), "indent" => $indent, "indent_spaces" => str_repeat(" ", $indent), "url" => $url, "path" => $forum["forum_path"]); } return $forum_picker; }
// You should have received a copy of the Phorum License // // along with this program. // // // //////////////////////////////////////////////////////////////////////////////// if (!defined("PHORUM_ADMIN")) { return; } require_once './include/api/forums.php'; // Show message if set in the URL. if (isset($_GET['okmsg'])) { phorum_admin_okmsg(htmlspecialchars($_GET['okmsg'])); } $folder_id = (int) (isset($_GET["parent_id"]) ? $_GET["parent_id"] : 0); $parent_parent_id = (int) (isset($_GET["pparent"]) ? $_GET["pparent"] : 0); // Load the info for the current folder. $folder = phorum_api_forums_get($folder_id); // Load the list of forums and folders that are in the current folder. $forums = phorum_api_forums_by_folder_id($folder_id, PHORUM_FLAG_INCLUDE_INACTIVE); // Change the display order of the items in the list. if (isset($_GET['display_up']) || isset($_GET['display_down'])) { if (isset($_GET['display_up'])) { $forum_id = (int) $_GET['display_up']; $movement = 'up'; } else { $forum_id = (int) $_GET['display_down']; $movement = 'down'; } phorum_api_forums_change_order($folder_id, $forum_id, $movement, 1); // Get a fresh forum list with updated order. $forums = phorum_api_forums_by_folder_id($folder_id); }
{ call : "getforumsettings", forum_id : 10 } Retrieve the default forum settings: { call : "getforumsettings", forum_id : 0 } RETURN VALUE An object containing the settings data for a forum. ERRORS The call will return an error if no forum exists for the provided forum_id or if the active user does not have read access for the forum. AUTHOR Maurice Makaay <*****@*****.**> */ if (!defined('PHORUM')) { return; } require_once PHORUM_PATH . '/include/api/forums.php'; // Process the arguments. $forum_id = phorum_ajax_getarg('forum_id', 'int'); // For forum_id = 0, we return the default settings. if ($forum_id == 0) { phorum_ajax_return($PHORUM['default_forum_options']); } // Retrieve and return the forum data. No permission checking is needed. // The forum_id parameter is checked from common.php already. $data = phorum_api_forums_get($forum_id); if (!$data) { phorum_ajax_error("Forum {$forum_id} does not exist"); } phorum_ajax_return($data);
// but WITHOUT ANY WARRANTY, without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // // // // You should have received a copy of the Phorum License // // along with this program. // // // //////////////////////////////////////////////////////////////////////////////// if (!defined("PHORUM")) { return; } require_once PHORUM_PATH . '/include/api/format/forums.php'; // -------------------------------------------------------------------- // Retrieve information from the database // -------------------------------------------------------------------- // Retrieve the children for the current folder. $forums = phorum_api_forums_get(NULL, $PHORUM['forum_id'], NULL, $PHORUM['vroot']); // For the directory index view, we show the folders and forums separately. // Here we separate the forum_ids for these two. $folder_ids = array(); $forum_ids = array(); foreach ($forums as $forum_id => $forum) { // Handle folders. if ($forum['folder_flag']) { $folder_ids[] = $forum_id; } else { // If inaccessible forums should be hidden on the index, then check // if the current user has rights to access the current forum. if (!$forum['folder_flag'] && $PHORUM['hide_forums'] && !phorum_api_user_check_access(PHORUM_USER_ALLOW_READ, $forum_id)) { continue; } $forum_ids[] = $forum_id;
// After running this script, you can use those groups for assigning // moderators to the forums. // if we are running in the webserver, bail out if ('cli' != php_sapi_name()) { echo "This script cannot be run from a browser."; return; } define("PHORUM_ADMIN", 1); define('phorum_page', 'create_moderator_groups'); chdir(dirname(__FILE__) . "/.."); require_once './common.php'; require_once './include/api/forums.php'; // Make sure that the output is not buffered. phorum_api_buffer_clear(); print "\nCreate forum moderator groups ...\n"; $forums = phorum_api_forums_get(); // Find out which forums already have a moderator group available. $forum_has_moderator = array(); $groups = $PHORUM['DB']->get_groups(); foreach ($groups as $id => $group) { foreach ($group['permissions'] as $forum_id => $permission) { if ($permission & PHORUM_USER_ALLOW_MODERATE_MESSAGES) { $forum_has_moderator[$forum_id] = TRUE; } } } foreach ($forums as $forum_id => $fdata) { if (!empty($fdata['folder_flag'])) { continue; } print "> forum {$fdata['name']} ";
* Same as input. */ phorum_hook('after_split', $_POST['message']); break; default: if (!isset($PHORUM['DATA']['OKMSG'])) { $PHORUM['DATA']['OKMSG'] = ""; } $PHORUM['DATA']["URL"]["REDIRECT"] = $PHORUM["DATA"]["URL"]["LIST"]; } // remove the affected messages from the cache if caching is enabled. if ($PHORUM['cache_messages']) { $invalidate_forums = array(); foreach ($invalidate_message_cache as $message) { phorum_cache_remove('message', $message["message_id"]); $invalidate_forums[$message['forum_id']] = $message['forum_id']; } if (is_array($invalidate_forums) && count($invalidate_forums)) { require_once './include/api/forums.php'; // retrieve the data for all involved forums to get the correct cache version $forums_data = phorum_api_forums_get($invalidate_forums); // increment the cache version for all involved forums once foreach ($invalidate_forums as $forum_id) { phorum_db_update_forum(array('forum_id' => $forum_id, 'cache_version' => $forums_data[$forum_id]['cache_version'] + 1)); } } } if (!isset($PHORUM['DATA']['BACKMSG'])) { $PHORUM['DATA']["BACKMSG"] = $PHORUM['DATA']["LANG"]["BackToList"]; } phorum_output($template);
// // //////////////////////////////////////////////////////////////////////////////// if (!defined("PHORUM_ADMIN")) { return; } require_once './include/api/forums.php'; if ($_GET["confirm"] == "Yes") { $res = phorum_api_forums_delete((int) $_GET['forum_id']); if ($res === NULL) { $msg = "No action was taken."; } else { $msg = $res['folder_flag'] ? "The folder has been deleted. All forums and folders from " . "this folder have been moved to the folder's parent." : "The forum and all messages it contained have been deleted."; } } elseif ($_GET["confirm"] == "No") { $msg = "No action was taken."; } else { $forum = phorum_api_forums_get((int) $_GET['forum_id'], NULL, NULL, NULL, PHORUM_FLAG_INCLUDE_INACTIVE); if ($forum["folder_flag"]) { $msg = "Are you sure you want to delete {$forum['name']}? All forums and folders in this folder will be moved to this folder's parent."; } else { $msg = "Are you sure you want to delete {$forum['name']}? All messages in this forum will be deleted"; } $frm_url = phorum_admin_build_url(); $msg .= "<form action=\"{$frm_url}\" method=\"get\"><input type=\"hidden\" name=\"phorum_admin_token\" value=\"{$PHORUM['admin_token']}\"><input type=\"hidden\" name=\"module\" value=\"{$module}\" /><input type=\"hidden\" name=\"forum_id\" value=\"{$forum['forum_id']}\" /><input type=\"hidden\" name=\"folder_flag\" value=\"{$forum['folder_flag']}\" /><input type=\"submit\" name=\"confirm\" value=\"Yes\" /> <input type=\"submit\" name=\"confirm\" value=\"No\" /></form>"; } ?> <div class="PhorumInfoMessage"><?php echo $msg; ?> </div>