Gal kam pravers... Wordpress widget: Ban Status

Forumas skirtas klausimams/pamokoms susijusioms su PHP, SQL (MySQL), web technologijomis, HTML, CSS, javascript, turinio valdymo sistemomis ir kita.
Post Reply
arnux
Parašęs kelias žinutes
Posts: 9
Joined: 2010 Oct 21 05:17
Skype: klimax.lt

Gal kam pravers... Wordpress widget: Ban Status

Post by arnux »

Sveiki, gal kam bus naudinga. Kurtas naudoti su AMXBans # Gm 1.6.

Kodas: Select all

<?php/*Plugin Name: Ban StatusDescription: Provides a widget to list ban status.Version: 1.0Author: ArnasAuthor URI: http://klimax.lt*/ class ban_status extends WP_Widget {      function ban_status() {        parent::WP_Widget(false, $name = 'Ban Status');     }     function widget($args, $instance) {         extract( $args );                $title = apply_filters('widget_title', $instance['title']);        $database = $instance['database'];        $user = $instance['user'];        $password = $instance['password'];        $host = $instance['host'];        $website = $instance['website'];                        if(!$size)            $size = 40;         ?>              <?php echo $before_widget; ?>                  <?php if ( $title )                        echo $before_title . $title . $after_title; ?>                            <ul>                                <?php                                     $ip = $_SERVER['REMOTE_ADDR'];                                     $connect = mysql_connect($host, $user, $password) or die(mysql_error());                                    $select = mysql_select_db($database, $connect) or die(mysql_error());                                     $result = mysql_query("SELECT bid FROM amx_bans") or die(mysql_error());                                    $rows = mysql_num_rows($result);                                      echo "Bans in database: <b><a href=".$website." target = _blank>".$rows."</a></b><br>                                    IP address - <b>".$ip."</b><br>";                                      $r = mysql_query("SELECT * FROM amx_bans WHERE player_ip = '$ip' AND expired = '0' LIMIT 1");                                    $row = mysql_fetch_array($r, MYSQL_ASSOC);                                         if(!$row) {                                        echo "Status: <b><span style=\"color:green\">Not banned.</span></b><br>";                                    } else {                                         echo "Status: <b><span style=\"color:red\">You have been banned!</span></b><br>Reason: <b>$row[ban_reason]</b><br><br>";}                                 ?>                            </ul>              <?php echo $after_widget; ?>        <?php    }     function update($new_instance, $old_instance) {             $instance = $old_instance;        $instance['title'] = strip_tags($new_instance['title']);        $instance['database'] = strip_tags($new_instance['database']);        $instance['user'] = strip_tags($new_instance['user']);        $instance['password'] = strip_tags($new_instance['password']);        $instance['host'] = strip_tags($new_instance['host']);        $instance['website'] = strip_tags($new_instance['website']);        return $instance;    }     function form($instance) {                  $title = esc_attr($instance['title']);        $database = esc_attr($instance['database']);        $user = esc_attr($instance['user']);        $password = esc_attr($instance['password']);        $host = esc_attr($instance['host']);        $website = esc_attr($instance['website']);                ?>        <p>          <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>           <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />        </p>                <p>          <label for="<?php echo $this->get_field_id('database'); ?>"><?php _e('Database name:'); ?></label>           <input class="widefat" id="<?php echo $this->get_field_id('database'); ?>" name="<?php echo $this->get_field_name('database'); ?>" type="text" value="<?php echo $database; ?>" />        </p>                <p>          <label for="<?php echo $this->get_field_id('user'); ?>"><?php _e('Username:'); ?></label>           <input class="widefat" id="<?php echo $this->get_field_id('user'); ?>" name="<?php echo $this->get_field_name('user'); ?>" type="text" value="<?php echo $user; ?>" />        </p>        <p>                  <label for="<?php echo $this->get_field_id('password'); ?>"><?php _e('Password:'); ?></label>           <input class="widefat" id="<?php echo $this->get_field_id('password'); ?>" name="<?php echo $this->get_field_name('password'); ?>" type="password" value="<?php echo $password; ?>" />        </p>                <p>          <label for="<?php echo $this->get_field_id('host'); ?>"><?php _e('Host:'); ?></label>           <input class="widefat" id="<?php echo $this->get_field_id('host'); ?>" name="<?php echo $this->get_field_name('host'); ?>" type="text" value="<?php echo $host; ?>" />        </p>                <p>          <label for="<?php echo $this->get_field_id('website'); ?>"><?php _e('Amxbans website:'); ?></label>           <input class="widefat" id="<?php echo $this->get_field_id('website'); ?>" name="<?php echo $this->get_field_name('website'); ?>" type="text" value="<?php echo $website; ?>" />        </p>        <?php     }  } add_action('widgets_init', create_function('', 'return register_widget("ban_status");')); 
Attachments
ban-status.zip
(1.46 KiB) Downloaded 229 times

kesiukas
Jau po truputį tampa savu
Posts: 187
Joined: 2011 Jan 11 18:32
Skype: kesys19
Location: Kaunas/Batniava

Re: Gal kam pravers... Wordpress widget: Ban Status

Post by kesiukas »

kur ikelti reikia, i kuria vieta?

User avatar
popilas
Gana aktyvus vartotojas
Posts: 387
Joined: 2017 Apr 04 11:44
Location: Alytus

Re: Gal kam pravers... Wordpress widget: Ban Status

Post by popilas »

kesiukas wrote:kur ikelti reikia, i kuria vieta?

I savo svetaine,


\
PATYLĖK!!! Bent protingesnis atrodysi :))

kesiukas
Jau po truputį tampa savu
Posts: 187
Joined: 2011 Jan 11 18:32
Skype: kesys19
Location: Kaunas/Batniava

Re: Gal kam pravers... Wordpress widget: Ban Status

Post by kesiukas »

ikelus nieko nerodo. tuscias langas ir vsio

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest