当前位置: 首页>>代码示例>>PHP>>正文


PHP loadClassFile函数代码示例

本文整理汇总了PHP中loadClassFile函数的典型用法代码示例。如果您正苦于以下问题:PHP loadClassFile函数的具体用法?PHP loadClassFile怎么用?PHP loadClassFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了loadClassFile函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ManageGames

function ManageGames()
{
    global $scripturl, $txt, $context, $sourcedir, $smcFunc, $modSettings;
    require_once $sourcedir . '/Arcade.php';
    require_once $sourcedir . '/Subs-ArcadeAdmin.php';
    // Templates
    loadTemplate('ManageGames');
    SMFArcade::loadArcade('admin', 'manage_games');
    loadClassFile('Class-Package.php');
    // Need to update files in database?
    if (!empty($modSettings['arcadeGamecacheUpdate']) && (empty($modSettings['arcadeDBUpdate']) || $modSettings['arcadeDBUpdate'] < max(filemtime($modSettings['gamesDirectory']), filemtime(__FILE__)))) {
        updateGameCache();
    }
    if (isset($_REQUEST['uninstall_submit']) && !isset($_REQUEST['sa'])) {
        $_REQUEST['sa'] = 'uninstall';
    }
    if (isset($_REQUEST['done']) && !empty($_SESSION['qaction'])) {
        $context['show_done'] = true;
        if ($_SESSION['qaction'] == 'install') {
            $context['qaction_title'] = $txt['arcade_install_complete'];
            $context['qaction_text'] = $txt['arcade_install_following_games'];
        } elseif ($_SESSION['qaction'] == 'uninstall') {
            $context['qaction_title'] = $txt['arcade_uninstall_complete'];
            $context['qaction_text'] = $txt['arcade_uninstall_following_games'];
        }
        if (isset($_SESSION['qaction_data']) && is_array($_SESSION['qaction_data'])) {
            $context['qaction_data'] = $_SESSION['qaction_data'];
        }
        unset($_SESSION['qaction_data']);
        unset($_SESSION['qaction']);
    }
    $subActions = array('list' => array('ManageGamesList', 'arcade_admin'), 'uninstall' => array('ManageGamesUninstall', 'arcade_admin'), 'uninstall2' => array('ManageGamesUninstall2', 'arcade_admin'), 'install' => array('ManageGamesInstall', 'arcade_admin'), 'install2' => array('ManageGamesInstall2', 'arcade_admin'), 'upload' => array('ManageGamesUpload', 'arcade_admin'), 'upload2' => array('ManageGamesUpload2', 'arcade_admin'), 'quickedit' => array('ManageGamesQuickEdit', 'arcade_admin'), 'edit' => array('EditGame', 'arcade_admin'), 'edit2' => array('EditGame2', 'arcade_admin'), 'export' => array('ExportGameinfo', 'arcade_admin'));
    // What user wants to do?
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'list';
    // Do we have reason to allow him/her to do it?
    isAllowedTo($subActions[$_REQUEST['sa']][1]);
    $context[$context['admin_menu_name']]['tab_data']['title'] = $txt['arcade_manage_games'];
    $context[$context['admin_menu_name']]['tab_data']['description'] = $txt['arcade_manage_games_desc'];
    $subActions[$_REQUEST['sa']][0]();
}
开发者ID:nikop,项目名称:SMF-Arcade,代码行数:40,代码来源:ManageGames.php

示例2: gif_loadFile

function gif_loadFile($lpszFileName, $iIndex = 0)
{
    // The classes needed are in this file.
    loadClassFile('Class-Graphics.php');
    $gif = new gif_file();
    if (!$gif->loadFile($lpszFileName, $iIndex)) {
        return false;
    }
    return $gif;
}
开发者ID:valek0972,项目名称:hackits,代码行数:10,代码来源:Subs-Graphics.php

示例3: PackageGBrowse

