Вход Регистрация
Файл: monst/core/pag/forge.php
Строк: 371
<?
upd_loc
('forge');
?>
<div class='op_top_im'>

<img src='/core/i/pic/forge.jpg' alt='' class='title_img' />
</div>
<div style='position: relative; top: -100px; color: #999; height: 0;'>
    <span style='background: #000; font-size: 20px;'><?=$lang['forge.php']['title']?></span><br/>
    <span style='background: #000; font-size: 11px;'><?=$lang['forge.php']['title_text']?></span><br/>
</div>

<div class='padding'>
    <div style='text-align: center; co2lor: #756861; border-top: 1px solid #999;'>
        <?=$lang['forge.php']['desc']?><br/>
    </div>
</div>

<br/>

<?
$craft_levels 
= [
    
=> array('max_param' => 10'cost' => 50),
    
=> array('max_param' => 30'cost' => 100),
    
=> array('max_param' => 50'cost' => 500),
    
=> array('max_param' => 100'cost' => 3000),
    
=> array('max_param' => 200'cost' => 3000),
    
=> array('max_param' => 1000'cost' => 10000),

];


// q
foreach ( $quest as $q ) {
    if ( 
$q['type'] == 'craft_level' ) {
        if ( 
$q['uniq_id'] <= $user['craft_level'] ) {
            
$quest_db[$q['id']]['count'] = 1;

            
$_users -> update(
                [
                    
'id' => $user['id']
                ],

                [
                    
'$set' => [
                        
'quest' => $quest_db,
                    ]
                ]
            );

        }
    }
}


if ( isset(
$_GET['level_up'] ) ) {
    
$cost $craft_levels[$user['craft_level'] + 1]['cost'];
    if ( !
$cost ) {
        
g('/forge');
    }

    if ( 
$user['gold'] < $cost ) {
        
?>
        <div class='error_box'>
            <?=$lang['forge.php']['no_gold']?><br/>
            <div style='text-align: center;'>
                <a href='/gold'><?=$lang['forge.php']['buy_gold']?> <img src='<?=$gold_icon?>' alt='' width='15'/></a>
            </div>


        </div>
        <?
    
} else {
        
$_users -> update(
            [
                
'id' => $user['id']
            ],

            [
                
'$set' => [
                    
'craft_level' => $user['craft_level'] + 1,
                    
'gold' => $user['gold'] - $cost
                
]
            ]
        );

//        foreach ( $quest as $q ) {
//            if ( $q['type'] == 'craft_level' ) {
//                if ( $q['uniq_id'] == $user['craft_level'] + 1 ) {
//                    $quest_db[$q['id']]['count'] = 1;
//
//                    $_users -> update(
//                        [
//                            'id' => $user['id']
//                        ],
//
//                        [
//                            '$set' => [
//                                'quest' => $quest_db,
//                            ]
//                        ]
//                    );
//
//                }
//            }
//        }

        
g('/forge?leveling');
    }
}

if ( isset(
$_GET['leveling']) ) print '<div class="ok_box">'.$lang['forge.php']['leveling'].'</div>';

include 
$HOME '/core/file/item.php';

$step = ( isset($_GET['step']) ? $_GET['step'] : );

if ( !
$step ) {
    
?>
    <div style='text-align: center; background: #000; padding: 20px; color: #999; font-size: 15px;'>
        <?=$lang['forge.php']['craft_level']?>: <span style='font-size: 30px;'><?=$user['craft_level']?></span><br/>

        <span style='color: #555; font-size: 11px;'>
            <?=$lang['forge.php']['param']?> +<?=$craft_levels[$user['craft_level']]['max_param']?>
        </span>

        <!--        <span style='color: #777; font-size: 11px;'>-->
        <!--            След. уровень --><?//=$craft_levels[$user['craft_level'] + 1]['max_param']?>
        <!--        </span>-->

    </div>

    <?
    
if ( isset($craft_levels[$user['craft_level'] + 1]) ) {
        
?>
        <a href='/forge?level_up'>
            <div class='bt_gray'>
                <?=$lang['forge.php']['level_upper']?> <img src='<?=$gold_icon?>' alt='' width='15'/><span class='gold_color'><?=$craft_levels[$user['craft_level'] + 1]['cost']?></span>
            </div>
        </a>

        <?
    
}
    
?>

    <br/>

    <div class='padding'>

        <div style='text-align: center;'>


            <div style='display: inline-block;'>
                <div class="npc_left">
                    <img src="/core/i/npc/bob.jpg" alt="" width="70" class="npc_img_left"/>
                    <div class="npc_name"><?=$lang['forge.php']['npc_name']?></div>

                </div>
            </div>

            <div style='display: inline-block;'>
                <?=$lang['forge.php']['says']?>

            </div>

        </div>

    </div>



    <br/>

    <?
    
foreach ( $ITEM_TYPES as $id => $name ) {
        
?>
        <a href='/forge?step=2&amp;type=<?=$id?>'>
            <div class='bt_black'>
                <?=$name?>
            </div>
        </a>
        <?

        
if ( $id == ) break;
    }

    
?>
    <br/><br/>
    <div style='text-align: center;'>
        <a href='/forge'><?=$lang['forge.php']['back']?></a>
    </div>
    <br/>
    <?
}

