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


PHP config::increment方法代码示例

本文整理汇总了PHP中phpbb\config\config::increment方法的典型用法代码示例。如果您正苦于以下问题:PHP config::increment方法的具体用法?PHP config::increment怎么用?PHP config::increment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpbb\config\config的用法示例。


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

示例1: add_page_header_links

    public function add_page_header_links($event)
    {
        if (!empty($this->config['allow_visits_counter'])) {
            $this->language->add_lang('common', 'dmzx/counter');
            $sql = 'SELECT COUNT(*) AS visits_counter
				FROM ' . $this->visits_counter_table . '
				WHERE ' . $this->db->sql_in_set('uvc_ip', $this->user->ip);
            $result = $this->db->sql_query($sql);
            $visits_counter = (int) $this->db->sql_fetchfield('visits_counter');
            $this->db->sql_freeresult($result);
            $visits = $this->config['visits_counter'];
            if ($visits_counter == 0) {
                $sql_ary = array('uvc_ip' => $this->user->ip, 'uvc_timestamp' => time());
                $sql = 'INSERT INTO ' . $this->visits_counter_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                $this->db->sql_query($sql);
                $this->config->increment('visits_counter', 1, true);
            } else {
                $sql_ary = array('uvc_timestamp' => time());
                $sql = 'UPDATE ' . $this->visits_counter_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE ' . $this->db->sql_in_set('uvc_ip', $this->user->ip);
                $this->db->sql_query($sql);
            }
            $timestamp = time() - 3600 * 24;
            $sql_ary = array($timestamp);
            $sql = 'DELETE FROM ' . $this->visits_counter_table . '
				WHERE uvc_timestamp < ' . $timestamp;
            $this->db->sql_query($sql);
            $sql = 'SELECT COUNT(*) AS num_del
				FROM ' . $this->visits_counter_table . ' ';
            $result = $this->db->sql_query($sql);
            $visitsok = (int) $this->db->sql_fetchfield('num_del');
            $this->template->assign_vars(array('UNIQUE_VISITS_COUNTER' => $this->language->lang('UNIQUE_VISITS_COUNTER', $visitsok)));
        }
    }
开发者ID:dmzx,项目名称:phpBB-3.2-Unique-Visits-Counter,代码行数:34,代码来源:listener.php

