Function code list - PHP fun!
(Forums : Coding & Scripting : Function code list - PHP fun!)
|
Locked
|
Thread Options
|
|
|
Jul 20 2003
Anchor
|
I decided to post this for some php fun, plus if 40oz see's this then it should give him insentive to get PHPing
Any errors or suggestions are welcome.
<?PHP
/*
+=================================================+
| Wuggawoo version 1.5
| Created by Aaron Lote
| Address: http://www.wuggawoo.co.uk/
| Email: azz0r@wuggawoo.co.uk
| > Function List
+=================================================+
*/
/*Make's sure the page isnt cached; useful for sql driven pages - called in every page header*/
function disable_cache($update_date='')
{header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");}
/*Used to convert date fields into actual dates - called in user profile*/
function datetimeformat($format, $datetimestr)
{list($date, $time2) = explode(" ", $datetimestr);
list($year, $month, $day) = explode("-", $date);
list($hour, $minute, $second) = explode(":", $time2);
return date($format, mktime($hour, $minute, $second, $month, $day, $year));}
/*Defines the $time variable as the unix timestamped time - called in every page header*/
$time = time();
/*Figures out the diffrence between the variable and the current time, based on unix timestamp - called in various places*/
function TimeDiffo($time)
{$time=time()-$time;
$weeks=$time/604800;
$days=($time%604800)/86400;
$hours=(($time%604800)%86400)/3600;
$minutes=((($time%604800)%86400)%3600)/60;
$seconds=(((($time%604800)%86400)%3600)%60);
if(round($days)) $timestring.=round($days)."d ";
if(round($hours)) $timestring.=round($hours)."h ";
if(round($minutes)) $timestring.=round($minutes)."m";
if(!round($minutes)&&!round($hours)&&!round($days)) $timestring.=" ".round($seconds)."s";
return $timestring;}
/*Collects smilies from the DB and replaces sections in the variable where match is found - called on most pages with dynamic text*/
function smileys($smile)
{$query = mysql_query("SELECT * FROM unz_smilies");
while($smily = mysql_fetch_object($query))
{$smile = str_replace("$smily->replace", "<img src='images/smilies/$smily->link' alt='$smily->alt'>",$smile);}
return $smile;}
/*Collects the categories from the DB and turns them into a drop down box - called in most pages*/
function Category_Drop()
{echo "<select name='cid'>";
$query = mysql_query("SELECT cid, name FROM unz_category ORDER BY cid DESC");
while($category = mysql_fetch_object($query))
{echo "<option value='$category->cid' class='ip1'>$category->name</option>";}
echo "</select>";}
/*Collects the birthday from the DB and then selects then date in the option box, if they match then the date/month/year is preselected - called in edit profile page*/
function Category_DropChosen($day)
{echo "<select name='cid'>";
$query = mysql_query("SELECT cid, name FROM unz_category ORDER BY cid DESC");
while($category = mysql_fetch_object($query))
if($day == $category->cid)
{echo "<option value='$category->cid' class='ip1' selected>$category->name</option>";}
else
{echo "<option value='$category->cid' class='ip1'>$category->name</option>";}
echo "</select>";}
/*Cleans data made by user of possibly evil codes - called in all pages with user text*/
function safeHTML($comment)
{$comment = stripslashes($comment);
$comment = strip_tags($comment, '< b>< i>< u>< a>');
$comment = ereg_replace ("<a[^>]+href *= *([^ ]+)[^>]*>", "<a href=1>", $comment);
$comment = ereg_replace ("<([b|i|u])[^>]*>", "<1>", $comment);
$comment = preg_replace ("/([^s]{45,})/e", "''.wordwrap('1', 45, ' ', 1).''", $comment);
$comment = preg_replace('/<!--.+?-->/','',$comment);
$comment = str_replace("<", "<", $comment);
$comment = str_replace(">", ">", $comment);
$comment = addslashes($comment);
return $comment;}
/*Error table - called if theres an error*/
function error_box($error, $forward=""))
{echo "<table width='100%' cellspacing='1' cellpadding='4' class='bg6' style='margin-top : 7px;'><tr><td class='bg3'>
<font class='newstitle'>Error</font></br>
<font class='newstext'>$error</font>
</td></tr></table>";
if(!$forward)
{NULL}
else
{echo "<script>function redirect() { window.location.replace('javascript:history.go(-1)'); }
setTimeout('redirect();', 2000);</script>";}}
/*Success table - called if theres a successful insertion*/
function success_box($success, $forward)
{echo"<table width='100%' cellspacing='1' cellpadding='4' class='bg6' style='margin-top : 7px;'><tr><td class='bg3'>
<font class='newstitle'>Success</font></br><font class='newstext'>$success</font>
</td></tr></table>
<script>function redirect() { window.location.replace('$forward'); }
setTimeout('redirect();', 1000);</script>";}
/*Collects the birthday from the DB and then selects then date in the option box, if they match then the date/month/year is preselected - called in edit profile page*/
function day_dropdown($day)
{print '<select name='date'><option class='ip1' value=''>Day</option>';
$count = 00;
while ($count < 31)
{if ($count == $day)
{$out .= "<option name='$day' class='ip1' selected>$day</option>";}
else
{$out .= "<option class='ip1' name='$count'>$count</option>";}
$count++;}
$out .= '</select>';
return $out;}
/*Collects the birthday from the DB and then selects then date in the option box, if they match then the date/month/year is preselected - called in edit profile page*/
function month_dropdown($month)
{print '<select name='month'><option class='ip1' value=''>Month</option>';
$count = 00;
while ($count < 12)
{if ($count == $month)
{$out .= "<option name='$month' class='ip1' selected>$month</option>";}
else
{$out .= "<option class='ip1' name='$count'>$count</option>";}
$count++;}
$out .= '</select>';
return $out;}
/*Collects the birthday from the DB and then selects then date in the option box, if they match then the date/month/year is preselected - called in edit profile page*/
function year_dropdown($year)
{print '<select name='year'><option class='ip1' value=''>Year</option>';
$count = 1959;
$thisyear = date("Y");
while ($count < $thisyear)
{if ($count == $year)
{$out .= "<option name='$year' class='ip1' selected>$year</option>";}
else
{$out .= "<option class='ip1' name='$count'>$count</option>";}
$count++;}
$out .= '</select>';
return $out;}
/*Beta random password generator, doesnt work yet - called when user signs-up*/
function password()
{$chars = "abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ023456789";
for($i = 0; $i < $length; $i++)
{$x = rand(0, strlen($chars) -1);
$password .= $chars{$x};}
return $password;}
/*Checks data for BB code - called quite abit, anything with possible BB code*/
function InsertBBCode($unznews){
$bbcodes_open = array("[move]","[sub]","[tt]","[sup]","<s>","[ b]","[ i]","[ u]","[ quote]","[ code]");
$bbcodes_close = array("[/move]","[/sub]","[/tt]","[/sup]","</s>","[/b]","[/i]","[/u]","[ /quote]","[ /code]");
for($i = 0; $i < 10; $i++ )
{$bbcode_open = $bbcodes_open[$i];
$bbcode_close = $bbcodes_close[$i];
$open_cnt = substr_count( $unznews, $bbcode_open );
$close_cnt = substr_count( $unznews, $bbcode_close );
$div = abs( $open_cnt - $close_cnt );
if ( $open_cnt > $close_cnt)
{for ($i = 0; $i < $div; $i++)
$unznews .= $bbcode_close;}
if ( $open_cnt < $close_cnt )
{for ($i = 0; $i < $div; $i++)
$unznews = $bbcode_open.$unznews;}}
$unznews = str_replace("[sub]", "<sub>", $unznews);
$unznews = str_replace("[/sub]", "</sub>", $unznews);
$unznews = str_replace("[tt]", "<tt>", $unznews);
$unznews = str_replace("[/tt]", "</tt>", $unznews);
$unznews = str_replace("[sup]", "<sup>", $unznews);
$unznews = str_replace("[/sup]", "</sup>", $unznews);
$unznews = str_replace("<s>", "<s>", $unznews);
$unznews = str_replace("</s>", "</s>", $unznews);
$unznews = str_replace("<strong>", "<b>", $unznews);
$unznews = str_replace("</strong>", "</b>", $unznews);
$unznews = str_replace("<em>", "<i>", $unznews);
$unznews = str_replace("</em>", "</i>", $unznews);
$unznews = str_replace("<u>", "<u>", $unznews);
$unznews = str_replace("</u>", "</u>", $unznews);
$unznews = str_replace("[ quote]", "<table width='50%' cellspacing='1' cellpadding='4' class='bg6' style='margin-top : 7px;'><tr><td class='bg3'><font class='newstitle'>Quote</font></br><div class='news'>", $unznews);
$unznews = str_replace("[ /quote]", "</div></td></tr></table>", $unznews);
$unznews = str_replace("[ code]","<blockquote><span class="12px">code:</span><hr><pre>",$unznews);
$unznews = str_replace("[ /code]","</pre><hr></blockquote>",$unznews);
$unznews = str_replace("<li>", "<li>", $unznews); </li>$unznews = str_replace("[hr]", "<hr>", $unznews);
$unznews = eregi_replace("<span style="color:"[^[">*)]([^[]*)</span>","<font color="1">2</font>",$unznews);
$unznews = eregi_replace("[size=([^[]*)]([^[]*)[/size]","<font size="1">2</font>",$unznews);
$unznews = eregi_replace("[font=([^[]*)]([^[]*)[/font]","<font face="1">2</font>",$unznews);
$unznews = eregi_replace("[<a href="http://([^[" target="_blank" rel="nofollow">*)]IMAGE</a>]","<img src="1">",$unznews);
$unznews = eregi_replace("[align=([^[]*)]([^[]*)[/align]","<p align="1">2</p>",$unznews);
$unznews = eregi_replace("<a href="mailto:([^[]*)">([^[]*)</a>", "<a href="mailto:1">1</a>",$unznews);
$unznews = eregi_replace("[email=([^[]*)]([^[]*)[/email]", "<a href="mailto:1">2</a>",$unznews);
$unznews = eregi_replace("(^|[>[:space:]n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]n]|$)","1<a href="2://34" target="_blank">2://34</a>", $unznews);
$unznews = preg_replace("/([n >(])www((.[w-_]+)+(:[d]+)?((/[w-_%]+(.[w-_%]+)*)|(/[~]?[w-_%]*))*(/?(?[&;=w+%]+)*)?(#[w-_]*)?)/", "1<a href="http://www2">www2</a>", $unznews);
$unznews = eregi_replace("www.([^[]*)", "<a href="http://www.1" target=_blank>1</a>",$unznews);
$unznews = eregi_replace("([^[]*)","<a href="1" target=_blank>1</a>",$unznews);
$unznews = eregi_replace("<a href="http://([^[" target="_blank" rel="nofollow">*)]([^[]*)</a>","<a href="1" target=_blank>2</a>",$unznews);
return $unznews;}
/*Beta size calculator - Will be used on avatar checking*/
function calc_size ( $size )
{if ( $size < 1000 )
return $size + ' Bytes';
if ( $size < 1000000 )
return number_format(($size/1024), 2, '.', '').' kB';
if ( $size < 1000000000 )
return number_format($size/(1024*1024), 2, '.', '').' MB';
if ( $size < 1000000000000 )
return number_format($size/(1024*1024*1024), 2, '.', '').' GB';}
?>
- Edited By azz0r On Sun 20th, Jul 2003 @ 1:36:56pm
|
|
Jul 20 2003
Anchor
|
Just to show azz0r some clean code:
<?php
#------------------------------------------------------------#
# Core CMS v00001 #
# Copyright 2003 by Core PHP #
#------------------------------------------------------------#
# INIT CORE CMS ------------------------------------ #
session_start ();
list($usec, $sec) = explode(' ', microtime());
$head['time_start'] = ((float)$usec + (float)$sec);
# Load required files:
require('./settings/main.php');
require('./functions.php');
require('./classes/mysql.php');
# Set head vals:
$head['body'] = '';
$head['time'] = time();
$head['active'] = false;
$head['delsql'] = '';
$head['found'] = false;
$head['lang'] = 'en';
$head['theme'] = 'default';
$head['page'] = $_GET['p'];
$head['title'] = $set['sitename'];
$head['location'] = '';
# Make sure we have a page to go to:
if (!$head['page']){
header('Location: ' . $set['defpage']);
exit;
}
# Add site name to location bar:
$head['location'][] = array($set['sitename'], './index.php');
# Start Database:
$database = new db; $database->open();
# Cache main templates:
$mtpl = load_temp(array(
'main_user_color',
'main_user_plain',
'main',
));
# MANAGE SESSIONS ---------------------------------- #
# Check to see if there is a session to wrok with:
if (isset($_SESSION['username']) and isset($_SESSION['password']) and isset($_SESSION['userid'])) {
$_SESSION['username'] = addslashes($_SESSION['username']);
$userinf = $database->query("SELECT * FROM $set[sqlpref]users WHERE id = '" . $_SESSION['userid'] . "' LIMIT 1");
$userinf = $database->fetch_array($userinf);
$userinf['password'] = stripslashes($userinf['password']);
$_SESSION['password'] = stripslashes($_SESSION['password']);
if($_SESSION['password'] == $userinf['password']) {
$head['active'] = true;
$head['username'] = $userinf['name'];
$head['id'] = $userinf['id'];
$head['ip'] = $_SERVER['REMOTE_ADDR'];
$head['level'] = $_SESSION['userlevel'];
}
}
$_SESSION['username'] = stripslashes($_SESSION['username']);
if (!$head['active']) {
$head['username'] = $set['guestname'];
$head['id'] = 0;
$head['ip'] = $_SERVER['REMOTE_ADDR'];
$head['level'] = 0;
}
# Find users online entries that need deleting:
$res = $database->query("SELECT id, ip, time FROM $set[sqlpref]usersonline");
while ($user = $database->fetch_array($res)) {
if ($user['ip'] <> $_SERVER['REMOTE_ADDR']) {
if ($head['time'] - $user['time'] > $set['seslen']) {
if (!$head['delsql']) {
$head['delsql'] .= "DELETE FROM $set[sqlpref]usersonline WHERE ip='$user[ip]' ";
} else {
$head['delsql'] .= 'OR ip='' . $user['ip'] . '' ';
}
}
} else {
if (!$head['found']) {
$head['found'] = true;
$database->query("UPDATE $set[sqlpref]usersonline SET time='$head[time]' WHERE ip='$_SERVER[REMOTE_ADDR]' LIMIT 1");
}
}
}
if (!$head['found']) {
$database->query("INSERT INTO $set[sqlpref]usersonline VALUES ('$head[userid]', '$head[username]', '$_SERVER[REMOTE_ADDR]', '$head[time]', '', '')");
}
# Chack to see if there where any to dalete and delete them:
if ($head['delsql']) {
$database->query($head['delsql']);
}
# CAPTURE ------------------------------------------ #
# Start output capturing:
ob_start();
# PAGE --------------------------------------------- #
#print $set['defpage'] . ' - ' . $_SERVER['REQUEST_URI'];
# Make sure we can open the requested page:
if (file_exists("./langs/$head[lang]_$head[page].php") and file_exists("./settings/$head[page].php") and file_exists("./pages/$head[page].php")) {
require("./langs/$head[lang]_$head[page].php");
require("./settings/$head[page].php");
require("./pages/$head[page].php");
} else {
header('Location: ' . $set['404page']);
}
# PAGE BLOCKS -------------------------------------- #
# Load block templates:
$btpl = array();
$blocks = $database->query("SELECT * FROM $set[sqlpref]plugin_tags");
while ($row = $database->fetch_array($blocks)) {
$btpl["block_$row[id]"] = load_temp(array("block_$row[id]"));
}
$blocks = $database->query("SELECT t.*, i.* FROM $set[sqlpref]plugin_tags t LEFT JOIN $set[sqlpref]plugin_items i ON (i.pid=t.id) WHERE i.pos<>0 ORDER BY i.pos ASC");
while ($row = $database->fetch_array($blocks)) {
eval("$row[title] = "" . addslashes($row['title']) . "";");
eval("$row[data] = "" . addslashes($row['data']) . "";");
eval("$block[$row[id]] .= "" . $btpl["block_$row[id]"] . "";");
}
# END CAPTURE -------------------------------------- #
# Save output and stop capturing:
$head['body'] = ob_get_contents();
ob_end_clean();
# FINALIZE ----------------------------------------- #
# Make the location selector:
$location = ''; $i = 1;
if ($set['defpage'] <> '.' . $_SERVER['REQUEST_URI']) {
foreach ($head['location'] as $k) {
if ($i <> count($head['location'])) {
$location .= "<a href="$k[1]">$k[0]</a> > ";
} else {
$location .= "<b>$k[0]</b>";
$head['pagetitle'] = $k[0];
}
$i++;
}
} else {
$location .= '<b>' . $head['location'][0][0] . '</b>';
$head['pagetitle'] = $head['location'][1][0];
}
$head['location'] = $location;
unset($location);
# Update users online:
$database->query("UPDATE $set[sqlpref]usersonline SET ls_title='$head[pagetitle]', ls_url='.$_SERVER[REQUEST_URI]' WHERE ip='$_SERVER[REMOTE_ADDR]' LIMIT 1");
list($usec, $sec) = explode(' ', microtime());
$head['time_end'] = ((float)$usec + (float)$sec);
$head['time_end'] = number_format(($head['time_end'] - $head['time_start']), 5, '.', '');
$head['count_sql'] = $database->querycount;
# Eval main template:
eval("$output = "" . $mtpl['main'] . "";");
print stripslashes($output);
# -------------------------------------------------- #
?>
- Edited By The_Wolf On Sun 20th, Jul 2003 @ 7:32:27am
-- “I hereby state my opinion that the notion of a [expletive deleted] is a basic superstition, that there is no evidence for the existence of any [expletive deleted].”
|
|
Jul 20 2003
Anchor
|
Ok fix0red my function list...heres my...start-up
<?
$query_setting = mysql_query("SELECT * FROM unz_settings");
$setting = mysql_fetch_object($query_setting);
$site_properties['site'] = $setting->site;
$site_properties['commenting'] = $setting->commenting;
$site_properties['guest_comment'] = $setting->guest_comment;
$site_properties['sign_up'] = $setting->sign_up;
$site_properties['per_page'] = $setting->per_page;
$site_properties['guest_vote'] = $setting->guest_vote;
$site_properties['chatter_pp'] = $setting->chatter_pp;
$site_properties['guest_chatter'] = $setting->guest_chatter;
if($site_properties['site'] == 'off')
{include("pages/misc/site_off.php");
exit();}
else
{if(isset($_COOKIE['username']) && isset($_COOKIE['password']))
{$sql = "SELECT uid,username,password,status FROM unz_users WHERE username = '" . $_COOKIE['username'] . "' AND password = '" . $_COOKIE['password'] . "'";
$query = mysql_query($sql);
$auth = mysql_fetch_object($query);
$user_properties['username'] = $auth->username;
$user_properties['status'] = $auth->status;
$user_properties['uid'] = $auth->uid;}}
if(!$_COOKIE['visited'])
{if(!$user_properties['uid'])
{setcookie ("visited", "visited", time()+60*60*24*30,'/','.wuggawoo.co.uk', 0);
mysql_query("INSERT INTO unz_stats (uid,status,host,ip,browser,time,referer,qstring) VALUES ('2','unique','$host','$ip','$browser',
'$time','$referer','$qstring')");}
else
{mysql_query("INSERT INTO unz_stats (uid,status,host,ip,browser,time,referer,qstring) VALUES ('".$user_properties['uid']."','unique','$host','$ip','$browser', '$time','$referer','$qstring')");}}
else
{if(!$user_properties['uid'])
{mysql_query("INSERT INTO unz_stats (uid,status,host,ip,qstring) VALUES ('2','pageview','$host','$ip','$qstring'
)");}
else
{mysql_query("INSERT INTO unz_stats (uid,status,host,ip,qstring) VALUES ('".$user_properties['uid']."','pageview','$host','$ip','$qstring')");}}
?>
|
|
Jul 20 2003
Anchor
|
Look at the clean!
Ccms.corephp.org
-- “I hereby state my opinion that the notion of a [expletive deleted] is a basic superstition, that there is no evidence for the existence of any [expletive deleted].”
|
|
Jul 20 2003
Anchor
|
Looks like ass to me
|
|
Jul 20 2003
Anchor
|
:o so confusing! Which one of you is right? ARGH!
|
|
Jul 20 2003
Anchor
|
me obviously.
although most PHP sites will favour wolfs bracketing style; btw no1's code is wrong, and no-ones is right.
|
|
Jul 21 2003
Anchor
|
Thats correct, mine just happens to be easy to read...
-- “I hereby state my opinion that the notion of a [expletive deleted] is a basic superstition, that there is no evidence for the existence of any [expletive deleted].”
|
|
Jul 21 2003
Anchor
|
|
|
Jul 22 2003
Anchor
|
/me continues writing Domination code
-- BigBird
Mod DB Guy
Play Something Different
|
|
Jul 22 2003
Anchor
|
erm, i cant actually play the game though... just displays member info, including a non bleeped password
and azzy, i like your commenting... makes it easy to change things if a certain feature is borked
- Edited By PsychoFarmer On Mon 21st, Jul 2003 @ 9:24:34pm
-- ___________________________
Today seems like a good day to burn a bridge or two
I am the freakiest man in the world!!!!
I beg to differ, on the contrary, I agree with every word that you say
|
|
Jul 22 2003
Anchor
|
yeh yeh the game is still very much so in development...
and ofcourse it's unbleeped... (i dun have a reason for havin it unbleeped but there ya go...)
-- BigBird
Mod DB Guy
Play Something Different
|
|
Jul 22 2003
Anchor
|
Indeed PF, I really cant understand Wolfs code usually cos its like bracketing hell.
|
|
Jul 22 2003
Anchor
|
Core CMS is neat, very neat but you are making code to be publically released, azz0r and myself are not planning that, so we have a little extra freedom.
I would show off my new forum code, but it still is a while off and messy
|
|
Jul 22 2003
Anchor
|
don't talk to me about messy...
hehe last time i showed you some code i had written INtense! your shot me down.. said it works but was like php v1 n00b style coding hehe (well they weren't your words but that was what was emplied )
but yeh my code is generally neat cos i'm from a vb back ground and vb helps to be structured... and my code is getting more and more complex on a weekly basis...
-- BigBird
Mod DB Guy
Play Something Different
|
|
Jul 27 2003
Anchor
|
Wuggawoo.co.uk > to see this in action
view wrote: <?php
if(!$uid)
{$error = "You didnt input a user ID.";
error_box($error, $forward);}
else
{$query = mysql_query("SELECT * FROM unz_users WHERE uid='$uid'");
$num_rows = mysql_num_rows($query);
if($num_rows > 0)
{$user = mysql_fetch_object($query);
mysql_query("UPDATE unz_users SET views = views + 1 WHERE uid = '$uid'");
if($user->uid == $user_properties['uid'] || $user_properties['status'] == admin)
{$edit = "<font class='newsunder'>: <a href='?section=edit_account'>Edit account</a></font>";}
echo "<table width='100%' cellspacing='1' cellpadding='4' class='bg6' style='margin-top : 7px;'>
<tr align='left' valign='top'>
<td class='bg1'><font class='newstitle'>Viewing $user->username $edit</font>";
echo "<table width='100%' cellspacing='1' cellpadding='4' class='bg6' style='margin-top : 7px;'>
<tr align='left' valign='top'>
<td class='bg3'><font class='newstitle'>Vital statistics</font>
<font class='newstext'>User ID : $user->uid</font>
<font class='newstext'>Registered : ".date('jS F y', $user->regdate)."</font>
<font class='newstext'>Last login : ".date('jS F y', $user->last_login)." (";
echo TimeDiffo($user->last_login);
echo " ago)</font>
<font class='newstext'>Host address : $user->host</font></td></tr></table>";
/*User defined data box start*/
if($user->email && !$user->email_hide)
{$email = "<font class='newstext'>Email Address : <a href='mailto:$user->email' subject='Emailed from wuggawoo.co.uk'>$user->email</a></font>
";}
if($user->site)
{$site = "<font class='newstext'>Website : <a href='$user->site' target='_blank'>$user->site</a></font>
";}
if($user->msn && !$user->msn_hide)
{$msn = "<font class='newstext'>MSN address : $user->msn</font>
";}
if($user->sex == 'M')
{$sex = "<a href='http://www.bullz-eye.com/'>Male</a>";}
elseif ($user->sex == 'F')
{$sex = "<a href='http://www.ivillage.com/'>Female</a>";}
else{$sex = "Not available";}
echo "<table width='100%' cellspacing='1' cellpadding='4' class='bg6' style='margin-top : 7px;'>
<tr align='left' valign='top'>
<td class='bg3'><font class='newstitle'>User defined data</font>
$email
$site
$msn
<font class='newstext'>Gender : $sex</font>
<font class='newstext'>Birthday : ".datetimeformat('jS F Y', $user->bday)."</font></td></tr></table>";
/*Contribution box start*/
$query_comment = mysql_query("SELECT uid FROM unz_comments WHERE uid= '$uid'");
$query_chatter = mysql_query("SELECT uid FROM unz_chatterbox WHERE uid = '$uid'");
$comment_count = mysql_num_rows($query_comment);
$chatter_count = mysql_num_rows($query_chatter);
echo "<table width='100%' cellspacing='1' cellpadding='4' class='bg6' style='margin-top : 7px;'>
<tr align='left' valign='top'>
<td class='bg3'>
<font class='newstitle'>Site contribution</font>
<font class='newstext'>News Comment : $comment_count</font>
<font class='newstext'>ChatterBox entries : $chatter_count</font>
<font class='newstext'>Logins / Logouts : $user->login / $user->logout</font></td></tr></table>";
/*Tag wall meter start*/
if($user->tag !="")
{$user->tag = nl2br($user->tag);
$user->tag = smileys($user->tag);
$user->tag = InsertBBCode($user->tag);
echo "<table width='100%' cellspacing='1' cellpadding='4' class='bg6' style='margin-top : 7px;'>
<tr align='left' valign='top'>
<td class='bg3'>
<font class='newstitle'>FreeSpeech box</font>
<font class='newstext'>$user->tag</font></td></tr></table>"
;;}
/*Respect meter start*/
if ($user->respect_total == NULL || $user->people_voted == NULL)
{$respect = 0;
$user->respect_total = 0;
$user->people_voted = 0;}
else
{$respect = $user->respect_total / $user->people_voted;
$respect = substr($respect, 0, strrpos($respect, '.') + 2);}
echo "<table width='100%' cellspacing='1' cellpadding='4' class='bg6' style='margin-top : 7px;'>
<tr align='left' valign='top'>
<td class='bg3'>
<font class='newstitle'>Respect vote</font>
<font class='newstext'>$respect out of 5</font>
<font class='newstext'>Total ($user->respect_total) / Total people voted ($user->people_voted)</font>
<font class='newstext'><a href='?section=voting_user&uid=$uid&vote=1' target='_self' class='navbar'>1</a>
<a href='?section=voting_user&uid=$uid&vote=2' target='_self' class='navbar'>2</a>
<a href='?section=voting_user&uid=$uid&vote=3' target='_self' class='navbar'>3</a>
<a href='?section=voting_user&uid=$uid&vote=4' target='_self' class='navbar'>4</a>
<a href='?section=voting_user&uid=$uid&vote=5' target='_self' class='navbar'>5</a></font></td></tr></table>"
;;
echo "</td></tr></table>";}
else
{$forward = "";
$error = "No such user exists.";
$forward = "yep";
error_box($error, $forward);}}
?>
My favourite page, not to complex
- Edited By azz0r On Sun 27th, Jul 2003 @ 3:52:58pm
|
|
Jul 27 2003
Anchor
|
BigBird wrote: don't talk to me about messy...
hehe last time i showed you some code i had written INtense! your shot me down.. said it works but was like php v1 n00b style coding hehe (well they weren't your words but that was what was emplied )
but yeh my code is generally neat cos i'm from a vb back ground and vb helps to be structured... and my code is getting more and more complex on a weekly basis...
PHP v1 n00b style? Haha! Birdeh that sucks but it's funny. Where would you guys recommend me to look to get good assistance on PHP? I want to teach myself.
|
|
Jul 27 2003
Anchor
|
|
|
Jul 27 2003
Anchor
|
i tried php.net, and it was helpful for about 10 mins before it went WAY over my head...
that, plus the fact that i dont have a place to view php on, atm...
-- ___________________________
Today seems like a good day to burn a bridge or two
I am the freakiest man in the world!!!!
I beg to differ, on the contrary, I agree with every word that you say
|
|
Jul 28 2003
Anchor
|
Notepad? Internet Explorer?
|
|
Jul 28 2003
Anchor
|
View? Do you mean that you don't have a php IDE app to help you code, or you don't have a php-capable web server to host your stuff? Or perhaps something even more cryptic?
Google to the rescue! Don't have it? Find it and download it. Or try Download.com or even Tucows.com .
|
|
Mar 4 2004
Anchor
|
heres my startup.php
<?
list($var_null, $var_section, $var_id, $var_page, $var_extra, $var_extra1) = explode('/', $_SERVER['PATH_INFO']);//smart clean urls
if(isset($_COOKIE['username']) && isset($_COOKIE['password']))
{$auth = mysql_fetch_object(mysql_query("SELECT uid, username, password, status, warn, timezone, avatoo, sigoo FROM $UserDB.unz_users WHERE username = '".$_COOKIE['username']."' AND password = '".$_COOKIE['password']."'")) or die(mysql_error());
if($auth->status == '0' || $auth->warn > 2)//IF USERS BANNED...
{$user_properties['banned'] = '0';}
else
{$user_properties['banned'] = 1;}
$user_properties['status_id'] = $auth->status;
$user_properties['username'] = $auth->username; //SET USER VARIABLES
$user_properties['uid'] = $auth->uid;
$user_properties['avatoo'] = $auth->avatoo;
$user_properties['sigoo'] = $auth->sigoo;
$user_properties['timezone'] = $auth->timezone;}
//FORUM SETTINGS
$settings = mysql_fetch_object(mysql_query("SELECT * FROM $forumzDB.forumz_settings")) or die(mysql_error());
$forum_properties['status'] = $settings->status; //1 for on, 0 for off
if($forum_properties['status'] == '0' && $user_properties['status_id'] <= 1) //IF FORUM IS OFF, AND USER IS NOT A STAFFER OR ADMIN
{$reason = "$settings->reason"; require_once("pages/html/site_off.html"); exit();}//THEN DISPLAY SITEOFF.PHP
else
{$forum_properties['reason'] = $settings->reason;}
$forum_properties['site_name'] = $settings->site_name; //site name used in title and header
$forum_properties['cookieURL'] = $settings->cookieURL; //cookie URL
$forum_properties['adminemail'] = $settings->admin_email; //admin email address
$forum_properties['sign_up'] = $settings->sign_up; //1 for signing up
$forum_properties['scar'] = $settings->scar; // 1 to leave edit marks
$forum_properties['guests'] = $settings->guests;// 1 to let guests post
$forum_properties['attachments'] = $settings->attachments;// 1 to allow attachment posting
$forum_properties['attachments_guest'] = $settings->attachments_guest;// 1 to let guests see attachments
$forum_properties['user_titles'] = $settings->user_titles;// 1 to have user titles
$forum_properties['custom_titles'] = $settings->custom_titles;// 1 to let users edit there title
$forum_properties['ot'] = $settings->ot; //in seconds
$forum_properties['df'] = $settings->df; //deleted forum ID
$forum_properties['dt'] = $settings->dt; //deleted thread ID
$forum_properties['version'] = "2.40"; // forumz version
$forum_properties['forumzURL'] = $settings->forumzURL;//images + attachments url
$forum_properties['base_url'] = "".$forum_properties['forumzURL']."/index";//base url
//ARRAY
$setting_array = array(
array('smilies'),// 1 for smilies
array('swears'),//1 for swearbot
array('memberslist_pp'),//members per page on memberlist
array('active_pp'),//threads per active topics
array('thread_pp'),//posts per thread page
array('forum_pp'),//threads per forum page
array('newposts_pp'),//threads per forum page
array('pm_pp'));//messages per pm page
foreach($setting_array as $subarray)
{list($set) = $subarray;
if(!$_COOKIE["$set"])
{$forum_properties["$set"] = $settings->$set;}//set the forum properties using the DB
else
{$forum_properties["$set"] = $_COOKIE["$set"];}}//set the forum properties using the cookie
if(!$user_properties['uid'])//IF USER IS A GUEST THEN ADD TO STATS, ELSE ADD TO USER LIST AND STORE IP+HOST
{mysql_query("UPDATE $forumzDB.unz_stats SET guest = guest + 1 WHERE stid = 1") or die(mysql_error());}
else
{mysql_query("UPDATE $forumzDB.unz_stats SET user = user + 1 WHERE stid = 1") or die(mysql_error());
hostIP($user_properties['uid']);}
//CHECK TO SEE IF THE USER IS A UNIQUE OR A REVISIT AND RECORD
if($_COOKIE['visited'] == 1)
{mysql_query("UPDATE $forumzDB.unz_stats SET pageview = pageview + 1 WHERE stid = 1") or die(mysql_error());}
else
{mysql_query("UPDATE $forumzDB.unz_stats SET `unique` = `unique` + 1 WHERE stid = 1");
setcookie ("visited", "1", time()+60*60*24*30,'/',"".$forum_properties['cookieURL']."", 0);}
//SET THEME DEPENEDENT ON VARIABLE IN LINK - thx nicholas
if($submitted == true)
{setcookie ("theme", "$tc", time()+60*60*24*30,'/',"".$forum_properties['cookieURL']."", 0);
header("Location: $HTTP_REFERER");}
if(!$_COOKIE['theme'])
{setcookie ("theme", "default", time()+60*60*24*30,'/',"".$forum_properties['cookieURL']."", 0);
header("Location: ?section=index");}
if(!$_COOKIE['username'])
{$user_properties['banned'] = 1;}//if were a guest we arent banned
if($_COOKIE['last_visit'])
{if($user_properties['status_id'] > 1)
{$count = mysql_num_rows(mysql_query("SELECT time FROM $forumzDB.forumz_posts WHERE time > ".$_COOKIE['last_visit'].""));}
else
{$count = mysql_num_rows(mysql_query("SELECT p.time, p.pid, f.type, f.fid FROM $forumzDB.forumz_posts p LEFT
JOIN $forumzDB.forumz_forums f ON (p.fid = f.fid) WHERE ((p.time > ".$_COOKIE['last_visit'].")
&& (f.type = 'anon' OR f.type = 'publ'))"));}
if($count > 0)
{$nposts = "<a href=\"index/new_posts/".$_COOKIE['last_visit']."\">New Posts ($count)</a> : ";}}
else
{last_visit($section);}
$theme = $_COOKIE['theme'];//$theme is now our oyster
usersonline($user_properties['uid']);//Puts the user online
disable_cache();//Clears old data
last_visit($var_section);
?>
|
|
Mar 4 2004
Anchor
|
azz0r how is Wuggawoo coming along? I haven't been there in awhile and we don't talk on MSN anymore.
|
|
Mar 9 2004
Anchor
|
Why dont you go see its not nearly as active really. I dont use msn much anymore either :o
|
|
Mar 9 2004
Anchor
|
Then what do you do? You should post some more with me, let's show the nubs how we do it around here.
|