<?php
/*
Plugin Name: MochiAds Arcade Plugin
Plugin URI: http://www.emanueleferonato.com/triqui-mochiads-arcade-plugin-for-wordpress-official-page/
Description: Turns your blog into a MochiAds Arcade portal.
Author: Emanuele Feronato
Version: 1.2
Author URI: http://www.emanueleferonato.com/
*/

add_action('admin_menu', 'add_plugin_pages');
add_action('admin_menu', 'load_scripts', 1);
add_action('wp_ajax_handle_mochi', 'handle_mochi' );

function handle_mochi(){
     global $wpdb;
     switch($_POST[func]){
          case "publish":
               mochi_add_games($_POST[id]);
               break;
          case "unpublish":
               mochi_unpublish_games($_POST[id]);
               break;
          case "delete";
               mochi_delete_games($_POST[blog_id]);
               break;
          case "toggle":
               mochi_toggle_games($_POST[id]);
               break;
          
     }
     echo_game($_POST[id]);
     die();
}

function load_scripts() {
     wp_enqueue_script('jquery');
     wp_enqueue_script('thickbox');
     $css = get_option('siteurl')."/".WPINC."/js/thickbox/thickbox.css";
     wp_enqueue_style('thickbox_css', $css, false, false, 'screen');
     $css = WP_PLUGIN_URL."/mochi/mochi.css";
     wp_enqueue_style('mochi_css', $css, false, false, 'screen');
}

function add_plugin_pages() {
     add_menu_page('MochiAds', 'MochiAds', 8, __FILE__, 'mt_toplevel_page',plugins_url('mochi/mochi.png'));
     add_submenu_page(__FILE__, 'Setup', 'Setup', 8, 'mochi-setup', 'mochi_setup');
     add_submenu_page(__FILE__, 'Feed Games', 'Feed Games', 8, 'mochi-feed-games', 'mochi_feed_games');
     add_submenu_page(__FILE__, 'Manage Games', 'Manage Games', 8, 'mochi-manage_games', 'mochi_manage_games');
}

function mt_toplevel_page() {
     echo "<h2 class = \"mochih2\">MochiAds Arcade Plugin</h2 class = \"mochih2\">";
     echo "<p>Welcome to <strong>MochiAds Arcade Plugin</strong></p>";
     echo "<p>This software is not developed and not supported by Mochi Media</p>";
     echo "<p>I simply love these guys and this plugin is a tribute to their excellent work</p>";
     echo "<p>For information about the use of this plugin, troubleshooting, updates and so on visit the <strong><a href = \"http://www.emanueleferonato.com/triqui-mochiads-arcade-plugin-for-wordpress-official-page/\">official page</a></strong> on my blog</p>";
     echo "<p>If you are making money out of it, please consider a small donation</p>";
     echo "<p><form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"><input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\"><input type=\"hidden\" name=\"hosted_button_id\" value=\"6222631\"><input type=\"image\" src=\"https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\"><img alt=\"\" border=\"0\" src=\"https://www.paypal.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\"></form></p>";
	echo "<p><iframe frameborder = \"0\" height = \"200\" width = \"500\" scrolling = \"auto\" src = \"http://www.triqui.com/_news.php\"></iframe></p>";
}