function PackageGBrowse()
{
    global $txt, $boardurl, $context, $scripturl, $boarddir, $sourcedir, $forum_version, $context, $smcFunc;
    if (isset($_GET['server'])) {
        if ($_GET['server'] == '') {
            redirectexit('action=admin;area=packages;get');
        }
        $server = (int) $_GET['server'];
        // Query the server list to find the current server.
        $request = $smcFunc['db_query']('', '
			SELECT name, url
			FROM {db_prefix}package_servers
			WHERE id_server = {int:current_server}
			LIMIT 1', array('current_server' => $server));
        list($name, $url) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
        // If the server does not exist, dump out.
        if (empty($url)) {
            fatal_lang_error('couldnt_connect', false);
        }
        // If there is a relative link, append to the stored server url.
        if (isset($_GET['relative'])) {
            $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative'];
        }
        // Clear any "absolute" URL.  Since "server" is present, "absolute" is garbage.
        unset($_GET['absolute']);
    } elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') {
        // Initialize the requried variables.
        $server = '';
        $url = $_GET['absolute'];
        $name = '';
        $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language'];
        // Clear any "relative" URL.  Since "server" is not present, "relative" is garbage.
        unset($_GET['relative']);
        $token = checkConfirm('get_absolute_url');
        if ($token !== true) {
            $context['sub_template'] = 'package_confirm';
            $context['page_title'] = $txt['package_servers'];
            $context['confirm_message'] = sprintf($txt['package_confirm_view_package_content'], htmlspecialchars($_GET['absolute']));
            $context['proceed_href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . urlencode($_GET['absolute']) . ';confirm=' . $token;
            return;
        }
    } else {
        fatal_lang_error('couldnt_connect', false);
    }
    // In safe mode or on lycos?  Try this URL. (includes package-list for informational purposes ;).)
    //if (@ini_get('safe_mode'))
    //	redirectexit($url . '/index.php?package-list&language=' . $context['user']['language'] . '&ref=' . $boardurl);
    // Attempt to connect.  If unsuccessful... try the URL.
    if (!isset($_GET['package']) || file_exists($_GET['package'])) {
        $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language'];
    }
    // Check to be sure the packages.xml file actually exists where it is should be... or dump out.
    if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) {
        fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
    }
    // Might take some time.
    @set_time_limit(600);
    // Read packages.xml and parse into xmlArray. (the true tells it to trim things ;).)
    loadClassFile('Class-Package.php');
    $listing = new xmlArray(fetch_web_data($_GET['package']), true);
    // Errm.... empty file?  Try the URL....
    if (!$listing->exists('package-list')) {
        fatal_lang_error('packageget_unable', false, array($url . '/index.php'));
    }
    // List out the packages...
    $context['package_list'] = array();
    $listing = $listing->path('package-list[0]');
    // Use the package list's name if it exists.
    if ($listing->exists('list-title')) {
        $name = $listing->fetch('list-title');
    }
    // Pick the correct template.
    $context['sub_template'] = 'package_list';
    $context['page_title'] = $txt['package_servers'] . ($name != '' ? ' - ' . $name : '');
    $context['package_server'] = $server;
    // By default we use an unordered list, unless there are no lists with more than one package.
    $context['list_type'] = 'ul';
    $instmods = loadInstalledPackages();
    $installed_mods = array();
    // Look through the list of installed mods...
    foreach ($instmods as $installed_mod) {
        $installed_mods[$installed_mod['package_id']] = $installed_mod['version'];
    }
    // Get default author and email if they exist.
    if ($listing->exists('default-author')) {
        $default_author = $smcFunc['htmlspecialchars']($listing->fetch('default-author'));
        if ($listing->exists('default-author/@email')) {
            $default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email'));
        }
    }
    // Get default web site if it exists.
    if ($listing->exists('default-website')) {
        $default_website = $smcFunc['htmlspecialchars']($listing->fetch('default-website'));
        if ($listing->exists('default-website/@title')) {
            $default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title'));
        }
    }
    $the_version = strtr($forum_version, array('SMF ' => ''));
    if (!empty($_SESSION['version_emulate'])) {
//.........这里部分代码省略.........
开发者ID:Kheros,项目名称:MMOver,代码行数:101,代码来源:PackageGet.php

示例4: fetch_web_data

function fetch_web_data($url, $post_data = '', $keep_alive = false, $redirection_level = 0)
{
    global $webmaster_email;
    static $keep_alive_dom = null, $keep_alive_fp = null;
    preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\\d+))?(.+)$~', $url, $match);
    // An FTP url. We should try connecting and RETRieving it...
    if (empty($match[1])) {
        return false;
    } elseif ($match[1] == 'ftp') {
        // Include the file containing the ftp_connection class.
        loadClassFile('Class-Package.php');
        // Establish a connection and attempt to enable passive mode.
        $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email);
        if ($ftp->error !== false || !$ftp->passive()) {
            return false;
        }
        // I want that one *points*!
        fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n");
        // Since passive mode worked (or we would have returned already!) open the connection.
        $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5);
        if (!$fp) {
            return false;
        }
        // The server should now say something in acknowledgement.
        $ftp->check_response(150);
        $data = '';
        while (!feof($fp)) {
            $data .= fread($fp, 4096);
        }
        fclose($fp);
        // All done, right?  Good.
        $ftp->check_response(226);
        $ftp->close();
    } elseif (isset($match[1]) && $match[1] == 'http') {
        if ($keep_alive && $match[3] == $keep_alive_dom) {
            $fp = $keep_alive_fp;
        }
        if (empty($fp)) {
            // Open the socket on the port we want...
            $fp = @fsockopen(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? $match[2] ? 443 : 80 : $match[5], $err, $err, 5);
            if (!$fp) {
                return false;
            }
        }
        if ($keep_alive) {
            $keep_alive_dom = $match[3];
            $keep_alive_fp = $fp;
        }
        // I want this, from there, and I'm not going to be bothering you for more (probably.)
        if (empty($post_data)) {
            fwrite($fp, 'GET ' . $match[6] . ' HTTP/1.0' . "\r\n");
            fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? $match[2] ? ':443' : '' : ':' . $match[5]) . "\r\n");
            fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n");
            if ($keep_alive) {
                fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n");
            } else {
                fwrite($fp, 'Connection: close' . "\r\n\r\n");
            }
        } else {
            fwrite($fp, 'POST ' . $match[6] . ' HTTP/1.0' . "\r\n");
            fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? $match[2] ? ':443' : '' : ':' . $match[5]) . "\r\n");
            fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n");
            if ($keep_alive) {
                fwrite($fp, 'Connection: Keep-Alive' . "\r\n");
            } else {
                fwrite($fp, 'Connection: close' . "\r\n");
            }
            fwrite($fp, 'Content-Type: application/x-www-form-urlencoded' . "\r\n");
            fwrite($fp, 'Content-Length: ' . strlen($post_data) . "\r\n\r\n");
            fwrite($fp, $post_data);
        }
        $response = fgets($fp, 768);
        // Redirect in case this location is permanently or temporarily moved.
        if ($redirection_level < 3 && preg_match('~^HTTP/\\S+\\s+30[127]~i', $response) === 1) {
            $header = '';
            $location = '';
            while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') {
                if (strpos($header, 'Location:') !== false) {
                    $location = trim(substr($header, strpos($header, ':') + 1));
                }
            }
            if (empty($location)) {
                return false;
            } else {
                if (!$keep_alive) {
                    fclose($fp);
                }
                return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1);
            }
        } elseif (preg_match('~^HTTP/\\S+\\s+20[01]~i', $response) === 0) {
            return false;
        }
        // Skip the headers...
        while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') {
            if (preg_match('~content-length:\\s*(\\d+)~i', $header, $match) != 0) {
                $content_length = $match[1];
            } elseif (preg_match('~connection:\\s*close~i', $header) != 0) {
                $keep_alive_dom = null;
                $keep_alive = false;
            }