示例2: execute

 /**
  * Executes the command cache:purge.
  *
  * Purge the cache (including permissions) and increment the asset_version number
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->config->increment('assets_version', 1);
     $this->cache->purge();
     // Clear permissions
     $this->auth->acl_clear_prefetch();
     phpbb_cache_moderators($this->db, $this->cache, $this->auth);
     $this->log->add('admin', ANONYMOUS, '', 'LOG_PURGE_CACHE', time(), array());
     $output->writeln($this->user->lang('PURGE_CACHE_SUCCESS'));
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:20,代码来源:purge.php

示例3: remove_post_from_statistic

	/**
	* Remove post from topic and forum statistics
	*
	* @param $data			array	Contains information from the topics table about given topic
	* @param &$sql_data		array	Populated with the SQL changes, may be empty at call time
	* @return null
	*/
	public function remove_post_from_statistic($data, &$sql_data)
	{
		if ($data['post_visibility'] == ITEM_APPROVED)
		{
			$sql_data[$this->topics_table] = ((!empty($sql_data[$this->topics_table])) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved - 1';
			$sql_data[$this->forums_table] = ((!empty($sql_data[$this->forums_table])) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved - 1';

			if ($data['post_postcount'])
			{
				$sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1';
			}

			$this->config->increment('num_posts', -1, false);
		}
		else if ($data['post_visibility'] == ITEM_UNAPPROVED || $data['post_visibility'] == ITEM_REAPPROVE)
		{
			$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_unapproved = forum_posts_unapproved - 1';
			$sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_unapproved = topic_posts_unapproved - 1';
		}
		else if ($data['post_visibility'] == ITEM_DELETED)
		{
			$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_softdeleted = forum_posts_softdeleted - 1';
			$sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_softdeleted = topic_posts_softdeleted - 1';
		}
	}
开发者ID:bantu,项目名称:phpbb,代码行数:32,代码来源:content_visibility.php

示例4: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->language->add_lang('migrator');
     if (!isset($this->config['version_update_from'])) {
         $this->config->set('version_update_from', $this->config['version']);
     }
     $original_version = $this->config['version_update_from'];
     $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new installer_migrator_output_handler($this->iohandler), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
     $this->migrator->create_migrations_table();
     $migrations = $this->extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes();
     $this->migrator->set_migrations($migrations);
     $migration_step_count = $this->installer_config->get('database_update_migration_steps', -1);
     if ($migration_step_count < 0) {
         $migration_step_count = count($this->migrator->get_installable_migrations()) * 2;
         $this->installer_config->set('database_update_migration_steps', $migration_step_count);
     }
     $progress_count = $this->installer_config->get('database_update_count', 0);
     $restart_progress_bar = $progress_count === 0;
     // Only "restart" when the update runs for the first time
     $this->iohandler->set_task_count($migration_step_count, $restart_progress_bar);
     $this->installer_config->set_task_progress_count($migration_step_count);
     while (!$this->migrator->finished()) {
         try {
             $this->migrator->update();
             $progress_count++;
             $last_run_migration = $this->migrator->get_last_run_migration();
             if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed']) {
                 // We skipped two step, so increment $progress_count by another one
                 $progress_count++;
             } else {
                 if ($last_run_migration['task'] === 'process_schema_step' && !$last_run_migration['state']['migration_schema_done'] || $last_run_migration['task'] === 'process_data_step' && !$last_run_migration['state']['migration_data_done']) {
                     // We just run a step that wasn't counted yet so make it count
                     $migration_step_count++;
                 }
             }
             $this->iohandler->set_task_count($migration_step_count);
             $this->installer_config->set_task_progress_count($migration_step_count);
             $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count);
         } catch (exception $e) {
             $msg = $e->getParameters();
             array_unshift($msg, $e->getMessage());
             $this->iohandler->add_error_message($msg);
             throw new user_interaction_required_exception();
         }
         if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) {
             $this->installer_config->set('database_update_count', $progress_count);
             $this->installer_config->set('database_update_migration_steps', $migration_step_count);
             throw new resource_limit_reached_exception();
         }
     }
     if ($original_version !== $this->config['version']) {
         $this->log->add('admin', isset($this->user->data['user_id']) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, array($original_version, $this->config['version']));
     }
     $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL');
     $this->config->delete('version_update_from');
     $this->cache->purge();
     $this->config->increment('assets_version', 1);
 }
开发者ID:phpbb,项目名称:phpbb-core,代码行数:61,代码来源:update.php

