Parašė Zidezzon· 2008 Rugp. 5 12:08:38
#24
Mr NBA parašė:
Gal gali išimti ir čia parašyti tą kodą kurį reikia į profile.ophp dėti?
Cia ta visa funkcija atrodo....
1. Atsidarome savo profile.php, ir susirandame sitas eilutes
if (!isset($group_id)) {
if (!isset($lookup) || !isNum($lookup)) fallback("index.php");
$result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='$lookup'");
if (dbrows($result)) { $data = dbarray($result); } else { redirect("index.php"); }
Ir jas pakeiciame i stai si koda:
if (!isset($lookup) || !isNum($lookup)) {
fallback("index.php");
} else {
$result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='$lookup'");
if (dbrows($result)) { $data = dbarray($result); } else { redirect("index.php"); }
}
if (!isset($group_id) && !isset($_GET['view'])) {
if (isset($_POST['rate'])) {
if (isNum($_POST['rating']) && !dbcount("(*)","user_ratings","rate_user = '".$userdata['user_id']."' AND rate_subject = '$lookup'") && iMEMBER) {
$result = dbquery("INSERT INTO ".$db_prefix."user_ratings (rate_user,rate_subject,rate_opt,rate_date,rate_ip) VALUES ('".$userdata['user_id']."','$lookup','".$_POST['rating']."','".time()."','".$_SERVER['REMOTE_ADDR']."');");
if ($result) redirect(FUSION_SELF."?lookup=$lookup");
} else {
fallback("http://www.google.lt/");
}
}
Susirandame sita eilute:
echo ($data['user_avatar'] ? "<img src='".IMAGES."avatars/".$data['user_avatar']."' alt='".$locale['u017']."'>" : $locale['u046'])."</td>
Ir virs jos dedame sita koda:
$v = 0;
$result = dbquery("SELECT * FROM ".$db_prefix."user_ratings WHERE rate_subject = '$lookup'");
while ($datax = dbarray($result)) $v = $v+$datax['rate_opt'];
$res = $v;
$vert = (dbrows($result) != 0 ? round($res/dbrows($result),2) : "Nëra");
$rdata = dbarray(dbquery("SELECT * FROM ".$db_prefix."user_ratings WHERE rate_subject = '$lookup' ORDER BY rate_date DESC LIMIT 1"));
echo "Vartotojø ávertinimas: $vert<br>\n";
if (iMEMBER) {
if (!dbcount("(*)","user_ratings","rate_user = '".$userdata['user_id']."' AND rate_subject = '$lookup'")) {
echo " <form method='post' action='".FUSION_SELF."?lookup=$lookup'>\n<select name='rating' class='textbox'>\n";
for ($i = 1; $i < 11; $i++) echo "<option value='$i'>$i</option>\n";
echo "</select> <input name='rate' type='submit' value='Vertinti' class='textbox'>\n</form>\n";
}
}
Issaugome profile.php faila.
2. Atsidarome infusions/user_info_panel/user_info_panel.php faila
Susirandame:
openside($userdata['user_name']);
Po sia eilute dedame:
$sk = 0;
$result = dbquery("SELECT * FROM ".$db_prefix."user_ratings WHERE rate_subject = '".$userdata['user_id']."'");
if (dbrows($result)) {
while ($data = dbarray($result)) $sk = $sk+$data['rate_opt'];
}
$vert = (dbrows($result) > 0 ? round($sk/dbrows($result),2) : "Nëra");
Dabar susirandame sita eilute:
<img src='".THEME."images/bullet.gif' alt=''> <a href='".BASEDIR."edit_profile.php' class='side'>".$locale['080']."</a><br>
Ir virs jos dedame:
<img src='".THEME."images/bullet.gif' alt=''> Vidutinis ávertinimas: $vert<br>
Viska issaugojame
3. Paskutinis zingsnis
Susikuriame faila sql.php , ir i ji rasome:
<?php
include "maincore.php";
include THEME."theme.php";
echo "<meta http-equiv='Content-Type' content='text/html; charset=windows-1257'>
<link rel='stylesheet' href='".THEME."styles.css' type='text/css'>\n";
$sql = dbquery("CREATE TABLE ".$db_prefix."user_ratings (
rated_id BIGINT(20) NOT NULL AUTO_INCREMENT ,
rate_user BIGINT(20) NOT NULL default '0',
rate_subject BIGINT(20) NOT NULL default '0',
rate_opt ENUM( '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ) NOT NULL ,
rate_date BIGINT(20) NOT NULL default '0',
rate_ip VARCHAR(255) NOT NULL default '0',
PRIMARY KEY (rated_id)
) TYPE = MyISAM;");
if ($sql) {
echo "Lentelė sukurta, galite trinti sql.php failą";
} else {
echo mysql_error();
}
?>
Issaugome. Visus failus sukeliame i serverio pagrindine direktorija.
Dabar atsidaryk pvz
http://tavosaitas.lt/sql.php ir viskas
Bandyk... Gal iseis :)
Redagavo Zidezzon· 2008 Rugp. 5 12:08:16