Trang Chủ

Thứ Năm, 23 tháng 12, 2010

0 Champi.info

Champi.info


Anh champi giúp em lỗi quản lý thành viên

Posted: 23 Dec 2010 01:02 AM PST

vài quản lý user thì nó hiện thế này



Not Acceptable

An appropriate representation of the requested resource /admin.php could not be found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at nhiuchien.com Port 80



em lên mạng search thì biết tại host gator ko hỗ trợ! a pi có cách nào ko?

Sample code để tạo poll cho blog và web bằng php và ajax

Posted: 22 Dec 2010 10:32 PM PST

Đầu tiên bạn xem demo ở đây: http://champi.info/demo/poll/

Bấm xem ảnh ở cửa sổ mới
Bấm xem ảnh ở cửa sổ mới

1. Đầu tiên tạo 1 file setting để tạo các lựa chọn cho poll , setting sẽ bao gồm câu hỏi và các lựa chọn như sau
<?php
$poll_tieude="Do you like Champi.info?";
$poll_data[0]="Very link";
$poll_data[1]="Good";
$poll_data[2]="Normal";
$poll_data[3]="No";
$poll_num=4;
$poll_ip_file = "poll_ip.txt";
$poll_vote_file = "poll_vote.txt";
?>


2. Tạo 1 file index.php để hiển thị poll
- Đầu tiên là check IP đang xem đã bình chọn hay chưa, nếu rồi thì hiển thị kết quả
- Nếu chưa bình chọn thì hiển thị bình chọn
<?php  
require_once ("setting.php");  
echo "<script src='poll.js' type='text/javascript'></script>";  
echo "<div id='poll'>";  
echo $poll_tieude;  
$poll_sum_vote=0;  
$poll_ip_content = file($poll_ip_file);    
$poll_user_ip = stripos($poll_ip_content[0],$_SERVER['REMOTE_ADDR']);  
if ($poll_user_ip !== false) {    
$poll_vote_content = file($poll_vote_file);    
$poll_vote_result = explode("||", $poll_vote_content[0]);    
$poll_sum_vote = $poll_vote_result[0] + $poll_vote_result[1] + $poll_vote_result[2] + $poll_vote_result[3];    
echo "<br/>Kết quả:";    
echo "<table>";    
for ($i=0;$i<$poll_num;$i++) {      
$poll_result_img[$i] = 100*round($poll_vote_result[$i]/$poll_sum_vote,2);      
echo "<tr>";      
echo "<td>{$poll_data[$i]}({$poll_vote_result[$i]})</td>";      
echo "<td>{$poll_result_img[$i]} % <img src='poll.gif' width='{$poll_result_img[$i]}' height='18'></td>";      
echo "</tr>";     }    
echo "</table>";   }
if ($poll_sum_vote==0) {  
echo "<form>";  
for ($i=0;$i<$poll_num;$i++) {    
echo "<input type='radio' name='vote' value='{$i}' onclick='getVote(this.value);'>{$poll_data[$i]}<br/>";   }  
echo "</form>"; }
echo "</div>";
?>


3. Tạo file poll_vote.php để cập nhập bình chon mới
<?php  
$poll_vote = $_REQUEST['vote'];
if ($poll_vote==null) {
echo "access deny"; exit;}
require_once ("setting.php");
$poll_ip = $_SERVER['REMOTE_ADDR'];  
$poll_ip_content = file($poll_ip_file);
$poll_vote_content = file($poll_vote_file);
$poll_vote_result = explode("||", $poll_vote_content[0]);  
$poll_user_ip = stripos($poll_ip_content[0],$poll_ip);
if ($poll_user_ip == false) {    
$poll_ip_file_w = fopen($poll_ip_file, 'w');  
fwrite($poll_ip_file_w, $poll_ip_content[0]);  
fwrite($poll_ip_file_w, $poll_ip."|");  
fclose($poll_ip_file_w);        
switch($poll_vote) {    
case 0:      
$poll_vote_result[0] = $poll_vote_result[0] +1;      
break;    
case 1:      
$poll_vote_result[1] = $poll_vote_result[1] +1;      
break;    
case 2:      
$poll_vote_result[2] = $poll_vote_result[2] +1;      
break;    
case 3:      
$poll_vote_result[3] = $poll_vote_result[3] +1;      
break;    
default:      
echo "access deny"; exit;       break;   }          
$poll_vote_insert = $poll_vote_result[0]."||".$poll_vote_result[1]."||".$poll_vote_result[2]."||".$poll_vote_result[3];
$poll_vote_file_w = fopen($poll_vote_file,"w");  
fputs($poll_vote_file_w,$poll_vote_insert);  
fclose($poll_vote_file_w); }  
$poll_vote_sum = $poll_vote_result[0] + $poll_vote_result[1]+ $poll_vote_result[2] + $poll_vote_result[3];
echo $poll_tieude;
echo "<br/>Kết quả:";
echo "<table>";
for ($i=0;$i<$poll_num;$i++) {  
$poll_result_img[$i] = 100*round($poll_vote_result[$i]/$poll_vote_sum,2);  
echo "<tr>";  
echo "<td>{$poll_data[$i]}({$poll_vote_result[$i]})</td>";  
echo "<td>{$poll_result_img[$i]} % <img src='poll.gif' width='{$poll_result_img[$i]}' height='18'></td>";  
echo "</tr>"; }
echo "</table>";  ?>


4. Cuối cùng là tạo 3 file
- poll_ip.txt để cập nhập IP bình chọn
- poll_vote.txt để cập nhập số bình chọn
- poll.js để tạo code ajax

Bạn có thể download demo ở đây:
Tệp tin tải về
Tệp tin này chỉ tải được sau khi bạn đăng nhập. Hãy Đăng ký hoặc Đăng nhập


Tags - , , , ,

0 nhận xét:

Đăng nhận xét