สอบถามผู้รู้เกี่ยวกับ Fatal error: require() [function.require]:..........
ไม่ใช่แระ คุณเข้าใจผิดแระ ที่มันฟ้อง error แบบนี้
คุณ require ไฟล์มาไม่สมบูรณ์ มันหา class.php ใน path อ้างอิงไม่ได้ ครับ
Date :
2014-08-17 05:56:13
By :
deawx
'.;C:\AppServ\php5\pear
รูปแบบของ path ไม่ถูกนะครับ เขียนให้ถูกด้วยครับ
ไม่ควรมี .; (จุด เซมิโคล่อน) อยู่ด้านหน้า C: นะครับ
ปล. เพื่อความชัดเจน เอาโค๊ดตรง include มาดูครับ
ประวัติการแก้ไข 2014-08-17 08:38:10
Date :
2014-08-17 08:37:30
By :
Chaidhanan
index
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
date_default_timezone_set(@date_default_timezone_get());
define('_sep', str_replace('\\', '\\\\', DIRECTORY_SEPARATOR));
define('_root', str_replace('\\', '\\\\', __DIR__) . _sep);
require _root . '_class' . _sep . 'class.php';
?>
<!DOCTYPE html>
<html>
<head>
<title> Pulse </title>
<link rel="stylesheet" type="text/css" href="/cache/cache.php?f=style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="header">
<div class="wrap0">
<a href="/"> Home </a>
<a href="/powers"> Powers </a>
<a href="/create"> Create Group </a>
<a href="/edit"> Edit Chat </a>
<a href="/search"> Search </a>
<?php
if($core->auth)
{
$avatar = is_numeric($core->user['avatar']) ? sprintf('/av/%s.png', $core->user['avatar']) : htmlspecialchars($core->user['avatar']);
print '<a href="/profile?u=' . $core->user['username'] . '" class="profile myprofile" style="background-image: url(\'' . $avatar . '\');">' . $core->user['username'] . '</a>';
}
else
{
print '<a href="/profile" class="profile"> Login // Register </a>';
}
?>
</div>
</div>
<div class="wrap1 f0px">
<!-- Spacing --> <div class="block c1"></div> <!-- End Spacing -->
<?php $core->doPage(); ?>
</div>
<?php
if(isset($core->user['username']))
{
$pcount = $mysql->fetch_array('select count(*) as `count` from `userpowers` where `userid`=' . $core->user['id'] . ';');
$username = strlen($core->user['username']) > 15 ? substr($core->user['username'], 0, 15) . '...' : $core->user['username'];
print '<div class="hoverprofile">';
print '<table width="99%" align="center">';
print '<tr> <td colspan="2" class="tc"> ' . $username . ' </td> </tr>';
print '<tr> <td> xats </td> <td class="fr hoverxats"></td> </tr>';
print '<tr> <td> days </td> <td class="fr hoverdays"></td> </tr>';
print '<tr> <td> powers </td> <td class="fr"> ' . $pcount[0]['count'] . ' </td> </tr>';
/*Ranks*/
$admins = array('Pulse');
$vols = array();
$debugStaff = array();
$IPbanned = array();
$torched = array();
/*End*/
if(in_array($username, $admins)) {
print '<img src="/images/images/pawns/admin.png" title="Pulse Administrator"> Administrator';
print '<hr width="100%">';
}
else if(in_array($username, $vols)) {
print '<img src="/images/images/pawns/spec.png" title="Pulse Volunteer"> Volunteer';
print '<hr width="100%">';
}
else if(in_array($username, $debugStaff)) {
print '<img src="/images/images/pawns/promoted.png" title="Pulse Debug Volunteer"> Debug Volunteer';
print '<hr width="100%">';
}
else {
print '<img src="/images/images/pawns/online.png" title="Pulse User"> Normal User';
print '<hr width="100%">';
}
print '</table>';
print '</div>';
}
?>
<script type="text/javascript">
var ranks = new Array();
<?php
$constants = get_defined_constants(true);
foreach($constants['user'] as $i => $u)
{
if(substr($i, 0, strpos($i, '_')) == 'RANK')
{
print 'ranks["' . strtolower(substr($i, strpos($i, '_') + 1)) . '"] = ' . $u . ';';
}
}
?>
</script>
<script src="/cache/cache.php?f=query.js"></script>
<script src="/cache/cache.php?f=script.js"></script>
</body>
</html>
Date :
2014-08-17 13:10:28
By :
freedom454
Class
<?php
define('RANK_GUEST', 0);
define('RANK_MEMBER', 1);
define('RANK_ADMIN', 2);
class core
{
private $page = 'home';
public $user = array();
public $auth = false;
public function __construct()
{
global $core, $mysql, $config;
if(!class_exists('Database'))
{
require _root . '_class' . _sep . 'pdo.php';
if(file_exists(_root . '_class' . _sep . 'config.php') && !Isset($_GET['anal']))
{
include _root . '_class' . _sep . 'config.php';
$mysql = new Database($config->db[0], $config->db[1], $config->db[2], $config->db[3]);
if(!$mysql->connected)
{
$config = $mysql = false;
}
else
{
$server = $mysql->fetch_array('select * from `server` limit 0, 2;');
if(count($server) > 0)
{
$config->bind_ip = $server[0]['server_ip'];
$config->server_ip = $server[0]['connect_ip'];
$config->server_pt = $server[0]['server_pt'];
$config->server_dm = $server[0]['server_domain'];
$config->xats = $server[0]['starting_xats'];
$config->days = $server[0]['starting_days'];
$config->info = $server[0];
$admin = $mysql->fetch_array('select count(*) from `users` where `username`!=\'Unregistered\';');
if($admin[0]['count(*)'] > 0)
{
$config->complete = true;
try
{
if(isset($_COOKIE['loginKey']) && strlen($_COOKIE['loginKey']) == 32)
{
$user = $mysql->fetch_array('select * from `users` where `loginKey`=:key;', array('key' => $_COOKIE['loginKey']));
if(empty($user))
{
throw new Exception;
}
if(!isset($_COOKIE['xats']) || $_COOKIE['xats'] != $user[0]['xats'])
{
setCookie('xats', $user[0]['xats']);
}
if(!isset($_COOKIE['days']) || $_COOKIE['days'] != floor($user[0]['days'] / 86400))
{
setCookie('days', floor($user[0]['days'] / 86400));
}
if(!isset($_COOKIE['rank']) || $_COOKIE['rank'] != $user[0]['rank'])
{
setCookie('rank', $user[0]['rank']);
}
$this->user = $user[0];
$this->auth = true;
}
}
catch(Exception $e)
{
/* Do Nothing */
}
}
}
}
}
}
}
public function checkRanks() {
$admins = array('saint', 'Insecure');
$vols = array('ixat');
if(in_array($user, $admins)) {
print "Administrator";
}
else if(in_array($user, $vols)) {
print "Volunteer";
}
else {
print "Normal User";
}
}
public function doPage()
{
global $mysql, $config, $core;
$pages = array();
foreach(glob(_root . '_pages' . _sep . '*.php') as $i => $u)
{
$pages[substr(basename($u), 0, -4)] = $u;
}
if(isset($_GET['page']) && array_key_exists($_GET['page'], $pages))
{
$this->page = $_GET['page'];
}
elseif(isset($_GET['page']))
{
if(is_string($_GET['page']))
{
$chat = $mysql->fetch_array('select * from `chats` where `name`=:chat;', array('chat' => $_GET['page']));
if(!empty($chat))
{
$this->page = 'chat';
}
}
}
require $pages[$this->page];
}
public function allset()
{ /* So I can cheat */
$args = func_get_args();
$array = array_shift($args);
foreach($args as $index)
{
if(!isset($array[$index]) || !is_string($array[$index]))
{
return false;
}
}
return true;
}
public function getEmbed($chat, $pass = false, $w = 730, $h = 490)
{
global $mysql, $config;
$chat = $mysql->fetch_array('select * from `chats` where `name`=:a or `id`=:b;', array('a' => $chat, 'b' => $chat));
if($pass !== false)
{
$pass = '&pass=' . urlencode($pass);
}
$debug = isset($_GET['debug']) ? 'chat2.swf' : 'chat.swf';
return empty($chat) ? false : "<embed id=\"XenoBox\" width=\"{$w}\" height=\"{$h}\" type=\"application/x-shockwave-flash\" quality=\"high\" src=\"http://{$config->info['server_domain']}/cache/cache.php?f={$debug}&d=flash&id={$chat[0]["id"]}&gn={$chat[0]["name"]}{$pass}\" flashvars=\"id={$chat[0]["id"]}&gn={$chat[0]["name"]}{$pass}\" wmode=\"transparent\">";
}
public function refreshLogin($redirect = true)
{
global $mysql, $config;
if(!isset($_COOKIE['loginKey']) || strlen($_COOKIE['loginKey']) != 32)
{
return false;
}
$user = $mysql->fetch_array('select * from `users` where `loginKey`=:key;', array('key' => $_COOKIE['loginKey']));
if(empty($user))
{
return false;
}
$upowers = $mysql->fetch_array("select * from `userpowers` where `userid`={$user[0]['id']};");
$spowers = $mysql->fetch_array("select * from `powers` where `name` not like '%(Undefined)%';");
list($vals, $p, $dO, $powerO, $pp) = array(array(), array(), '', '', '');
foreach($spowers as $i => $u)
{
$vals[$u["id"]] = array($u["section"], $u["subid"]);
if(!isset($p[$u["section"]]))
{
$p[$u["section"]] = 0;
}
}
foreach($upowers as $i => $u)
{
if($u["count"] >= 1 && isset($vals[$u["powerid"]]) && isset($p[$vals[$u["powerid"]][0]]))
{
$str = $u['powerid'] . '=' . ($u['count'] > 1 ? ($u['count'] -1) : 1) . '|';
$dO .= $str;
if($u['count'] > 1)
{
$powerO .= $str;
}
$p[$vals[$u["powerid"]][0]] += $vals[$u["powerid"]][1];
}
}
foreach($p as $i => $u)
{
$pp .= "w_d" . (substr($i, 1) + 4) . "={$u}&";
}
/* Nickname / Status */
$nickname = explode('##', $user[0]['nickname'], 2);
if(count($nickname) != 2)
{
$nickname[1] = "";
}
$user[0] = array_map('urlencode', $user[0]);
$vars = "";
$vars .= "w_userno={$user[0]["id"]}&";
$vars .= "w_avatar={$user[0]["avatar"]}&";
$vars .= "w_k1={$user[0]["k"]}&";
$vars .= "w_d0={$user[0]['d0']}&";
$vars .= "w_d1={$user[0]['days']}&";
$vars .= "w_d2={$user[0]['d2']}&";
$vars .= "w_d3=&";
$vars .= $pp;
$vars .= "w_dt=0&";
$vars .= "w_homepage={$user[0]['url']}&";
$vars .= "w_Powers=" . implode(",", $p) . "&";
$vars .= "w_PowerO=" . urlencode($powerO) . "&";
$vars .= "w_status=" . urlencode($nickname[1]) . "&";
$vars .= "w_dO=" . urlencode($dO) . "&";
$vars .= "w_dx={$user[0]["xats"]}&";
$vars .= "w_registered={$user[0]["username"]}&";
$vars .= "w_k2={$user[0]["k2"]}&";
$vars .= "w_k3={$user[0]["k3"]}&";
$vars .= "w_name=" . urlencode($nickname[0]);
/* Finish Login */
return "<embed height=\"1\" width=\"1\" type=\"application/x-shockwave-flash\" flashvars=\"{$vars}" . ($redirect ? '&redirect=1' : '') . "\" src=\"http://{$config->info['server_domain']}/cache/cache.php?f=login.swf&d=flash\">";
}
}
$core = new core();
if(isset($_GET['ajax']) || isset($_GET['page']) && $_GET['page'] == 'config')
{
header('Content-Type: text/plain');
$core->doPage();
exit;
}
Date :
2014-08-17 13:11:07
By :
freedom454
Code (PHP)
$pth = _root . '_class' . _sep . 'class.php';
if(!file_exists($pth)) {
echo 'notfound ' , $pth , "<br/>\n"
, '_sep = ', _sep, " -- " , DIRECTORY_SEPARATOR, "<br/>\n"
, '_root = ', _root ,' -- ', __DIR__;
exit;
}
require $pth;
ลองแก้เป็นแบบนี้ แล้วเอาผลมาดูหน่อยครับ
ประวัติการแก้ไข 2014-08-17 13:22:20
Date :
2014-08-17 13:17:56
By :
Chaidhanan
เอา php code ครอบ ดีกว่า เอา อื่นๆ ครอบครับ มันแยกสีให้ด้วย
Date :
2014-08-17 13:21:54
By :
Chaidhanan
ถามครับ ตัว class ใช้ ctrl+A หรือเปล่าครับ หรือใช้เม้าส์ลากมาแปะ (สำคัญมาก)
เพราะ ?> มันหายไปจาก ด้านล่างไม่เห็นมีครับ
Date :
2014-08-17 13:28:38
By :
Chaidhanan
ตอบความคิดเห็นที่ : 9 เขียนโดย : freedom454 เมื่อวันที่ 2014-08-17 13:58:05
รายละเอียดของการตอบ ::
ต้องใส่ ปิด tag php ด้วยครับ มันผิดหลักไวยกรณ์ ไฟล์นี้จะเสียไม่สามารถใช้งานได้ครับ
ตอบความคิดเห็นที่ : 10 เขียนโดย : freedom454 เมื่อวันที่ 2014-08-17 13:59:22
รายละเอียดของการตอบ ::
define('_sep', str_replace('\\', '\\\\', DIRECTORY_SEPARATOR));
define('_root', str_replace('\\', '\\\\', __DIR__) . _sep);
สองบันทัดสีแดงนี่ str_replace ไว่ทำอะไรครับลองเอาออกครับ
index.php ต้องเป็นแบบนี้นะครับ ไม่ใช่ รัน เฉพาะ โค๊ดของผมเพียวๆ นะครับ
Code (PHP)
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
date_default_timezone_set(@date_default_timezone_get());
define('_sep', DIRECTORY_SEPARATOR );
define('_root', __DIR__ . _sep);
$pth = _root . '_class' . _sep . 'class.php';
if(!file_exists($pth)) {
echo 'notfound ' , $pth , "<br/>\n"
, '_sep = ', _sep, " -- " , DIRECTORY_SEPARATOR, "<br/>\n"
, '_root = ', _root ,' -- ', __DIR__;
exit;
}
require $pth;
?><doctype .........
ประวัติการแก้ไข 2014-08-17 14:15:00
Date :
2014-08-17 14:12:53
By :
Chaidhanan
Load balance : Server 03