function mochi_manage_games(){
     $statuses = array("","new","published","unpublished");
     global $wpdb;
     if($_POST[limit]){
          $_POST[limit]=intval($_POST[limit]);
     }
     else{
          $_POST[limit]=20;
     }
     if($_POST[offset]){
          $_POST[offset]=intval($_POST[offset]);
     }
     else{
          $_POST[offset]=0;
     }
     if($_POST[status]){
          $_POST[status]=intval($_POST[status]);
          if($_POST[status]<1 or $_POST[status]>3){
               $_POST[status]=1;
          }
     }
     else{
          $_POST[status]=1;
     }
     echo "<h2 class = \"mochih2\">Manage Games</h2 class = \"mochih2\">";
     echo "<form method = \"post\">";
     echo "<p>Show <input name = \"limit\" value = \"$_POST[limit]\" type = \"text\" size = \"3\" maxlenght=\"3\"> games from offset <input name = \"offset\" value = \"$_POST[offset]\" type = \"text\" size = \"3\" maxlenght=\"3\"> marked as ";
     echo "<select name = \"status\">";
     for($x=1;$x<=3;$x++){
          $selected = "";
          if($_POST[status]==$x){
               $selected = "selected";
          }
          echo "<option $selected value = \"$x\">".$statuses[$x]."</option>";
     }
     echo "</select></p>";
     echo "<p>containing <input type = \"text\" name = \"cont\" value = \"$_POST[cont]\" /> in the name and <input type = \"text\" name = \"tagz\" value = \"$_POST[tagz]\" /> in the tags</p>";
     echo "<p><input type = \"submit\" value = \"Show\" /></p>";
     echo "</form>";
     $query = "select id from ".$wpdb->prefix."mochi where position(\"$_POST[cont]\" in name)>0 and position(\"$_POST[tagz]\" in tags)>0 and status = \"".$statuses[$_POST[status]]."\" order by feed_approval_created desc limit $_POST[offset],$_POST[limit]";
     $games = $wpdb->get_results($query,ARRAY_A);
     if($games){
          foreach($games as $game){
               echo_game($game[id]);
          }
     }
     else{
          echo "<p>No games with these search options</p>";
     }

}

function mochi_setup(){
     mochi_directory();
     mochi_create_categories();
     mochi_table();
     mochi_purge();
}

function echo_game($id){
     global $wpdb;
     $game = $wpdb->get_row("select * from ".$wpdb->prefix."mochi where id = $id",ARRAY_A);
     if($game[blog_url]){
          $game[swf_url]=$game[blog_url];
     }
     echo "<div id = \"game_$game[id]\"><div class = \"divstyle_$game[status]\" style = \"background-image:url($game[thumbnail_url]);\">";
     echo "<p>";
     if($game[coins_enabled]){
          echo "<strong>$$</strong> &bull; ";
     } 
     echo "<strong><a class=\"thickbox\" title = \"$game[name]\" href = \"".WP_PLUGIN_URL."/mochi/showswf.php?file=".str_replace("http://","",$game[swf_url])."&h=$game[height]&w=$game[width]&keepThis=true&TB_iframe=true&height=$game[height]&width=$game[width]\">$game[name]</a></strong> &bull; $game[width]x$game[height] &bull; Approved on ".substr($game[feed_approval_created],0,10)." &bull; Game size: ".round($game[swf_file_size]/1024)."kB &bull; id: $game[game_tag]</p>";
     
     echo "<p> Status: <strong>$game[status]</strong>";
     if($game[status]=="published"){
          if($game[blog_url]){
               echo " &bull; publisher feature: <span class = \"gameon\">ON</span> (you are getting publisher revenue from this game)&nbsp;&nbsp;&nbsp;<button  class = \"mochibutton\" type = \"button\" onclick = \"jQuery('#game_$game[id]').html('<div class = \'wip\' style = \'background-image:url($game[thumbnail_url])\'>Deleting game...</div>');jQuery.post('".ADMIN_COOKIE_PATH."/admin-ajax.php',{action:'handle_mochi',id:'$game[id]',func:'toggle'},function(data){jQuery('#game_$game[id]').html(data);});\">Turn off</button>";
          }
          else{
               echo " &bull; publisher feature: <span class = \"gameoff\">OFF</span> (you aren't getting publisher revenue from this game)&nbsp;&nbsp;&nbsp;<button class = \"mochibutton\" type = \"button\" onclick = \"jQuery('#game_$game[id]').html('<div class = \'wip\' style = \'background-image:url($game[thumbnail_url])\'>Downloading game...</div>');jQuery.post('".ADMIN_COOKIE_PATH."/admin-ajax.php',{action:'handle_mochi',id:'$game[id]',func:'toggle'},function(data){jQuery('#game_$game[id]').html(data);});\">Turn on</button>";
          }    
     }
     echo "</p>";
     echo "<p>";
     switch($game[status]){
          case "new":
               echo "<button type = \"button\" class = \"mochibutton\" onclick = \"jQuery('#game_$game[id]').html('<div class = \'wip\' style = \'background-image:url($game[thumbnail_url])\'>Updating game status...</div>');jQuery.post('".ADMIN_COOKIE_PATH."/admin-ajax.php',{action:'handle_mochi',id:'$game[id]',func:'publish'},function(data){jQuery('#game_$game[id]').html(data);});\">publish</button>";
               echo "<button type = \"button\" class = \"mochibutton\" onclick = \"jQuery('#game_$game[id]').html('<div class = \'wip\' style = \'background-image:url($game[thumbnail_url])\'>Updating game status...</div>');jQuery.post('".ADMIN_COOKIE_PATH."/admin-ajax.php',{action:'handle_mochi',id:'$game[id]',func:'unpublish'},function(data){jQuery('#game_$game[id]').html(data);});\">don't publish</button>";
               break;
          case "published":
               echo "<button type = \"button\" class = \"mochibutton\" onclick = \"jQuery('#game_$game[id]').html('<div class = \'wip\' style = \'background-image:url($game[thumbnail_url])\'>Updating game status...</div>');jQuery.post('".ADMIN_COOKIE_PATH."/admin-ajax.php',{action:'handle_mochi',id:'$game[id]',blog_id:'$game[blog_id]',func:'delete'},function(data){jQuery('#game_$game[id]').html(data);});\">delete</button>";         
               break;
          case "unpublished":
               echo "<button type = \"button\" class = \"mochibutton\" onclick = \"jQuery('#game_$game[id]').html('<div class = \'wip\' style = \'background-image:url($game[thumbnail_url])\'>Updating game status...</div>');jQuery.post('".ADMIN_COOKIE_PATH."/admin-ajax.php',{action:'handle_mochi',id:'$game[id]',func:'publish'},function(data){jQuery('#game_$game[id]').html(data);});\">publish</button>";
               break;
     }
     echo "</p>";
     echo "</div></div>";
}

