Clan Adverts

Sponsors

CT on Facebook

Latest Product

User Box

Anonymous
38.107.179.219
Nickname:

Password:

Security Code
Security Code
Type Security Code


PND Downloads Feed

Phpnuke Downloads
How to Delete or Reset yo...
How to Delete or Reset your PHPNuke Admin Account
Lost your admin password ?  Cant login to your admin account ? This s...
Back Online & Stuff
Back Online & Stuff
Look at us with our nifty website back up and running… Seriously...
How to edit the admins in...
How to edit the admins in the forums
Here is a way to make someone admin in your forums on your Evo site. I...
Demo Splash Screen
Demo Splash Screen
Ped @ Clan Themes has released a simple splash screen entrance hack. ...
Free Phpnuke Business The...
Free Phpnuke Business Theme 6
This is the 6th Business theme for Phpnuke that Clan Themes has releas...
Tricked Out Slider
Tricked Out Slider
We have seen some great new things come out of Tricked Out News and th...

Custom Work

PHP Nuke Custom Work

www.clanthemes.com :: View topic - Creating my first ever block
Creating my first ever block
Goto page 1, 2  Next

22 Replies / 802 Views


Post new topic   Reply to topic  

   www.clanthemes.com Forum Index » Blocks

View previous topic :: View next topic


actnreactgaming
Reputation: 40.3 Add RepSubtract Rep
Local time: 12:52 PM

blank.gif

Stand-by Stand-by
Stand-by Stand-by

1.72 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)

Joined: Nov 09, 2011
Last Visit: 25 May 2012
Posts: 342
Points: 18017 

Post Creating my first ever block Posted: Tue Dec 20, 2011 9:57 pm

Shop Purchases:
Modern Gamer Multi Theme

Hi all! (my questions are most directed towards Ped / Dre / Noto / 5STAR me thinks)

but here comes the question:

I'm trying to code my first ever PHP block. I noticed that there are much blocks about for TeamSpeak 2 / 3, haven't found a proper PHP block yet for Ventrilo. So I figured I was going to code my own.

In my research towards learning PHP (I still know very little) I stumbled upon the inclusion of the block file and header and whatnot. I'm quite astonished in how different it can be!

for instance i'm running Raven's PHP-Nuke 2.40.01 and I have a theme purchased through this site up and running, which comes with certain block files aswell. So I thought I'd compare the starting point of two complete different blocks (that is one being from the core Raven's PHP-Nuke package and one being the block-CT-Shout.php)

the code looked something like this for the core one:

if (!defined('BLOCK_FILE'))
{
Header('Location: ../index.php');
die();
}

and the code from the CT-Shout block:

if (eregi("block-CT-Shout.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}

Why the eregi ? and what does it do? should I start small and just stick with the core coding (the one that Dre also uses in his tutorial on how to create your own block) or would the eregi one be more elegant?

best regards,
actnreactgaming
 

 
View user's profileSend private message Reply with quote

Noto
Reputation: 1072.7 Add RepSubtract Rep
votes: 13
Local time: 12:52 PM
Location: Sunny UK !
uk.gif

Site Admin
Site Admin

0.60 posts per day
Medals: 3 (View more...)
Site Supporter (Amount: 1)
Theme Guru
Theme Guru
Joined: May 03, 2007
Last Visit: 26 May 2012
Posts: 1118
Points: 73959 

Post Re: Creating my first ever block Posted: Tue Dec 20, 2011 10:28 pm

That was the old way blocks were coded. php is alway evolving, it will still work but its best to keep up to date with the disto your using.

eregi is deprecated now and will soon be obsolete, so use what raven is using and you cant go wrong. http://php.net/manual/en/function.eregi.php
 

Tactical Combat Evolved - Sig Showcase  
View user's profileSend private messageVisit poster's website Reply with quote

actnreactgaming
Reputation: 40.3 Add RepSubtract Rep
Local time: 12:52 PM

blank.gif

Stand-by Stand-by
Stand-by Stand-by

1.72 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)

Joined: Nov 09, 2011
Last Visit: 25 May 2012
Posts: 342
Points: 18017 

Post Re: Creating my first ever block Posted: Tue Dec 20, 2011 11:20 pm

Shop Purchases:
Modern Gamer Multi Theme

Meaning that once php version 6.x.x would launch eregi would not work at all no more resulting in a rewrite of the block of ct-shout? That being the general line of the story?

Best regards,
actnreactgaming
 

 
View user's profileSend private message Reply with quote


Noto
Reputation: 1072.7 Add RepSubtract Rep
votes: 13
Local time: 12:52 PM
Location: Sunny UK !
uk.gif

Site Admin
Site Admin

0.60 posts per day
Medals: 3 (View more...)
Site Supporter (Amount: 1)
Theme Guru
Theme Guru
Joined: May 03, 2007
Last Visit: 26 May 2012
Posts: 1118
Points: 73959 

Post Re: Creating my first ever block Posted: Wed Dec 21, 2011 12:26 am

Yes thats it you got it, for now you get warning basiclly saying "update your code or soon it wont work at all".

http://en.wikipedia.org/wiki/Deprecation
 

 
View user's profileSend private messageVisit poster's website Reply with quote

actnreactgaming
Reputation: 40.3 Add RepSubtract Rep
Local time: 12:52 PM

blank.gif

Stand-by Stand-by
Stand-by Stand-by

1.72 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)

