В программировании я совсем недавно, поэтому возникают совершенно дурацкие вопросы, о которых даже стыдно спрашивать Но моя проблема состоит вот в чем: Есть 3 файла index.php config.php backend/backend.php Вся система открывается через index.php, который использует в своей работе backend.php И в том самом backend.php есть адрес, который лучше заменить на переменную, прописываемую в config.php Я пробовал инклюдить и в сам index.php и в сам backend.php, но ничего не получается. Он не видит эту переменную Ну вот и сами файлики config.php Код (Text): <?php $skin_path = 'http://s3.amazonaws.com/MinecraftSkins/'; ?> index.php Код (Text): <!-- 3-D Minecraft Skin Viewer By Kent Rasmussen @ earthiverse.ath.cx Using Three.Js HTML5 3D Engine from https://github.com/mrdoob/three.js/ Add ?user=USERNAME to render a specific username Add &refresh to re-grab the skin and generate new parts Add &webgl to render in webgl --> <?php include('backend/backend.php'); include('config.php'); if(!isset($user)) $user = earthiverse; if(isset($refresh)) minecraft_skin_delete($user); minecraft_skin_download($user);?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="backend/resources/3d/Three.js"></script> <script type="text/javascript" src="backend/resources/3d/Cube.js"></script> <script type="text/javascript" src="backend/resources/3d/ImageUtils.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="style.css" rel="stylesheet" type="text/css" /> <title>3d minecraft body test v1.0</title> </head> <body> <script type="text/javascript"> var camera, scene, renderer; init(); setInterval( loop, 1000 / 60 ); function init() { camera = new THREE.Camera(20, window.innerWidth / window.innerHeight, 1, 1000); scene = new THREE.Scene(); var head_materials = [new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/head_right.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/head_left.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/head_top.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/head_bottom.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/head_back.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/head_front.png')})]; head = new THREE.Mesh( new Cube(8, 8, 8, 1, 1, head_materials), new THREE.MeshFaceMaterial()); head.position.x = 0; head.position.y = 0; head.position.z = 0; scene.addObject(head); var body_materials = [new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/body_right.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/body_left.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/body_top.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/body_bottom.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/body_back.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/body_front.png')})]; body = new THREE.Mesh( new Cube(8, 12, 4, 1, 1, body_materials), new THREE.MeshFaceMaterial()); body.position.x = 0; body.position.y = -10; body.position.z = 0; scene.addObject(body); var arm_left_materials = [new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_left_inner.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_left_outer.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_left_top.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_left_bottom.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_left_back.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_left_front.png')})]; arm_left = new THREE.Mesh( new Cube(4, 12, 4, 1, 1, arm_left_materials), new THREE.MeshFaceMaterial()); arm_left.position.x = 6; arm_left.position.y = -10; arm_left.position.z = 0; scene.addObject(arm_left); var arm_right_materials = [new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_right_outer.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_right_inner.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_right_top.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_right_bottom.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_right_back.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/arm_right_front.png')})]; arm_right = new THREE.Mesh( new Cube(4, 12, 4, 1, 0, arm_right_materials), new THREE.MeshFaceMaterial()); arm_right.position.x = -6; arm_right.position.y = -10; arm_right.position.z = 0; scene.addObject(arm_right); var leg_left_materials = [new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_left_inner.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_left_outer.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_left_top.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_left_bottom.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_left_back.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_left_front.png')})]; leg_left = new THREE.Mesh( new Cube(4, 12, 4, 1, 1, leg_left_materials), new THREE.MeshFaceMaterial()); leg_left.position.x = 2; leg_left.position.y = -22; leg_left.position.z = 0; leg_left.rotation.y = 180 * Math.PI; scene.addObject(leg_left); var leg_right_materials = [new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_right_outer.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_right_inner.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_right_top.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_right_bottom.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_right_back.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/leg_right_front.png')})]; leg_right = new THREE.Mesh( new Cube(4, 12, 4, 1, 1, leg_right_materials), new THREE.MeshFaceMaterial()); leg_right.position.x = -2; leg_right.position.y = -22; leg_right.position.z = 0; scene.addObject(leg_right); var hat_materials = [new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/hat_right.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/hat_left.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/hat_top.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/hat_bottom.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/hat_back.png')}),new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('images/skins/<?php echo $user; ?>/hat_front.png')})]; hat = new THREE.Mesh( new Cube(9, 9, 9, 1, 1, hat_materials), new THREE.MeshFaceMaterial()); hat.position.x = 0; hat.position.y = 0; hat.position.z = 0; scene.addObject(hat); <?php if(isset($_GET['webgl'])) echo 'renderer = new THREE.WebGLRenderer();'; else echo 'renderer = new THREE.CanvasRenderer();'; ?> renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); } var xvar = 0; function loop() { xvar += Math.PI/90 camera.target.position.x = 0; camera.target.position.y = -11; camera.target.position.z = 0; //Leg Swing leg_left.rotation.x = Math.cos(xvar); leg_left.position.z = 0 - 6*Math.sin(leg_left.rotation.x); leg_left.position.y = -16 - 6*Math.abs(Math.cos(leg_left.rotation.x)); leg_right.rotation.x = Math.cos(xvar + (Math.PI)); leg_right.position.z = 0 - 6*Math.sin(leg_right.rotation.x); leg_right.position.y = -16 - 6*Math.abs(Math.cos(leg_right.rotation.x)); //Arm Swing arm_left.rotation.x = Math.cos(xvar + (Math.PI)); arm_left.position.z = 0 - 6*Math.sin(arm_left.rotation.x); arm_left.position.y = -4 - 6*Math.abs(Math.cos(arm_left.rotation.x)); arm_right.rotation.x = Math.cos(xvar); arm_right.position.z = 0 - 6*Math.sin(arm_right.rotation.x); arm_right.position.y = -4 - 6*Math.abs(Math.cos(arm_right.rotation.x)); camera.position.x = 0 - 100*Math.sin(xvar); camera.position.y = 0 - 30*Math.sin(xvar); camera.position.z = 0 - 100*Math.cos(xvar); renderer.render( scene, camera ); } </script> </body> </html> backend.php Код (Text): <?php error_reporting(E_ALL); //List of Variables used on the site if(isset($_GET['user'])) $user = htmlentities($_GET['user'],ENT_QUOTES); //Minecraft Username if(isset($_GET['refresh'])) $refresh = htmlentities($_GET['refresh'],ENT_QUOTES); //Used for refreshing minecraft skins //Check for hooligans if(isset($_GET['refresh']) && $user == "") { // If this was executed, all skins would be erased. echo "Please don't try and glitch things.<br/>\nThanks."; exit; } function minecraft_skin_3d_part($original, $user, $xpos, $ypos, $width, $height, $texturesize, $name, $flipx, $flipy) { $temp = imagecreatetruecolor($texturesize,$texturesize); imagealphablending($temp, false); imagesavealpha($temp, true); if($flipx == TRUE && $flipy == TRUE) { $xpos = $xpos + $width -1; $width = 0 - $width; $ypos = $ypos + $height -1; $height = 0 - $height; } else if($flipx == TRUE) { $xpos = $xpos + $width-1; $width = 0 - $width; } else if($flipy == TRUE) { $ypos = $ypos + $height-1; $height = 0 - $height; } imagecopyresampled($temp, $original, 0, 0, $xpos, $ypos, $texturesize, $texturesize, $width, $height); imagepng($temp, "images/skins/".$user."/".$name.".png"); imagedestroy($temp); } function minecraft_skin_download($user) { if(!file_exists('images/skins/'.$user.'/base.png')) { if(@getimagesize($skin_path.$user.'.png')) { //Make a new directory If(!is_dir('images/skins/'.$user)) { mkdir('images/skins/'.$user,0777); } //Download the skin from Minecraft.net and put it in /images/skins/ $url = $skin_path.$user.'.png'; $img = 'images/skins/'.$user.'/base.png'; file_put_contents($img, file_get_contents($url)); //Create another image twice the size $original = imagecreatefrompng('images/skins/'.$user.'/base.png'); //Create Base_x2 //If you want, you can delete the next 6 rows after these comments without worrying. //I just use these to add faces to usernames in the stats lists with some css magic. $temp = imagecreatetruecolor(128,64); imagealphablending($temp, false); imagesavealpha($temp, true); imagecopyresized($temp, $original, 0, 0, 0, 0, 128, 64, 64, 32); imagepng($temp, "images/skins/".$user."/base_x2.png"); imagedestroy($temp); ///////////////////////// // Body Parts (for 3D) // ///////////////////////// minecraft_skin_3d_part($original,$user,40,0,8,8,256,"hat_top", TRUE, TRUE); minecraft_skin_3d_part($original,$user,48,0,8,8,256,"hat_bottom", TRUE, TRUE); minecraft_skin_3d_part($original,$user,32,8,8,8,256,"hat_left", FALSE, FALSE); minecraft_skin_3d_part($original,$user,40,8,8,8,256,"hat_front", FALSE, FALSE); minecraft_skin_3d_part($original,$user,48,8,8,8,256,"hat_right", FALSE, FALSE); minecraft_skin_3d_part($original,$user,56,8,8,8,256,"hat_back", FALSE, FALSE); minecraft_skin_3d_part($original,$user,8,0,8,8,256,"head_top", TRUE, TRUE); minecraft_skin_3d_part($original,$user,16,0,8,8,256,"head_bottom", TRUE, TRUE); minecraft_skin_3d_part($original,$user,0,8,8,8,256,"head_left", TRUE, FALSE); minecraft_skin_3d_part($original,$user,8,8,8,8,256,"head_front", FALSE, FALSE); minecraft_skin_3d_part($original,$user,16,8,8,8,256,"head_right", TRUE, FALSE); minecraft_skin_3d_part($original,$user,24,8,8,8,256,"head_back", FALSE, FALSE); minecraft_skin_3d_part($original,$user,20,16,8,4,256,"body_top", FALSE, TRUE); minecraft_skin_3d_part($original,$user,28,16,8,4,256,"body_bottom", FALSE, TRUE); minecraft_skin_3d_part($original,$user,16,20,4,12,256,"body_right", TRUE, FALSE); minecraft_skin_3d_part($original,$user,20,20,8,12,256,"body_front", FALSE, FALSE); minecraft_skin_3d_part($original,$user,28,20,4,12,256,"body_left", TRUE, FALSE); minecraft_skin_3d_part($original,$user,32,20,8,12,256,"body_back", FALSE, FALSE); minecraft_skin_3d_part($original,$user,44,16,4,4,256,"arm_left_top", FALSE, TRUE); minecraft_skin_3d_part($original,$user,48,16,4,4,256,"arm_left_bottom", FALSE, TRUE); minecraft_skin_3d_part($original,$user,40,20,4,12,256,"arm_left_outer", FALSE, FALSE); minecraft_skin_3d_part($original,$user,44,20,4,12,256,"arm_left_front", FALSE, FALSE); minecraft_skin_3d_part($original,$user,48,20,4,12,256,"arm_left_inner", FALSE, FALSE); minecraft_skin_3d_part($original,$user,52,20,4,12,256,"arm_left_back", FALSE, FALSE); minecraft_skin_3d_part($original,$user,44,16,4,4,256,"arm_right_top", TRUE, TRUE); minecraft_skin_3d_part($original,$user,48,16,4,4,256,"arm_right_bottom", TRUE, TRUE); minecraft_skin_3d_part($original,$user,40,20,4,12,256,"arm_right_outer", TRUE, FALSE); minecraft_skin_3d_part($original,$user,44,20,4,12,256,"arm_right_front", TRUE, FALSE); minecraft_skin_3d_part($original,$user,48,20,4,12,256,"arm_right_inner", FALSE, FALSE); minecraft_skin_3d_part($original,$user,52,20,4,12,256,"arm_right_back", TRUE, FALSE); minecraft_skin_3d_part($original,$user,4,16,4,4,256,"leg_left_top", FALSE, TRUE); minecraft_skin_3d_part($original,$user,8,16,4,4,256,"leg_left_bottom", FALSE, TRUE); minecraft_skin_3d_part($original,$user,0,20,4,12,256,"leg_left_outer", FALSE, FALSE); minecraft_skin_3d_part($original,$user,4,20,4,12,256,"leg_left_front", FALSE, FALSE); minecraft_skin_3d_part($original,$user,8,20,4,12,256,"leg_left_inner", FALSE, FALSE); minecraft_skin_3d_part($original,$user,12,20,4,12,256,"leg_left_back", FALSE, FALSE); minecraft_skin_3d_part($original,$user,4,16,4,4,256,"leg_right_top", TRUE, TRUE); minecraft_skin_3d_part($original,$user,8,16,4,4,256,"leg_right_bottom", TRUE, TRUE); minecraft_skin_3d_part($original,$user,0,20,4,12,256,"leg_right_outer", TRUE, FALSE); minecraft_skin_3d_part($original,$user,4,20,4,12,256,"leg_right_front", TRUE, FALSE); minecraft_skin_3d_part($original,$user,8,20,4,12,256,"leg_right_inner", TRUE, FALSE); minecraft_skin_3d_part($original,$user,12,20,4,12,256,"leg_right_back", TRUE, FALSE); //Release original from memory (Skin from minecraft.net) imagedestroy($original); } } } function minecraft_skin_delete($user) { rrmdir('images/skins/'.$user); } // Functions not created by me include_once('rmdir.php'); // Script found on php.net that removes all the files in a folder, then the folder itself ?> Заранее благодарен
Правильно я понял, что в функции minecraft_skin_download($user) не видна переменная $skin_path? Если да, то добавьте в функцию объявление global $skin_path: Код (PHP): function minecraft_skin_download($user) { global $skin_path; ...