//.........这里部分代码省略.........
开发者ID:norv,项目名称:EosAlpha,代码行数:101,代码来源:Subs-Package.php

示例5: AddLanguage

function AddLanguage()
{
    global $context, $sourcedir, $forum_version, $boarddir, $txt, $smcFunc, $scripturl;
    // Are we searching for new languages courtesy of Simple Machines?
    if (!empty($_POST['smf_add_sub'])) {
        // Need fetch_web_data.
        require_once $sourcedir . '/Subs-Package.php';
        $context['smf_search_term'] = htmlspecialchars(trim($_POST['smf_add']));
        // We're going to use this URL.
        $url = 'http://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => '')));
        // Load the class file and stick it into an array.
        loadClassFile('Class-Package.php');
        $language_list = new xmlArray(fetch_web_data($url), true);
        // Check it exists.
        if (!$language_list->exists('languages')) {
            $context['smf_error'] = 'no_response';
        } else {
            $language_list = $language_list->path('languages[0]');
            $lang_files = $language_list->set('language');
            $context['smf_languages'] = array();
            foreach ($lang_files as $file) {
                // Were we searching?
                if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) {
                    continue;
                }
                $context['smf_languages'][] = array('id' => $file->fetch('id'), 'name' => $smcFunc['ucwords']($file->fetch('name')), 'version' => $file->fetch('version'), 'utf8' => $file->fetch('utf8'), 'description' => $file->fetch('description'), 'link' => $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id']);
            }
            if (empty($context['smf_languages'])) {
                $context['smf_error'] = 'no_files';
            }
        }
    }
    $context['sub_template'] = 'add_language';
}
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:34,代码来源:ManageServer.php

示例6: PackagePermissions