function mochi_directory(){
     echo "<h2 class = \"mochih2\">Mochi Directory</h2 class = \"mochih2\">";
     $dirname = WP_PLUGIN_DIR."/mochi/mochigames";
     if (!file_exists($dirname)){
          $creation = mkdir($dirname, 0777);
          if($creation){
               echo "<p>Mochi Directory successfully created at <strong>$dirname</strong></p>";
          }
          else{
               echo "<p>Mochi Directory not created - try again</p>";
          }
     }
     else{
          echo "<p>Mochi Directory already created at <strong>$dirname</strong></p>";
     }
}

function mochi_toggle_games($id){
     global $wpdb;
     $id = intval($id);    
     $query = "select id,swf_url,blog_url,blog_id from ".$wpdb->prefix."mochi where id = $id";
     $game = $wpdb->get_row($query,ARRAY_A);
     if($game[blog_url]){
          $unlink = unlink($game[blog_url]);
          if($unlink){
               $query = "update ".$wpdb->prefix."mochi set blog_url = \"\" where id = $game[id]";
               $wpdb->query($query);
          }     
     }
     else{
          $filename = WP_PLUGIN_DIR."/mochi/mochigames/".$game[blog_id].".swf";
          $copy = copy($game[swf_url],$filename);
          if($copy){
               $query = "update ".$wpdb->prefix."mochi set blog_url = \"$filename\" where id = $game[id]";
               $wpdb->query($query);
          }   
     }   
}

function mochi_unpublish_games($id){
     global $wpdb;
     $id = intval($id);
     $query = "update ".$wpdb->prefix."mochi set status = 'unpublished' where id='$id'";
     $wpdb->query($query);
}

