
-----------------------------------
Amailer
Tue Jun 24, 2003 12:05 am

Got any fav PHP scripts? ( post em here :)..duh... )
-----------------------------------
Guys, who ever is into PHP....got any fav scripts/functipn/clases etc? Post them over here.


Mine, its BBCODE!
well...hehe i just use it for my news, and well its nto my fav but i just made it.


//BBC

//
//  	$code_start_html = 'Code:';
//	$code_end_html = '';
//	$info = str_replace('[code]', "$code_start_html", $info);
//	$info = str_replace('[/code]', "$code_end_html", $info);

  $preg = array(
    // Font and text manipulation ( [color] [size] [font] [align] )
    '/\[color=(.*?)(?::\w+)?\](.*?)\[\/color(?::\w+)?\]/si'   => "\\2",
    '/\[size=(.*?)(?::\w+)?\](.*?)\[\/size(?::\w+)?\]/si'     => "\\2",
    '/\[font=(.*?)(?::\w+)?\](.*?)\[\/font(?::\w+)?\]/si'     => "\\2",
    '/\[align=(.*?)(?::\w+)?\](.*?)\[\/align(?::\w+)?\]/si'   => "\\2",
    '/\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si'                 => "\\1",
    '/\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si'                 => "\\1",
    '/\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si'                 => "\\1",
    '/\[center(?::\w+)?\](.*?)\[\/center(?::\w+)?\]/si'       => "\\1",
// '/\[code(?::\w+)?\](.*?)\[\/code(?::\w+)?\]/si'           => "\\1",
    // [email]
    '/\[email(?::\w+)?\](.*?)\[\/email(?::\w+)?\]/si'         => "\\1",
    '/\[email=(.*?)(?::\w+)?\](.*?)\[\/email(?::\w+)?\]/si'   => "\\2",
    // [url]
    '/\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si'        => "\\1",
    '/\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si'             => "\\1",
    '/\[url=(.*?)(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si'       => "\\2",
    // [img]
    '/\[img(?::\w+)?\](.*?)\[\/img(?::\w+)?\]/si'             => "",
    '/\[img=(.*?)x(.*?)(?::\w+)?\](.*?)\[\/img(?::\w+)?\]/si' => "",
    // [quote]
    '/\[quote(?::\w+)?\](.*?)\[\/quote(?::\w+)?\]/si'         => "Quote:
  
    \\1
  

",
    '/\[quote=(?:&quot;|"|\')?(.*?)["\']?(?:&quot;|"|\')?\](.*?)\[\/quote(?::\w+)?\]/si'   => "Quote \\1:\\2",
    // [list]
    '/\[\*(?::\w+)?\]\s*([^\[]*)/si'                          => "\\1",
    '/\[list(?::\w+)?\](.*?)\[\/list(?::\w+)?\]/si'           => "\\1",
    '/\[list(?::\w+)?\](.*?)\[\/list:u(?::\w+)?\]/s'          => "\\1",
    '/\[list=1(?::\w+)?\](.*?)\[\/list(?::\w+)?\]/si'         => "\\1",
    '/\[list=i(?::\w+)?\](.*?)\[\/list(?::\w+)?\]/s'          => "\\1",
    '/\[list=I(?::\w+)?\](.*?)\[\/list(?::\w+)?\]/s'          => "\\1",
    '/\[list=a(?::\w+)?\](.*?)\[\/list(?::\w+)?\]/s'          => "\\1",
    '/\[list=A(?::\w+)?\](.*?)\[\/list(?::\w+)?\]/s'          => "\\1",
    '/\[list(?::\w+)?\](.*?)\[\/list:o(?::\w+)?\]/s'          => "\\1",
    // the following lines clean up our output a bit
    '/(?:.*?)/si'         => "",
    '/(?:.*?)/si'         => ""
  );
  $info = preg_replace(array_keys($preg), array_values($preg), $info);


//END OF 




