Ditutup

A event software

So I'm from faroeisland a small country and i've made a software for Dota 2, Counter strike and League of legends where people are able to sit down in a lobby on my webpage(wordpress). But I need some improvements in my code and some additional features.

I'm not sure what the budget is needed but If you know your PhP and mysql it's an easy task.

This is my code so far :)

PHP

[url removed, login to view]

<?php

/*Plugin Name: Lobby manager

Description: Show a lobby section

Version: 0.1

Author: Jóannes á Fløtti

Author URI: [url removed, login to view]

License: GPLv2

*/

/* Lobby lists

/* ------------------------------------ */

function generate_lobby_list($game) {

global $wpdb;

$list = [];

$query = $wpdb->get_results( "SELECT ID, time FROM esport_event where game = '".$game."' order by time");

foreach($query as $row) {

$list[$row->ID] = ['time' => $row->time];

}

//$query = $wpdb->get_results( "SELECT user_id, event_id FROM esport_user_event where date = '" . date('Y-m-d') ."'" );

return $list;

}

function my_assets() {

wp_enqueue_style('lobby-manager', plugins_url( '/css/[url removed, login to view]', __FILE__ ));

wp_enqueue_script( 'lobby-manager', plugins_url( '/js/[url removed, login to view]', __FILE__ ), array( 'jquery' ) );

wp_localize_script( 'lobby-manager', 'sitdown', array(

'ajax_url' => admin_url( '[url removed, login to view]' )

));

}

add_action( 'wp_enqueue_scripts', 'my_assets' );

class ESport_Lobby_Manager_Widget extends WP_Widget {

function __construct() {

parent::__construct(

// base ID of the widget

'esport_lobby_mananger_widget',

// name of the widget

__('Lobby manager', 'esport' ),

// widget options

array (

'description' => __( 'Creates a lobby section', 'esport' )

)

);

}

function form( $instance ) {

// markup for form

$time = $instance[ 'lobbytime' ];

$game = $instance[ 'lobbygame' ];

?>

<p>

<label for="<?php echo $this->get_field_id( 'lobbygame' ); ?>">Spæl:</label>

<select class="widefat" name="<?php echo $this->get_field_name( 'lobbygame' ); ?>" id="<?php echo $this->get_field_id( 'lobbygame' ); ?>">

<option value="dota2">Dota 2</option>

<option value="cs">Counter Strike: Global Offensive</option>

<option value="lol">League of legends</option>

<option value="rocketleague">Rocket League</option>

</select>

</p>

<?php

}

function update( $new_instance, $old_instance ) {

$instance = $old_instance;

$instance[ 'lobbygame' ] = strip_tags( $new_instance[ 'lobbygame' ] );

return $instance;

}

function widget( $args, $instance ) {

extract( $args );

$date = new DateTime();

$list = generate_lobby_list($instance['lobbygame']);

echo '<div class="row" style="z-index:10">';

foreach($list as $key => $lobby) {

$timeArr = explode(':',$lobby['time']);

$date->setTime($timeArr[0],$timeArr[1]);

?>

<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 lobby-<?php echo $key; ?>">

<h2 class="lead">

Klokkan <?php echo substr($lobby['time'],0,-3); ?> FO t&iacute;&eth;

<img src="<?php echo plugins_url( '/img/[url removed, login to view]', __FILE__); ?>" class="loading pull-right">

</h2>

<form class="form-inline lobby-container">

<?php

if ( is_user_logged_in()) {

if($date->getTimestamp() > time()) {

$user = wp_get_current_user();

?>

<div class="regForm hide">

<div class="form-group">

<label class="sr-only" for="playerProfileName">Eyðkennis navn</label>

<input type="text" class="form-control" name="playerProfileName" value="<?php echo esc_attr( get_the_author_meta( 'dotaprofile', $user->ID ) ); ?>" placeholder="Eyknevni">

<input type="hidden" name="playerProfileID" value="<?php echo $user->ID; ?>" placeholder="Eyðkennis navn">

</div>

<button type="button" class="btn btn-success sitdown">Set teg</button>

</div>

<button type="button" value="<?php echo $user->ID; ?>" class="btn btn-warning leave hide">Reis teg</button>

<?php } else { ?>

<p>

<strong>

Ikki møguligt at seta seg!

</strong>

</p>

<?php

}

} else { ?>

<p>

<strong>

Logga á fyri at seta teg!

</strong>

</p>

<?php }

?>

<ul class="lobby-list fade-in" id="playersInLobby-<?php echo $key; ?>"></ul>

<!-- <button type="button" class="btn btn-default update hide">Dagfør</button>-->

</form>

<script>

jQuery(function(){

jQuery('lobby-<?php echo $key; ?>').lobbyManager({

lobby: 'div.lobby-<?php echo $key; ?>',

lobbyID: <?php echo $key; ?>,

container: 'form.lobby-container',

list: '#playersInLobby-<?php echo $key; ?>'

});

});

</script>

</div>

<?php

}

echo '</div>';

}

}

function esport_register_lobby_manager_widget() {

register_widget( 'ESport_Lobby_Manager_Widget' );

}

add_action( 'widgets_init', 'esport_register_lobby_manager_widget' );