function mochi_delete_games($id){
     global $wpdb;
     $id = intval($id);
     $query = "update ".$wpdb->prefix."mochi set status = 'unpublished' where blog_id='$id'";
     $wpdb->query($query);
     wp_delete_post($id);
     $query = "select id,swf_url,blog_url from ".$wpdb->prefix."mochi where blog_id = $id";
     $game = $wpdb->get_row($query,ARRAY_A);
     if($game[blog_url]){
          $unlink = unlink($game[blog_url]);
          if($unlink){
               $query = "update ".$wpdb->prefix."mochi set blog_url = \"\" where id = $game[id]";
               $wpdb->query($query);
          }     
     } 
}

function mochi_add_games($id){
     global $wpdb;
     $id = intval($id);
     $inserted = false;
     $row = $wpdb->get_row("select * from ".$wpdb->prefix."mochi where status != 'published' and id = $id");
     if($row){
          $inserted = true;
          $cat_id = array();
          foreach($row as $varname => $varvalue) {
               $$varname = $varvalue;
          }
          $categs = explode(",",$categories);
          for($x=0;$x<count($categs);$x++){
               $categs[$x] = str_replace("-"," ",$categs[$x]);
               array_push ($cat_id,get_cat_id($categs[$x])); 
          }
          if($leaderboard_enabled){
               array_push ($cat_id,get_cat_id("High Scores")); 
          }
          $post = array();
          $post['post_title'] = $name;
          $post['post_status'] = 'publish';
          $post['post_author'] = 1;
          $post['post_type'] = 'post';
          $post['post_category'] = $cat_id;
          $post['post_date'] = $feed_approval_created;
          $post['tags_input'] =  $tags.','.$author;
          $post_id = wp_insert_post($post);
          add_post_meta($post_id, 'description', $description);
          add_post_meta($post_id, 'height', $height); 
          add_post_meta($post_id, 'instructions', $instructions);
          add_post_meta($post_id, 'author', $author);  
          add_post_meta($post_id, 'swf_url', $swf_url); 
          add_post_meta($post_id, 'thumbnail_url', $thumbnail_url); 
          add_post_meta($post_id, 'width', $width);
          $query = "update ".$wpdb->prefix."mochi set status = 'published', blog_id='$post_id' where id = $id";
          $wpdb->query($query); 
     }
}


function mochi_feed_games(){
     global $wpdb;
     $list = "";
     $inserted = 0;
     if($_POST[offset]){
          $_POST[offset]=intval($_POST[offset]);
     }
     else{
          $_POST[offset]=0;
     }
     if($_POST[limit]){
          $_POST[limit]=intval($_POST[limit]);
     }
     else{
          $_POST[limit]=100;
     }
     echo "<h2 class = \"mochih2\">Feed Games</h2 class = \"mochih2\">";
     echo "<form method = \"post\">";
     echo "<p>Looking for latest <input size = \"4\" value = \"$_POST[limit]\" type = \"text\" name = \"limit\"> games from offset <input size = \"4\" value = \"$_POST[offset]\" type = \"text\" name = \"offset\"> <input type = \"submit\" name = \"sub\" value = \"GO\"></p>";
     echo "</form>";
     $mochi_url = "http://www.mochiads.com/feeds/games?format=json&limit=$_POST[limit]&offset=$_POST[offset]";
     $feed = file_get_contents($mochi_url);
     $games_array = json_decode($feed,true);
     $number_of_games = count($games_array[games]);
     for($x=0;$x<$number_of_games;$x++){
          $insert = "";
          $values = "";
          foreach($games_array[games][$x] as $varname => $varvalue) {
               $$varname = $varvalue;
               if($varname=="controls"){
                    $app ="";
                    for($y=0;$y<count($controls);$y++){
                         $app.= implode("=",$controls[$y]);
                         if($y<count($controls)-1){
                              $app.= ";";  
                         }
                    }
                    $controls = $app;
               }
               if($varname=="tags"){	
                    $tags = implode(",",$tags); 
               }
               if($varname=="categories"){	
                    $categories = implode(",",$categories); 
               }
               $insert.= "$varname,";
               $values.= "'".str_replace("'","\\'",$$varname)."',";
          }
          $id = $wpdb->get_var("SELECT uuid FROM ".$wpdb->prefix."mochi WHERE game_tag = '$game_tag'");
          if(!$id){
               $query = "insert into ".$wpdb->prefix."mochi (".$insert."status)values(".$values."'new')";
               //echo $query."<br />";
			$list .= "<li style = \"color:green\">".$name."</li>";
               $wpdb->query($query);
               $inserted++;
          }
          else{
               $list .= "<li style = \"color:silver\">".$name."</li>";
          }
     }
     if($inserted){
          echo "<p>$inserted new games found</p>";
     }
     else{
          echo "<p>No new games at the moment...</p>";
     }
     echo "<p><ol>$list</ol></p>";
}