示例5: round

    function random_bonus_increment($user_id)
    {
        /**
         * Read out config values
         */
        $sql = 'SELECT *
			FROM ' . $this->points_values_table;
        $result = $this->db->sql_query($sql);
        $points_values = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        $bonus_chance = '';
        $bonus = false;
        // Basic value, sorry..
        $bonus_value = 0.0;
        // Basic value
        // Following numbers are 'times 100' to get rid of commas, as mt_rand doesn't get comma numbers.
        $bonus_chance = $points_values['points_bonus_chance'] * 100;
        // The chance percentage for a user to get the bonus
        $random_number = mt_rand(0, 10000);
        // The random number we compare to the chance percentage
        if ($random_number <= $bonus_chance) {
            $bonus = true;
            // Check if we want a fixed bonus value or not
            if ($points_values['points_bonus_min'] == $points_values['points_bonus_max']) {
                $bonus_value = $points_values['points_bonus_min'];
            } else {
                // Create the bonus value, between the set minimum and maximum
                // Following numbers are 'times 100' to get rid of commas, as mt_rand doesn't get comma numbers.
                $bonus_random = mt_rand($points_values['points_bonus_min'] * 100, $points_values['points_bonus_max'] * 100) / 100;
                $bonus_value = round($bonus_random, 0, PHP_ROUND_HALF_UP);
            }
        }
        if ($bonus && $bonus_value) {
            $this->add_points((int) $user_id, $bonus_value);
            // Send out notification
            // Increase our notification sent counter
            $this->config->increment('points_notification_id', 1);
            // Store the notification data we will use in an array
            $data = array('points_notify_id' => (int) $this->config['points_notification_id'], 'points_notify_msg' => sprintf($this->user->lang['NOTIFICATION_RANDOM_BONUS'], $bonus_value, $this->config['points_name']), 'sender' => (int) $this->user->data['user_id'], 'receiver' => (int) $user_id, 'mode' => 'logs');
            $this->notification_manager->add_notifications('dmzx.ultimatepoints.notification.type.points', $data);
            $sql_array = array('SELECT' => 'username', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $user_id);
            $sql = $this->db->sql_build_query('SELECT', $sql_array);
            $result = $this->db->sql_query($sql);
            $points_user = $this->db->sql_fetchrow($result);
            // Add logs
            $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MOD_POINTS_RANDOM', false, array($points_user['username']));
        }
    }
开发者ID:rampmaster,项目名称:Ultimate-Points-Extension,代码行数:48,代码来源:functions_points.php

示例6: send_notification

 /**
  * Send notification to users
  *
  * @param int $rule_id The rule identifier
  * @return null
  * @access public
  */
 public function send_notification($rule_id)
 {
     // Use a confirmation box routine when sending notifications
     if (confirm_box(true)) {
         // Increment our notifications sent counter
         $this->config->increment('boardrules_notification', 1);
         // Store the notification data we will use in an array
         $notification_data = array('rule_id' => $rule_id, 'notification_id' => $this->config['boardrules_notification']);
         // Create the notification
         $this->notification_manager->add_notifications('phpbb.boardrules.notification.type.boardrules', $notification_data);
         // Log the notification
         $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_BOARDRULES_NOTIFY_LOG');
     } else {
         // Request confirmation from the user to send notification to all users
         // Build a hidden array of the form data
         confirm_box(false, $this->user->lang('ACP_BOARDRULES_NOTIFY_CONFIRM'), build_hidden_fields(array('action_send_notification' => true, 'rule_id' => $rule_id)));
     }
 }
开发者ID:Nicofuma,项目名称:boardrules,代码行数:25,代码来源:admin_controller.php

示例7: set_post_count

 /**
  * Do not increase the user's post count when copying the topic
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function set_post_count($event)
 {
     $post_mode = $event['post_mode'];
     $data = $event['data'];
     if ($this->config['copy_topic_enable'] && $post_mode == 'post' && $data['forum_id'] == $this->config['copy_topic_to_forum']) {
         if ($this->check_fora()) {
             $sql_data = $event['sql_data'];
             // We do not want to increase the user's post count when copying the topic so we remove thr " + 1" from the end of the string
             $sql_data[$this->table_prefix . 'users']['stat'][0] = substr($sql_data[$this->table_prefix . 'users']['stat'][0], 0, -4);
             // We need to reduce the total topic & post count unless it is being overridden
             if (!$this->config['copy_topic_count_override']) {
                 $this->config->increment('num_posts', -1, false);
                 $this->config->increment('num_topics', -1, false);
             }
             $event->offsetSet('sql_data', $sql_data);
         }
     }
 }
开发者ID:david63,项目名称:david63-copynewtopic,代码行数:25,代码来源:listener.php

示例8: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->language->add_lang('migrator');
     if (!isset($this->config['version_update_from'])) {
         $this->config->set('version_update_from', $this->config['version']);
     }
     $original_version = $this->config['version_update_from'];
     $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new installer_migrator_output_handler($this->iohandler), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
     $this->migrator->create_migrations_table();
     $migrations = $this->extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes();
     $this->migrator->set_migrations($migrations);
     $migration_count = count($this->migrator->get_migrations());
     $this->iohandler->set_task_count($migration_count, true);
     $progress_count = $this->installer_config->get('database_update_count', 0);
     while (!$this->migrator->finished()) {
         try {
             $this->migrator->update();
             $progress_count++;
             $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count);
         } catch (exception $e) {
             $msg = $e->getParameters();
             array_unshift($msg, $e->getMessage());
             $this->iohandler->add_error_message($msg);
             $this->iohandler->send_response();
             throw new user_interaction_required_exception();
         }
         if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) {
             $this->installer_config->set('database_update_count', $progress_count);
             throw new resource_limit_reached_exception();
         }
     }
     if ($original_version !== $this->config['version']) {
         $this->log->add('admin', isset($this->user->data['user_id']) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, array($original_version, $this->config['version']));
     }
     $this->iohandler->finish_progress('INLINE_UPDATE_SUCCESSFUL');
     $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL');
     $this->config->delete('version_update_from');
     $this->cache->purge();
     $this->config->increment('assets_version', 1);
 }
开发者ID:hybiepoo,项目名称:phpbb,代码行数:43,代码来源:update.php

示例9: remove_from_filesystem

 /**
  * Delete attachments from filesystem
  */
 protected function remove_from_filesystem()
 {
     $space_removed = $files_removed = 0;
     foreach ($this->physical as $file_ary) {
         if ($this->unlink_attachment($file_ary['filename'], 'file', true) && !$file_ary['is_orphan']) {
             // Only non-orphaned files count to the file size
             $space_removed += $file_ary['filesize'];
             $files_removed++;
         }
         if ($file_ary['thumbnail']) {
             $this->unlink_attachment($file_ary['filename'], 'thumbnail', true);
         }
     }
     /**
      * Perform additional actions after attachment(s) deletion from the filesystem
      *
      * @event core.delete_attachments_from_filesystem_after
      * @var	string	mode			Variable containing attachments deletion mode, can be: post|message|topic|attach|user
      * @var	mixed	ids				Array or comma separated list of ids corresponding to the mode
      * @var	bool	resync			Flag indicating if posts/messages/topics should be synchronized
      * @var	string	sql_id			The field name to collect/delete data for depending on the mode
      * @var	array	post_ids		Array with post ids for deleted attachment(s)
      * @var	array	topic_ids		Array with topic ids for deleted attachment(s)
      * @var	array	message_ids		Array with private message ids for deleted attachment(s)
      * @var	array	physical		Array with deleted attachment(s) physical file(s) data
      * @var	int		num_deleted		The number of deleted attachment(s) from the database
      * @var	int		space_removed	The size of deleted files(s) from the filesystem
      * @var	int		files_removed	The number of deleted file(s) from the filesystem
      * @since 3.1.7-RC1
      */
     $vars = array('mode', 'ids', 'resync', 'sql_id', 'post_ids', 'topic_ids', 'message_ids', 'physical', 'num_deleted', 'space_removed', 'files_removed');
     extract($this->dispatcher->trigger_event('core.delete_attachments_from_filesystem_after', compact($vars)));
     if ($space_removed || $files_removed) {
         $this->config->increment('upload_dir_size', $space_removed * -1, false);
         $this->config->increment('num_files', $files_removed * -1, false);
     }
 }
开发者ID:phpbb,项目名称:phpbb-core,代码行数:40,代码来源:delete.php

示例10: finalise_update

 protected function finalise_update()
 {
     $this->cache->purge();
     $this->config->increment('assets_version', 1);
 }