function PackagePermissions()
{
    global $context, $txt, $modSettings, $boarddir, $sourcedir, $cachedir, $package_ftp;
    // Let's try and be good, yes?
    checkSession('get');
    // If we're restoring permissions this is just a pass through really.
    if (isset($_GET['restore'])) {
        create_chmod_control(array(), array(), true);
        fatal_lang_error('no_access', false);
    }
    // This is a memory eat.
    @ini_set('memory_limit', '128M');
    @set_time_limit(600);
    // Load up some FTP stuff.
    create_chmod_control();
    if (empty($package_ftp) && !isset($_POST['skip_ftp'])) {
        loadClassFile('Class-Package.php');
        $ftp = new ftp_connection(null);
        list($username, $detect_path, $found_path) = $ftp->detect_path($boarddir);
        $context['package_ftp'] = array('server' => isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost', 'port' => isset($modSettings['package_port']) ? $modSettings['package_port'] : '21', 'username' => empty($username) ? isset($modSettings['package_username']) ? $modSettings['package_username'] : '' : $username, 'path' => $detect_path, 'form_elements_only' => true);
    } else {
        $context['ftp_connected'] = true;
    }
    // Define the template.
    $context['page_title'] = $txt['package_file_perms'];
    $context['sub_template'] = 'file_permissions';
    // Define what files we're interested in, as a tree.
    $context['file_tree'] = array(strtr($boarddir, array('\\' => '/')) => array('type' => 'dir', 'contents' => array('agreement.txt' => array('type' => 'file', 'writable_on' => 'standard'), 'Settings.php' => array('type' => 'file', 'writable_on' => 'restrictive'), 'Settings_bak.php' => array('type' => 'file', 'writable_on' => 'restrictive'), 'attachments' => array('type' => 'dir', 'writable_on' => 'restrictive'), 'avatars' => array('type' => 'dir', 'writable_on' => 'standard'), 'cache' => array('type' => 'dir', 'writable_on' => 'restrictive'), 'custom_avatar_dir' => array('type' => 'dir', 'writable_on' => 'restrictive'), 'Smileys' => array('type' => 'dir_recursive', 'writable_on' => 'standard'), 'Sources' => array('type' => 'dir', 'list_contents' => true, 'writable_on' => 'standard'), 'Themes' => array('type' => 'dir_recursive', 'writable_on' => 'standard', 'contents' => array('default' => array('type' => 'dir_recursive', 'list_contents' => true, 'contents' => array('languages' => array('type' => 'dir', 'list_contents' => true))))), 'Packages' => array('type' => 'dir', 'writable_on' => 'standard', 'contents' => array('temp' => array('type' => 'dir'), 'backup' => array('type' => 'dir'), 'installed.list' => array('type' => 'file', 'writable_on' => 'standard'))))));
    // Directories that can move.
    if (substr($sourcedir, 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Sources']);
        $context['file_tree'][strtr($sourcedir, array('\\' => '/'))] = array('type' => 'dir', 'list_contents' => true, 'writable_on' => 'standard');
    }
    // Moved the cache?
    if (substr($cachedir, 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['cache']);
        $context['file_tree'][strtr($cachedir, array('\\' => '/'))] = array('type' => 'dir', 'list_contents' => false, 'writable_on' => 'restrictive');
    }
    // Are we using multiple attachment directories?
    if (!empty($modSettings['currentAttachmentUploadDir'])) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']);
        if (!is_array($modSettings['attachmentUploadDir'])) {
            $modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
        }
        // !!! Should we suggest non-current directories be read only?
        foreach ($modSettings['attachmentUploadDir'] as $dir) {
            $context['file_tree'][strtr($dir, array('\\' => '/'))] = array('type' => 'dir', 'writable_on' => 'restrictive');
        }
    } elseif (substr($modSettings['attachmentUploadDir'], 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']);
        $context['file_tree'][strtr($modSettings['attachmentUploadDir'], array('\\' => '/'))] = array('type' => 'dir', 'writable_on' => 'restrictive');
    }
    if (substr($modSettings['smileys_dir'], 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Smileys']);
        $context['file_tree'][strtr($modSettings['smileys_dir'], array('\\' => '/'))] = array('type' => 'dir_recursive', 'writable_on' => 'standard');
    }
    if (substr($modSettings['avatar_directory'], 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['avatars']);
        $context['file_tree'][strtr($modSettings['avatar_directory'], array('\\' => '/'))] = array('type' => 'dir', 'writable_on' => 'standard');
    }
    if (isset($modSettings['custom_avatar_dir']) && substr($modSettings['custom_avatar_dir'], 0, strlen($boarddir)) != $boarddir) {
        unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['custom_avatar_dir']);
        $context['file_tree'][strtr($modSettings['custom_avatar_dir'], array('\\' => '/'))] = array('type' => 'dir', 'writable_on' => 'restrictive');
    }
    // Load up any custom themes.
    $request = smf_db_query('
		SELECT value
		FROM {db_prefix}themes
		WHERE id_theme > {int:default_theme_id}
			AND id_member = {int:guest_id}
			AND variable = {string:theme_dir}
		ORDER BY value ASC', array('default_theme_id' => 1, 'guest_id' => 0, 'theme_dir' => 'theme_dir'));
    while ($row = mysql_fetch_assoc($request)) {
        if (substr(strtolower(strtr($row['value'], array('\\' => '/'))), 0, strlen($boarddir) + 7) == strtolower(strtr($boarddir, array('\\' => '/')) . '/Themes')) {
            $context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Themes']['contents'][substr($row['value'], strlen($boarddir) + 8)] = array('type' => 'dir_recursive', 'list_contents' => true, 'contents' => array('languages' => array('type' => 'dir', 'list_contents' => true)));
        } else {
            $context['file_tree'][strtr($row['value'], array('\\' => '/'))] = array('type' => 'dir_recursive', 'list_contents' => true, 'contents' => array('languages' => array('type' => 'dir', 'list_contents' => true)));
        }
    }
    mysql_free_result($request);
    // If we're submitting then let's move on to another function to keep things cleaner..
    if (isset($_POST['action_changes'])) {
        return PackagePermissionsAction();
    }
    $context['look_for'] = array();
    // Are we looking for a particular tree - normally an expansion?
    if (!empty($_REQUEST['find'])) {
        $context['look_for'][] = base64_decode($_REQUEST['find']);
    }
    // Only that tree?
    $context['only_find'] = isset($_GET['xml']) && !empty($_REQUEST['onlyfind']) ? $_REQUEST['onlyfind'] : '';
    if ($context['only_find']) {
        $context['look_for'][] = $context['only_find'];
    }
    // Have we got a load of back-catalogue trees to expand from a submit etc?
    if (!empty($_GET['back_look'])) {
        $potententialTrees = unserialize(base64_decode($_GET['back_look']));
        foreach ($potententialTrees as $tree) {
            $context['look_for'][] = $tree;
        }
//.........这里部分代码省略.........
开发者ID:norv,项目名称:EosAlpha,代码行数:101,代码来源:Packages.php

示例7: AdminSearchOM

function AdminSearchOM()
{
    global $context, $sourcedir;
    $docsURL = 'docs.simplemachines.org';
    $context['doc_scripturl'] = 'http://docs.simplemachines.org/index.php';
    // Set all the parameters search might expect.
    $postVars = array('search' => $context['search_term']);
    // Encode the search data.
    foreach ($postVars as $k => $v) {
        $postVars[$k] = urlencode($k) . '=' . urlencode($v);
    }
    // This is what we will send.
    $postVars = implode('&', $postVars);
    // Get the results from the doc site.
    require_once $sourcedir . '/lib/Subs-Package.php';
    $search_results = fetch_web_data($context['doc_scripturl'] . '?action=search2&xml', $postVars);
    // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded?
    if (!$search_results || preg_match('~<' . '\\?xml\\sversion="\\d+\\.\\d+"\\sencoding=".+?"\\?' . '>\\s*(<smf>.+?</smf>)~is', $search_results, $matches) != true) {
        fatal_lang_error('cannot_connect_doc_site');
    }
    $search_results = $matches[1];
    // Otherwise we simply walk through the XML and stick it in context for display.
    $context['search_results'] = array();
    loadClassFile('Class-Package.php');
    // Get the results loaded into an array for processing!
    $results = new xmlArray($search_results, false);
    // Move through the smf layer.
    if (!$results->exists('smf')) {
        fatal_lang_error('cannot_connect_doc_site');
    }
    $results = $results->path('smf[0]');
    // Are there actually some results?
    if (!$results->exists('noresults') && !$results->exists('results')) {
        fatal_lang_error('cannot_connect_doc_site');
    } elseif ($results->exists('results')) {
        foreach ($results->set('results/result') as $result) {
            if (!$result->exists('messages')) {
                continue;
            }
            $context['search_results'][$result->fetch('id')] = array('topic_id' => $result->fetch('id'), 'relevance' => $result->fetch('relevance'), 'board' => array('id' => $result->fetch('board/id'), 'name' => $result->fetch('board/name'), 'href' => $result->fetch('board/href')), 'category' => array('id' => $result->fetch('category/id'), 'name' => $result->fetch('category/name'), 'href' => $result->fetch('category/href')), 'messages' => array());
            // Add the messages.
            foreach ($result->set('messages/message') as $message) {
                $context['search_results'][$result->fetch('id')]['messages'][] = array('id' => $message->fetch('id'), 'subject' => $message->fetch('subject'), 'body' => $message->fetch('body'), 'time' => $message->fetch('time'), 'timestamp' => $message->fetch('timestamp'), 'start' => $message->fetch('start'), 'author' => array('id' => $message->fetch('author/id'), 'name' => $message->fetch('author/name'), 'href' => $message->fetch('author/href')));
            }
        }
    }
}
开发者ID:norv,项目名称:EosAlpha,代码行数:47,代码来源:Admin.php

示例8: loadPaymentGateways

function loadPaymentGateways()
{
    global $sourcedir;
    $gateways = array();
    if ($dh = opendir($sourcedir)) {
        while (($file = readdir($dh)) !== false) {
            if (is_file($sourcedir . '/' . $file) && preg_match('~^Subscriptions-([A-Za-z\\d]+)\\.php$~', $file, $matches)) {
                // Check this is definitely a valid gateway!
                $fp = fopen($sourcedir . '/' . $file, 'rb');
                $header = fread($fp, 4096);
                fclose($fp);
                if (strpos($header, '// SMF Payment Gateway: ' . strtolower($matches[1])) !== false) {
                    loadClassFile($file);
                    $gateways[] = array('filename' => $file, 'code' => strtolower($matches[1]), 'valid_version' => class_exists(strtolower($matches[1]) . '_payment') && class_exists(strtolower($matches[1]) . '_display'), 'payment_class' => strtolower($matches[1]) . '_payment', 'display_class' => strtolower($matches[1]) . '_display');
                }
            }
        }
    }
    closedir($dh);
    return $gateways;
}
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:21,代码来源:ManagePaid.php

示例9: MaintenanceGameCache

function MaintenanceGameCache()
{
    global $db_prefix, $modSettings, $smcFunc, $context;
    loadClassFile('Class-Package.php');
    updateGameCache();
}
开发者ID:nikop,项目名称:SMF-Arcade,代码行数:6,代码来源:ArcadeMaintenance.php

示例10: PlushSearch2

function PlushSearch2()
{
    global $scripturl, $modSettings, $sourcedir, $txt, $db_connection;
    global $user_info, $context, $options, $messages_request, $boards_can;
    global $excludedWords, $participants, $smcFunc, $search_versions, $searchAPI;
    if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
        fatal_lang_error('loadavg_search_disabled', false);
    }
    // No, no, no... this is a bit hard on the server, so don't you go prefetching it!
    if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
        ob_end_clean();
        header('HTTP/1.1 403 Forbidden');
        die;
    }
    $weight_factors = array('frequency', 'age', 'length', 'subject', 'first_message', 'sticky');
    $weight = array();
    $weight_total = 0;
    foreach ($weight_factors as $weight_factor) {
        $weight[$weight_factor] = empty($modSettings['search_weight_' . $weight_factor]) ? 0 : (int) $modSettings['search_weight_' . $weight_factor];
        $weight_total += $weight[$weight_factor];
    }
    // Zero weight.  Weightless :P.
    if (empty($weight_total)) {
        fatal_lang_error('search_invalid_weights');
    }
    // These vars don't require an interface, they're just here for tweaking.
    $recentPercentage = 0.3;
    $humungousTopicPosts = 200;
    $maxMembersToSearch = 500;
    $maxMessageResults = empty($modSettings['search_max_results']) ? 0 : $modSettings['search_max_results'] * 5;
    // Start with no errors.
    $context['search_errors'] = array();
    // Number of pages hard maximum - normally not set at all.
    $modSettings['search_max_results'] = empty($modSettings['search_max_results']) ? 200 * $modSettings['search_results_per_page'] : (int) $modSettings['search_max_results'];
    // Maximum length of the string.
    $context['search_string_limit'] = 100;
    loadLanguage('Search');
    if (!isset($_REQUEST['xml'])) {
        loadTemplate('Search');
    } else {
        $context['sub_template'] = 'results';
    }
    // Are you allowed?
    isAllowedTo('search_posts');
    require_once $sourcedir . '/Display.php';
    require_once $sourcedir . '/Subs-Package.php';
    // Search has a special database set.
    db_extend('search');
    // Load up the search API we are going to use.
    $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
    if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) {
        fatal_lang_error('search_api_missing');
    }
    loadClassFile('SearchAPI-' . ucwords($modSettings['search_index']) . '.php');
    // Create an instance of the search API and check it is valid for this version of SMF.
    $search_class_name = $modSettings['search_index'] . '_search';
    $searchAPI = new $search_class_name();
    if (!$searchAPI || $searchAPI->supportsMethod('isValid') && !$searchAPI->isValid() || !matchPackageVersion($search_versions['forum_version'], $searchAPI->min_smf_version . '-' . $searchAPI->version_compatible)) {
        // Log the error.
        loadLanguage('Errors');
        log_error(sprintf($txt['search_api_not_compatible'], 'SearchAPI-' . ucwords($modSettings['search_index']) . '.php'), 'critical');
        loadClassFile('SearchAPI-Standard.php');
        $searchAPI = new standard_search();
    }
    // $search_params will carry all settings that differ from the default search parameters.
    // That way, the URLs involved in a search page will be kept as short as possible.
    $search_params = array();
    if (isset($_REQUEST['params'])) {
        // Due to IE's 2083 character limit, we have to compress long search strings
        $temp_params = base64_decode(str_replace(array('-', '_', '.'), array('+', '/', '='), $_REQUEST['params']));
        // Test for gzuncompress failing
        $temp_params2 = @gzuncompress($temp_params);
        $temp_params = explode('|"|', !empty($temp_params2) ? $temp_params2 : $temp_params);
        foreach ($temp_params as $i => $data) {
            @(list($k, $v) = explode('|\'|', $data));
            $search_params[$k] = $v;
        }
        if (isset($search_params['brd'])) {
            $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
        }
    }
    // Store whether simple search was used (needed if the user wants to do another query).
    if (!isset($search_params['advanced'])) {
        $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
    }
    // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
    if (!empty($search_params['searchtype']) || !empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2) {
        $search_params['searchtype'] = 2;
    }
    // Minimum age of messages. Default to zero (don't set param in that case).
    if (!empty($search_params['minage']) || !empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0) {
        $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
    }
    // Maximum age of messages. Default to infinite (9999 days: param not set).
    if (!empty($search_params['maxage']) || !empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999) {
        $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
    }
    // Searching a specific topic?
    if (!empty($_REQUEST['topic'])) {
        $search_params['topic'] = (int) $_REQUEST['topic'];
//.........这里部分代码省略.........
开发者ID:chenhao6593,项目名称:smf,代码行数:101,代码来源:Search.php

示例11: loadSearchAPIs

function loadSearchAPIs()
{
    global $sourcedir, $txt;
    $apis = array();
    if ($dh = opendir($sourcedir)) {
        while (($file = readdir($dh)) !== false) {
            if (is_file($sourcedir . '/' . $file) && preg_match('~SearchAPI-([A-Za-z\\d_]+)\\.php~', $file, $matches)) {
                // Check this is definitely a valid API!
                $fp = fopen($sourcedir . '/' . $file, 'rb');
                $header = fread($fp, 4096);
                fclose($fp);
                if (strpos($header, '* SearchAPI-' . $matches[1] . '.php') !== false) {
                    loadClassFile($file);
                    $index_name = strtolower($matches[1]);
                    $search_class_name = $index_name . '_search';
                    $searchAPI = new $search_class_name();
                    // No Support?  NEXT!
                    if (!$searchAPI->is_supported) {
                        continue;
                    }
                    $apis[$index_name] = array('filename' => $file, 'setting_index' => $index_name, 'has_template' => in_array($index_name, array('custom', 'fulltext', 'standard')), 'label' => $index_name && isset($txt['search_index_' . $index_name]) ? $txt['search_index_' . $index_name] : '', 'desc' => $index_name && isset($txt['search_index_' . $index_name . '_desc']) ? $txt['search_index_' . $index_name . '_desc'] : '');
                }
            }
        }
    }
    closedir($dh);
    return $apis;
}
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:28,代码来源:ManageSearch.php

示例12: updateGameCache

function updateGameCache()
{
    global $scripturl, $txt, $db_prefix, $modSettings, $context, $sourcedir, $smcFunc, $boarddir;
    // Clear entries
    $smcFunc['db_query']('truncate_table', '
		TRUNCATE {db_prefix}arcade_files');
    require_once $sourcedir . '/Subs-Package.php';
    loadClassFile('Class-Package.php');
    // Try to get more memory
    @ini_set('memory_limit', '128M');
    // Do actual update
    gameCacheInsertGames(getAvailableGames());
    updateSettings(array('arcadeDBUpdate' => time()));
}
开发者ID:nikop,项目名称:SMF-Arcade,代码行数:14,代码来源:Subs-ArcadeAdmin.php

示例13: loadArcade

    /**
     *
     */
    public static function loadArcade($mode = 'normal', $index = '')
    {
        global $db_prefix, $scripturl, $txt, $modSettings, $context, $settings, $sourcedir, $user_info;
        global $smcFunc, $boarddir;
        static $loaded = false;
        if (!empty($loaded)) {
            return;
        }
        spl_autoload_register(array('SMFArcade', 'autoload'));
        $loaded = true;
        $context['arcade'] = array();
        require_once $sourcedir . '/Subs-Arcade.php';
        // Load language
        loadLanguage('Arcade');
        // Permission query
        arcadePermissionQuery();
        // Normal mode
        if ($mode == 'normal' || $mode == 'arena') {
            if (empty($modSettings['arcadeEnabled'])) {
                return false;
            }
            loadTemplate('Arcade', array('forum', 'arcade'));
            $user_info['arcade_settings'] = loadArcadeSettings($user_info['id']);
            $context['games_per_page'] = !empty($user_info['arcade_settings']['gamesPerPage']) ? $user_info['arcade_settings']['gamesPerPage'] : $modSettings['gamesPerPage'];
            $context['scores_per_page'] = !empty($user_info['arcade_settings']['scoresPerPage']) ? $user_info['arcade_settings']['scoresPerPage'] : $modSettings['scoresPerPage'];
            if (!empty($modSettings['arcadeSkipJquery'])) {
                $context['html_headers'] .= '<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/arcade/jquery.js"></script>';
            }
            // Arcade javascript
            $context['html_headers'] .= '<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/arcade/main.js"></script>';
            // Add Arcade to link tree
            $context['linktree'][] = array('url' => $scripturl . '?action=arcade', 'name' => $txt['arcade']);
            // What I can do?
            $context['arcade']['can_play'] = allowedTo('arcade_play');
            $context['arcade']['can_favorite'] = !empty($modSettings['arcadeEnableFavorites']) && !$user_info['is_guest'];
            $context['arcade']['can_rate'] = !empty($modSettings['arcadeEnableRatings']) && !$user_info['is_guest'];
            $context['arcade']['can_submit'] = allowedTo('arcade_submit');
            $context['arcade']['can_comment_own'] = allowedTo('arcade_comment_own');
            $context['arcade']['can_comment_any'] = allowedTo('arcade_comment_any');
            $context['arcade']['can_admin_arcade'] = allowedTo('arcade_admin');
            $context['arcade']['can_create_match'] = allowedTo('arcade_create_match');
            $context['arcade']['can_join_match'] = allowedTo('arcade_join_match');
            // Or can I (do I have enought posts etc.)
            PostPermissionCheck();
            // Finally load Arcade Settings
            LoadArcadeSettings();
            if (!isset($_REQUEST['xml'])) {
                $context['template_layers'][] = 'Arcade';
            }
        } elseif ($mode == 'profile') {
            loadTemplate('ArcadeProfile', array('arcade', 'forum'));
        } elseif ($mode == 'admin') {
            loadTemplate('ArcadeAdmin');
            loadLanguage('ArcadeAdmin');
            $context['html_headers'] .= '
			<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/arcade.js"></script>';
            // Update games database?
            if (file_exists($boarddir . '/Games.xml')) {
                loadClassFile('Class-Package.php');
                $games = new xmlArray(file_get_contents($boarddir . '/Games.xml'));
                $database = $games->path('smf/database');
                $database = $database->to_array();
                $xmlGames = $games->set('smf/game');
                if (!empty($modSettings['arcadeGameDatabaseVersion']) && $modSettings['arcadeGameDatabaseVersion'] > $database['version']) {
                    break;
                }
                $games = array();
                foreach ($xmlGames as $game) {
                    $games[] = array($game->fetch('id'), $game->fetch('name'), $game->fetch('description'), $game->fetch('url/info'), $game->fetch('url/download'));
                }
                $smcFunc['db_insert']('replace', '{db_prefix}arcade_game_info', array('internal_name' => 'string', 'game_name' => 'string', 'description' => 'string', 'info_url' => 'string', 'download_url' => 'string'), $games, array('internal_name'));
                updateSettings(array('arcadeGameDatabaseVersion' => $database['version'], 'arcadeGameDatabaseUpdate' => $database['update']));
                @unlink($boarddir . '/Games.xml');
            }
            $context['template_layers'][] = 'ArcadeAdmin';
            $context['page_title'] = $txt['arcade_admin_title'];
        }
    }
开发者ID:nikop,项目名称:SMF-Arcade,代码行数:81,代码来源:Arcade.php

示例14: initRelated

function initRelated()
{
    global $context, $modSettings;
    // Already initialized?
    if (isset($context['relatedClass'])) {
        return true;
    }
    $context['rt_ignore'] = empty($modSettings['relatedIgnoredboards']) ? array() : explode(',', $modSettings['relatedIgnoredboards']);
    // Recycle board should be ignored by default
    if (!empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board'])) {
        $context['rt_ignore'][] = $modSettings['recycle_board'];
    }
    // Make sure each board is only one time there
    $context['rt_ignore'] = array_unique($context['rt_ignore']);
    // No methods selected? No need to do this then
    if (empty($modSettings['relatedIndex'])) {
        return false;
    }
    $context['relatedClass'] = array();
    $relatedIndexes = explode(',', $modSettings['relatedIndex']);
    foreach ($relatedIndexes as $indexType) {
        $indexType = ucwords($modSettings['relatedIndex']);
        $class = 'RelatedTopics' . $indexType;
        loadClassFile('Subs-Related' . $indexType . '.php');
        $context['relatedClass'][] = new $class();
    }
    if (empty($context['relatedClass'])) {
        return false;
    }
    return true;
}
开发者ID:ahrasis,项目名称:Related-Topics,代码行数:31,代码来源:Subs-Related.php


注:本文中的loadClassFile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。