function mochi_create_categories() {
     echo "<h2 class = \"mochih2\">Categories</h2 class = \"mochih2\">";
     echo "<ul>";
     $categories = array("Action","Adventure","Board Game","Casino","Dress Up","Driving","Fighting","High Scores","Other","Customize","Puzzles","Shooting","Sports");
     $nicenames = array("action","adventure","board_game","casino","dress_up","driving","fighting","leaderboard_enabled","other","customize","puzzles","shooting","sports");
     for($x=0;$x<count($categories);$x++){ 
          $new_category = array("cat_name" => $categories[$x],"category_description" => "Flash $categories[$x] Games");
          $cat_id = wp_insert_category($new_category);
          if(!$cat_id){
               return(new IXR_Error(500, __("Sorry, the new category failed.")));
          }
          else{
               echo "<li><strong>$categories[$x]</strong> category successfully created with id = <strong>$cat_id</strong></li>";
          }
     }
     echo "</ul>";
}

function mochi_table() {
     global $wpdb;
     echo "<h2 class = \"mochih2\">Mysql table</h2 class = \"mochih2\">";
     $table_name = $wpdb->prefix . "mochi";
     $query = "CREATE TABLE `$table_name` (
     `id` int(11) NOT NULL auto_increment,
     `rating` text collate utf8_unicode_ci NOT NULL,
     `updated` text collate utf8_unicode_ci NOT NULL,
     `popularity` text collate utf8_unicode_ci NOT NULL,
     `description` text collate utf8_unicode_ci NOT NULL,
     `key_mappings` text collate utf8_unicode_ci NOT NULL,
     `height` text collate utf8_unicode_ci NOT NULL,
     `controls` text collate utf8_unicode_ci NOT NULL,
     `game_url` text collate utf8_unicode_ci NOT NULL,
     `tags` text collate utf8_unicode_ci NOT NULL,
     `slug` text collate utf8_unicode_ci NOT NULL,
     `categories` text collate utf8_unicode_ci NOT NULL,
     `instructions` text collate utf8_unicode_ci NOT NULL,
     `uuid` text collate utf8_unicode_ci NOT NULL,
     `author` text collate utf8_unicode_ci NOT NULL,
     `control_scheme` text collate utf8_unicode_ci NOT NULL,
     `author_link` text collate utf8_unicode_ci NOT NULL,
     `feed_approval_created` text collate utf8_unicode_ci NOT NULL,
     `name` text collate utf8_unicode_ci NOT NULL,
     `swf_url` text collate utf8_unicode_ci NOT NULL,
     `recommended` text collate utf8_unicode_ci NOT NULL,
     `thumbnail_url` text collate utf8_unicode_ci NOT NULL,
     `created` text collate utf8_unicode_ci NOT NULL,
     `game_tag` text collate utf8_unicode_ci NOT NULL,
     `leaderboard_enabled` text collate utf8_unicode_ci NOT NULL,
     `zip_url` text collate utf8_unicode_ci NOT NULL,
     `width` text collate utf8_unicode_ci NOT NULL,
     `status` text collate utf8_unicode_ci NOT NULL,
     PRIMARY KEY  (`id`)
     ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
     require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     dbDelta($query);
     $query = "ALTER TABLE `$table_name` ADD `swf_file_size` TEXT NOT NULL AFTER `key_mappings`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `recommendation` TEXT NOT NULL AFTER `controls`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `blog_url` TEXT NOT NULL AFTER `game_url`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `resolution` TEXT NOT NULL AFTER `width`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `blog_id` TEXT NOT NULL AFTER `status`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `coins_revshare_enabled` TEXT NOT NULL AFTER `recommendation`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `coins_enabled` TEXT NOT NULL AFTER `feed_approval_created`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `screen1_thumb` TEXT NOT NULL AFTER `key_mappings`;";
     $wpdb->query($query);
	 $query = "ALTER TABLE `$table_name` ADD `languages` TEXT NOT NULL AFTER `screen1_thumb`;";
	 $wpdb->query($query);
	  $query = "ALTER TABLE `$table_name` ADD `achievements_enabled` TEXT NOT NULL AFTER `languages`;";
	 $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `screen1_url` TEXT NOT NULL AFTER `zip_url`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `thumbnail_large_url` TEXT NOT NULL AFTER `width`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `screen2_thumb` TEXT NOT NULL AFTER `rating`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `screen2_url` TEXT NOT NULL AFTER `game_url`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `video_url` TEXT NOT NULL AFTER `author`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `screen3_thumb` TEXT NOT NULL AFTER `screen2_thumb`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `screen4_thumb` TEXT NOT NULL AFTER `screen3_thumb`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `screen3_url` TEXT NOT NULL AFTER `screen2_url`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `screen4_url` TEXT NOT NULL AFTER `screen3_url`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `alternate_url` TEXT NOT NULL AFTER `thumbnail_url`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `category` TEXT NOT NULL AFTER `coins_revshare_enabled`;";
     $wpdb->query($query);
     $query = "ALTER TABLE `$table_name` ADD `metascore` TEXT NOT NULL AFTER `screen1_thumb`;";
     $wpdb->query($query);
     echo "Table <strong>".$wpdb->prefix."mochi</strong> successfully created and updated (working at 2010-02-26)";
}