开发者ID:phpbb,项目名称:phpbb,代码行数:5,代码来源:migration_command.php

示例11: main


//.........这里部分代码省略.........
            }
            // Add all required informations
            $username = utf8_normalize_nfc($this->request->variable('username', '', true));
            $attacked_amount = round($this->request->variable('attacked_amount', 0.0), 2);
            if ($attacked_amount <= 0) {
                $message = $this->user->lang['ROBBERY_TOO_SMALL_AMOUNT'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                trigger_error($message);
            }
            // Check, if user has entered the name of the user to be robbed
            if (empty($username)) {
                $message = $this->user->lang['ROBBERY_NO_ID_SPECIFIED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                trigger_error($message);
            }
            // Check, if user tries to rob himself
            if ($this->user->data['username_clean'] == utf8_clean_string($username)) {
                $message = $this->user->lang['ROBBERY_SELF'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                trigger_error($message);
            }
            // Check, if user is trying to rob to much cash
            if ($points_values['robbery_loose'] != 0) {
                if ($this->user->data['user_points'] < $attacked_amount / 100 * $points_values['robbery_loose']) {
                    $message = $this->user->lang['ROBBERY_TO_MUCH'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                    trigger_error($message);
                }
            }
            // Select the user_id of user to be robbed
            $sql_array = array('SELECT' => 'user_id', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'username_clean = "' . $this->db->sql_escape(utf8_clean_string($username)) . '"');
            $sql = $this->db->sql_build_query('SELECT', $sql_array);
            $result = $this->db->sql_query($sql);
            $user_id = (int) $this->db->sql_fetchfield('user_id');
            $this->db->sql_freeresult($result);
            // If no matching user id is found
            if (!$user_id) {
                $message = $this->user->lang['POINTS_NO_USER'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                trigger_error($message);
            }
            // If the robbed user doesn't have enough cash
            $sql_array = array('SELECT' => 'user_points', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $user_id);
            $sql = $this->db->sql_build_query('SELECT', $sql_array);
            $result = $this->db->sql_query($sql);
            $pointsa = $this->db->sql_fetchfield('user_points');
            $this->db->sql_freeresult($result);
            if ($attacked_amount > $pointsa) {
                $message = $this->user->lang['ROBBERY_TO_MUCH_FROM_USER'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                trigger_error($message);
            }
            // Check, if user tries to rob more than x % of users cash
            if ($points_values['robbery_max_rob'] != 0) {
                if ($attacked_amount > $pointsa / 100 * $points_values['robbery_max_rob']) {
                    $message = sprintf($this->user->lang['ROBBERY_MAX_ROB'], $points_values['robbery_max_rob']) . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                    trigger_error($message);
                }
            }
            // Get some info about the robbed user
            $user_namepoints = get_username_string('full', $checked_user['user_id'], $checked_user['username'], $checked_user['user_colour']);
            // Genarate a random number
            $rand_base = $points_values['robbery_chance'];
            $rand_value = rand(0, 100);
            // If robbery was successful and notification is enabled, send notification
            if ($rand_value <= $rand_base) {
                $this->functions_points->add_points($this->user->data['user_id'], $attacked_amount);
                $this->functions_points->substract_points($user_id, $attacked_amount);
                // Add robbery to the log
                $sql = 'INSERT INTO ' . $this->points_log_table . ' ' . $this->db->sql_build_array('INSERT', array('point_send' => (int) $this->user->data['user_id'], 'point_recv' => $user_id, 'point_amount' => $attacked_amount, 'point_sendold' => $this->user->data['user_points'], 'point_recvold' => $pointsa, 'point_comment' => '', 'point_type' => '3', 'point_date' => time()));
                $this->db->sql_query($sql);
                if ($points_config['robbery_notify']) {
                    // Increase our notification sent counter
                    $this->config->increment('points_notification_id', 1);
                    // Store the notification data we will use in an array
                    $data = array('points_notify_id' => (int) $this->config['points_notification_id'], 'points_notify_msg' => sprintf($this->user->lang['NOTIFICATION_ROBBERY_SUCCES'], $attacked_amount, $this->config['points_name']), 'sender' => (int) $this->user->data['user_id'], 'receiver' => (int) $user_id, 'mode' => 'robbery');
                    // Create the notification
                    $this->notification_manager->add_notifications('dmzx.ultimatepoints.notification.type.points', $data);
                }
                $message = $this->user->lang['ROBBERY_SUCCESFUL'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                trigger_error($message);
            } else {
                if ($points_values['robbery_loose'] != 0) {
                    $lose = $attacked_amount / 100 * $points_values['robbery_loose'];
                    $this->functions_points->substract_points($this->user->data['user_id'], $lose);
                    if ($points_config['robbery_notify']) {
                        // Increase our notification sent counter
                        $this->config->increment('points_notification_id', 1);
                        // Store the notification data we will use in an array
                        $data = array('points_notify_id' => (int) $this->config['points_notification_id'], 'points_notify_msg' => $this->user->lang['NOTIFICATION_ROBBERY_FAILED'], 'sender' => (int) $this->user->data['user_id'], 'receiver' => (int) $user_id, 'mode' => 'robbery');
                        // Create the notification
                        $this->notification_manager->add_notifications('dmzx.ultimatepoints.notification.type.points', $data);
                    }
                    $message = $this->user->lang['ROBBERY_BAD'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
                    trigger_error($message);
                }
            }
            $this->template->assign_vars(array('USER_NAME' => get_username_string('full', $checked_user['user_id'], $points_config['username'], $points_config['user_colour']), 'U_ACTION' => $this->u_action, 'S_HIDDEN_FIELDS' => $hidden_fields));
        }
        $this->template->assign_vars(array('USER_POINTS' => sprintf($this->functions_points->number_format_points($pointsa)), 'POINTS_NAME' => $this->config['points_name'], 'LOTTERY_NAME' => $points_values['lottery_name'], 'BANK_NAME' => $points_values['bank_name'], 'L_ROBBERY_CHANCE' => sprintf($this->user->lang['ROBBERY_CHANCE'], $this->functions_points->number_format_points($points_values['robbery_max_rob']), $this->functions_points->number_format_points($points_values['robbery_chance'])), 'L_ROBBERY_AMOUNTLOSE' => sprintf($this->user->lang['ROBBERY_AMOUNTLOSE'], $this->functions_points->number_format_points($points_values['robbery_loose'])), 'U_FIND_USERNAME' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", "mode=searchuser&amp;form=post&amp;field=username"), 'U_TRANSFER_USER' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'transfer_user')), 'U_LOGS' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'logs')), 'U_LOTTERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'lottery')), 'U_BANK' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')), 'U_ROBBERY' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'robbery')), 'U_INFO' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'info')), 'U_USE_TRANSFER' => $this->auth->acl_get('u_use_transfer'), 'U_USE_LOGS' => $this->auth->acl_get('u_use_logs'), 'U_USE_LOTTERY' => $this->auth->acl_get('u_use_lottery'), 'U_USE_BANK' => $this->auth->acl_get('u_use_bank'), 'U_USE_ROBBERY' => $this->auth->acl_get('u_use_robbery')));
        // Generate the page
        page_header($this->user->lang['POINTS_ROBBERY']);
        // Generate the page template
        $this->template->set_filenames(array('body' => 'points/points_robbery.html'));
        page_footer();
    }
开发者ID:rampmaster,项目名称:Ultimate-Points-Extension,代码行数:101,代码来源:points_robbery.php

示例12: main

    function main()
    {
        // Get all values
        $sql = 'SELECT *
				FROM ' . $this->points_values_table;
        $result = $this->db->sql_query($sql);
        $points_values = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // Check Points Config Table if Bank is Enabled
        $sql = 'SELECT config_value
				FROM ' . $this->points_config_table . '
				WHERE config_name = "bank_enable"';
        $result = $this->db->sql_query($sql);
        $is_bank_enabled = $this->db->sql_fetchfield('config_value');
        $this->db->sql_freeresult($result);
        // Check if bank is enabled
        if (1 > $points_values['bank_pay_period']) {
            $message = $this->user->lang['BANK_ERROR_PAYOUTTIME_SHORT'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')) . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
            trigger_error($message);
        }
        if ($is_bank_enabled != 1) {
            $message = $this->user->lang['BANK_DISABLED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller') . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
            trigger_error($message);
        }
        if (!$this->auth->acl_get('u_use_bank')) {
            $message = $this->user->lang['NOT_AUTHORISED'] . '<br /><br /><a href="' . $this->helper->route('dmzx_ultimatepoints_controller') . '">&laquo; ' . $this->user->lang['BACK_TO_PREV'] . '</a>';
            trigger_error($message);
        }
        $withdrawtotal_check = '';
        // Add part to bar
        $this->template->assign_block_vars('navlinks', array('U_VIEW_FORUM' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank')), 'FORUM_NAME' => $points_values['bank_name']));
        // Check, if it's time to pay users
        $time = time();
        if ($time - $points_values['bank_last_restocked'] > $points_values['bank_pay_period']) {
            $this->functions_points->set_points_values('bank_last_restocked', $time);
            // Pay the users
            $sql = 'UPDATE ' . $this->points_bank_table . '
					SET holding = holding + round((holding / 100) * ' . $points_values['bank_interest'] . ')
					WHERE holding < ' . $points_values['bank_interestcut'] . '
						OR ' . $points_values['bank_interestcut'] . ' = 0';
            $this->db->sql_query($sql);
            // Mantain the bank costs
            if ($points_values['bank_cost'] != '0') {
                $sql = 'UPDATE ' . $this->points_bank_table . '
						SET holding = holding - ' . $points_values['bank_cost'] . '
						WHERE holding >= ' . $points_values['bank_cost'] . '';
                $this->db->sql_query($sql);
            }
            // Increase our notification sent counter
            $this->config->increment('points_notification_id', 1);
            $data = array('points_notify_id' => (int) $this->config['points_notification_id'], 'points_notify_msg' => $this->user->lang['NOTIFICATION_BANK_PAYOUT'], 'sender' => $this->user->data['user_id'], 'receiver' => (int) $this->user->data['user_id'], 'mode' => 'bank');
            // Send the notification
            $this->notification_manager->add_notifications('dmzx.ultimatepoints.notification.type.points', $data);
            $sql_array = array('SELECT' => 'username', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $this->user->data['user_id']);
            $sql = $this->db->sql_build_query('SELECT', $sql_array);
            $result = $this->db->sql_query($sql);
            $points_user = $this->db->sql_fetchrow($result);
            // Add logs
            $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MOD_POINTS_BANK_PAYS', false, array($points_user['username']));
        }
        $sql_array = array('SELECT' => '*', 'FROM' => array($this->points_bank_table => 'u'), 'WHERE' => 'user_id = ' . (int) $this->user->data['user_id']);
        $sql = $this->db->sql_build_query('SELECT', $sql_array);
        $result = $this->db->sql_query($sql);
        $row = $this->db->sql_fetchrow($result);
        $action = $this->request->variable('action', '');
        add_form_key('bank_action');
        // Default bank info page
        if (empty($action)) {
            $this->template->set_filenames(array('body' => 'points/points_bank.html'));
            if (!isset($row['holding']) && $this->user->data['user_id'] > 0 && $this->user->data['username'] != ANONYMOUS) {
                $this->template->assign_block_vars('no_account', array('USER_NO_ACCOUNT' => sprintf($this->user->lang['BANK_USER_NO_ACCOUNT'], $points_values['bank_name']), 'OPEN_ACCOUNT' => sprintf($this->user->lang['BANK_OPEN_ACCOUNT'], '<a href="' . $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank', 'action' => 'createaccount')) . '" title="' . $this->user->lang['BANK_OPEN_ACCOUNT'] . '!">', '</a>')));
            } else {
                if ($this->user->data['user_id'] > 0 && $this->user->data['username'] != ANONYMOUS) {
                    $this->template->assign_block_vars('has_account', array());
                }
            }
            $sql_array = array('SELECT' => 'SUM(holding) AS total_holding, count(user_id) AS total_users', 'FROM' => array($this->points_bank_table => 'u'), 'WHERE' => 'id > 0');
            $sql = $this->db->sql_build_query('SELECT', $sql_array);
            $result = $this->db->sql_query($sql);
            $b_row = $this->db->sql_fetchrow($result);
            $bankholdings = $b_row['total_holding'] ? $b_row['total_holding'] : 0;
            $bankusers = $b_row['total_users'];
            $withdrawtotal = $row['fees'] == 'on' ? $row['holding'] - round($row['holding'] / 100 * $points_values['bank_fees']) : $row['holding'];
            if ($row['fees'] == 'on' && $this->user->lang['BANK_WITHDRAW_RATE']) {
                $this->template->assign_block_vars('switch_withdraw_fees', array());
            }
            if ($points_values['bank_min_withdraw']) {
                $this->template->assign_block_vars('switch_min_with', array());
            }
            if ($points_values['bank_min_deposit']) {
                $this->template->assign_block_vars('switch_min_depo', array());
            }
            $banklocation = ' -> <a href="' . $this->helper->route('dmzx_ultimatepoints_controller') . '" class="nav">' . $points_values['bank_name'] . '</a>';
            $title = $points_values['bank_name'] . '; ' . (!is_numeric($row['holding']) ? $this->user->lang['BANK_ACCOUNT_OPENING'] : $this->user->lang['BANK_DEPOSIT_WITHDRAW'] . ' ' . $this->config['points_name']);
            page_header($points_values['bank_name']);
            $bank_enable = $is_bank_enabled;
            $this->template->assign_vars(array('BANK_NAME' => $points_values['bank_name'], 'BANKLOCATION' => $banklocation, 'BANK_OPENED' => $this->user->format_date($bank_enable), 'BANK_HOLDINGS' => sprintf($this->functions_points->number_format_points($bankholdings)), 'BANK_ACCOUNTS' => $bankusers, 'BANK_FEES' => $points_values['bank_fees'], 'BANK_INTEREST' => $points_values['bank_interest'], 'BANK_MIN_WITH' => sprintf($this->functions_points->number_format_points($points_values['bank_min_withdraw'])), 'BANK_MIN_DEPO' => sprintf($this->functions_points->number_format_points($points_values['bank_min_deposit'])), 'BANK_MAX_HOLD' => sprintf($this->functions_points->number_format_points($points_values['bank_interestcut'])), 'BANK_TITLE' => $title, 'POINTS_NAME' => $this->config['points_name'], 'USER_BALANCE' => sprintf($this->functions_points->number_format_points($row['holding'])), 'USER_GOLD' => $this->user->data['user_points'], 'USER_WITHDRAW' => sprintf(number_format($withdrawtotal, 2, '.', '')), 'U_WITHDRAW' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank', 'action' => 'withdraw')), 'U_DEPOSIT' => $this->helper->route('dmzx_ultimatepoints_controller', array('mode' => 'bank', 'action' => 'deposit'))));
        } else {
            if ($action == 'createaccount') {
                if (!$this->user->data['is_registered']) {
//.........这里部分代码省略.........
开发者ID:rampmaster,项目名称:Ultimate-Points-Extension,代码行数:101,代码来源:points_bank.php


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