HEHE useful, but the 
//Ok, im putting the view profile here,
//so...it kinda is part of the news though :)
function d_profile() {
global $rec, $result;
global $displays, $title;
global $name, $password, $email, $aim, $msn, $icq, $info, $id, $avatar, $websites;
global $PHP_SELF;

$displays = "Profile information Of: $name";
$title = "Profile info of: $name";

mysql_select_db("amailerforum");

$result = mysql_query("SELECT * FROM phpbb_users WHERE username='$name'");


while($rec = mysql_fetch_array($result)) {


//Now this is the important information
//the pass name email
$name = $rec['username'];
$password = $rec['user_password'];
$email = $rec['user_email'];

//this is the attitional information
$aim = $rec['user_aim'];
$msn = $rec['user_msnm'];
$icq = $rec['user_icq'];

//the web site of the user
$website = $rec['user_website'];

//this is like a user comment
$occ = $rec['user_occ'];
$intrests = $rec['user_interests'];

//ah yes, user avatar
$avatar = $rec['user_avatar'];

//the id of the user
$id = $rec['user_id'];


//So, if the Intrests are empty
//display 'None'
if($intrests == "") {
	$intrests = "None";
}


//If the Occ is empty
//display 'None'
if($occ == "") {
	$occ = "None";
}


//The thing that viewsers will have to click
//inorder to go to the users site
$webname = "Click here to visit";


//If the website is empty
//display a diffrent table with the name ''None''
if($website == "") {
	$websites = "
		
	  
	
  
    Website:
    None
  
";

//else if the website is not empty
//then display the information needed
} elseif($website != "") {
$websites = "
		
	  
	
  
    Website:
    $webname
  ";
}


//Checking if the AIM field is blank or not
if($aim == "") {
	$aims = "
	    AIM:
    None
  
";
} else {
	 $aims = "AIM:
    $aim
  
";
}

//Checkign if the MSN field is blank or not
if($msn == "") {
	$msns = "
  
    MSN:
    None
  
";
} else {
	$msns = "
  
    MSN:
    $msn
  
";
}


//Checking if the ICQ field is blank or not!
if($icq == "") {
	$icqs = "
	
  
    ICQ:
    None
  ";

} else {
	$icqs = "
	
  
    ICQ:
    $icq
  ";
}


//After all the checks,
//we can finaly display the main thing
$displays .= "

  
    Username:
    $name
  
  
    Email:
    $email
  
  
    &nbsp;&nbsp;
    
    &nbsp;&nbsp;
    
  
  
$aims
$msns
$icqs
$websites

  
    PM:
    
Click to send a private message&nbsp;
  

	  
  
    &nbsp;
    &nbsp;
  


  
    Small Info:
    Interests: $intrestsOccupation: $occ
  
  
    Avatar:
    
  



Return back";
}


mysql_select_db("amailersite");
main_sites($displays, $title);
}


Basicaly i have connected to the phpBB forum, to get the user info. There is about...well not about there IS 2097 lines of code in my modules.php file :) i shoved  all my functions and etc in there, also my test stuff...which i did not delete, but it does nto take up much space...I KNOW its a bad way of coding but :( hey :) 


Reason is that, i kinda am lazy to make function for everything and then use it for my future projects and etc. But im making a php NUKE NOW! wee! Good thing is i got everythign ready, i just need to put it all togeather and everything will be good. BTW as you can see the scripts on top, PHP IS EASY!

-----------------------------------
Blade
Tue Jun 24, 2003 11:17 am


-----------------------------------
really nice... but you should attach massive amounts of code as txt file or something... lol

-----------------------------------
Amailer
Tue Jun 24, 2003 3:10 pm


-----------------------------------
Yes well sorry, i got some more i want to post [[ small ones, for mysql ]]
But, i guess no one is into php here :(

im currently going to have to put my whole forum in my sites layout, its going to take some time but oh well :|

-----------------------------------
Homer_simpson
Tue Jun 24, 2003 5:03 pm


-----------------------------------
i am interested in php projects but those things you made are addons to phpbb.. =(

-----------------------------------
Amailer
Tue Jun 24, 2003 5:08 pm


-----------------------------------
What things? the scripts i made? err...no...they are for my site. phpbb got its own stuff.... go to:
http://termix-zero.ath.cx/scripts/amailers/modules.php?module=news

i think is the url, click the name 'admin' you will see what the profile script does. ITS SO SIMPLE, to test it your self, creat an account on my forum, and go to:
http://termix-zero.ath.cx/scripts/amailers/modules.php?module=profile&name=YOUR FORUM NAME HERE

:) you will see how it works...

-----------------------------------
Homer_simpson
Tue Jun 24, 2003 5:38 pm


-----------------------------------
lol i cant add comment to your news for some reason... and i already how to create a forum or a website with signup and everything :D...
so uh... how bout a big php project? you come up with the idea we script it?

-----------------------------------
Amailer
Tue Jun 24, 2003 5:46 pm


-----------------------------------
Comment, err...as it says, its not ready.

Second, what kinda of project you wanna work on?
Project management one? :)

Need tip:
Ok, should i change the forum layout to fit in my main sites layout? Or should i jsut use an iframe to put the forum on my main site?

-----------------------------------
PaddyLong
Tue Jun 24, 2003 6:12 pm


