Directly opening php file
#1

I get a VPS and i install apache and configure that.Now when i enter ip adress in my browser i can see index.php source code.How to fix that?
Reply
#2

Make sure you use PHP's opening and closing braces to contain your code.

Code:
<?php and ?>
Reply
#3

I use it.Now only with this .php file and with others.
Reply
#4

Show me the source code please.
Reply
#5

Xiss game panel index page.
Code:
<?php
/**
 * Copyright © 2013-2014 "Nate 'L0",
 * PHP Script for Game Server management over web interface.
 * 
 * This file is part of XISS Game Panel.
 * 
 * XISS Game Panel is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * XISS Game Panel 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 Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with XISS Game Panel. If not, see <http://www.gnu.org/licenses/>.
 */
 
/**
 * Index file
 * 
 * Main entry point.
 */

/**
 * For Statistics class
 */
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];
$memoryload = memory_get_usage();

/**
 * Set entry point for router 
 */
define("_BASE_", true);

/**
 * Set root directory for files 
 */
define('_ROOT_', __DIR__ .'/');

/**
 * Start Session
 */
if (function_exists('session_start'))
	session_start();


/**
 * Load router
 */
require_once 'core/router.php';
Reply
#6

Quote:
Originally Posted by CloW
View Post
Xiss game panel index page.
Code:
<?php
/**
 * Copyright © 2013-2014 "Nate 'L0",
 * PHP Script for Game Server management over web interface.
 * 
 * This file is part of XISS Game Panel.
 * 
 * XISS Game Panel is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * XISS Game Panel 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 Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with XISS Game Panel. If not, see <http://www.gnu.org/licenses/>.
 */
 
/**
 * Index file
 * 
 * Main entry point.
 */

/**
 * For Statistics class
 */
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];
$memoryload = memory_get_usage();

/**
 * Set entry point for router 
 */
define("_BASE_", true);

/**
 * Set root directory for files 
 */
define('_ROOT_', __DIR__ .'/');

/**
 * Start Session
 */
if (function_exists('session_start'))
	session_start();


/**
 * Load router
 */
require_once 'core/router.php';
There is no ?> at the end. Be sure to add ?> to close the php source.

Here's how it should look like
PHP Code:
<?php
/**
 * Copyright © 2013-2014 "Nate 'L0",
 * PHP Script for Game Server management over web interface.
 * 
 * This file is part of XISS Game Panel.
 * 
 * XISS Game Panel is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * XISS Game Panel 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 Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with XISS Game Panel. If not, see <http://www.gnu.org/licenses/>.
 */
 
/**
 * Index file
 * 
 * Main entry point.
 */
/**
 * For Statistics class
 */
$starttime explode(' 'microtime());
$starttime $starttime[1] + $starttime[0];
$memoryload memory_get_usage();
/**
 * Set entry point for router 
 */
define("_BASE_"true);
/**
 * Set root directory for files 
 */
define('_ROOT_'__DIR__ .'/');
/**
 * Start Session
 */
if (function_exists('session_start'))
    
session_start();
/**
 * Load router
 */
require_once 'core/router.php';
/* See, this thingie down here is what you were missing. */
?>
Reply
#7

I fix that and i get a message You don't have permission to access / on this server.
Reply
#8

Quote:
Originally Posted by Jstylezzz
View Post
There is no ?> at the end. Be sure to add ?> to close the php source.
That is actually not recommended and also not necessary, at the end of the file. If you accidentally put some spaces or tabs behind the closing tag, the browser will consider that as "output" and will attempt to render it on screen. If you later include more PHP code that modifies header values, you will get nasty warnings about "headers already sent".
Reply
#9

Make sure PHP is installed properly. Some VPS come without preinstalled PHP.
Reply
#10

In this case, make sure You've got PHP installed(You can check it by executing "php -v", if the command works, it will return the php version, if it doesn't work.. you don't have PHP installed)
When you can transfer the PHP file, that means APACHE isn't configurated to call the PHP interpreter(Other words: You don't have PHP installed), so APACHE will handle the .php file as a file to be downloaded.

Quote:
Originally Posted by Vince
View Post
If you later include more PHP code that modifies header values, you will get nasty warnings about "headers already sent".
No, these warnings only shows if you had already performed any kind of output(this is, content header already sent to the client)

If so, the best thing We can do is the catch the output(ob_start) and at the end of the file release the buffer(ob_end_flush).
This will make sure that every header function called in the php script will be sent before the output itself.
The ram usage will be higher.
Reply
#11

I reinstall VPS and install all again,but now when i try to enter on my vps,vps no answer,page isn't loading.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)