<link rel="StyleSheet" href="<?php echo Banners_URL; ?>/admin/css/styles.css" type="text/css" media="screen, projection, print" />
<?php
global $wpdb;

if ($_POST['save_banner1_es']) {

    $allowedExts = array("jpg", "jpeg", "gif", "png");
    $extension = end(explode(".", $_FILES["BannerImg1es"]["name"]));
    if ((($_FILES["BannerImg1es"]["type"] == "image/gif")
                    || ($_FILES["BannerImg1es"]["type"] == "image/jpeg")
                    || ($_FILES["BannerImg1es"]["type"] == "image/png")
                    || ($_FILES["BannerImg1es"]["type"] == "image/pjpeg"))
                    && in_array($extension, $allowedExts))
    {
        if ($_FILES["BannerImg1es"]["error"] > 0) {
            echo "Return Code: " . $_FILES["BannerImg1es"]["error"] . "<br>";
        } else {
                $from = $_FILES["BannerImg1es"]["tmp_name"];
                $target = getcwd() . '/../wp-content/plugins/Banners/imgs-banners/' . $_FILES["BannerImg1es"]["name"];
                
                move_uploaded_file($from,$target);
                update_option('banner1_img_es', Banners_URL . '/imgs-banners/' . $_FILES["BannerImg1es"]["name"]);
        }
    }
    
    update_option('banner1_url_es', $_POST['BannerUrl1es']);
    update_option('banner1_alt_es', $_POST['BannerAlt1es']);
    
}

if ($_POST['save_banner1_eu']) {

    $allowedExts = array("jpg", "jpeg", "gif", "png");
    $extension = end(explode(".", $_FILES["BannerImg1eu"]["name"]));
    if ((($_FILES["BannerImg1eu"]["type"] == "image/gif")
                    || ($_FILES["BannerImg1eu"]["type"] == "image/jpeg")
                    || ($_FILES["BannerImg1eu"]["type"] == "image/png")
                    || ($_FILES["BannerImg1eu"]["type"] == "image/pjpeg"))
                    && in_array($extension, $allowedExts))
    {
        if ($_FILES["BannerImg1eu"]["error"] > 0) {
            echo "Return Code: " . $_FILES["BannerImg1eu"]["error"] . "<br>";
        } else {
            $from = $_FILES["BannerImg1eu"]["tmp_name"];
            $target = getcwd() . '/../wp-content/plugins/Banners/imgs-banners/' . $_FILES["BannerImg1eu"]["name"];

            move_uploaded_file($from,$target);
            update_option('banner1_img_eu', Banners_URL . '/imgs-banners/' . $_FILES["BannerImg1eu"]["name"]);
        }
    }

    update_option('banner1_url_eu', $_POST['BannerUrl1eu']);
    update_option('banner1_alt_eu', $_POST['BannerAlt1eu']);

}

if ($_POST['save_banner2_es']) {

    $allowedExts = array("jpg", "jpeg", "gif", "png");
    $extension = end(explode(".", $_FILES["BannerImg2es"]["name"]));
    if ((($_FILES["BannerImg2es"]["type"] == "image/gif")
                    || ($_FILES["BannerImg2es"]["type"] == "image/jpeg")
                    || ($_FILES["BannerImg2es"]["type"] == "image/png")
                    || ($_FILES["BannerImg2es"]["type"] == "image/pjpeg"))
                    && in_array($extension, $allowedExts))
    {
        if ($_FILES["BannerImg2es"]["error"] > 0) {
            echo "Return Code: " . $_FILES["BannerImg2es"]["error"] . "<br>";
        } else {
            $from = $_FILES["BannerImg2es"]["tmp_name"];
            $target = getcwd() . '/../wp-content/plugins/Banners/imgs-banners/' . $_FILES["BannerImg2es"]["name"];

            move_uploaded_file($from,$target);
            update_option('banner2_img_es', Banners_URL . '/imgs-banners/' . $_FILES["BannerImg2es"]["name"]);
        }
    }

    update_option('banner2_url_es', $_POST['BannerUrl2es']);
    update_option('banner2_alt_es', $_POST['BannerAlt2es']);

}

if ($_POST['save_banner2_eu']) {

    $allowedExts = array("jpg", "jpeg", "gif", "png");
    $extension = end(explode(".", $_FILES["BannerImg2eu"]["name"]));
    if ((($_FILES["BannerImg2eu"]["type"] == "image/gif")
                    || ($_FILES["BannerImg2eu"]["type"] == "image/jpeg")
                    || ($_FILES["BannerImg2eu"]["type"] == "image/png")
                    || ($_FILES["BannerImg2eu"]["type"] == "image/pjpeg"))
                    && in_array($extension, $allowedExts))
    {
        if ($_FILES["BannerImg2eu"]["error"] > 0) {
            echo "Return Code: " . $_FILES["BannerImg2eu"]["error"] . "<br>";
        } else {
            $from = $_FILES["BannerImg2eu"]["tmp_name"];
            $target = getcwd() . '/../wp-content/plugins/Banners/imgs-banners/' . $_FILES["BannerImg2eu"]["name"];

            move_uploaded_file($from,$target);
            update_option('banner2_img_eu', Banners_URL . '/imgs-banners/' . $_FILES["BannerImg2eu"]["name"]);
        }
    }

    update_option('banner2_url_eu', $_POST['BannerUrl2eu']);
    update_option('banner2_alt_eu', $_POST['BannerAlt2eu']);

}