-----------------------------------
could make a full content management type of thing... like php nuke type of thing

-----------------------------------
Amailer
Tue Jun 24, 2003 6:14 pm


-----------------------------------
Those are boring, many people make it. Just don't get famous. My amailer site is PARTLY like php nuke, but its not fully compleated, since...well. lol the admin center has not been started :).

But if i would make a thing like phpNUKE...then i would let people change the FULL layout of the site, i mean the tables and everything, cept my copyright :)

-----------------------------------
PaddyLong
Tue Jun 24, 2003 8:41 pm


-----------------------------------
of course...

like do everything as modules and then the designer can just do an include("somemodule.php") where ever in the layout they want it

the OSCommerce shopping cart is kind of like that with the side bars... each one of the things (like menu, search, feature product, etc) is its own file

but really, the things like nuke I think are mostly just for lazy or unexperienced people who are just looking for a quick thing that they can some what, but easily control

-----------------------------------
Amailer
Tue Jun 24, 2003 8:49 pm


-----------------------------------
They cant just include the file, if they are doing that, itneeds to have crtin stuff in it, so it can display the links and etc...

But it will be very easy to edit the layout. It would be like templates, put your templates in the templated folder. It has to have the stuff to display the links.  And then once you have made your own template, the admin can choose which ever he/she wantes. Course it has to include downloads, links etc like a  phpNUKE, but it should be made for programmers. Not the normal public

-----------------------------------
Amailer
Tue Jun 24, 2003 11:28 pm


-----------------------------------
These are some small scripts that are IMPORTANT!


//Connect DB function
function db_connect() {
   global $dbhost, $dbusername, $dbuserpassword, $default_dbname;
   global $MYSQL_ERRNO, $MYSQL_ERROR;

   $link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);
   if(!$link_id) {
      $MYSQL_ERRNO = 0;
      $MYSQL_ERROR = "Connection failed to the host $dbhost";
      
      return 0;
  
   }
   else return $link_id;
 }




$dbconnect = db_connect(); //Connect to mySQL

mysql_select_db("DBNAME"); //select a database


//Thats for selecting infromation from a table :)
	$result = mysql_query("SELECT * FROM table");
        while($rec = mysql_fetch_array($result)) {
        $variable = $rec['field'];
        }



there are a lot more, update, delete and etc :)

-----------------------------------
Amailer
Wed Jun 25, 2003 11:31 pm


-----------------------------------
Well no once likes PHP 



So...once we know that...lets see our php information.




Copy and past that in a file name it: phpinfo.php
and then run it on your browser.

You will see all your PHP INFO :) 



Now the echo is like print...in other languages you should know :)
But in php there is PRINT and ECHO





Yes well, you should know what echo is...because you WILL ...be using it in ALL you scripts at some point :)

Now some if statements, with variables :)




Ahh ok, hehe lil if statements :)
Ok now, != means NOT EQUAL
and you should know what the rest means...you all are programmers here right? RIGHT!
:)!
THIS TUTORIAL SUCKS..wait...its not 1 :) ahh im happy good.



OK NOW...DATE/TIME/YEAR SCRIPT!!..ya..

 







Guys look at the post down....WHO on earth turns HTML ON? look what sort of things you can do when html is on :)

-----------------------------------
Amailer
Wed Jun 25, 2003 11:42 pm


-----------------------------------
Guys...why did you turn HTML ON!?
err look what CAN happne with html on :

Mod Edit: Thanks for that whonderfull Demo of what not to do :twisted: 

-----------------------------------
Dan
Thu Jun 26, 2003 12:09 am


-----------------------------------
well i have it on b/c i turst poleop for now, if poelop abuse it they lose it. (like the rime?).

it helps with other stuff but it is easy enfogth for now to stop any one who trys to do dum things.

-----------------------------------
Amailer
Thu Jun 26, 2003 1:47 am


-----------------------------------
hey i was going to take it out but...thx :)

Anyway..

-----------------------------------
Amailer
Thu Jun 26, 2003 9:11 pm


-----------------------------------
Finaly! i have STARTED putting the forum [[[ of amailers ]] on the main sites layout! WOO! took some time, i had to change my whole sites code :( sad but oh well. The links ont he forums layout are not done, so hehe :) Ill finish them

-----------------------------------
Amailer
Sun Jun 29, 2003 1:55 am


-----------------------------------
Mods/Admins etc, you see when you click a forum you will see on top:
Moderators: None
and soemthign else...

Can you like make it display who the mod is for which forum...insted of only whent he mod comes on it tells us?
