AzureCamera - Habbo Hotel Camera API

Results 1 to 15 of 15
  1. #1
    git bisect -m ovflowd is offline
    MemberRank
    Sep 2011 Join Date
    2,191Posts

    happy AzureCamera - Habbo Hotel Camera API

    Hello Folks, after a while, i'm releasing the AzureCamera a PhP Class for Habbo Hotel Room Thumbnail and Habbo Câmera.




    For All Informations about the Script, check out the README, clicking here




    You can Download the lastest ZIP from the Repository by, clicking here




    You can help us to find bugs, submit pull requests, by clicking here




    You can also download the package by composer, using "composer require claudio.santoro/habbo-camera-server"




    We recommend for a fully working ServerCamera, using the BETA Habbo Asset Extractor (Code is BETA and weird, but totally working), by clicking here




    Snippets Entire Class xD
    Spoiler:
    PHP Code:
    <?php

    /**
     *      ,-. ,_, . . ,-. ,-. ,-. ,-. ,-,-. ,-. ,-. ,-.
     *      ,-|  /  | | |   |-' |   ,-| | | | |-' |   ,-|
     *      `-^ '"' `-^ '   `-' `-' `-^ ' ' ' `-' '   `-^
     * because a camera script need more than a good name.
     * @author Claudio A. Santoro Wunder
     * [MENTION=316612]Version[/MENTION] 1.0b
     * [MENTION=822345]Copyright[/MENTION] Sulake Corporation Oy
     */

    /**
     * [MENTION=310096]Abo[/MENTION]ut Azure Camera is a PhP class, that emulates Sulake's Habbo Hotel "in-game camera", (that applet that is used for Selfies)
     * [MENTION=310096]Abo[/MENTION]ut This script doesn't use any script or code-parts from Sulake Corporation Oy
     */

    /*
        Azure Camera PhP GD API, a Graphical PhP Class to Generate Habbo`s Camera API Images.
        Copyright (C) 2015 Claudio Santoro
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
    */

    /**
     * Few Words:
     *
     *      "The ultimate tragedy is not the oppression and cruelty by the bad people but the silence over that by the good people."
     * - Martin Luther King
     *
     * Read more at [url=http://www.brainyquote.com/quotes/authors/m/martin_luther_king_jr.html#zmow4kbu42Dpt9yH.99]Martin Luther King, Jr. Quotes - BrainyQuote[/url]
     */

    /*
     * Attention!
     * Is Required PhP 5.4x or Higher
     * Is Required Built-In GD Library
     * Is Recommended Safe Thread PhP Version
     * Is Recommended don't give CHMOD 777X for that file.
     * Is Recommended create a special user for that File.
     * Is Recommended Put Adobe's X-CORS Policy. Read in README.md
     * Any Dudes? Create Issues
     * And, if you are from Sulake.. Hello!
     */

    /**
     * Class CameraGD
     * @package AzureCamera
     * Main Class to Generate Image
     */
    final class CameraGD
    {
        
    /** [MENTION=1333430648]Var[/MENTION] array|mixed */
        
    private $json = [];
        
    /** [MENTION=1333430648]Var[/MENTION] resource */
        
    private $image;
        
    /** [MENTION=1333430648]Var[/MENTION] resource */
        
    private $image_small;
        
    /** [MENTION=1333430648]Var[/MENTION] array */
        
    private $settings = [];

        
    /**
         * Do the Thing
         * @author sant0ro
         *
         * [MENTION=2000183830]para[/MENTION]m array $settings
         */
        
    function __construct($settings = [])
        {
            
    /* set settings variables */
            
    $this->settings $settings;

            
    /* do an action */
            
    echo $this->trace_routers();
        }

        
    /**
         * # string manipulation functions #
         */

        /**
         * escape text to a safe string.
         *
         * [MENTION=2000183830]para[/MENTION]m array|mixed|string $text_string
         * [MENTION=850422]return[/MENTION] array|mixed|string
         */
        
    static function escape_text($text_string)
        {
            
    /* if is array, return the self method for each array value */
            
    if (is_array($text_string))
                return 
    array_map(__METHOD__$text_string);
            
    /* if isn't empty and if is a valid string.. */
            
    if ((!empty($text_string)) && (is_string($text_string)))
                return 
    str_replace(['\\'"\0""\n""\r""'"'"'"\x1a"], ['\\\\''\\0''\\n''\\r'"\\'"'\"''\\Z'], $text_string);
            
    /* if not return something that can be something.. */
            
    return $text_string;
        }

        
    /**
         * # magic functions #
         */

        /**
         * set a specific variable to a specific value
         *
         * [MENTION=2000183830]para[/MENTION]m string $variable
         * [MENTION=2000183830]para[/MENTION]m string $value
         */
        
    function __set($variable ''$value '')
        {
            
    $this->$variable self::escape_text($value);
        }

        
    /**
         * return a variable, if not exists, return null
         *
         * [MENTION=2000183830]para[/MENTION]m string $variable
         * [MENTION=850422]return[/MENTION] array|mixed|null|string
         */
        
    function __get($variable '')
        {
            return ((isset(
    $this->$variable)) ? self::escape_text($this->$variable) : null);
        }

        
    /**
         * # routing functions #
         */

        /**
         * trace routers and do the actions
         * @author Claudio Santoro
         * [MENTION=6887]Tod[/MENTION]o Improve this
         * [MENTION=574887]Observation[/MENTION] That is a Simple Router System.
         *
         * [MENTION=850422]return[/MENTION] mixed
         */
        
    private function trace_routers()
        {
            
    /* trace routers by get */
            
    switch (((isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : 'run')):
                case 
    'install':
                    return 
    $this->actions('install'true);
                case 
    'test':
                    return 
    $this->actions('test'true);
                case 
    'room':
                    return 
    $this->actions('room'false);
                default:
                case 
    'run':
                    return 
    $this->actions('run'false);
            endswitch;
        }

        
    /**
         * # camera functions #
         */

        /**
         * Do the Camera Script
         * @author Claudio Santoro
         *
         * [MENTION=2000183830]para[/MENTION]m string $json
         * [MENTION=2000183830]para[/MENTION]m bool $show_image
         * [MENTION=2000183830]para[/MENTION]m int $run_mode
         * [MENTION=850422]return[/MENTION] mixed
         */
        
    private function do_it($json ''$show_image false$run_mode 1)
        {
            
    /* let's get php input */
            
    if (empty($this->json json_decode($jsontrue)))
                return 
    $this->just_die('500''the php input, isn\'t a valid jSON data!'true);

            
    /* other prob y? */
            
    if ((!isset($this->json['roomid'])) || (!isset($this->json['timestamp'])))
                return 
    $this->just_die('403''the jSON doesn\'t contains timestamp || roomid'true);

            
    /* set the user-defined variables */
            
    $this->set_variables($this->settings, ($this->settings['image-settings']['path-settings']['image-url']), ($this->settings['thumbnail-settings']['path-settings']['image-url']), ($this->settings['room-thumbnail-settings']['path-settings']['image-url']));

            
    /* i love this song */
            
    return $this->let_it_go($show_image$run_mode);
        }

        
    /**
         * do system actions...
         * @author Claudio Santoro
         *
         * [MENTION=2000183830]para[/MENTION]m string $action_name
         * [MENTION=2000183830]para[/MENTION]m bool|false $only_white_list
         * [MENTION=850422]return[/MENTION] string|void
         */
        
    private function actions($action_name ''$only_white_list false)
        {
            
    /* check if your ip is in white list */
            
    if (($only_white_list) && (!in_array($_SERVER['REMOTE_ADDR'], $this->settings['white-list'])))
                return 
    $this->just_die('403''you have not authorization to execute that item'true);

            
    /* select an action */
            
    switch ($action_name):
                case 
    'run':
                    
    header('Content-Type:text/html; charset=UTF-8');
                    return 
    $this->do_it(file_get_contents('php://input'), false1);
                case 
    'room':
                    
    header('Content-Type:text/html; charset=UTF-8');
                    return 
    $this->do_it(file_get_contents('php://input'), false2);
                case 
    'install':
                    
    header('Content-Type:text/html; charset=UTF-8');
                    return 
    $this->create_folders();
                case 
    'test':
                    
    header('Content-Type: image/png');
                    return 
    $this->test_json();
                default:
                    
    header('Content-Type:text/html; charset=UTF-8');
                    return 
    $this->just_die('001''this action doesn\'t exists'true);
            endswitch;
        }

        
    /**
         * do the script in test mode
         * @author Claudio Santoro
         * [MENTION=574887]Observation[/MENTION] Used a Default jSON of Habbo Camera
         *
         * [MENTION=850422]return[/MENTION] mixed
         */
        
    private function test_json()
        {
            
    /* return the message with default mode */
            
    return $this->do_it('{ "planes": [ { "z": 2540.7555503285, "bottomAligned": false, "color": 0, "cornerPoints": [ { "x": 320, "y": 320 }, { "x": 0, "y": 320 }, { "x": 320, "y": 0 }, { "x": 0, "y": 0 } ], "texCols": [] }, { "z": 2410.9300623285, "bottomAligned": false, "color": 15790320, "cornerPoints": [ { "x": 177, "y": 192 }, { "x": 145, "y": 176 }, { "x": 209, "y": 176 }, { "x": 177, "y": 160 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 1506.1493179876, "bottomAligned": false, "color": 10066329, "cornerPoints": [ { "x": 273, "y": 29 }, { "x": 265, "y": 25 }, { "x": 281, "y": 25 }, { "x": 273, "y": 21 } ], "texCols": [] }, { "z": 1505.9755480235, "bottomAligned": false, "color": 10066329, "cornerPoints": [ { "x": 465, "y": 125 }, { "x": 273, "y": 29 }, { "x": 473, "y": 121 }, { "x": 281, "y": 25 } ], "texCols": [] }, { "z": 1505.9705480233, "bottomAligned": false, "color": 10066329, "cornerPoints": [ { "x": 49, "y": 141 }, { "x": 41, "y": 137 }, { "x": 273, "y": 29 }, { "x": 265, "y": 25 } ], "texCols": [] }, { "z": 1502.4311487396, "bottomAligned": false, "color": 10066329, "cornerPoints": [ { "x": 49, "y": 141 }, { "x": -15, "y": 109 }, { "x": 57, "y": 137 }, { "x": -7, "y": 105 } ], "texCols": [] }, { "masks": [ { "name": "door_64", "flipH": false, "flipV": false, "location": { "x": 128, "y": 29 } } ], "z": 1005.8245539166, "bottomAligned": false, "color": 13421772, "cornerPoints": [ { "x": 273, "y": 176 }, { "x": 49, "y": 288 }, { "x": 273, "y": 29 }, { "x": 49, "y": 141 } ], "texCols": [{"assetNames": ["wall_texture_64_3_wall_color_jagged3"]}] }, { "z": 1005.8224287303, "bottomAligned": false, "color": 16777215, "cornerPoints": [ { "x": 465, "y": 240 }, { "x": 273, "y": 144 }, { "x": 465, "y": 125 }, { "x": 273, "y": 29 } ], "texCols": [{"assetNames": ["wall_texture_64_3_wall_color_jagged3"]}] }, { "z": 1002.2851546329, "bottomAligned": false, "color": 16777215, "cornerPoints": [ { "x": 49, "y": 288 }, { "x": -15, "y": 256 }, { "x": 49, "y": 141 }, { "x": -15, "y": 109 } ], "texCols": [{"assetNames": ["wall_texture_64_3_wall_color_jagged3"]}] }, { "z": 1001.9421546338, "bottomAligned": false, "color": 15790320, "cornerPoints": [ { "x": -79, "y": 352 }, { "x": -143, "y": 320 }, { "x": 49, "y": 288 }, { "x": -15, "y": 256 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 1001.4078447412, "bottomAligned": false, "color": 15790320, "cornerPoints": [ { "x": 241, "y": 384 }, { "x": 49, "y": 288 }, { "x": 281, "y": 364 }, { "x": 89, "y": 268 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 1001.4038447411, "bottomAligned": false, "color": 13684944, "cornerPoints": [ { "x": 281, "y": 364 }, { "x": 89, "y": 268 }, { "x": 281, "y": 356 }, { "x": 89, "y": 260 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 1000.5319949204, "bottomAligned": false, "color": 15790320, "cornerPoints": [ { "x": 113, "y": 448 }, { "x": -79, "y": 352 }, { "x": 241, "y": 384 }, { "x": 49, "y": 288 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 999.57783340867, "bottomAligned": false, "color": 15790320, "cornerPoints": [ { "x": 281, "y": 356 }, { "x": 89, "y": 260 }, { "x": 289, "y": 352 }, { "x": 97, "y": 256 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 999.57383340859, "bottomAligned": false, "color": 13684944, "cornerPoints": [ { "x": 289, "y": 352 }, { "x": 97, "y": 256 }, { "x": 289, "y": 344 }, { "x": 97, "y": 248 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 997.74782207614, "bottomAligned": false, "color": 15790320, "cornerPoints": [ { "x": 289, "y": 344 }, { "x": 97, "y": 248 }, { "x": 297, "y": 340 }, { "x": 105, "y": 244 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 997.74382207606, "bottomAligned": false, "color": 13684944, "cornerPoints": [ { "x": 297, "y": 340 }, { "x": 105, "y": 244 }, { "x": 297, "y": 332 }, { "x": 105, "y": 236 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 997.44642873053, "bottomAligned": false, "color": 15790320, "cornerPoints": [ { "x": 305, "y": 320 }, { "x": 113, "y": 224 }, { "x": 465, "y": 240 }, { "x": 273, "y": 144 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 995.91781074361, "bottomAligned": false, "color": 15790320, "cornerPoints": [ { "x": 297, "y": 332 }, { "x": 105, "y": 236 }, { "x": 305, "y": 328 }, { "x": 113, "y": 232 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 995.91381074353, "bottomAligned": false, "color": 13684944, "cornerPoints": [ { "x": 305, "y": 328 }, { "x": 113, "y": 232 }, { "x": 305, "y": 320 }, { "x": 113, "y": 224 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] }, { "z": 995.20873088684, "bottomAligned": false, "color": 11579568, "cornerPoints": [ { "x": 465, "y": 248 }, { "x": 305, "y": 328 }, { "x": 465, "y": 240 }, { "x": 305, "y": 320 } ], "texCols": [{"assetNames": ["floor_texture_64_1_floor_tiles5"]}] } ], "sprites": [ { "name": "pixel_floor_silver_64_b_0_0", "x": -79, "color": 16777215, "y": 255, "z": 71.788064989959 }, { "name": "pixel_floor_silver_64_b_0_0", "x": -15, "color": 16777215, "y": 287, "z": 70.37389759669 }, { "name": "pixel_floor_silver_64_b_0_0", "x": -79, "color": 16777215, "y": 319, "z": 68.959745564013 }, { "name": "pixel_floor_silver_64_a_0_0", "x": -79, "color": 16777215, "y": 256, "z": 36.433433037376 }, { "name": "pixel_floor_silver_64_a_0_0", "x": -15, "color": 16777215, "y": 288, "z": 35.019265644107 }, { "name": "cubie_shelf_1_b_64_a_0_0", "x": 278, "color": 16777215, "y": 130, "z": 3.8992843786696 }, { "name": "cubie_shelf_1_b_64_b_0_4", "x": 284, "color": 16777215, "y": 149, "z": 3.8985772719254 }, { "name": "cubie_shelf_2_b_64_a_0_0", "x": 310, "color": 16777215, "y": 146, "z": 3.1922083617946 }, { "name": "cubie_shelf_2_b_64_b_0_1", "x": 316, "color": 16777215, "y": 170, "z": 3.1915012550504 }, { "name": "usva_shelf_64_sd_0_0", "color": 16777215, "y": 240, "z": 1.7780717322081, "x": 272, "alpha": 48 }, { "name": "usva_shelf_64_b_0_1", "x": 272, "color": 16777215, "y": 199, "z": 1.7780717321711 }, { "name": "h_std_sd_1_0_0", "color": 16777215, "y": 249, "z": 1.3638735741835, "x": 192, "alpha": 50 }, { "name": "pura_mdl2_64_d_0_0", "x": 208, "color": 16777215, "y": 192, "z": 1.0794425525807 }, { "name": "pixel_bed_blue_64_sd_0_0", "flipH": true, "y": 276, "z": 1.0780534903108, "x": -103, "alpha": 48, "color": 16777215 }, { "name": "pura_mdl2_64_a_0_0", "x": 208, "color": 16777215, "y": 219, "z": 1.0780283389074 }, { "name": "pura_mdl2_64_b_0_0", "x": 213, "color": 6204152, "y": 211, "z": 1.0773212321632 }, { "name": "usva_shelf_64_a_0_1", "x": 273, "color": 16777215, "y": 200, "z": 1.0709649509475 }, { "name": "pura_mdl2_64_c_0_0", "x": 214, "color": 6204152, "y": 205, "z": 1.0483298541715 }, { "name": "pura_mdl3_64_a_0_0", "x": 240, "color": 16777215, "y": 235, "z": 0.38226603171534 }, { "name": "pura_mdl3_64_b_0_0", "x": 239, "color": 6204152, "y": 224, "z": 0.38085181818997 }, { "name": "avatar_0", "x": 164, "color": 16777215, "y": 142, "z": 0.35287357414649 }, { "name": "h_std_bd_1_3_0", "x": 197, "color": 16763800, "y": 206, "z": 0.35287357414649 }, { "name": "h_std_sh_2044_3_0", "x": 199, "color": 12971494, "y": 254, "z": 0.35277357414649 }, { "name": "h_std_sh_2045_3_0", "x": 200, "color": 14540253, "y": 255, "z": 0.35267357414649 }, { "name": "h_std_lg_2129_3_0", "x": 198, "y": 235, "z": 0.35257357414649 }, { "name": "h_std_lg_2130_3_0", "x": 199, "color": 7572334, "y": 239, "z": 0.35247357414649 }, { "name": "h_std_ch_2126_3_0", "x": 202, "y": 208, "z": 0.35237357414649 }, { "name": "h_std_ch_2127_3_0", "x": 207, "color": 1973790, "y": 216, "z": 0.35227357414649 }, { "name": "h_std_ch_2128_3_0", "x": 198, "color": 13016945, "y": 206, "z": 0.35217357414649 }, { "name": "h_std_hd_3_3_0", "x": 196, "color": 16763800, "y": 182, "z": 0.35207357414649 }, { "name": "h_std_fc_1_3_0", "x": 206, "color": 16763800, "y": 204, "z": 0.35197357414649 }, { "name": "h_std_ey_1_3_0", "x": 202, "y": 198, "z": 0.35187357414649 }, { "name": "h_std_hr_2268_3_0", "x": 194, "color": 7816226, "y": 171, "z": 0.35177357414649 }, { "name": "h_std_hrb_2268_3_0", "x": 194, "color": 7816226, "y": 171, "z": 0.35167357414649 }, { "name": "h_std_lh_1_3_0", "x": 218, "color": 16763800, "y": 208, "z": 0.35157357414649 }, { "name": "h_std_ls_2128_3_0", "x": 218, "color": 13016945, "y": 206, "z": 0.35147357414649 }, { "name": "h_std_rh_1_3_0", "x": 193, "color": 16763800, "y": 208, "z": 0.35137357414649 }, { "name": "h_std_rs_2128_3_0", "x": 193, "color": 13016945, "y": 206, "z": 0.35127357414649 }, { "name": "pura_mdl3_64_c_0_0", "x": 240, "color": 6204152, "y": 218, "z": 0.34408226560527 }, { "name": "pura_mdl1_64_a_0_0", "x": 272, "color": 16777215, "y": 251, "z": -0.33612369450966 }, { "name": "pura_mdl1_64_b_0_0", "x": 271, "color": 6204152, "y": 240, "z": -0.33683080125385 }, { "name": "pixel_bed_blue_64_b_0_0", "color": 16777215, "y": 240, "z": -0.33686717895446, "x": -109, "flipH": true }, { "name": "pura_mdl1_64_c_0_0", "x": 272, "color": 6204152, "y": 234, "z": -0.3658221792455 }, { "name": "pura_mdl1_64_d_0_0", "x": 300, "color": 16777215, "y": 238, "z": -0.36652928598968 }, { "name": "pixel_bed_blue_64_c_0_0", "color": 16777215, "y": 274, "z": -0.69112767629192, "x": -78, "flipH": true }, { "name": "pixel_bed_blue_64_d_0_0", "color": 16777215, "y": 290, "z": -1.3989415642227, "x": -46, "flipH": true }, { "name": "chair_polyfon_64_a_2_0", "color": 16777215, "y": 313, "z": -3.1431911580272, "x": 171, "flipH": true } ], "modifiers": [], "filters": [], "roomid": 3, "status": 108, "timestamp": 1436635320404, "checksum": 6097 }'true);
        }

        
    /**
         * create default folders...
         * @author Claudio Santoro
         *
         * [MENTION=850422]return[/MENTION] string|void
         */
        
    private function create_folders()
        {
            
    /* check existence of masks folder */
            
    self::create_folder($this->settings['folder-settings']['masks-folder']);

            
    /* check existence of sprites folder */
            
    self::create_folder($this->settings['folder-settings']['sprites-folder']);

            
    /* check existence of thumbnail output folder */
            
    self::create_folder($this->settings['thumbnail-settings']['path-settings']['server-camera']);

            
    /* check existence of image output folder */
            
    self::create_folder($this->settings['image-settings']['path-settings']['server-camera']);

            
    /* show success message */
            
    return $this->just_show('Yes. Folders Created Successfully..'true);
        }

        
    /**
         * create folder first checking if everything is valid
         *
         * [MENTION=2000183830]para[/MENTION]m string $folder_name
         */
        
    static private function create_folder($folder_name '')
        {
            
    /** create a secure folder (or not kidding) */
            
    if ((!empty($folder_name) && (!is_dir($folder_name))))
                
    mkdir($folder_name0755);
        }

        
    /**
         * define run-time global variables
         *
         * [MENTION=2000183830]para[/MENTION]m string $name
         * [MENTION=2000183830]para[/MENTION]m string $value
         */
        
    static private function set_variable($name ''$value '')
        {
            
    /* must check if is a valid string yeah? */
            
    if (((!empty($name)) && (!empty($value))) && ((is_string($name) && ((is_string($value)) || (is_numeric($value))))))
                
    defined($name) || define($name$value);
        }

        
    /**
         * set the user defined variables of the CameraGD script.
         *
         * [MENTION=2000183830]para[/MENTION]m array $settings
         * [MENTION=2000183830]para[/MENTION]m string $image_url
         * [MENTION=2000183830]para[/MENTION]m string $image_small_url
         * [MENTION=2000183830]para[/MENTION]m string $image_room_url
         */
        
    private function set_variables($settings = [], $image_url ''$image_small_url ''$image_room_url '')
        {
            
    /* let's do it now! */
            
    $image_url       = ((($settings['image-settings']['path-settings']['image-name']) == 'default') ? str_replace('[IMAGE_URL]', ($this->json['roomid'] . '-' $this->json['timestamp']), $image_url) : (str_replace('[IMAGE_URL]', ($settings['image-settings']['path-settings']['image-name']), $image_url)));
            
    $image_small_url = ((($settings['thumbnail-settings']['path-settings']['image-name']) == 'default') ? str_replace('[IMAGE_SMALL_URL]', ($this->json['roomid'] . '-' $this->json['timestamp'] . '_small'), $image_small_url) : (str_replace('[IMAGE_SMALL_URL]', ($settings['thumbnail-settings']['path-settings']['image-name']), $image_small_url)));

            
    /* define folder-path variables */
            
    self::set_variable('ROOT_DIR'__DIR__);

            
    /* variable for room_id */
            
    self::set_variable('ROOM_ID', ($this->json['roomid']));

            
    /* variable for time-stamp */
            
    self::set_variable('TIME_STAMP', ($this->json['timestamp']));

            
    /* camera main image sizes */
            
    self::set_variable('IMAGE_W', ($settings['image-settings']['size-settings']['image-width']));
            
    self::set_variable('IMAGE_H', ($settings['image-settings']['size-settings']['image-height']));

            
    /* camera thumbnail image sizes */
            
    self::set_variable('IMAGE_R_W', ($settings['room-thumbnail-settings']['size-settings']['image-width']));
            
    self::set_variable('IMAGE_R_H', ($settings['room-thumbnail-settings']['size-settings']['image-height']));

            
    /* camera room thumbnail image sizes */
            
    self::set_variable('IMAGE_S_W', ($settings['thumbnail-settings']['size-settings']['image-width']));
            
    self::set_variable('IMAGE_S_H', ($settings['thumbnail-settings']['size-settings']['image-height']));

            
    /* server-camera image root dir (output for generated images) */
            
    self::set_variable('SERVER_CAMERA', ($settings['image-settings']['path-settings']['server-camera']));

            
    /* server-camera thumbnail root dir (output for generated images) */
            
    self::set_variable('SERVER_CAMERA_S', ($settings['thumbnail-settings']['path-settings']['server-camera']));

            
    /* validate hotel requester image country */
            
    self::set_variable('HOTEL_COUNTRY', ((($settings['image-settings']['path-settings']['hotel-country']) == 'default') ? $this->visitor_country((@$_SERVER['HTTP_CLIENT_IP']), (@$_SERVER['HTTP_X_FORWARDED_FOR']), (@$_SERVER['REMOTE_ADDR'])) : strtolower($settings['image-settings']['path-settings']['hotel-country'])));

            
    /* validate hotel requester thumbnail country */
            
    self::set_variable('HOTEL_COUNTRY_S', ((($settings['thumbnail-settings']['path-settings']['hotel-country']) == 'default') ? $this->visitor_country((@$_SERVER['HTTP_CLIENT_IP']), (@$_SERVER['HTTP_X_FORWARDED_FOR']), (@$_SERVER['REMOTE_ADDR'])) : strtolower($settings['thumbnail-settings']['path-settings']['hotel-country'])));

            
    /* validate hotel requester room thumbnail country */
            
    self::set_variable('HOTEL_COUNTRY_R', ((($settings['room-thumbnail-settings']['path-settings']['hotel-country']) == 'default') ? $this->visitor_country((@$_SERVER['HTTP_CLIENT_IP']), (@$_SERVER['HTTP_X_FORWARDED_FOR']), (@$_SERVER['REMOTE_ADDR'])) : strtolower($settings['room-thumbnail-settings']['path-settings']['hotel-country'])));

            
    /**
             * you need Habbo avatars, furniture, effects, and pets sprites extracted manually from all SWF's.
             * you can get, extract all seeing the habbo-asset-extractor repository.
             * [MENTION=2000172648]link[/MENTION] [url]http://github.com/sant0ro/habbo-asset-extractor/[/url]
             *
             * @author Claudio Santoro
             * @package habbo-asset-extractor
             */
            
    self::set_variable('SPRITES_ROOT'ROOT_DIR . ($settings['folder-settings']['sprites-folder']));
            
    self::set_variable('MASKS_ROOT'ROOT_DIR . ($settings['folder-settings']['masks-folder']));

            
    /* camera main image url */
            
    self::set_variable('IMAGE_URL'str_replace('[SERVER_CAMERA]'SERVER_CAMERAstr_replace('[HOTEL_COUNTRY]'HOTEL_COUNTRY$image_url)));

            
    /* camera thumbnail image url */
            
    self::set_variable('IMAGE_SMALL_URL'str_replace('[SERVER_CAMERA_S]'SERVER_CAMERA_Sstr_replace('[HOTEL_COUNTRY_S]'HOTEL_COUNTRY_S$image_small_url)));

            
    /* camera room thumbnail image url */
            
    self::set_variable('IMAGE_ROOM_URL'str_replace('[HOTEL_COUNTRY_R]'HOTEL_COUNTRY_R$image_room_url));
        }

        
    /**
         * get visitors country code
         * [MENTION=2000170950]InDeed[/MENTION] visitors in this case need to bet the Habbo Client requesting the Camera..
         * [MENTION=2000170950]InDeed[/MENTION] If this not happen you have security Violation
         * [MENTION=287391]See[/MENTION] Adobe's Flash X-CORS HTTP Request Policy (crossdomain.xml)
         * [MENTION=2000172648]link[/MENTION] [url]http://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html[/url]
         * @author Claudio Santoro
         *
         * [MENTION=2000183830]para[/MENTION]m string $client HTTP_CLIENT_IP
         * [MENTION=2000183830]para[/MENTION]m string $forward HTTP_X_FORWARDED_FOR
         * [MENTION=2000183830]para[/MENTION]m string $remote REMOTE_ADDR
         * [MENTION=850422]return[/MENTION] string Country Code
         */
        
    private function visitor_country($client ''$forward ''$remote '')
        {
            
    /* filter ip data, check if is valid, and get geoplugin ip data */
            
    $ip_data json_decode(file_get_contents('http://www.geoplugin.net/json.gp?ip=' . ((filter_var($clientFILTER_VALIDATE_IP)) ? $client : ((filter_var($forwardFILTER_VALIDATE_IP)) ? $forward $remote))));

            
    /* return country code */
            
    return strtolower(((($ip_data) && ($ip_data->geoplugin_countryCode != null)) ? ($ip_data->geoplugin_countryCode) : 'us'));
        }

        
    /**
         * let it go
         * allocate image and call all image voids
         * @author Claudio Santoro
         *
         * [MENTION=2000183830]para[/MENTION]m bool $show_image
         * [MENTION=2000183830]para[/MENTION]m int $run_mode
         * [MENTION=850422]return[/MENTION] mixed
         */
        
    private function let_it_go($show_image false$run_mode 1)
        {
            
    /* let allocate everything */
            
    $this->image imagecreatetruecolor((($run_mode == 1) ? IMAGE_W IMAGE_R_W), (($run_mode == 1) ? IMAGE_H IMAGE_R_H));

            
    /* render all jSON planes */
            
    $this->render_planes();

            
    /* render all jSON sprites */
            
    $this->render_sprites();

            
    /* create thumbnail image */
            
    ($run_mode != 1) || $this->smaller_image();

            
    /* save the image */
            
    $this->image_create($show_image$run_mode);

            if (
    $run_mode == 2) return null;

            
    /* i must give back the url of main image because CLIENT need's */
            
    if ($show_image) return $this->image;

            
    /* if don't need to show image */
            
    return IMAGE_URL;
        }

        
    /**
         * Converts a Hex String into RGB
         * Based on
         * [MENTION=2000172648]link[/MENTION] [url]http://bavotasan.com/2011/convert-hex-color-to-rgb-using-php/[/url]
         * @author Claudio Santoro, C.Bavota
         *
         * [MENTION=2000183830]para[/MENTION]m string $hex Input Hex
         * [MENTION=850422]return[/MENTION] array RGB String
         */
        
    private function hex_to_rgb($hex '')
        {
            
    // remove the hex identifier tag
            
    $hex str_replace('#'''$hex);

            
    // replaces the correspondent hex value
            
    $r = ((strlen($hex) == 3) ? hexdec(substr($hex01) . substr($hex01)) : hexdec(substr($hex02)));
            
    $g = ((strlen($hex) == 3) ? hexdec(substr($hex11) . substr($hex11)) : hexdec(substr($hex22)));
            
    $b = ((strlen($hex) == 3) ? hexdec(substr($hex21) . substr($hex21)) : hexdec(substr($hex42)));

            
    // return rgb array
            
    return [$r$g$b];
        }

        
    /**
         * Colorize a image part set Image
         * @author Claudio Santoro
         *
         * [MENTION=2000183830]para[/MENTION]m resource $image Resource Link
         * [MENTION=2000183830]para[/MENTION]m integer $red R-GB
         * [MENTION=2000183830]para[/MENTION]m integer $green R-G-B
         * [MENTION=2000183830]para[/MENTION]m integer $blue RG-B
         */
        
    private function image_recolor(&$image$red 255$green 255$blue 255)
        {
            
    // get image width and height
            
    $width  imagesx($image);
            
    $height imagesy($image);

            
    // recolor every pixel
            
    for ($x 0$x $width$x++) for ($y 0$y $height$y++) self::part_recolor($image$red$green$blue$x$y);
        }

        
    /**
         * recolor specific pixel of a given image
         * @author AntoineFR
         * [MENTION=440911]Edit[/MENTION]or Claudio Santoro
         *
         * [MENTION=2000183830]para[/MENTION]m $image
         * [MENTION=2000183830]para[/MENTION]m int $red
         * [MENTION=2000183830]para[/MENTION]m int $green
         * [MENTION=2000183830]para[/MENTION]m int $blue
         * [MENTION=2000183830]para[/MENTION]m int $x
         * [MENTION=2000183830]para[/MENTION]m int $y
         */
        
    static private function part_recolor(&$image$red 255$green 255$blue 255$x 0$y 0)
        {
            
    // get rgb of the pixel
            
    $rgb imagecolorsforindex($image, (imagecolorat($image$x$y)));

            
    // put the rgb color
            
    $r = (($red 255) * ($rgb['red']));
            
    $g = (($green 255) * ($rgb['green']));
            
    $b = (($blue 255) * ($rgb['blue']));

            
    // set the new pixel
            
    imagesetpixel($image$x$y, (imagecolorallocatealpha($image$r$g$b, ($rgb['alpha']))));
        }

        
    /**
         * An Old but Needed function for the Actual Days of PhP
         * [MENTION=1333455600]source[/MENTION] [url]http://forums.devnetwork.net/viewtopic.php?f=1&t=103330#p553333[/url]
         * @author RedMonkey
         * [MENTION=440911]Edit[/MENTION]or Claudio Santoro
         *
         *  [MENTION=574887]Observation[/MENTION] Sorry of this function need to be big. Is because the simpliest approaches found in internet"
         * "doesn't work as well that these approach.."
         * "i know oop need small functions, but sorry"
         *
         * [MENTION=2000183830]para[/MENTION]m resource $dst Destination Allocated Image
         * [MENTION=2000183830]para[/MENTION]m resource $src Source Allocated Image
         * [MENTION=2000183830]para[/MENTION]m int $dst_x Destination Position X
         * [MENTION=2000183830]para[/MENTION]m int $dst_y Destination Position Y
         * [MENTION=2000183830]para[/MENTION]m int $src_x Source Position X
         * [MENTION=2000183830]para[/MENTION]m int $src_y Source Position Y
         * [MENTION=2000183830]para[/MENTION]m int $w Width
         * [MENTION=2000183830]para[/MENTION]m int $h Height
         * [MENTION=2000183830]para[/MENTION]m int $pct Alpha Percent
         * [MENTION=850422]return[/MENTION] null
         */
        
    private function image_copy_merge_with_alpha($dst$src$dst_x 0$dst_y 0$src_x 0$src_y 0$w 0$h 0$pct 100)
        {
            
    /* yes divide */
            
    $pct /= 100;

            
    /* make sure opacity level is within range before going any further */
            
    $pct max(min(1$pct), 0);

            
    /* work out if we need to bother correcting for opacity */
            
    if ($pct 1):
                
    /* we need a copy of the original to work from, only copy the cropped */
                /* area of src                                                        */
                
    $src_copy imagecreatetruecolor($w$h);

                
    /* attempt to maintain alpha levels, alpha blending must be *off* */
                
    imagealphablending($src_copyfalse);
                
    imagesavealpha($src_copytrue);

                
    imagecopy($src_copy$src00$src_x$src_y$w$h);

                
    /* we need to know the max transparency of the image */
                
    $max_t 0;

                for (
    $y 0$y $h$y++):
                    for (
    $x 0$x $w$x++):
                        
    $src_c imagecolorat($src_copy$x$y);
                        
    $src_a = (($src_c >> 24) & 0xFF);
                        
    $max_t = (($src_a $max_t) ? $src_a $max_t);
                    endfor;
                endfor;

                
    /* src has no transparency? set it to use full alpha range */
                
    $max_t = (($max_t == 0) ? 127 $max_t);

                
    /* $max_t is now being reused as the correction factor to apply based */
                /* on the original transparency range of  src                         */
                
    $max_t /= 127;

                
    /* go back through the image adjusting alpha channel as required */
                
    for ($y 0$y $h$y++):
                    for (
    $x 0$x $w$x++):
                        
    $src_c imagecolorat($src$src_x $x$src_y $y);
                        
    $src_a = (($src_c >> 24) & 0xFF);
                        
    $src_r = (($src_c >> 16) & 0xFF);
                        
    $src_g = (($src_c >> 8) & 0xFF);
                        
    $src_b = (($src_c) & 0xFF);

                        
    /* alpha channel compensation */
                        
    $src_a = ((($src_a 127) - (127 $pct)) * $max_t);
                        
    $src_a = (($src_a 127) ? 127 : (int)$src_a);

                        
    /* get and set this pixel's adjusted RGBA colour index */
                        
    $rgba imagecolorallocatealpha($src_copy$src_r$src_g$src_b$src_a);

                        
    /* [MENTION=774304]Method[/MENTION] /imagecolorclosestalpha returns -1 for PHP versions prior  */
                        /* to 5.1.3 when allocation failed */
                        
    if (($rgba === false) || ($rgba == -1)) $rgba imagecolorclosestalpha($src_copy$src_r$src_g$src_b$src_a);

                        
    imagesetpixel($src_copy$x$y$rgba);
                    endfor;
                endfor;

                
    /* call image copy passing our alpha adjusted image as src */
                
    imagecopy($dst$src_copy$dst_x$dst_y00$w$h);

                
    /* cleanup, free memory */
                
    imagedestroy($src_copy);
                return 
    null;
            endif;

            
    /* still here? no opacity adjustment required so pass straight through to */
            /* [MENTION=774304]Method[/MENTION] /imagecopy rather than [MENTION=774304]Method[/MENTION] /imagecopymerge to retain alpha channels          */
            
    imagecopy($dst$src$dst_x$dst_y$src_x$src_y$w$h);
            return 
    null;
        }

        
    /**
         * rotate_polygon
         * [MENTION=437887]Beta[/MENTION]
         * This Function is a Experimental Function to try to Create a 2d Polygon Distortion
         * These Function Reassing Polygon |Corner Points| Coordinates
         * [MENTION=2000172648]link[/MENTION] [url]http://stackoverflow.com/a/29352686[/url]
         * @author Steve Burgess
         * [MENTION=440911]Edit[/MENTION]or Claudio Santoro
         *
         * [MENTION=2000183830]para[/MENTION]m array $polygon Original Corner Points
         * [MENTION=2000183830]para[/MENTION]m int $angle
         * [MENTION=2000183830]para[/MENTION]m int $centre_x
         * [MENTION=2000183830]para[/MENTION]m int $centre_y
         * [MENTION=2000183830]para[/MENTION]m int $scale
         * [MENTION=850422]return[/MENTION] array Reassigned Corner Points
         */
        
    static private function rotate_polygon($polygon = [], $angle 0$centre_x 0$centre_y 0$scale 1)
        {
            
    /** I have negated the angle here so the function rotates in the same
             * direction as the imagerotate() function in PHP
             *
             * PHP Trigonometric Functions (e.g. cosine, sine) require the angle to
             * be in radians rather than degrees - hence the deg2rad() conversion.
             */

            
    $angle deg2rad(-$angle);

            if (
    $scale <> 1):
                
    // Using the array_map() function performs the scaling for the entire array
                // in one line - rather than having to write code that loops through the array.

                
    $polygon_scaled array_map("scale"$polygonarray_fill(0count($polygon), $scale));
                
    $polygon        $polygon_scaled;
                
    $centre_x       = ($centre_x $scale);
                
    $centre_y       = ($centre_y $scale);
            endif;

            
    $rotated = [];

            for (
    $i 0$i count($polygon); $i $i 2):
                
    // Using the array map function to perform these transformations was beyond me.
                // If anyone has any bright ideas about this, please drop me a line

                // Original coordinates of each point
                
    $x $polygon[$i];
                
    $y $polygon[$i 1];

                
    // As imagepolygon requires a 1 dimensional array, the new x and the new y
                // coordinates are simply added to the rotated array one after the other
                
    $rotated[] = ($centre_x + (($x $centre_x) * cos($angle)) - (($y $centre_y) * sin($angle)));
                
    $rotated[] = ($centre_y + (($x $centre_x) * sin($angle)) + (($y $centre_y) * cos($angle)));
            endfor;

            return 
    $rotated;
        }

        
    /**
         * render specific tex_col
         *
         * [MENTION=2000183830]para[/MENTION]m array $tex_col
         * [MENTION=2000183830]para[/MENTION]m array $color_rgb
         * [MENTION=2000183830]para[/MENTION]m array $polygon_array
         * [MENTION=2000183830]para[/MENTION]m int $a CornerPoints [0]X
         * [MENTION=2000183830]para[/MENTION]m int $b CornerPoints [0]Y
         * [MENTION=2000183830]para[/MENTION]m int $c Plane Z:
         */
        
    private function render_tex_col($tex_col = [], $color_rgb = [], $polygon_array = [], $a 0$b 0$c 0)
        {
            
    /* sure that happen? */
            
    if (empty($tex_col)) return;

            
    /* jingle */
            
    if ((isset($tex_col['flipH'])) && (stripos('_flipH'$tex_col['assetNames'][0] !== false))) $tex_col['assetNames'] = str_ireplace('_flipH''', ($tex_col['assetNames'][0]));

            
    /* let's create a image.. */
            
    if (is_bool($tex_cols_asset = [MENTION=78006]image[/MENTION]createfrompng(MASKS_ROOT $tex_col['assetNames'][0] . '.png'))) return;

            
    /* soo flip, soo flip, flip. */
            
    if (isset($tex_col['flipH']) && ($tex_col['flipH'] == 'true')) imageflip($tex_cols_assetIMG_FLIP_HORIZONTAL);

            
    /**
             * # [MENTION=437887]Beta[/MENTION] #
             * beta .. trying to code 3d image distortion
             * > sadly php has not 3d and 2d image distortion functions built-in..
             * > trying to create manually
             * > Here is the Void (Experimentally
             * $c is seated to 0 because we don't have a correct rotation value. And
             * rotate_polygon() only does 2d Rotation (360? degrees)
             */
            //$polygon_array = self::rotate_polygon($polygon_array, $c, $a, $b);
            
    $polygon_array self::rotate_polygon($polygon_array0$a$b);

            
    /**
             * # [MENTION=437887]Beta[/MENTION] #
             * beta .. trying to code 3d image distortion
             * > sadly php has not 3d and 2d image distortion functions built-in..
             * > trying to create manually
             */
            //$tex_cols_asset = imagerotate($tex_cols_asset, 155, imagecolorallocatealpha($tex_cols_asset, 0, 0, 0, 127));
            //$this->image = imagerotate($this->image, 155, imagecolorallocatealpha($this->image, 0, 0, 0, 127));

            /* really, tha color is really bad.. */
            
    $this->image_recolor($tex_cols_asset$color_rgb[0], $color_rgb[1], $color_rgb[2]);
            
    imagesettile($this->image$tex_cols_asset);

            
    /* the tex_cols must be putted back into original image, y? */
            
    imagefilledpolygon($this->image$polygon_array, (count($polygon_array) / 2), IMG_COLOR_TILED);

            
    /** curiously that can avoid the pixelated tiles... to improve the quality of image. */
            //imagepolygon($this->image, $polygon_array, (count($polygon_array) / 2), IMG_COLOR_TILED);

            /* no garbage, sir */
            
    imagedestroy($tex_cols_asset);
        }

        
    /**
         * render specific mask
         *
         * [MENTION=2000183830]para[/MENTION]m array $mask
         * [MENTION=2000183830]para[/MENTION]m array $plane
         */
        
    private function render_mask($mask = [], $plane = [])
        {
            
    /* sure that happened? */
            
    if (empty($mask)) return;

            
    /* jingle */
            
    if ((isset($mask['flipH'])) && (stripos('_flipH'$mask['name'] !== false))) $mask['name'] = str_ireplace('_flipH''', ($mask['name']));

            
    /* dingle bells.. */
            
    if (is_bool($mask_asset = [MENTION=78006]image[/MENTION]createfrompng(MASKS_ROOT $mask['name'] . '.png'))) return;

            
    /* soo flip, soo flip, flip. */
            
    if (isset($mask['flipH']) && ($mask['flipH'] == 'true')) imageflip($mask_assetIMG_FLIP_HORIZONTAL);

            
    /* copy me please, and put me into original! */
            
    imagecopy($this->image$mask_asset$plane['cornerPoints'][1]['x'] + $mask['location']['x'], (($mask['location']['x']) - ($mask['location']['y'])), 00imagesx($mask_asset), imagesy($mask_asset));

            
    /* no garbage, sir */
            
    imagedestroy($mask_asset);
        }

        
    /**
         * render all the planes of the fuckin xit ;)
         * @author TyrexFR
         * @author sant0ro
         * [MENTION=6887]Tod[/MENTION]o: improve door math calculation
         * @bug: door position y is really bad.
         */
        
    protected function render_planes()
        {
            
    /* foreach each plane of the image */
            
    foreach ($this->json['planes'] as $plane):

                
    /* assign image assets resources */
                
    $color_rgb $this->hex_to_rgb(dechex($plane['color']));
                
    $color     imagecolorallocate($this->image$color_rgb[0], $color_rgb[1], $color_rgb[2]);

                
    /* array with polygons */
                
    $polygon_array = [];

                
    /* put in the polygon array */
                
    array_push($polygon_array$plane['cornerPoints'][0]['x'], $plane['cornerPoints'][0]['y'], $plane['cornerPoints'][1]['x'], $plane['cornerPoints'][1]['y'], $plane['cornerPoints'][3]['x'], $plane['cornerPoints'][3]['y'], $plane['cornerPoints'][2]['x'], $plane['cornerPoints'][2]['y']);

                
    /* is also a pokemon name. */
                
    imagefilledpolygon($this->image$polygon_array, (count($polygon_array) / 2), $color);

                
    /* get tex_cols of every plane */
                
    if (array_key_exists('texCols'$plane)) foreach ($plane['texCols'] as $tex_col$this->render_tex_col($tex_col$color_rgb$polygon_array$plane['cornerPoints'][0]['x'], $plane['cornerPoints'][0]['y'], $plane['z']);

                
    /* get masks of every plane */
                
    if (array_key_exists('masks'$plane)) foreach ($plane['masks'] as $mask$this->render_mask($mask$plane);

                
    $polygon_array null;

                
    /* adele says, this is the end (jingle) */
            
    endforeach;
        }

        
    /**
         * Render all Image Sprites for the Camera.
         * @author TyrexFR
         * @author sant0ro
         * [MENTION=6887]Tod[/MENTION]o: make this xit better
         * [MENTION=6887]Tod[/MENTION]o: better sprites positioning
         */
        
    protected function render_sprites()
        {
            
    /* every sprite... avatars, furniture, soo.. everything */
            
    foreach ($this->json['sprites'] as $sprite):

                
    /* get out of there */
                
    if (is_bool($tha_sprite = [MENTION=78006]image[/MENTION]createfrompng(SPRITES_ROOT $sprite['name'] . '.png'))) continue;

                
    /* i'm the alpha and omega, no, just alpha. */
                
    $alpha = ((isset($sprite['alpha'])) ? ((int)$sprite['alpha']) : 100);

                
    /* soo flip, soo flip, flip. */
                
    if (isset($sprite['flipH']) && ($sprite['flipH'] == 'true')) imageflip($tha_spriteIMG_FLIP_HORIZONTAL);

                
    /* @author Macklebee... really, why Habbo use bad TrueColor Codes? */
                
    if (array_key_exists('color'$sprite) && ($sprite['color'] != '16777215')):
                    
    $color_rgb $this->hex_to_rgb(dechex($sprite['color']));
                    
    $this->image_recolor($tha_sprite$color_rgb[0], $color_rgb[1], $color_rgb[2]);
                endif;

                
    /* really, that is good! */
                
    $this->image_copy_merge_with_alpha($this->image$tha_sprite$sprite['x'], $sprite['y'], 00imagesx($tha_sprite), imagesy($tha_sprite), $alpha);

                
    /* really, we don't wanna garbage! */
                
    imagedestroy($tha_sprite);
            endforeach;
        }

        
    /**
         * let's just die, okay?
         * @author Claudio Santoro
         * [MENTION=6887]Tod[/MENTION]o: make this better
         *
         * [MENTION=2000183830]para[/MENTION]m int $error_code
         * [MENTION=2000183830]para[/MENTION]m string $error_message
         * [MENTION=2000183830]para[/MENTION]m bool|false $must_die
         * [MENTION=850422]return[/MENTION] string|void
         */
        
    private function just_die($error_code 1$error_message ''$must_die false)
        {
            
    $r '<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"><br><br><br><div class="row"><div class="col-sm-2"></div><div class="col-sm-8"><div class="alert alert-danger"><h4><i>Oh No!</i> (#' $error_code ')</h4><b> We really sorry, but the following error happend:</b><br><hr><blockquote><h5>' $error_message '</h5></blockquote></div></div></div>';
            return ((
    $must_die) ? die($r) : $r);
        }

        
    /**
         * let's just show and die, okay?
         * @author Claudio Santoro
         * [MENTION=6887]Tod[/MENTION]o: make this better
         *
         * [MENTION=2000183830]para[/MENTION]m string $message
         * [MENTION=2000183830]para[/MENTION]m bool|false $must_die
         * [MENTION=850422]return[/MENTION] string|void
         */
        
    private function just_show($message ''$must_die false)
        {
            
    $r '<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"><br><br><br><div class="row"><div class="col-sm-2"></div><div class="col-sm-8"><div class="alert alert-success"><h4><>OK!</h4><b> The system write a special message for you: :</b><br><hr><blockquote><h5>' $message '</h5></blockquote></div></div></div>';
            return ((
    $must_die) ? die($r) : $r);
        }

        
    /**
         * this method save in a physical link, the allocated memory from the image
         * @uses image/png compression
         * [MENTION=287391]See[/MENTION] [url]https://en.wikipedia.org/wiki/Portable_Network_Graphics[/url]
         * also this method erases the allocated memory
         * [MENTION=2000183830]para[/MENTION]m bool $show_image
         * [MENTION=2000183830]para[/MENTION]m int $run_mode
         */
        
    private function image_create($show_image false$run_mode 1)
        {
            
    /* check if the variables are really valid resources.. otherwise try to create from string.. */
            
    @$this->image = (((!is_resource($this->image)) && (is_string($this->image))) ? (string)imagecreatefromstring($this->image) : $this->image);
            @
    $this->image_small = (((!is_resource($this->image_small)) && (is_string($this->image_small))) ? (string)imagecreatefromstring($this->image_small) : $this->image_small);

            
    /* save image alpha blending (only if in other steps didn't that)  */
            
    imagesavealpha($this->imagetrue);

            
    /* save main camera image */
            
    if (!$show_image) if ($run_mode == 1imagepng($this->imageIMAGE_URL); else imagepng($this->imageIMAGE_ROOM_URL); else imagepng($this->image);

            
    /* save the image thumbnail */
            
    if ($run_mode == 1) [MENTION=78006]image[/MENTION]png($this->image_smallIMAGE_SMALL_URL);
        }

        
    /**
         * resize the camera image, for a smaller image
         * that will be the thumbnail
         * @author sant0ro
         */
        
    private function smaller_image()
        {
            
    /* why a function only with that? */
            
    $this->image_small imagescale($this->imageIMAGE_S_WIMAGE_S_H);
        }

        
    /**
         * destroy! all generated images
         */
        
    function __destruct()
        {
            
    /* because we love destroy memory */
            
    [MENTION=78006]image[/MENTION]destroy($this->image_small);
            [
    MENTION=78006]image[/MENTION]destroy($this->image);
        }
    }

    /**
     * available replaced variables:
     * [SERVER_CAMERA], [HOTEL_COUNTRY], [IMAGE_URL], [ROOM_ID], [TIME_STAMP]
     */

    $settings = [
        
    'white-list' => [
            
    '127.0.0.1',
            
    'localhost',
            
    '0.0.0.0',
            
    'LOCALHOST'
        
    ],
        
    'image-settings' => [
            
    'size-settings' => [
                
    'image-width' => 320,
                
    'image-height' => 320
            
    ],
            
    'path-settings' => [
                
    'server-camera' => 'servercamera'// base folder
                
    'hotel-country' => 'default'// default will use get country code. you can set manually a country code.
                
    'image-name' => 'default'// using default will use the json-data for name, recommended use default.
                
    'image-url' => '[SERVER_CAMERA]/purchased/[HOTEL_COUNTRY]/[IMAGE_URL].png'
            
    ]
        ],
        
    'thumbnail-settings' => [
            
    'size-settings' => [
                
    'image-width' => 100,
                
    'image-height' => 100
            
    ],
            
    'path-settings' => [
                
    'server-camera' => 'servercamera'// base folder
                
    'hotel-country' => 'default'// default will use get country code. you can set manually a country code.
                
    'image-name' => 'default'// using default will use the json-data for name, recommended use default.
                
    'image-url' => '[SERVER_CAMERA_S]/purchased/[HOTEL_COUNTRY_S]/[IMAGE_SMALL_URL].png'
            
    ]
        ],
        
    'room-thumbnail-settings' => [
            
    'size-settings' => [
                
    'image-width' => 110,
                
    'image-height' => 110
            
    ],
            
    'path-settings' => [
                
    'hotel-country' => 'default'// default will use get country code. you can set manually a country code.
                
    'image-url' => 'navigator-thumbnail/[HOTEL_COUNTRY_R]/[ROOM_ID].png'
            
    ]
        ],
        
    'folder-settings' => [
            
    'masks-folder' => '/masks/',
            
    'sprites-folder' => '/sprites/'
        
    ]
    ];

    /* let sing a song */
    new CameraGD($settings);
    exit;





    Authors
    The Entire class was made by me, only some part of codes was developed initially by AntoineFR (Tyrex) (Azure Emulator Developer)




    Warning
    This class is unofficial, isn't part from Azure Group, since i left the Azure Group...




    Help us
    Helping with ideas, code snippets, pull requests, math teorems you can help us!




    Official Bugs
    Math Bugs
    1. PhP has not built-in polygon distortion functions/methods/classes that make the distortion of wallpaper and floorpaper partially impossible. The solution was trying to create a function using basic math functions like cos, sin
    2. The door Y coordinates aren't sended by the jSON of Habbo.swf, the solution was using Pitagoras Theorem to calc the base Y-axis from the other X,Z coordinates from the door polygon axis.


    Planned Features
    • Use jSON Interactor and Native jSON Handlers
    • Use Nategood/Httpful to a best REST and jSON communication
    • Use filp/whoops, to a better error display system
    • Try to use a better code nomenclature, and separate in namespaces, putting in many files the php scripts, and not in one file
    • refactor the code and improve documentation
    • try to put native asset extracting





    Thanks!
    Please give good Rep in this thread if you liked it.




    Demo
    If any hotel use this script, and extract all assets i will be glad.




    Assets Extracting Tutorial
    ATTENTION THAT IS TOTALLY IMPORTANT
    1. Download Habbo Asset Extractor
    2. In All PhP Files change the Habbo.com Urls of Versions (Need to be last RELEASE) and LAST habbo-web build, IF YOU USE HABBO.COM PLEASE USE EX.HABBO.COM
    3. You need C++ 2012 Redistributable
    4. Put these files in some WebServer DocumentRoot (HTDOCS/WWW)
    5. Remember to put 7777 CHMOD when you want to run the script
    6. Make assurance that only you have access to the webserver
    7. Open the browser and open each file in browser, like localhost/assets.php;
    8. Wait the Script Finishes All Download of All Assets and All Extraction
    9. The Script already extracts the SWF images
    10. And the script already put correct FILE names
    11. After all Extraction copy the two folders from the /DOWNLOAD/ folder to the same FOLDER where is ServerCamera.php !!


    IMPORTANT
    1. Pets Sprites Extraction isn't Coded
    2. PLEASE DON'T DELETE THE BUILT IN DOOR_64.PNG IMAGE, IF YOU PUT THE DOOR FROM HABBO.SWF THE DOOR IN CAMERA WILL NOT WORK 100%
    3. This happens because Door Math Algorithm isn't good.


    Cheers, Claudio Santoro


  2. #2
    Retired Robot is offline
    MemberRank
    Apr 2015 Join Date
    EnglandLocation
    720Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Awesome work as always man, great release. Will be trying out now!

  3. #3
    ◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜ Taiga is offline
    DeveloperRank
    May 2007 Join Date
    InternetLocation
    2,464Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Why are there tags inside the snippet?

  4. #4
    git bisect -m ovflowd is offline
    MemberRank
    Sep 2011 Join Date
    2,191Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Quote Originally Posted by new name View Post
    Why are there tags inside the snippet?
    Sorry? What tags? Ironically the Snippet is the class itself xD

  5. #5
    ◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜ Taiga is offline
    DeveloperRank
    May 2007 Join Date
    InternetLocation
    2,464Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Quote Originally Posted by bi0s View Post
    Sorry? What tags? Ironically the Snippet is the class itself xD
    Excuse me I forgot the word mention, the questions was why are there mention tags inside the snippet.

  6. #6
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,608Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Quote Originally Posted by new name View Post
    Excuse me I forgot the word mention, the questions was why are there mention tags inside the snippet.
    Because broken forum scripts. Several threads have been posted about that at the frontdesk yet nothing has changed.

  7. #7
    Account Upgraded | Title Enabled! Jamal7 is offline
    MemberRank
    Dec 2013 Join Date
    547Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Thanks for sharing.

  8. #8
    Not so spooky... MrSpooks is offline
    MemberRank
    May 2010 Join Date
    Under a rockLocation
    1,068Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Awesome cheers for the release dude will come in extremity handy!

  9. #9
    git bisect -m ovflowd is offline
    MemberRank
    Sep 2011 Join Date
    2,191Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Quote Originally Posted by new name View Post
    Excuse me I forgot the word mention, the questions was why are there mention tags inside the snippet.
    Hum.. Because the BBCode system of RageZONE has bugs?

  10. #10
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,608Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Source of the image extractor plz.

  11. #11
    Member DJGOMEZV is offline
    MemberRank
    Mar 2013 Join Date
    56Posts

    Re: AzureCamera - Habbo Hotel Camera API



    That's all I could get off?

  12. #12
    Proficient Member rockster34 is offline
    MemberRank
    Jan 2013 Join Date
    MarsLocation
    167Posts

    Re: AzureCamera - Habbo Hotel Camera API

    @bi0s thanks for sharing and for the people that dont know this this system was also in azureweb but it was not finished?? Need confirm of that but I know for sure this works :)

  13. #13
    ◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜ Taiga is offline
    DeveloperRank
    May 2007 Join Date
    InternetLocation
    2,464Posts

    Re: AzureCamera - Habbo Hotel Camera API

    After usage of the script, I suggest the following things:

    I found a bug where file_get_contents doesn't work properly, I had to manually download the XML files and redirect the URL to a local file.
    The script is slow due to the fact that it is single threaded. I suggest re-writing it in a language that supports multi-threading would speed up the script a lot. Caching the already downloaded content would be great as well when the script freezes so it can resume where it 'froze' or 'crashed'.

    It's not bad, it works after downloading the file but keep in mind that file_get_contents does not always work on all web servers / PHP instances.

  14. #14
    Member Badbygger is offline
    MemberRank
    Aug 2007 Join Date
    60Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Quote Originally Posted by new name View Post
    After usage of the script, I suggest the following things:

    I found a bug where file_get_contents doesn't work properly, I had to manually download the XML files and redirect the URL to a local file.
    This also happened to me... Guess habbo doesn't allow you to fetch the furnidatas etc. without a proper useragent or something like that. Still works great if you manually download those .xml's :)

  15. #15
    git bisect -m ovflowd is offline
    MemberRank
    Sep 2011 Join Date
    2,191Posts

    Re: AzureCamera - Habbo Hotel Camera API

    Quote Originally Posted by Badbygger View Post
    This also happened to me... Guess habbo doesn't allow you to fetch the furnidatas etc. without a proper useragent or something like that. Still works great if you manually download those .xml's :)

    That depends as your PhP configuration and if CLI and SSL is enabled.
    Also you need put the NEWEST urls, WITHOUT HTTPS://



Advertisement