function mochi_purge(){
     global $wpdb;
     $removed = 0;
     echo "<h2 class = \"mochih2\">Removing duplicated games</h2 class = \"mochih2\">";
     $query = "select count(*) as ngames from ".$wpdb->prefix."mochi";
     $wpdb->query($query);
     $n_games = $wpdb->get_row($query,ARRAY_A);
     echo "<p>Games found: $n_games[ngames]</p>";
     $query = "select count(distinct game_tag) as ngames from ".$wpdb->prefix."mochi";
     $wpdb->query($query);
     $u_games = $wpdb->get_row($query,ARRAY_A);
     echo "<p>Unique games found: $u_games[ngames]</p>";
     if($n_games[ngames]!=$u_games[ngames]){
          echo "<p>Found duplicate games... deleting them... this could take a while...</p>";
          $query = "select id,game_tag from ".$wpdb->prefix."mochi order by id desc";
          $games = $wpdb->get_results($query,ARRAY_A);
          if($games){
               foreach($games as $game){
                    $query = "select id from ".$wpdb->prefix."mochi where id < $game[id] and game_tag = \"$game[game_tag]\"";
                    $copy = $wpdb->get_row($query,ARRAY_A);
                    if($copy[id]){
                         $query = "delete from ".$wpdb->prefix."mochi where id = $game[id]";
                         $wpdb->query($query);
                         $removed ++;
                    }
               }
          }
     }
     if($removed){
          echo "<p>".$removed." duplicated games successfully removed</p>";
     }
     else{
          echo "<p>No duplicated games found</p>";
     }
}

?>