本文整理汇总了PHP中XMPP_ERROR_trigger函数的典型用法代码示例。如果您正苦于以下问题:PHP XMPP_ERROR_trigger函数的具体用法?PHP XMPP_ERROR_trigger怎么用?PHP XMPP_ERROR_trigger使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了XMPP_ERROR_trigger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: umc_vote_get_votable
/**
* This function displays the proposals the user has not voted on yet. It's displayed on user login
**/
function umc_vote_get_votable($username = false, $web = false)
{
XMPP_ERROR_trace(__FUNCTION__, func_get_args());
global $UMC_DOMAIN, $vote_ranks, $UMC_USER;
$out = '';
if (!$username) {
$username = $UMC_USER['username'];
$uuid = $UMC_USER['uuid'];
} else {
$uuid = umc_uuid_getone($username, 'uuid');
}
if (!$username && !isset($UMC_USER['username'])) {
XMPP_ERROR_trigger("websend player undidentified");
}
$user_lvl = umc_get_userlevel($username);
$user_lvl_id = $vote_ranks[$user_lvl]['lvl'];
if ($user_lvl_id < 3) {
// start voting only for designers
return;
}
$sql = "SELECT proposals.pr_id, proposals.uuid, proposals.date, 60 - DATEDIFF(NOW(), proposals.date) as remainder, UUID.username as username FROM minecraft_srvr.proposals\r\n LEFT JOIN minecraft_srvr.proposals_votes ON proposals.pr_id=proposals_votes.pr_id AND voter_uuid='{$uuid}'\r\n LEFT JOIN minecraft_srvr.UUID ON proposals.uuid=UUID.UUID\r\n WHERE proposals_votes.pr_id IS NULL AND status='voting' ORDER BY proposals.`date` ASC";
$D = umc_mysql_fetch_all($sql);
$no_votes = array();
// echo $sql;
foreach ($D as $row) {
$proposal = $row['uuid'];
$proposal_username = $row['username'];
$prop_lvl = umc_get_uuid_level($proposal);
$prop_lvl_id = $vote_ranks[$prop_lvl]['lvl'];
if ($prop_lvl_id < $user_lvl_id) {
$days_left = $row['remainder'];
$no_votes[$proposal_username] = $days_left;
}
}
if (count($no_votes) > 0) {
if ($web) {
$out .= "<strong><a href=\"{$UMC_DOMAIN}/vote-for-users/\">Please vote</a>:</strong> (" . count($no_votes) . ") ";
foreach ($no_votes as $proposee => $days) {
$out .= "{$proposee}, ";
}
$out = rtrim($out, ", ");
return $out;
} else {
umc_header('Your missing votes: (days remaining)', true);
foreach ($no_votes as $proposee => $days) {
$out .= "{red}{$proposee} {grey}({$days}){white}, ";
}
umc_echo($out, true);
umc_echo("{gold}Please vote ASAP! Only YOU can determine the future of the server! {$UMC_DOMAIN}/vote-for-users/", true);
umc_footer(true);
}
} else {
return false;
}
}
示例2: umc_lot_mod
function umc_lot_mod()
{
global $UMC_USER;
$player = $UMC_USER['username'];
$args = $UMC_USER['args'];
/// /lotmember lot world add target
$addrem = $args[3];
$lot = strtolower($args[2]);
if (count($args) <= 2) {
umc_echo("Too few arguments!");
umc_show_help($args);
return;
}
$world = 'flatlands';
$user_id = umc_get_worldguard_id('user', strtolower($player));
if (!$user_id) {
umc_error("Your user id cannot be found!");
}
$player_group = umc_get_userlevel($player);
$world_id = umc_get_worldguard_id('world', $world);
if (!$world_id) {
umc_error("The lot '{$lot}' cannot be found in any world!");
}
if (!umc_check_lot_exists($world_id, $lot)) {
umc_error("There is no lot {$lot} in world {$world};");
}
if ($player_group !== 'Owner' && $player_group !== 'Elder' && $player_group !== 'ElderDonator' && $player_group !== 'ElderDonatorPlus') {
umc_error("You are not Elder or Owner, you are {$player_group}!");
}
if ($addrem == 'add') {
$sql_ins = "INSERT INTO minecraft_worldguard.region_players (`region_id`, `world_id`, `user_id`, `Owner`)\r\n VALUES ('{$lot}', '{$world_id}', {$user_id}, 0);";
umc_mysql_query($sql_ins, true);
umc_echo("Added you to {$lot} in the {$world}!");
} else {
if ($addrem == 'rem') {
// check if target is there at all
$sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$user_id} AND Owner=0 LIMIT 1;";
$D = umc_mysql_fetch_all($sql);
if (count($D) !== 1) {
umc_error("It appears you are not a member of lot {$lot} in world {$world}!");
}
$sql_del = "DELETE FROM minecraft_worldguard.region_players WHERE region_id = '{$lot}' AND world_id = {$world_id} AND user_id = {$user_id} AND Owner=0;";
umc_mysql_query($sql_del, true);
umc_echo("Removed you from {$lot} in the {$world}!");
} else {
umc_error("You can only use [add] or [rem], not {$args[1]}!");
}
}
umc_ws_cmd('region load -w flatlands', 'asConsole');
umc_log('lot', 'mod', "{$player} added himself to lot {$lot} to fix something");
XMPP_ERROR_trigger("{$player} added himself to lot {$lot} to fix something");
}
示例3: unc_gallery_admin_init
/**
* This adds the Wordpress features for the admin pages
*
* @global type $UNC_GALLERY
*/
function unc_gallery_admin_init()
{
global $UNC_GALLERY;
if ($UNC_GALLERY['debug']) {
XMPP_ERROR_trace(__FUNCTION__, func_get_args());
}
add_settings_section('unc_gallery_pluginPage_section', __('Settings', 'wordpress'), 'unc_gallery_settings_section_callback', 'unc_gallery_settings_page');
// we iterate the plugin settings and creat the menus dynamically from there
foreach ($UNC_GALLERY['user_settings'] as $setting => $D) {
$prefix = $UNC_GALLERY['settings_prefix'];
register_setting('unc_gallery_settings_page', $prefix . $setting);
$setting_value = get_option($prefix . $setting, $D['default']);
$args = array('setting' => $prefix . $setting, 'value' => $setting_value, 'help' => $D['help'], 'default' => $D['default']);
if ($D['type'] == 'text') {
$callback = 'unc_gallery_setting_text_field_render';
} else {
if ($D['type'] == 'dropdown') {
$callback = 'unc_gallery_setting_drodown_render';
$args['options'] = $D['options'];
} else {
if ($D['type'] == 'multiple') {
$callback = 'unc_gallery_setting_multiple_render';
$args['options'] = $D['options'];
} else {
if ($UNC_GALLERY['debug']) {
if ($UNC_GALLERY['debug']) {
XMPP_ERROR_trigger("Illegal option type " . $D['type']);
}
}
}
}
}
add_settings_field($prefix . $setting, __($D['title'], 'wordpress'), $callback, 'unc_gallery_settings_page', 'unc_gallery_pluginPage_section', $args);
}
// check if the upload folder exists:
$dirPath = $UNC_GALLERY['upload_path'];
if (!file_exists($dirPath)) {
echo unc_display_errormsg("The upload folder {$dirPath} does not exist!");
unc_gallery_plugin_activate();
}
}
示例4: umc_timer_from_json
/**
* Converts a JSON date to a DateTime Object
*
* @param string $json_date
* @return DateTimeObj or false
*/
function umc_timer_from_json($json_date)
{
XMPP_ERROR_trace(__FUNCTION__, func_get_args());
// do we have a timezone string or not?
if (strlen($json_date) == 13) {
$json_date .= "-0000";
}
//1433044095000 <- No timezone
//1365004652303-0500 <- timezone
$pattern = '/(\\d{10})(\\d{3})([\\+\\-]\\d{4})/';
$format = "U.u.O";
$mask = '%2$s.%3$s.%4$s';
$matches = false;
$r = preg_match($pattern, $json_date, $matches);
if (!$r) {
XMPP_ERROR_trigger("Failed to match date in {$json_date}");
}
$buffer = vsprintf($mask, $matches);
$result = DateTime::createFromFormat($format, $buffer);
if (!$result) {
XMPP_ERROR_trigger(sprintf('Failed To Create from Format "%s" for "%s".', $format, $buffer));
}
return $result;
}
示例5: umc_settler_new
//.........这里部分代码省略.........
umc_log('settler_test', 'step_5', "{$player} is at step 5");
$out .= "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . "<h1>Step 6: Get to the {$world} world</h1>";
// check if the player is actually in the portal house
// player is not in portal house
if ($player_world != 'city' || $x > 953 || $x < 938 || $z < -814 || $z > -793) {
$out .= "You need to be in the portal house to continue. Please type <strong>/warp spawn</strong> again to get there. " . "It should look like this inside:<br><img src=\"/websend/portals.png\"> Once you see this, press\n" . "<input type=\"submit\" name=\"Next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"step\" value=\"5\">\n";
} else {
$out .= "Since you chose a lot in the {$world} world, you need to go through the {$world} portal. " . "It looks like this: Notice the name of the world is written on the sign." . "<img src=\"/websend/{$world}_portal.png\">" . "Please step through and press " . "<input type=\"submit\" name=\"Next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"step\" value=\"6\">\n";
}
break;
case 6:
umc_log('settler_test', 'step_6', "{$player} is at step 6");
$spawn_lot = strtoupper($UMC_SETTING['world_data'][$world]['spawn']);
$lower_lot = strtolower($lot);
$lot_sql = "SELECT region_cuboid.region_id AS lot, sqrt(pow(max_x,2)+pow(max_z,2)) AS distance, max_x, max_z\r\n FROM minecraft_worldguard.world\r\n LEFT JOIN minecraft_worldguard.region_cuboid ON world.id=region_cuboid.world_id\r\n WHERE region_cuboid.region_id='{$lower_lot}';";
$D = umc_mysql_fetch_all($lot_sql);
$lot_data = $D[0];
// north/south difference
if ($lot_data['max_x'] < 0) {
$direction1 = "north";
} else {
if ($lot_data['max_x'] >= 0) {
$direction1 = "south";
}
}
// north/south difference
if ($lot_data['max_z'] < 0) {
$direction2 = "west";
} else {
if ($lot_data['max_z'] >= 0) {
$direction2 = "east";
}
}
$out .= "<form action=\"{$UMC_DOMAIN}/admin/index.php?function=create_map&world={$world}&freeonly=true\" method=\"post\">\n" . "<h1>Step 7: Getting to lot {$lot} in the {$world} world</h1>" . "Getting to your world is easy! You are now at the center of the {$world} world." . "Your lot is <strong>{$direction1}/{$direction2}</strong> from spawn! <br>" . "You can find out which direction you are looking with the <strong>/compass</strong> command.<br>" . "As a Guest level player, you cannot be killed by mobs until you finished this here.<br>" . "So you have to leave the spawn lot either through the {$direction1} or the {$direction2} exit.<br>" . "To know where you are, you can follow your icon {$user_icon} on the map while you get around.<br>" . "Please click NEXT to open the map, there you find your icon click the button next to it!<br><br>" . "<input type=\"submit\" name=\"next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"track_player\" value=\"{$player}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n";
$x = $loc[$player]['x'];
$z = $loc[$player]['z'];
break;
case 7:
umc_log('settler_test', 'step_7', "{$player} is at step 7");
// whereami
$out .= "<h1>Step 8: Find out where you are in-game</h1>" . "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . "Now that you know how to find yourself on the map, you need to find out where you are when in-game.<br>" . "The command to find your location in-game is called <strong>/whereami</strong>.<br>" . "Please go into the game and type <strong>/whereami</strong><br>" . "You will see something like this:<br>" . "<img src=\"/websend/whereami.png\"><br>" . "In this example, you can see the Lot (in the first line) is <img src=\"/websend/whereami_detail.png\"> So you would enter 'emp_z7'.<br>" . "Please go now into the game, type <strong>/whereami</strong>, and enter the information here:<br>" . "I am now in lot <input type=\"text\" name=\"check_lot\" value=\"\" size=\"7\"> and then press " . "<input type=\"submit\" name=\"next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"step\" value=\"8\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n";
// enter which lot you are in right now
break;
case 8:
// walk to your lot
umc_log('settler_test', 'step_8', "{$player} is at step 8");
$lower_lot = strtolower($lot);
$out .= "<form action=\"{$UMC_DOMAIN}/admin/index.php\" method=\"post\">\n" . "<h1>Step 9: Walk to your lot {$lot}!</h1>" . "Now you have everything you need to get to your lot!<br>You should follow your steps on the 2D map.<br>" . "You can either walk there, or use the command <pre>/lot warp {$lot}</pre> to get there. Please note that this command is only available while you are Guest.<br>" . "Press 'Next' to open the 2D map and follow your icon to lot {$lot}!<br>" . "<input type=\"submit\" name=\"next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"guide_lot\" value=\"{$player}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"freeonly\" value=\"true\">\n" . "<input type=\"hidden\" name=\"function\" value=\"create_map\">\n" . "<input type=\"hidden\" name=\"step\" value=\"9\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lower_lot}\">\n";
break;
case 9:
umc_log('settler_test', 'step_9', "{$player} is at step 9");
// do you like it? claim it
$out .= "<h1>Step 10: Do you like the lot {$s_post['lot']}?</h1>" . "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . '<input type="radio" name="step" value="10" checked>Yes! I take it! I will type <strong>/homes buy ' . $world . '</strong> now so I can warp back here!<br>' . '<input type="radio" name="step" value="1">No,I would like to start over!<br>' . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"submit\" name=\"next\" value=\"Finish!\">\n";
break;
case 10:
umc_log('settler_test', 'step_10', "{$player} is at step 10");
// final confirmation
$out .= "<h1>Step 11: Congratulations!</h1>" . "You have been promoted to Settler!<br>";
if ($userlevel == 'Guest') {
$cmd = "pex promote {$UMC_USER['uuid']}";
umc_exec_command($cmd);
// update UUID database
$sql = "UPDATE minecraft_srvr.UUID SET userlevel='Settler' WHERE UUID='{$UMC_USER['uuid']}';";
umc_mysql_query($sql);
umc_exec_command('pex reload');
umc_exec_command("ch qm u Congrats {$player} for becoming Settler!");
XMPP_ERROR_send_msg("{$userlevel} {$player} got promoted with command " . $cmd);
umc_log('settler_test', 'promotion', "{$player} ({$UMC_USER['uuid']})was promoted to settler (new test)");
$headers = "From: minecraft@uncovery.me\r\n" . "Reply-To: minecraft@uncovery.me\r\n" . 'X-Mailer: PHP/' . phpversion();
$subject = "[Uncovery Minecraft] Settler applicaton";
$mailtext = "The user: {$player} (email: {$email}) was promoted to Settler and got lot {$lot}.\n\n";
$check = mail('minecraft@uncovery.me', $subject, $mailtext, $headers);
if (!$check) {
XMPP_ERROR_trigger("The settler promotion email could not be sent!");
}
// check userlevel to make sure
$new_level = umc_get_userlevel($player);
if ($new_level != 'Settler') {
XMPP_ERROR_trigger("{$userlevel} {$player} did NOT got promoted with command " . $cmd . " he's still {$new_level}");
}
} else {
$out .= "Thanks for taking this test! Since you are {$userlevel} already, we will not promote you to Settler.<br>";
}
// try to assign the lot
$check = umc_lot_manager_check_before_assign($uuid, $lot);
$out .= "Trying to assign this lot to you: <strong>{$check['text']}</strong><br>";
if ($check['result'] == false) {
XMPP_ERROR_send_msg("Settler Test lot assignment failed!");
$out .= "There was an error giving the lot you reserved to you. You can get any other through your <a hreaf=\"{$UMC_DOMAIN}/server-access/lot-manager/\">lot manager</a>!<br>";
} else {
umc_lot_add_player($uuid, $lot, 1, $check['cost']);
$out .= $check['text'];
}
break;
default:
$out .= "This option was not recognized, please reload the page!";
}
$out .= "</form>\n";
return $out;
}
示例6: umc_lot_addrem
//.........这里部分代码省略.........
$count = count($D2);
if ($count == 0) {
// insert
$ins_sql = "INSERT INTO minecraft_worldguard.region_flag (region_id, world_id, flag, value) VALUES ('{$lot}', {$world_id}, '{$flagname}', '{$flag}');";
umc_mysql_query($ins_sql, true);
} else {
// update
$upd_sql = "UPDATE minecraft_worldguard.region_flag SET value='{$flag}' WHERE region_id='{$lot}' AND world_id={$world_id} AND flag='{$flagname}';";
umc_mysql_query($upd_sql, true);
}
umc_echo("done!");
umc_log('lot', 'addrem', "{$player} changed {$action} property of {$lot}");
} else {
if ($action == 'owner' || $action == 'give') {
if ($player != 'uncovery' && $player != '@Console') {
umc_error("Nice try, {$player}. Think I am stupid? Want to get banned?");
}
$owner_switch = 1;
} else {
if ($action == 'member') {
$user_id = umc_get_worldguard_id('user', strtolower($player));
if (!$user_id && $player !== 'uncovery') {
umc_error("Your user id cannot be found!");
}
$owner_switch = 0;
// check if player is Owner of lot
if ($player_group !== 'Owner') {
$sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$user_id} and Owner=1;";
$D3 = umc_mysql_fetch_all($sql);
$count = count($D3);
if ($count != 1) {
umc_error("It appears you ({$player} {$user_id}) are not Owner of lot {$lot} in world {$world}!");
}
}
} else {
umc_echo("Action {$action} not recognized!");
umc_show_help($args);
return;
}
}
// get list of active users
$active_users = umc_get_active_members();
for ($i = 4; $i < count($args); $i++) {
$target = strtolower($args[$i]);
// check if target player exists
$target_id = umc_get_worldguard_id('user', strtolower($target));
if (!$target_id) {
umc_error("The user {$target} does not exist in the database. Please check spelling of username");
}
if ($player != 'uncovery') {
$targ_group = umc_get_userlevel($target);
if ($targ_group == 'Guest') {
umc_error("You cannnot add Guests to your lot!;");
} else {
if (!in_array($target, $active_users)) {
XMPP_ERROR_trigger("{$player} tried to add {$target} to his lot {$lot}, but {$target} is not an active member!");
umc_error("{$target} is not an active user! You can only add people who have their own lot! See FAQ entry #32 please.");
}
}
}
// add / remove target player from lot
if ($addrem == 'add') {
// make sure target is not already there
$sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$target_id};";
$D3 = umc_mysql_fetch_all($sql);
$num = count($D3);
if ($num == 1) {
umc_error("It appears {$target} is already member of lot {$lot} in world {$world}!");
}
// add to the lot
umc_lot_add_player($target, $lot, 0);
umc_echo("Added {$target} to {$lot} in the {$world}!");
} else {
if ($addrem == 'rem') {
// check if target is there at all
$sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$target_id} AND Owner={$owner_switch} LIMIT 1;";
$D3 = umc_mysql_fetch_all($sql);
$num = count($D3);
if ($num !== 1) {
umc_error("It appears user {$target} is not a member of lot {$lot} in world {$world}!");
}
umc_lot_rem_player($target, $lot, 0);
umc_echo("Removed {$target} from {$lot} in the {$world}!");
} else {
if ($addrem == 'give') {
// remove all members and owners
umc_lot_remove_all($lot);
umc_lot_add_player($target, $lot, 1);
umc_echo("Gave {$lot} to {$target} in the {$world}! All other user removed!");
// logfile entry
umc_log('lot', 'addrem', "{$player} gave lot to {$target}");
} else {
umc_show_help($args);
}
}
}
}
}
umc_ws_cmd("region load -w {$world}", 'asConsole');
}
示例7: umc_web_table
/**
*
* @param string $table_name name of the table to enable several per page
* @param string $sort_column initial sorting column, format "7, 'desc'"
* @param misc $data recordset of all data in the table or array
* @param string $pre_table html to insert before table
* @param int $hide_cols one colums to hide
* @param array $non_numeric_cols names of columens that are not numerical
* @param array array('column' => 'function');
* @return string
*/
function umc_web_table($table_name, $sort_column, $data, $pre_table = '', $hide_cols = array(), $non_numeric_cols = false, $formats = false)
{
$headers = '';
if (!$non_numeric_cols) {
// default numeric cols if nothing else defined
// this should disappear once all inputing functions are updated
$non_numeric_cols = array('username', 'item', 'buyer', 'seller', 'meta', 'item_name');
}
$numeric_columns = array();
if (is_array($data)) {
if (count($data) == 0) {
return "{$pre_table}<br>No data found<hr>";
}
$keys = array_keys(current($data));
} else {
XMPP_ERROR_trigger("Data type passed to umc_web_table is not array!");
return '';
}
$counter = 0;
foreach ($keys as $col) {
if (in_array($col, $hide_cols)) {
continue;
} else {
$style = "style='text-align:left'";
$input_class = "";
if (!in_array($col, $non_numeric_cols)) {
array_push($numeric_columns, $counter);
$style = "style='text-align:right'";
$input_class = " numeric";
}
$headers .= "<th {$style}>" . umc_pretty_name($col) . "</th>\n";
$counter++;
}
}
$data_out = '';
foreach ($data as $row) {
$data_out .= umc_web_table_create_line($row, $numeric_columns, $formats, $hide_cols);
}
$numeric_columns_str = implode(",", $numeric_columns);
$out = "<script type=\"text/javascript\">\n var table_name = \"{$table_name}\";\n var numeric_columns = [{$numeric_columns_str}];\n var sort_columns = [[{$sort_column}]];\n var strnum_columns = [];\n </script>";
$out .= "<script type=\"text/javascript\" src=\"/admin/js/jquery.dataTables.min.js\"></script>\n" . "<script type=\"text/javascript\">" . 'jQuery(document).ready(function() {jQuery' . "('#shoptable_{$table_name}').dataTable( {\"autoWidth\": false, \"order\": [[ {$sort_column} ]],\"paging\": false,\"ordering\": true,\"info\": false} );;} );" . "</script>";
$out .= "{$pre_table}\n <table id='shoptable_{$table_name}'>\n <thead>\n <tr>\n {$headers}\n </tr>\n </thead>\n <tbody>\n {$data_out}\n </tbody>\n </table>";
return $out;
}
示例8: unc_display_images
/**
* Open a folder of a certain date and display all the images in there
*
* @global type $UNC_GALLERY
* @return string
*/
function unc_display_images()
{
global $UNC_GALLERY;
if ($UNC_GALLERY['debug']) {
XMPP_ERROR_trace(__FUNCTION__);
}
$D = $UNC_GALLERY['display'];
$header = '';
if (isset($D['dates'])) {
$date_str = $D['dates'][0];
if (current_user_can('manage_options') && is_admin()) {
$url = admin_url('admin.php?page=unc_gallery_admin_menu');
$header .= "\r\n <span class=\"delete_folder_link\">\r\n Sample shortcode for this day: <input id=\"short_code_sample\" onClick=\"SelectAll('short_code_sample');\" type=\"text\" value=\"[unc_gallery date="{$date_str}"]\">\r\n <a href=\"{$url}&folder_del={$date_str}\">\r\n Delete Date: {$date_str}\r\n </a>\r\n </span>\n";
}
}
// get all the files in the folder with attributes
$files = $D['files'];
// display except for skipped files and files out of time range
$images = '';
$featured = '';
$featured_fixed = false;
if ($UNC_GALLERY['featured_size_for_mixed_sizes'] != 'dynamic' && count($D['featured_image']) > 1) {
$featured_fixed = $UNC_GALLERY['featured_size_for_mixed_sizes'];
}
/*if ($D['slideshow']) {
$images .= '<ul id="lightSlider">';
} */
$i = 0;
// limit images
$max_images = intval($D['limit_images']);
$counter = 0;
foreach ($files as $F) {
// stop looping once we have the max number of images
if ($max_images && $i >= $max_images) {
break;
} else {
if ($max_images && $i == $max_images - 1) {
$not_shown = count($files) - $max_images;
if ($not_shown > 0) {
$UNC_GALLERY['not_shown'] = $not_shown;
}
}
}
$F['index'] = $i;
if (!$D['slideshow'] && $F['featured']) {
// select size for featured images
if ($featured_fixed) {
$feat_size = $featured_fixed;
} else {
if ($UNC_GALLERY['featured_size'] != 'dynamic') {
$feat_size = $UNC_GALLERY['featured_size'];
} else {
if ($F['orientation'] == 'portrait') {
$feat_size = $UNC_GALLERY['featured_size_for_portrait'];
} else {
$feat_size = $UNC_GALLERY['featured_size_for_landscape'];
}
}
}
$height_css = 'rows_' . $feat_size;
$counter++;
$featured .= "<div class=\"featured_photo {$height_css}\">\n" . unc_display_image_html($F['file_path'], false, $F) . "</div>\n";
/*} else if ($Df['slideshow']) { // slideshow does not have features
$images .= "<li>\n"
. unc_display_image_html($F['file_path'], false, $F)
. '<p>' . unc_tools_file_desc($F) . '</p>'
. "</li>\n";*/
} else {
$counter++;
$images .= "<div class=\"one_photo\">\n" . unc_display_image_html($F['file_path'], true, $F) . "</div>\n";
}
$i++;
}
/* if ($D['slideshow']) {
$images .= '</ul>';
} **/
$photoswipe = '';
if ($UNC_GALLERY['image_view_method'] == 'photoswipe') {
$photoswipe = unc_display_photoswipe_js($files);
}
if ($UNC_GALLERY['post_keywords'] != 'none') {
$check_tags = unc_tags_apply($files);
if ($check_tags) {
if ($UNC_GALLERY['debug']) {
XMPP_ERROR_trigger("Tags have been updated");
}
}
}
if ($UNC_GALLERY['post_categories'] != 'none') {
$check_cats = unc_categories_apply($files);
if ($check_cats) {
if ($UNC_GALLERY['debug']) {
XMPP_ERROR_send_msg("Categories have been updated");
}
//.........这里部分代码省略.........
示例9: umc_donation_level
function umc_donation_level($user, $debug = false)
{
XMPP_ERROR_trace(__FUNCTION__, func_get_args());
$U = umc_uuid_getboth($user);
$uuid = $U['uuid'];
$username = $U['username'];
$debug_txt = '';
global $UMC_SETTING;
$date_now = new DateTime("now");
$sql = "SELECT amount, date FROM minecraft_srvr.donations WHERE uuid='{$uuid}';";
$level = umc_get_uuid_level($uuid);
if ($level == 'Owner') {
return false;
}
$D = umc_mysql_fetch_all($sql);
// if there are 0 donations, user should not be changes
if (count($D) == 0 && strstr($level, "Donator")) {
XMPP_ERROR_trigger("User {$username} ({$uuid}) never donated but has a donator level ({$level})");
} else {
if (count($D) == 0) {
$debug_txt .= "{$username} ({$uuid}) does not have any donations\n";
return;
}
}
$debug_txt .= "Checking donation upgrade of user {$username}, current UserLevel: {$level}\n";
$donation_level = 0;
// go through all donations and find out how much is still active
foreach ($D as $row) {
$date_donation = new DateTime($row['date']);
$interval = $date_donation->diff($date_now);
$years = $interval->format('%y');
$months = $interval->format('%m');
$donation_term = $years * 12 + $months;
$donation_leftover = $row['amount'] - $donation_term;
if ($donation_leftover < 0) {
$donation_leftover = 0;
// do not create negative carryforward
}
$donation_level = $donation_level + $donation_leftover;
$debug_txt .= "Amount donated {$row['amount']} {$years} years {$months} m ago = {$donation_term} months ago, {$donation_leftover} leftover, level: {$donation_level}\n";
}
$donation_level_rounded = ceil($donation_level);
// get userlevel and check if demotion / promotion is needed
$debug_txt .= "user {$username} ({$uuid}) has donation level of {$donation_level_rounded}, now is {$level}\n";
// current userlevel
$ranks_lvl = array_flip($UMC_SETTING['ranks']);
$cur_lvl = $ranks_lvl[$level];
// get current promotion level
if (strpos($level, 'DonatorPlus')) {
$current = 2;
} else {
if (strpos($level, 'Donator')) {
$current = 1;
} else {
$current = 0;
}
}
// get future promotion level
if (count($D) == 0) {
// this never happens since it's excluded above
$future = 0;
} else {
if ($donation_level_rounded >= 1) {
$future = 2;
} else {
if ($donation_level_rounded < 1) {
$future = 1;
}
}
}
$debug_txt .= "future = {$future}, current = {$current}\n";
$change = $future - $current;
if ($change == 0) {
$debug_txt .= "User has right level, nothing to do\n";
return false;
// bail if no change needed
} else {
// we have a change in level, let's get an error report
$debug = true;
}
$debug_txt .= "User will change {$change} levels\n";
// get currect rank index
$debug_txt .= "Current Rank index = {$cur_lvl}\n";
// calculate base level
$base_lvl = $cur_lvl - $current;
$debug_txt .= "User base level = {$base_lvl}\n";
$new_lvl = $base_lvl + $future;
if ($new_lvl == $cur_lvl) {
XMPP_ERROR_send_msg("Donations upgrade: Nothing to do, CHECK this should have bailed earlier!");
return false;
}
$new_rank = $UMC_SETTING['ranks'][$new_lvl];
$debug_txt .= "User {$username} upgraded from {$level} to {$new_rank}\n";
umc_exec_command("pex user {$uuid} group set {$new_rank}");
umc_log('Donations', 'User Level de/promotion', "User {$username} upgraded from {$level} to {$new_rank}");
if ($debug) {
XMPP_ERROR_send_msg($debug_txt);
}
return $donation_level_rounded;
// . "($donation_level $current - $future - $change)";
//.........这里部分代码省略.........
示例10: umc_get_icons
/**
* This downloads all icons from Minecraft Wiki and stores it on the website
*
* @global array $UMC_DATA_ID2NAME
*/
function umc_get_icons()
{
global $UMC_DATA, $UMC_PATH_MC;
$base_url = 'http://hydra-media.cursecdn.com/minecraft.gamepedia.com';
$base_path = "{$UMC_PATH_MC}/server/bin/data/icons/";
$img_arr = array();
foreach ($UMC_DATA as $item => $D) {
if (isset($D['subtypes'])) {
foreach ($D['subtypes'] as $id => $S) {
if ($S['icon_url'] != '?') {
$img_arr[$S['name']] = $base_url . $S['icon_url'];
}
}
}
if ($D['icon_url'] === '?') {
continue;
} else {
$img_arr[$item] = $base_url . $D['icon_url'];
}
}
// pass all arrays to mass-downloader
$complete_count = count($img_arr);
$D = unc_serial_curl($img_arr);
$failed_icons = array();
foreach ($D as $img => $R) {
if ($R['response']['http_code'] !== 200) {
$failed_icons[] = array('img' => $img, 'url' => $R['response']['url'], 'reason' => "failed to get file from source");
} else {
// assemble target path
$full_url = $R['response']['url'];
$path_info = pathinfo($full_url);
if (!isset($path_info['extension'])) {
XMPP_ERROR_trace("Extension missning for {$img}", $full_url);
}
$ext = $path_info['extension'];
$target_path = $base_path . "{$img}.{$ext}";
// write target file
$written = file_put_contents($target_path, $R['content']);
if (!$written) {
$failed_icons[] = array('img' => $img, 'url' => $R['response']['url'], 'reason' => 'failed to write file to $target_path');
}
}
}
$count = count($failed_icons);
if ($count > 0) {
XMPP_ERROR_trace("failed users:", $failed_icons);
XMPP_ERROR_trigger("Failed to get {$count} of {$complete_count} Block icons, see error report for details");
}
}
示例11: umc_skyblock_challenge_select
function umc_skyblock_challenge_select()
{
global $UMC_USER;
$player = $UMC_USER['username'];
$args = $UMC_USER['args'];
if (!is_numeric($args[2])) {
umc_error("Your challenge ID needs to be a number!");
} else {
$lot_sql = "SELECT region_cuboid.region_id as lot FROM `region_cuboid`\r\n LEFT JOIN region_players ON region_cuboid.region_id=region_players.region_id\r\n WHERE user_id IS NULL\r\n\t\tAND region_cuboid.`region_id` LIKE 'block%'\r\n\t\tAND min_z<-768\r\n\t\tAND min_x>=-1152\r\n\t\tAND max_x<1024;";
$D = umc_mysql_fetch_all($lot_sql);
if (count($D) == 0) {
XMPP_ERROR_trigger("We ran out of challenge lots!");
umc_error("Sorry, there are currently no challenge lots free!");
} else {
$lot_row = $D[0];
$challenge_lot = $lot;
}
$id = $args[2];
$sql = "SELECT * FROM minecraft_quiz.block_challenges WHERE challenge_id={$id};";
$rst = umc_mysql_query($sql);
$row = umc_mysql_fetch_array($rst);
$lot = $row['lot'];
$biome = $row['biome'];
$inventory = $row['inventory'];
$name = $row['name'];
$desc = $row['desc'];
$win_conditions = $row['win_conditions'];
umc_header("Challenge {$id}: {$name}");
umc_echo("{white}{$desc}");
$lot_str = $lot;
if ($lot == null) {
$lot_str = 'standard';
}
umc_echo("{green}Lot type: {white}{$lot_str}");
$biome_str = $biome;
if ($biome == null) {
$biome_str = 'standard';
}
umc_echo("{green}Lot type: {white}{$biome_str}");
if (umc_skyblock_web_display_table($id)) {
umc_echo("{green}Sub challenges: {white}This challenge has subchallenges. Please see the website for details.");
}
$inv_str = umc_skyblock_inv_to_desc($inventory);
umc_echo("{green}Starting Inventory:{white}{$inv_str}");
$winstr = umc_skyblock_inv_to_desc($win_conditions);
umc_echo("{green}Winning conditions:{white}{$winstr}");
$sub_challenge = $row['sub_challenge'];
$challenge = $id;
if ($sub_challenge !== null) {
$challenge = $sub_challenge;
}
$sql = "INSERT INTO `minecraft_quiz`.`block_games` (`game_id`, `username`, `start`, `end`, `status`, `challenge_id`, `sub_challenge_id`, `lot`)\r\n VALUES (NULL, '{$player}', NOW(), NULL, 'selected', '{$challenge}', '{$sub_challenge}', '{$challenge_lot}');";
umc_mysql_query($sql, true);
umc_echo("Please type {green}/skyblock start{white} or {green}/skyblock cancel");
umc_footer();
}
}
示例12: umc_do_deposit_internal
function umc_do_deposit_internal($all = false)
{
global $UMC_USER, $UMC_SETTING, $UMC_DATA;
$player = $UMC_USER['username'];
$uuid = $UMC_USER['uuid'];
$args = $UMC_USER['args'];
// make sure user holds item
$all_inv = $UMC_USER['inv'];
if (!$all) {
$item_slot = $UMC_USER['current_item'];
if (!isset($all_inv[$item_slot])) {
umc_error("{red}You need to hold the item you want to deposit! (current slot: {$item_slot});");
}
$all_inv = array($item_slot => $all_inv[$item_slot]);
}
$sent_out_of_space_msg = 0;
$seen = array();
foreach ($all_inv as $slot) {
$item_id = $slot['item_name'];
if (!isset($UMC_DATA[$item_id])) {
XMPP_ERROR_trigger("Invalid item deposit cancelled!");
umc_error("Sorry, the item in your inventory is bugged, uncovery was notfied and this should be fixed soon. IF you want to speed it up, please send a ticket with as much detail as possible.");
}
$data = $slot['data'];
if ($slot['meta']) {
$meta = serialize($slot['meta']);
} else {
$meta = false;
}
// don't assign the same twice
$item = umc_goods_get_text($slot['item_name'], $slot['data'], $slot['meta']);
if (isset($seen[$item['full']])) {
continue;
}
$inv = umc_check_inventory($slot['item_name'], $slot['data'], $slot['meta']);
if ($inv == 0) {
XMPP_ERROR_trigger("Item held could not be found in inventory: {$slot['item_name']}, {$slot['data']}, " . var_export($slot['meta'], true));
umc_error("There was a system error. The admin has been notified. Deposit aborted.");
}
if (isset($args[2]) && $args[2] != 'lot_reset') {
$recipient = umc_sanitize_input($args[2], 'player');
$recipient_uuid = umc_user2uuid($recipient);
} else {
if (isset($args[2]) && $args[2] == 'lot_reset') {
$recipient_uuid = 'reset000-lot0-0000-0000-000000000000';
$recipient = $args[2];
} else {
$recipient = $player;
$recipient_uuid = $uuid;
if (!$all) {
umc_echo("{yellow}[!]{gray} No recipient given. Depositing for {gold}{$player}");
}
}
}
if (!$all && isset($args[3])) {
$amount = umc_sanitize_input($args[3], 'amount');
$amount_str = $amount;
if ($amount > $inv) {
umc_echo("{yellow}[!]{gray} You do not have {yellow}{$amount} {green}{$item['full']}{gray}. Depositing {yellow}{$inv}{gray}.");
$amount = $inv;
$amount_str = $inv;
}
} else {
$amount = $inv;
$amount_str = $inv;
}
umc_echo("{yellow}[!]{gray} You have {yellow}{$inv}{gray} items in your inventory, depositing {yellow}{$amount}");
// check if recipient has space
$userlevel = umc_get_uuid_level($recipient_uuid);
$allowed = $UMC_SETTING['depositbox_limit'][$userlevel];
$remaining = umc_depositbox_checkspace($recipient_uuid, $userlevel);
$count = $allowed - $remaining;
// umc_echo("Group: $userlevel Allowed: $allowed Remaining $remaining");
$sql = "SELECT * FROM minecraft_iconomy.deposit\r\n WHERE item_name='{$item['item_name']}' AND recipient_uuid='{$recipient_uuid}'\r\n AND damage='{$data}' AND meta='{$meta}' AND sender_uuid='{$uuid}';";
$D = umc_mysql_fetch_all($sql);
// create the seen entry so we do not do this again
$seen[$item['full']] = 1;
// check first if item already is being sold
if (count($D) > 0) {
$row = $D[0];
umc_echo("{green}[+]{gray} You already have {$item['full']}{gray} in the deposit for {gold}{$recipient}{gray}, adding {yellow}{$amount}{gray}.");
$sql = "UPDATE minecraft_iconomy.`deposit` SET `amount`=amount+'{$amount}' WHERE `id`={$row['id']} LIMIT 1;";
} else {
//check if recipient has space
if ($count >= $allowed && $player != 'uncovery' && $recipient != 'lot_reset') {
if (!$sent_out_of_space_msg) {
umc_echo("{red}[!] {gold}{$recipient}{gray} does not have any more deposit spaces left " . "(Used {white}{$count} of {$allowed}{gray} available for group {white}{$userlevel}{gray})!");
$sent_out_of_space_msg = 1;
}
continue;
}
// check if recipient is an active user
$target_active = umc_user_countlots($recipient);
if ($target_active == 0 && $recipient != 'lot_reset') {
umc_error("{red}[!] {gold}{$recipient}{gray} is not an active user, so you cannot deposit items for them!");
}
// create a new deposit box
if (strlen($item['item_name']) < 3) {
XMPP_ERROR_trigger("Error depositing, item name too short!");
umc_error("There was an error with the deposit. Please send a ticket to the admin so this can be fixed.");
//.........这里部分代码省略.........
示例13: umc_hunger_find_random_location
/**
* tries to find a location far out that was not used as a hunger game before
* this will also create the warp point in essentials
*
* @return array('x' => $center_x, 'z' => $center_z)
*/
function umc_hunger_find_random_location()
{
// 30 Mio is the MC hard limit
$min_val = 1000;
$max_val = 30000000 - 2000;
//we take the max and some margin
// find a center
$center_x = rand($min_val, $max_val);
$center_z = rand($min_val, $max_val);
// which quarter of the map?
$dir_x = rand(0, 1);
if ($dir_x == 0) {
$center_x = $center_x * -1;
}
$dir_z = rand(0, 1);
if ($dir_z == 0) {
$center_z = $center_z * -1;
}
// check if a game existed on that location
$sql = "SELECT id FROM minecraft_iconomy.hunger_games\r\n WHERE x > ({$center_x} - 500)\r\n\t AND x < ({$center_x} + 500)\r\n\t AND z < ({$center_z} + 500)\r\n\t AND z > ({$center_z} - 500);";
$data = umc_mysql_fetch_all($sql);
// too close, try again
if (count($data) > 0) {
umc_log('hunger', 'found_location_fail', "Found alrady existing location X: {$center_x} Z: {$center_z} - retrying");
XMPP_ERROR_trigger("hunger rejected location X: {$center_x} Z: {$center_z}, trying again");
return umc_hunger_find_random_location();
} else {
XMPP_ERROR_send_msg("hunger Found location X: {$center_x} Z: {$center_z}");
// update warp point
$text = "yaw: 0.0\nname: hunger\npitch: 0.0\nz: {$center_z}\ny: 250\nworld: hunger\nx: {$center_x}";
$filename = '/home/minecraft/server/bukkit/plugins/Essentials/warps/hunger.yml';
file_put_contents($filename, $text);
// reload essentials
umc_ws_cmd('ess reload', 'asConsole');
return array('x' => $center_x, 'z' => $center_z);
}
}
示例14: umc_lottery_lot_fix_time
function umc_lottery_lot_fix_time($datetime)
{
if (!strstr($datetime, ':')) {
// unix timestamp
$datetime = "@{$datetime}";
if (strlen($datetime) > 10) {
$datetime = substr($datetime, 0, 11);
}
$date_new = new DateTime($datetime);
} else {
$pieces = explode(" ", $datetime);
if (count($pieces) == 2) {
$date_new = new DateTime($datetime);
} else {
// 2014-07-18 09:07:48 -0700
$date_new = DateTime::createFromFormat('Y-m-d H:i:s T', $datetime);
}
}
if (!$date_new) {
XMPP_ERROR_trigger("Error: failed to parse date format {$datetime} (umc_lottery_lot_fix_time)");
}
$date_new->setTimezone(new DateTimeZone('Asia/Hong_Kong'));
$time = $date_new->format('Y-m-d H:i:s');
return $time;
}
示例15: unc_day_images_list
/**
* Iterate all files in a folder and make a list of all the images with all the info
* for them
*
* @global type $UNC_GALLERY
* @param type $folder
* @return array
*/
function unc_day_images_list($D = false)
{
global $UNC_GALLERY, $wpdb;
if ($UNC_GALLERY['debug']) {
XMPP_ERROR_trace(__FUNCTION__, func_get_args());
}
if (!$D) {
$D = $UNC_GALLERY['display'];
}
$dates = $D['dates'];
if (count($dates) == 0) {
return false;
}
$files = array();
$featured_list = array();
// SQL construction
$sql_filter = '';
// both end_time and start_time are set
if ($D['range']['end_time'] && $D['range']['start_time']) {
$start_time = $D['date_range']['start_time'];
$end_time = $D['date_range']['end_time'];
$date = $D['dates'][0];
if ($D['range']['start_time'] < $D['range']['end_time']) {
$sql_filter = " (file_time >= '{$start_time}' AND file_time <= '{$end_time}')";
} else {
if ($D['range']['start_time'] > $D['range']['end_time']) {
$sql_filter = " ((file_time >= '{$date} 00:00:00' AND file_time <= '{$end_time}') OR (file_time >= '{$start_time}' AND file_time <= '{$date} 23:59:59'))";
}
}
} else {
if ($D['range']['end_time']) {
// get everything from day start until end time
$end_time = $D['date_range']['end_time'];
$date = $D['dates'][0];
$sql_filter = " (file_time >= '{$date} 00:00:00' AND file_time <= '{$end_time}')";
} else {
if ($D['range']['start_time']) {
// get everything from start till day end
$start_time = $D['date_range']['start_time'];
$date = $D['dates'][0];
$sql_filter = " (file_time >= '{$start_time}' AND file_time <= '{$date} 23:59:59')";
} else {
$dates = $D['dates'];
$date_sql = implode($dates, "','");
$sql_filter = " (att_value IN('{$date_sql}'))";
}
}
}
// get all images for the selected dates
$img_table_name = $wpdb->prefix . "unc_gallery_img";
$att_table_name = $wpdb->prefix . "unc_gallery_att";
$sql = "SELECT * FROM `{$img_table_name}`\r\n LEFT JOIN {$att_table_name} ON {$img_table_name}.id={$att_table_name}.file_id\r\n WHERE ({$att_table_name}.att_name='date_str') AND {$sql_filter}\r\n ORDER BY file_time ASC;";
$file_data = $wpdb->get_results($sql, 'ARRAY_A');
XMPP_ERROR_trace("sql", $sql);
//XMPP_ERROR_trace("sql_dates", $file_data);
//XMPP_ERROR_trace("Date settings", $D);
//XMPP_ERROR_trigger("test");
foreach ($file_data as $F) {
$I = unc_image_info_read($F['file_path']);
if (in_array($F['file_name'], $D['featured_image'])) {
$I['featured'] = true;
$featured_list[] = $I;
} else {
$I['featured'] = false;
$files[] = $I;
}
}
// TODO: Move this to the SQL string
// random featured file
if (in_array('random', $D['featured_image'])) {
$new_featured_key = array_rand($files);
$new_featured_arr = $files[$new_featured_key];
$new_featured_arr['featured'] = true;
$featured_list[] = $new_featured_arr;
unset($files[$new_featured_key]);
}
// TODO: Move this to the SQL string
if (in_array('latest', $D['featured_image'])) {
reset($files);
$first_key = key($files);
$new_featured_arr = $files[$first_key];
$new_featured_arr['featured'] = true;
$featured_list[] = $new_featured_arr;
unset($files[$first_key]);
}
foreach ($featured_list as $feat) {
array_unshift($files, $feat);
}
if (count($files) == 0) {
if ($UNC_GALLERY['debug']) {
XMPP_ERROR_trigger("Zero images found");
}
//.........这里部分代码省略.........