?>
<div class="Banners-admin-div">
    <img style="float: left; margin: 13px; height: 34px;" src="<?php echo Banners_URL; ?>/admin/images/logo0.png" />
    <div class="title-main">
        <?php _e('Banners', 'buddypress'); ?>
    </div>
</div>


<div id="Banners-Content">

    <div id="Banner-Top">
        <form method="POST" action="" enctype="multipart/form-data" id="Banners-top-Es">
            
            <a href="<?php echo get_option('banner1_url_es'); ?>" alt="<?php echo get_option('banner1_alt_es'); ?>" style="float: left;">
                <img src="<?php echo get_option('banner1_img_es'); ?>" alt="<?php echo get_option('banner1_alt_es'); ?>" />
            </a>
            
            <label for="Banner-top-img"><?php _e('Imagen Banner 1 Es', 'buddypress'); ?></label>
            <input type="file" name="BannerImg1es" value="" id="Banner-top-img" />
            
            <label for="Banner-top-url"><?php _e('Url Banner 1 Es', 'buddypress'); ?></label>
            <input type="text" name="BannerUrl1es" value="<?php echo get_option('banner1_url_es'); ?>" id="Banner-top-url" />
            
            <label for="Banner-top-alt"><?php _e('Texto Alternativo Banner 1 Es', 'buddypress'); ?></label>
            <input type="text" name="BannerAlt1es" value="<?php echo get_option('banner1_alt_es'); ?>" id="Banner-top-alt" />
            
            <input type="submit" name="save_banner1_es" value="<?php _e('Guardar Banner 1 Es', 'buddypress'); ?>">
            
        </form>
        
        <form method="POST" action="" enctype="multipart/form-data" id="Banners-top-Eu">
            
            <a href="<?php echo get_option('banner1_url_eu'); ?>" alt="<?php echo get_option('banner1_alt_eu'); ?>" style="float: left;">
                <img src="<?php echo get_option('banner1_img_eu'); ?>" alt="<?php echo get_option('banner1_alt_eu'); ?>" />
            </a>
            
            <label for="Banner-top-img"><?php _e('Imagen Banner 1 Eu', 'buddypress'); ?></label>
            <input type="file" name="BannerImg1eu" value="" id="Banner-top-img" />
            
            <label for="Banner-top-url"><?php _e('Url Banner 1 Eu', 'buddypress'); ?></label>
            <input type="text" name="BannerUrl1eu" value="<?php echo get_option('banner1_url_eu'); ?>" id="Banner-top-url" />
            
            <label for="Banner-top-alt"><?php _e('Texto Alternativo Banner 1 Eu', 'buddypress'); ?></label>
            <input type="text" name="BannerAlt1eu" value="<?php echo get_option('banner1_alt_eu'); ?>" id="Banner-top-alt" />
            
            <input type="submit" name="save_banner1_eu" value="<?php _e('Guardar Banner 1 Eu', 'buddypress'); ?>">
            
        </form>
    </div>
    
    <div id="Banner-Bottom">
    
        <form method="POST" action="" enctype="multipart/form-data" id="Banners-bottom-Es">
            
            <a href="<?php echo get_option('banner2_url_es'); ?>" alt="<?php echo get_option('banner2_alt_es'); ?>" style="float: left;">
                <img src="<?php echo get_option('banner2_img_es'); ?>" alt="<?php echo get_option('banner2_alt_es'); ?>" />
            </a>
            
            <label for="Banner-top-img"><?php _e('Imagen Banner 2 Es', 'buddypress'); ?></label>
            <input type="file" name="BannerImg2es" value="" id="Banner-top-img" />
            
            <label for="Banner-top-url"><?php _e('Url Banner 2 Es', 'buddypress'); ?></label>
            <input type="text" name="BannerUrl2es" value="<?php echo get_option('banner2_url_es'); ?>" id="Banner-top-url" />
            
            <label for="Banner-top-alt"><?php _e('Texto Alternativo Banner 2 Es', 'buddypress'); ?></label>
            <input type="text" name="BannerAlt2es" value="<?php echo get_option('banner2_alt_es'); ?>" id="Banner-top-alt" />
            
            <input type="submit" name="save_banner2_es" value="<?php _e('Guardar Banner 2 Es', 'buddypress'); ?>">
        </form>
        
        <form method="POST" action="" enctype="multipart/form-data" id="Banners-bottom-Eu">
                
                <a href="<?php echo get_option('banner2_url_eu'); ?>" alt="<?php echo get_option('banner2_alt_eu'); ?>" style="float: left;">
                    <img src="<?php echo get_option('banner2_img_eu'); ?>" alt="<?php echo get_option('banner2_alt_eu'); ?>" />
                </a>
                
                <label for="Banner-top-img"><?php _e('Imagen Banner 2 Eu', 'buddypress'); ?></label>
                <input type="file" name="BannerImg2eu" value="" id="Banner-top-img" />
                
                <label for="Banner-top-url"><?php _e('Url Banner 2 Eu', 'buddypress'); ?></label>
                <input type="text" name="BannerUrl2eu" value="<?php echo get_option('banner2_url_eu'); ?>" id="Banner-top-url" />
                
                <label for="Banner-top-alt"><?php _e('Texto Alternativo Banner 2 Eu', 'buddypress'); ?></label>
                <input type="text" name="BannerAlt2eu" value="<?php echo get_option('banner2_alt_eu'); ?>" id="Banner-top-alt" />
                
                <input type="submit" name="save_banner2_eu" value="<?php _e('Guardar Banner 2 Eu', 'buddypress'); ?>">
            </form>
    
    </div>

</div>