if ( 
$step == ) {
    
$type = ( isset($_GET['type']) ? (int)$_GET['type'] : );
    if ( !
$type g('/forge');

    @
$type_name $ITEM_TYPES[$type];
    if ( !
$type_name g('/forge');

    if ( 
$type g('/forge');
    
?>
    <div class='padding'>
        <?=$lang['forge.php']['type']?><?=$ITEM_TYPES[$type]?><br/>
    </div>
    <br/>

    <div style='text-align: center;'>
        <a href='/forge?step=2.2&type=<?=$type?>'>
            <div class='bt_black'>
                <?=$lang['forge.php']['upload_icon']?>
            </div>
        </a>

<!--        <div class='bt_black'>-->
<!--            --><?//=$lang['forge.php']['select_icon']?>
<!--        </div>-->
    </div>

    <br/><br/>
    <div style='text-align: center;'>
        <a href='/forge'><?=$lang['forge.php']['back']?></a>
    </div>
    <br/>
    <?

}

if ( 
$step == '2.2' ) {
    
$type = ( isset($_GET['type']) ? (int)$_GET['type'] : );
    if ( !
$type ) {
        
g('/forge');
    }

    @
$type_name $ITEM_TYPES[$type];
    if ( !
$type_name ) {
        
g('/forge');
    }

    if ( 
$type ) {
        
g('/forge');
    }

    if ( !isset(
$_GET['sect']) ) {
        
$time time();
        
$_SESSION['item_time'] = $time;
    } else {
        
$time $_SESSION['item_time'];
    }

    
$filename $user['id'] . '_' $type '_' $time '.png';

    
$temp_icon_path $HOME '/content/item/temp/' $filename;
    
$icon_path $HOME '/content/item/' $user['id'] . '/' $filename;

    switch ( @
$_GET['sect'] ) {
        default:
            if ( isset(
$_GET['bad_size']) ) print '<div class="error_box">'.$lang['forge.php']['error']['bad_size'].'</div><br/><br/>';
            if ( isset(
$_GET['not_im']) ) print '<div class="error_box">'.$lang['forge.php']['error']['not_im'].'</div><br/><br/>';
            if ( isset(
$_GET['no_aspect']) ) print '<div class="error_box">'.$lang['forge.php']['error']['no_aspect'].'</div><br/><br/>';
            if ( isset(
$_GET['no_file']) ) print '<div class="error_box">'.$lang['forge.php']['error']['no_file'].'</div><br/><br/>';

            
?>
            <div style='text-align: center;'>
                <div class='padding'>
                    <?=$lang['forge.php']['upload_desc']?><br/>
                    <br/>
                </div>

                <form method='post' action='/forge?step=2.2&amp;type=<?=$type?>&amp;sect=crop' enctype="multipart/form-data">
                    <input type="hidden" name="MAX_FILE_SIZE" value="<?= 1024 1024 10 ?>"/>
                    <input type='file' name='im'/><br/>
                    <br/>
                    <input type='submit' value='<?=$lang['forge.php']['submit']['upload']?>'/>
                </form>

            </div>

            <br/><br/>
            <div style='text-align: center;'>
                <a href='/forge?step=2&amp;type=<?=$type?>'><?=$lang['forge.php']['back']?></a>
            </div>
            <br/>

            <?
            
break;

        case 
'crop':
            if ( !isset(
$_SESSION['item_time']) ) {
                
g('/forge');
            }

            function 
isImage($img){
                return (bool)
getimagesize($img);
            }

            if ( !
isImage($_FILES['im']['tmp_name']) ) {
                
g('/main');
            }

            
$im $_FILES['im'];

            if (
$im['size'] > 1024 1024 10) {
                
g('/forge?step=2.2&type='.$type.'&bad_size');
            }

            
$w getimagesize($im['tmp_name']);

            if ( !
$w ) {
                
g('/forge?step=2.2&type='.$type.'&not_im');
            }

            if ( 
$w['mime'] == 'image/jpg' OR $w['mime'] == 'image/jpeg') {
                
$im_type 'jpg';
            } elseif ( 
$w['mime'] == 'image/png') {
                
$im_type 'png';
            } elseif ( 
$w['mime'] == 'image/gif') {
                
$im_type 'gif';
            } else {
                
g('/forge?step=2.2&type='.$type.'&not_im');
            }

            if (
$w[0] < 200) {
                
$new_w $w[0];
                
$new_h $w[1];
            } else {
                
$new_w 200;
                
$new_h round($new_w $w[1] / $w[0]);
            }

            if ( 
$im_type == 'jpg' ) {
                
$img_r imagecreatefromjpeg($im['tmp_name']);
            } elseif ( 
$im_type == 'png' ) {
                
$img_r imagecreatefrompng($im['tmp_name']);
            } elseif ( 
$im_type == 'gif' ) {
                
$img_r imagecreatefromgif($im['tmp_name']);
            }

            
$dst_r ImageCreateTrueColor$new_w$new_h );

            
imagealphablending($dst_rfalse);
            
imagesavealpha($dst_rtrue);

            
imagecopyresampled($dst_r,$img_r,0,0,0,0,
                
$new_w,$new_h$w[0], $w[1]);

            
imagepng($dst_r$temp_icon_path);
            @
chmod($HOME $temp_icon_path0666);


            @
mkdir($HOME '/content/item/' $user['id']);
            @
chmod($HOME '/content/item/' $user['id'], 0777);
            
?>
            <link rel='stylesheet' href='/core/s/css/Jcrop/jquery.Jcrop.css' type='text/css'/>
            <script src='/core/j/jquery-3.2.1.min.js'></script>
            <script src='/core/j/jquery.Jcrop.js'></script>

            <script type="text/javascript">

                $(function () {
                    $('#target').Jcrop({
                        aspectRatio: 1,
                        onSelect: updateCoords,
                        bgFade: true,
                        //                        bgOpacity: .5,
                        setSelect: [0, 0, 999, 999]
                    });

                });

                function updateCoords(c) {
                    $('#x').val(c.x);
                    $('#y').val(c.y);
                    $('#w').val(c.w);
                    $('#h').val(c.h);
                }
                ;

                function checkCoords() {
                    if (parseInt($('#w').val())) return true;
                    alert('Error!');
                    return false;
                }
                ;

            </script>

            <div style='text-align: center;'>
                <div class='padding'>
                    <?=$lang['forge.php']['crop_desc']?>
                </div>
                <br/>
                <img src="/content/item/temp/<?=$filename?>?<?=r()?>" id="target" style="border: 1px solid #222;"/>

                <form action="/forge?step=2.2&amp;type=<?=$type?>&amp;sect=create" method="post" onsubmit="return checkCoords();">
                    <input type="hidden" name="crop" value="1"/>

                    <input type='hidden' id="x" name="x"/>
                    <input type='hidden' id="y" name="y"/>
                    <input type='hidden' id="w" name="w"/>
                    <input type='hidden' id="h" name="h"/>

                    <br/>
                    <input type="submit" value="<?=$lang['forge.php']['submit']['save']?>"/>
                </form>
            </div>

            <br/><br/>
            <div style='text-align: center;'>
                <a href='/forge?step=2.2&amp;type=<?=$type?>'><?=$lang['forge.php']['back']?></a>
            </div>
            <br/>

            <?
            
break;

        case 
'create':
            if ( !isset(
$_SESSION['item_time']) ) {
                
g('/forge');
            }

            if ( !
file_exists($temp_icon_path) ) {
                
g('/forge?no_file');
            }

            if ( !isset(
$_POST['crop']) ) {
                
g('/forge?step=2.2&type='.$type.'&no_aspect');
            }

            
$w = (int)$_POST['w'];
            
$h = (int)$_POST['h'];
            
$x = (int)$_POST['x'];
            
$y = (int)$_POST['y'];

            
$targ_w $targ_h 200;

            
$src $temp_icon_path;

            
$img_r imagecreatefrompng($src);
            
$dst_r ImageCreateTrueColor($targ_w$targ_h);

            
imagealphablending($dst_rfalse);
            
imagesavealpha($dst_rtrue);

            
imagecopyresampled($dst_r$img_r00$x$y,
                
$targ_w$targ_h$w$h);

            
imagepng($dst_r$icon_path);
            @
chmod($icon_path0666);
            @
unlink($temp_icon_path);

            
$time $_SESSION['item_time'];
            unset(
$_SESSION['item_time']);

            
g('/forge?step=3&type='.$type.'&iconfile=/content/item/'.$user['id'].'/'.$user['id'].'_'.$type.'_'.$time.'.png');

            break;
    }

}

if ( 
$step == ) {

    
$type = ( isset($_GET['type']) ? (int)$_GET['type'] : );
    if ( !
$type ) {
        
g('/forge');
    }

    @
$type_name $ITEM_TYPES[$type];
    if ( !
$type_name ) {
        
g('/forge');
    }

    if ( 
$type ) {
        
g('/forge');
    }

    
$iconfile $_GET['iconfile'];
    if ( !
$iconfile ) {
        
g('/forge');
    }

    if ( 
substr($iconfile014) != '/content/item/' AND substr($iconfile013) != '/core/i/item/' ) {
        
g('/forge');
    }

    if ( !
file_exists($HOME $iconfile ) ) {
        
g('/forge');
    }

    if ( isset(
$_GET['empty_name']) ) print '<div class="error_box">'.$lang['forge.php']['error']['empty_name'].'</div><br/><br/>';
    if ( isset(
$_GET['null_param']) ) print '<div class="error_box">'.$lang['forge.php']['error']['null_param'].'</div><br/><br/>';
    if ( isset(
$_GET['double']) ) print '<div class="error_box">'.$lang['forge.php']['error']['double'].'</div><br/><br/>';
    if ( isset(
$_GET['max']) ) print '<div class="error_box">'.$lang['forge.php']['error']['max'].'</div><br/><br/>';

    if ( isset(
$_GET['no_gold']) ) {
        
?>
        <div class='error_box'>
            <?=$lang['forge.php']['no_gold']?><br/>
            <div style='text-align: center;'>
                <a href='/gold'><?=$lang['forge.php']['buy_gold']?> <img src='<?=$gold_icon?>' alt='' width='15'/></a>
            </div>
        </div>
        <br/>
        <?
    
}
    
?>
    <script src='/core/j/jquery-3.2.1.min.js'></script>

    <div style='text-align: center;'>
        <div class='padding'>
            <?=$lang['forge.php']['type']?><?=$ITEM_TYPES[$type]?><br/>
            <br/>
            <img src='<?=$iconfile?>' alt='' width='70' class='item'/><br/>
            <br/>
            <form method='post' action='/forge?step=4&amp;type=<?=$type?>&amp;iconfile=<?=$iconfile?>'>
                <?=$lang['forge.php']['item_name']?>:<br/>
                <input name='name'/><br/>
                <?=$lang['forge.php']['item_desc']?>:<br/>
                <textarea name='desc' rows='3' style='width: 90%;'></textarea>
                <br/>
                <br/>

                <script>
                    var max = "<?=$craft_levels[$user['craft_level']]['max_param']?>";
                    max = parseInt(max);

                    function cost() {
                        var st = $('#st').val();
                        var hp = $('#hp').val();
                        var armor = $('#armor').val();

                        if ( st && hp && armor ) {
                            st = parseInt(st);
                            hp = parseInt(hp);
                            armor = parseInt(armor);

                            var cost = ( st + hp + armor ) * 2;

                            $('#cost').empty();
                            $('#cost').append(cost);

                            if ( st > max ) { $('#st').val('0'); }
                            if ( hp > max ) { $('#hp').val('0'); }
                            if ( armor > max ) { $('#armor').val('0'); }


                        }



                    }


                </script>

                <?=$lang['forge.php']['item_param']?>:<br/>
                <span style='color: #555;'>max. <?=$craft_levels[$user['craft_level']]['max_param']?></span><br/>
                <br/>

                <div style='display: inline-block; vertical-align: bottom;'>
                    <img src='/core/i/user/hp.png' alt='' width='55' style=''/>
                </div>

                <div style='display: inline-block;'>
                    <input id='hp' name='hp' style='width: 40px;' value='<?=$craft_levels[$user['craft_level']]['max_param']?>'/>
                </div>

                <br/>

                <div style='display: inline-block; vertical-align: bottom;'>
                    <img src='/core/i/user/st.png' alt='' width='55' style=''/>
                </div>

                <div style='display: inline-block;'>
                    <input id='st' name='st' style='width: 40px;' value='<?=$craft_levels[$user['craft_level']]['max_param']?>'/>
                </div>


                <br/>

                <div style='display: inline-block; vertical-align: bottom;'>
                    <img src='/core/i/user/armor.png' alt='' width='55' style=''/>
                </div>

                <div style='display: inline-block;'>
                    <input id='armor' name='armor' style='width: 40px;' value='<?=$craft_levels[$user['craft_level']]['max_param']?>'/>
                </div>

                <br/><br/>

                <?=$lang['forge.php']['item_cost']?>:<br/>
                <img src='<?=$gold_icon?>' alt='' width='30'/><span id='cost' class='gold_color'>0</span><br/>

                <br/>

                <input type='submit' value='<?=$lang['forge.php']['submit']['create']?>'/>

                <script>
                    setInterval(cost, 500);
                </script>
            </form>
        </div>
    </div>

    <?
}

if ( 
$step == ) {
    
$type = ( isset($_GET['type']) ? (int)$_GET['type'] : );
    if ( !
$type g('/forge');

    @
$type_name $ITEM_TYPES[$type];
    if ( !
$type_name g('/forge');

    if ( 
$type g('/forge');

    
$iconfile $_GET['iconfile'];
    if ( !
$iconfile g('/forge');

    if ( 
substr($iconfile014) != '/content/item/' AND substr($iconfile013) != '/core/i/item/' ) {
        
g('/forge');
    }

    if ( !
file_exists($HOME $iconfile ) ) {
        
g('/forge');
    }

    
$st = (int)$_POST['st'];
    if ( 
$st g('/forge');
    
$hp= (int)$_POST['hp'];
    if ( 
$hp g('/forge');
    
$armor = (int)$_POST['armor'];
    if ( 
$armor g('/forge');

    
$name null_html($_POST['name']);
    
$desc null_html($_POST['desc']);

    if ( empty(
$name) ) {
        
g('/forge?step=3&type='.$type.'&iconfile='.$iconfile.'&empty_name');
    }

    if ( 
$st == AND $hp == AND $armor == ) {
        
g('/forge?step=3&type='.$type.'&iconfile='.$iconfile.'&null_param');
    }

    
$cost = ( $st $hp $armor ) * 2;

    if ( 
$user['gold'] < $cost ) {
        
g('/forge?step=3&type='.$type.'&iconfile='.$iconfile.'&no_gold');
    } else {
        
$max $craft_levels[$user['craft_level']]['max_param'];

        if ( 
$st $max OR $hp $max OR $armor $max ) {
            
g('/forge?step=3&type='.$type.'&iconfile='.$iconfile.'&max');
        }

        
$find $_item -> findOne(
            [
                
'user_id' => $user['id'],
                
'name' => $name,
                
'type' => $type,
                
'c_time' => [
                    
'$gte' => time() - 60 10
                
]
            ]
        );

        if ( 
$find ) {
            
?>
            <div class='error_box'>
                <?=$lang['forge.php']['error']['double']?><br/>
            </div>
            <br/>
            <div style='text-align: center;'>
                <a href='/forge?step=3&type=<?=$type?>&iconfile=<?=$iconfile?>'><?=$lang['forge.php']['back']?></a>
            </div>
            <br/>
            <?
        
} else {

            
$id new_id('_item');

            
$_item -> insert(
                [
                    
'id' => $id,
                    
'user_id' => $user['id'],
                    
'name' => $name,
                    
'use' => 0,
                    
'type' => $type,
                    
'desc' => $desc,
                    
'c_time' => time(),
                    
'icon' => $iconfile,
                    
'cost' => $cost,
//                    'level' => $user['craft_level'],
                    
'st' => $st,
                    
'hp' => $hp,
                    
'armor' => $armor,
                    
'st_null' => $st,
                    
'hp_null' => $hp,
                    
'armor_null' => $armor,
                ]
            );

            
$_users -> update(
                [
                    
'id' => $user['id']
                ],

                [
                    
'$set' => [
                        
'gold' => $user['gold'] - $cost
                    
]
                ]
            );

            
?>
            <div class='padding'>
                <?=$lang['forge.php']['create_complete']?><br/>
            </div>

            <br/>
            <div style='text-align: center;'>
                <a href='/forge'><div class='bt_black'><?=$lang['forge.php']['title']?></div></a>
            </div>
            <br/>

            <?
        
}
    }

}
Онлайн: 0
Реклама