function esport_lobby_widgets_init() {

register_sidebar( array(

'name' => 'Dota lobby',

'id' => 'dota_lobby_section',

'before_widget' => '<div id="esport-dota-lobby-manager">',

'after_widget' => '</div>',

'before_title' => '<h2 class="rounded">',

'after_title' => '</h2>',

) );

}

add_action( 'widgets_init', 'esport_lobby_widgets_init' );

add_action( 'wp_ajax_take_a_seat', 'prefix_ajax_take_a_seat' );

//add_action( 'wp_ajax_nopriv_take_a_seat', 'prefix_ajax_take_a_seat' );

function prefix_ajax_take_a_seat() {

global $wpdb;

if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {

try {

$wpdb->insert(

'esport_user_event',

array(

'user_id' => filter_input(INPUT_POST, 'id'),

'event_id' => filter_input(INPUT_POST, 'event'),

'name' => filter_input(INPUT_POST, 'name'),

'date' => date('Y-m-d')

),

array(

'%d',

'%d',

'%s',

'%s',

)

);

echo json_encode(['status' => $wpdb->insert_id, 'message' => ($wpdb->insert_id > 0) ? 'Welcome to lobby' : 'No mana left!']);

} catch (Exception $e) {

echo $e->getMessage();

}

die();

} else {

echo json_encode(['status' => 0, 'message' => 'No funky business here!']);

die();

}

}

add_action( 'wp_ajax_leave_a_seat', 'prefix_ajax_leave_a_seat' );

//add_action( 'wp_ajax_nopriv_take_a_seat', 'prefix_ajax_take_a_seat' );

function prefix_ajax_leave_a_seat() {

global $wpdb;

if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {

try {

$wpdb->query( $wpdb->prepare(

"

DELETE FROM esport_user_event

WHERE

user_id = %d

AND

event_id = %d

AND

date = %s

",

filter_input(INPUT_POST, 'id'),

filter_input(INPUT_POST, 'event'),

date('Y-m-d')

) );

echo json_encode(['status' => 1, 'message' => 'Regeneration!']);

} catch (Exception $e) {

echo $e->getMessage();

}

die();

} else {

echo json_encode(['status' => 0, 'message' => 'No funky business here!']);

die();

}

}

add_action( 'wp_ajax_update_a_lobby', 'prefix_ajax_update_a_lobby' );

add_action( 'wp_ajax_nopriv_update_a_lobby', 'prefix_ajax_update_a_lobby' );

function prefix_ajax_update_a_lobby() {

global $wpdb, $current_user;

if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {

$user = wp_get_current_user();

$query = $wpdb->get_results( $wpdb->prepare(

"SELECT

user_id, name

FROM

esport_user_event

WHERE

event_id = %d

AND

date = %s

ORDER BY

id asc

",

filter_input(INPUT_POST, 'event'),

date('Y-m-d')

));

$list = "";

if($wpdb->num_rows) {

$i = 1;

$seated = false;

foreach($query as $row) {

if($i <= 10) {

$list .= '<li class="player-'.$row->user_id.'">' . $row->name . '</li>';

}

if($row->user_id == $current_user->ID) {

$seated = $i;

}

$i++;

}

} else {

$list .= '<li><strong>Eingin í lobby</strong></li>';

}

echo json_encode(['status' => 1, 'count' => $wpdb->num_rows, 'list' => $list, 'seated' => $seated]);

die();

} else {

echo json_encode(['status' => 0, 'message' => 'No funky business here!']);

die();

}

}

Kemahiran: CSS, MySQL, PHP, Kejuruteraan Perisian, Wordpress

Lihat lagi: wordpress a to z, widget manager, what is a placeholder, this class jquery, teg a in php, sm software, rocket software, reis, p&a group, lg com, img wordpress, ikki ikki, ikki com, ikki, global p, foreach in php and mysql, btn group, base exception, asc it, a placeholder, admin cs, photobooth software event, free software event registration, image slide software website horizontal right left arrow, event management shopping cart software

Tentang Majikan:
( 0 ulasan ) Denmark

ID Projek: #10110959

5 pekerja bebas membida secara purata $88 untuk pekerjaan ini

VnBestSolutions

Dear Sir. We claim to get it done perfectly for you EXACTLY in the way you want it - Kindly give we a chance and we will prove myself - Ready to prove our words, let's get it done right away and I mean RIGHT AWAY !! Lo Lagi

$126 USD dalam 3 hari
(125 Ulasan)
6.6
furqaanwar

Hello Sir I am an expert web developer with an experience of over 6 years and graduate in computer science major. With development i myself do the designing and layout of the sites on which i work. I have that visio Lagi

$111 USD dalam sehari
(11 Ulasan)
4.9
yogeshssanwal

Hi there - My name is Jhalak. I’ve read your brief and can see that you’d like to build an Website. My team has 4 years experience designing and developing mobile apps and Websites. I would approach your project by sta Lagi

$25 USD dalam sehari
(42 Ulasan)
4.8
sonuraj20692

Relevant Experience and Qualifications: Hello Dear I am Sanjay Rajput… Your job attracted my attention because it is compatible with my freelancing interests and experience… For your fee, you will receive my und Lagi

$66 USD dalam sehari
(0 Ulasan)
0.0
$111 USD dalam 15 hari
(0 Ulasan)
0.0