Joined: Nov 09, 2011
Last Visit: 25 May 2012
Posts: 342
Points: 18017 

Post Re: Creating my first ever block Posted: Wed Dec 21, 2011 8:31 am

Shop Purchases:
Modern Gamer Multi Theme

Great! Thanks, I suppose that preg_match is the non deprecated version for ereg then?
 

 
View user's profileSend private message Reply with quote

Guardian
Reputation: 535.9 Add RepSubtract Rep
votes: 1
Local time: 12:52 PM

slovakia.gif



0.04 posts per day
Medals: 0
Respected Member
Respected Member
Joined: Dec 09, 2006
Last Visit: 16 Apr 2012
Posts: 74
Points: 4757 

Post Creating my first ever block Posted: Thu Dec 22, 2011 8:58 pm

Taking it from the top..
Code:
if (!defined('BLOCK_FILE'))
{
Header('Location: ../index.php');
die();
}

BLOCK_FILE is a constant set in mainfile.php, what that line basically does is check if the constant BLOCK_FILE has been set in mainfile.php and if it hasn't it means the block file is being access directly, so should return whoever is trying to access the file back to the websites main index page.
In plain english, everything is controlled by mainfile.php and in that file it gives the system a key called BLOCK_FILE, which it carries around with it, where ever it goes. When the system tries to access the block file, it checks to see if it has the key.

Code:

if (eregi("block-CT-Shout.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}

This provides the same sort of 'check'. The first line basically checks to see if the file (with the file name you see) is being accessed by another file on the website and if it isn't, returns the user to the main index file.

Both methods are legitimate but the BLOCK_FILE method is considered more efficient, it's as simple as that.
Yes, eregi() is a native PHP function that is being phased out, so the BLOCK_FILE approach wins again :)
 

 
View user's profileSend private messageVisit poster's website Reply with quote


actnreactgaming
Reputation: 40.3 Add RepSubtract Rep
Local time: 12:52 PM

blank.gif

Stand-by Stand-by
Stand-by Stand-by

1.72 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)

Joined: Nov 09, 2011
Last Visit: 25 May 2012
Posts: 342
Points: 18017 

Post Re: Creating my first ever block Posted: Thu Dec 22, 2011 10:44 pm

Shop Purchases:
Modern Gamer Multi Theme

thanks for the clarification. I must admit I like your picture in ravenphpscripts better though ;)

Working on something bigger in one way, but smaller in another way now though.

A clan member has asked if I could make some kind of module which shows some kind of "roster" as he definded it. I would more like to call it a ranking system.

Basically what he asked for is:
Something which shows the Clan structure. For example if we would have a founder of the clan we would have a clan founder rank descending towards regular members (with every possible rank inbetween you could think of)

What I thought of was the following:
Create a module which allows you to set up custom ranks. using some kind of fetch_row command in PHP scripting to get the Nuke_Users table to pop up for selection to assign the Nuke_Users towards their corresponding defined custom ranks.

Once the module is configured I figured I would let it be displayed in some sort of block on the side or perhaps centre. Perhaps in a table perhaps just plain html make up, I haven't gotten that far yet.

Currently I'm in the phase of understanding how the PHP coding fits together in the whole. I've set up a WAMP server to play around with a custom made index.php file and see if I can work with the basics.

If you have any good tutorials on how to create a module (or if you find that the thing described above should be doable by the Module Tools addon for PHPNuke) let me know. I'm getting the hang of this and I'm eager to learn.

best regards,
actnreactgaming
 

 
View user's profileSend private message Reply with quote

actnreactgaming
Reputation: 40.3 Add RepSubtract Rep
Local time: 12:52 PM

blank.gif

Stand-by Stand-by
Stand-by Stand-by

1.72 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)

Joined: Nov 09, 2011
Last Visit: 25 May 2012
Posts: 342
Points: 18017 

Post Re: Creating my first ever block Posted: Sun Dec 25, 2011 5:20 pm

Shop Purchases:
Modern Gamer Multi Theme

update: I managed to get the "skeleton" for the module done. Including the language files for both German language as for English.

I might require some help in the coding of the actual script. but once I run into problems I will contact you guys for it.

On another side note: How does one run Raven's PHP nuke locally from a WAMP server? I've tried to google it, but couldn't get it to work... is there a specific path to point your browser to as soon as you have put the html folder of the Raven's Nuke distro package into the www directory of WAMP?

LMK please so I can test my module locally (currently it is operative on an old website I once had.)

best regards,
actnreactgaming
 

 
View user's profileSend private message Reply with quote

Noto
Reputation: 1072.7 Add RepSubtract Rep
votes: 13
Local time: 12:52 PM
Location: Sunny UK !
uk.gif

Site Admin
Site Admin

0.60 posts per day
Medals: 3 (View more...)
Super Dedicated User (Amount: 1)
Theme Guru
Theme Guru
Joined: May 03, 2007
Last Visit: 26 May 2012
Posts: 1118
Points: 73959 

Post Re: Creating my first ever block Posted: Sun Dec 25, 2011 8:21 pm

Install it inside htdocs then http://localhost
 

 
View user's profileSend private messageVisit poster's website Reply with quote


actnreactgaming
Reputation: 40.3 Add RepSubtract Rep
Local time: 12:52 PM

blank.gif

Stand-by Stand-by
Stand-by Stand-by

1.72 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)

Joined: Nov 09, 2011
Last Visit: 25 May 2012
Posts: 342
Points: 18017 

Post Re: Creating my first ever block Posted: Sun Dec 25, 2011 9:12 pm

Shop Purchases:
Modern Gamer Multi Theme

htdocs? should there be a folder inside: C:\wamp\ called htdocs? because I only get C:\wamp\www

furthermore i would like to pose another question which is related to my module:

<form method=\"post\" action=\"modules.php?name=$module_name&op=Apply\">

what does the action=\"modules.php?name=$module_name&op=Apply\"> part do?

could you break it down into explaining what the action part does and the &op=Apply\" part does? I'm having a hard time getting my head around it.

best regards,
actnreactgaming
 

 
View user's profileSend private message Reply with quote

actnreactgaming
Reputation: 40.3 Add RepSubtract Rep
Local time: 12:52 PM

blank.gif

Stand-by Stand-by
Stand-by Stand-by

1.72 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)

Joined: Nov 09, 2011
Last Visit: 25 May 2012
Posts: 342
Points: 18017 

Post Re: Creating my first ever block Posted: Sun Dec 25, 2011 9:32 pm

Shop Purchases:
Modern Gamer Multi Theme

nvm on the <form method=\"post\" action=\"modules.php?name=$module_name&op=Apply\"> line.

after a closer look I came to the conclusion that &op=Apply refers to

function Apply($uname, $email, $xfire, $msn, $age, $clans, $apply, $location, $conn, $micro, $extra){ .......................... etc ;)

that was the biggest mistery at first for me.
still wondering about the htdocs though ;)

thanks in advance for any clarification!

best regards,
actnreactgaming
 

 
View user's profileSend private message Reply with quote

Noto
Reputation: 1072.7 Add RepSubtract Rep
votes: 13
Local time: 12:52 PM
Location: Sunny UK !
uk.gif

Site Admin
Site Admin

0.60 posts per day
Medals: 3 (View more...)
Dedication (Amount: 1)
Theme Guru
Theme Guru
Joined: May 03, 2007
Last Visit: 26 May 2012
Posts: 1118
Points: 73959 

Post Re: Creating my first ever block Posted: Sun Dec 25, 2011 11:31 pm

htdocs, www, public_html, html, all the same just names for root folders, yours is www if thats what you have.
 

 
View user's profileSend private messageVisit poster's website Reply with quote

Post new topic   Reply to topic  
   www.clanthemes.com Forum Index » Blocks


 
22 Replies / 802 Views
Page 1 of 2
All times are GMT
Goto page 1, 2  Next
Display posts from previous:   
 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum