Let us Study, Learn and Understand the Joomla Code Together

Pag usapan ang mga bagay na ukol sa pangkalahatang interes sa web at Joomla!
User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon May 22, 2006 7:34 am

Let us study, learn and understand the Joomla code, share what we have learned and interact with exchange
of ideas with all interested in Joomla. Programmer or not, Newbie or Expert, Young and Old are all welcome.
I hope to promote interaction, cooperation and help towards others in Joomla and PHP in particular.

The contents of this are not necessarily 100% accurate because this is based on the study of users and
not developers, that is why their help are greatly encourage to clarify the contents and purpose of specific
code being studied.  Most probably user assumptions of variables, functions and logic maybe not quite
true or wrong, but this is the main purpose, To Study and Understand this Project and with the help of
our Joomla Hereos and Kababayan, I am assured the we will be guided along the way.

Disclaimer:  Joomla is Lisenced under GPL so we can distribute source code, modify and use it as we see fit.
But I urge everyone to NEVER EVER change the Licence and Credits stated therein.  Yes we can
can use, edit, distribute Joomla but, we must bear in mind that we did not create it, Let us give
credit where credit is due.  This is also not meant for hacking purposes but for helping others
in installing, configuring, using their Joolma sites and Specially learning PHP by studying Joomla.

Special Thanks to our Joomla Hero, Mr. Rey Gigataras a.k.a. (stingrey) for the ecourangement, help and support.

Mabuhay ang Pilipino.
Last edited by stingrey on Mon May 22, 2006 7:34 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

 
User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon May 22, 2006 7:35 am

Where do I begin?
Joomla has I think 1500+ files in 230+ directories, huh!  Well atleast thats what the folder properties tells me.
So I will first look in to the common main file which I also often use the INDEX.PHP under the Joomla
home directory.

Code: Select all

<?php
// Set flag that this is a parent file
define( '_VALID_MOS', 1 );
?>
First constant in the file is this.  Most of the code is well documented and easy to understand.  Like this
one, defines the contant and makes sure that the call was originally from the the main Joomla index file.
Hmmm, sigurista!

Code: Select all

<?php
// checks for configuration file, if none found loads installation page
if (!file_exists( 'configuration.php' ) || filesize( 'configuration.php' ) < 10) {
	$self = str_replace( '/index.php','', $_SERVER['PHP_SELF'] ). '/';
	header("Location: http://" . $_SERVER['HTTP_HOST'] . $self . "installation/index.php" );
	exit();
}
?>
Next one is the code that checks if our configuration (CONFIGURATION.PHP) file exists and if not proceeds to installation.
The configuration part is very important because this is where we declare our global site settings such as
Host, db, dbprefix, dbuser, dbpassword, site name, meta tags, base dir, email and alot of critical and global configurations.
I think it is safe to customize the contents of this file because the Licencse, Version and Credits are not included here.
Wonder why all of these are stored in variables and not in constants?

include_once( 'globals.php' );
require_once( 'configuration.php' );
require_once( 'includes/joomla.php' );

This gets exiting as we go on to the libraries.  GLOBALS.PHP is I as the comment suggests an emulation of
registers global on/ off.  There is also a function here which check for variables making sure it is allowed
or variables must not be the same as reserved words.  Beacause PHP not so strict, it allows us to declare
variables the same as reserved words, but this is discourage that is why there is an error checking here.
I also recommend to set register_globals = off in php.ini for security and proper variable handling in our
php scripts.

INCLUDES/JOOMLA.PHP - I think this is the main joomla function library, in Mambo its mambo.php and Joomla
also has a dummy, mambo.php which points to JOOMLA.PHP, probably for the older modules and components looking
for the said library.  This gets even better, I suggest not to memorize this file but only study its purpose
for the reason that it has 5000+ lines, although there are some useful functions here that can be adopted
in our own library such as mosStripslashes which stip slahes whether the variable is a scalar or array and
many more.  This file has a ton of classes and functions and also ensures mambo and joomla extension
compatibility like this define( '_MOS_MAMBO_INCLUDED', 1 ); and also has an script execution timer
(comProfiler) which im sure many would want to have.  It is also here where Joomla checks php version and
function compatibilty, existence, logs, acls, huh too many to enumerate.  Well I think its safe to say that this
file maybe the Joomla main function library.

Code: Select all

<?php
require_once( $mosConfig_absolute_path . '/includes/version.php' );
require_once( $mosConfig_absolute_path . '/includes/database.php' );
require_once( $mosConfig_absolute_path . '/includes/gacl.class.php' );
require_once( $mosConfig_absolute_path . '/includes/gacl_api.class.php' );
require_once( $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php' );
require_once( $mosConfig_absolute_path . '/includes/joomla.xml.php' );
require_once( $mosConfig_absolute_path . '/includes/phpInputFilter/class.inputfilter.php' );
?>
/includes/version.php
The above is some line in the INCLUDES/JOOMLA.PHP file which I think you will be interested in.
First is the version, This file contains a class for the version properties of the our Joomla CMS.

MORTAL SIN.  Please DONOT chage the contents of this file because what is contained here is the reality
and the truth of the this CMS.  Copyright License, not yours but Joomlas'.  Palitan nyo na lahat brod
wag lang ang laman nito.  Ang gawa ni Pedro, gawa ni Pedro at hindi ni Juan.

/includes/database.php
As the name implies, this is the database library of Joomla.  I use ADODB and PGSQL.  I hope in the
future that Joomla would support not just MySQL but PG, Oracle etc. for it to fit to most business
and personal needs.

replacePrefix( $sql, $prefix='#__' ) This is one function i found in the file, so thats why when they
issue a database query the table prefix is like that, this function changes it and replaces it with the
$mosConfig_dbprefix value in the configuration file.
Last edited by deathwingpnx on Thu Nov 09, 2006 2:26 pm, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
stingrey
Joomla! Hero
Joomla! Hero
Posts: 2756
Joined: Mon Aug 15, 2005 4:36 pm
Location: Marikina, Metro Manila, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by stingrey » Mon May 22, 2006 7:38 am

deathwingpnx wrote: Disclaimer:  Joomla is Lisenced under GPL so we can distribute source code, modify and use it as we see fit.
But I urge everyone to NEVER EVER change the Licence and Credits stated therein. 
Just to clarify, under the GPL license it is ILLEGAL to modify or remove the copyright information found in the source code of Joomla! files.

What this means is that you CANNOT change the statement found in the top of ALL Joomla! core files:
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.


Slightly offtopic to the thread but important to make clear
Rey Gigataras
http://www.wizmediateam.com <-- great team of talented Web Designers and Programmers!
http://about.me/reygigataras <-- About Me :)
Partner, Business Development & Project Manager, Event Manager, Sports Coach :D

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon May 22, 2006 7:42 am

Thanks Rey for the clarification, us newbies really appreciate your help.
Last edited by deathwingpnx on Thu Sep 21, 2006 3:00 pm, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon May 22, 2006 10:12 am

Hmm! Before I go through the other libraries such as acls, xml and mails functions, I notice that in JOOMLA.PHP
that most of the functions and module have output, which as I know must only have return values.  For example,
within those functions and modules are output and raw html like this one

Code: Select all

  function writableCell( $folder ) {

  	echo '<tr>';
  	echo '<td class="item">' . $folder . '/</td>';
  	echo '<td align="left">';
  	echo is_writable( "../$folder" ) ? '<b><font color="green">Writeable</font></b>' : '<b><font color="red">Unwriteable</font></b>' . '</td>';
  	echo '</tr>';
  }
and this one

Code: Select all

	function CloseButton ( &$params, $hide_js=NULL ) {
		// displays close button in Pop-up window
		if ( $params->get( 'popup' ) && !$hide_js ) {
			?>
			<div align="center" style="margin-top: 30px; margin-bottom: 30px;">
			<a href='javascript:window.close();'>
			<span class="small">
			<?php echo _PROMPT_CLOSE;?>
			</span>
			</a>
			</div>
			<?php
		}
	}
And I found the user class which Im sure all of us are interested in knowing what class, methods, and properties the user
has in line 2508 of JOOMLA.PHP

Code: Select all

class mosUser extends mosDBTable {
	/** @var int Unique id*/
	var $id				= null;
	/** @var string The users real name (or nickname)*/
	var $name			= null;
	/** @var string The login name*/
	var $username		= null;
	/** @var string email*/
	var $email			= null;
	/** @var string MD5 encrypted password*/
	var $password		= null;
	/** @var string */
	var $usertype		= null;
	/** @var int */
This is nice to play with  :P

Wow! Such a large library and so many files, im lucky if even scratch the surface of this one.  :P
Last edited by deathwingpnx on Thu Oct 05, 2006 7:47 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
KILLER_AJ
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 183
Joined: Sun Apr 23, 2006 1:41 am
Location: cebu
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by KILLER_AJ » Mon May 22, 2006 10:47 am

wat can i do here.. actually, i dont have any idea regarding codes of PHP coz.. my last PL was C and i am doing sself study right now.. i realy have hard time understanding codes wen i have errors on my JOOMLA ... but it gives me a challenge to go deeper and to study the PHP language.. mybe i do know some basics but it gives me a headache understanding the codes..

wen i start using this joomla, it came to my mind that it may look or similar to dreamweaver, it was a bomb on my head coz i realy dont know how to use it.. i was laughing at my self at that time.. coz im realy outdated.... and that encourage me to study on how joomla works.. now im glad i know few.. will with the aid of some members here... and my kababayans.

knowing the logic and basic concept of this languege are my goal now.. i am hoping, that soon, i can be one of those heros helping others.. "naks drama dating ko nito". but realy its my aim now gradualy i wll..

tnx to all those who help and replied my post..

goodluck to all joomla users and more power to all members here

ala ako masabi kasi

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon May 22, 2006 11:35 am

Greetings Bro!

No Prob! The whole point of this discussion is for all of us to study, learn, exchange information about Joomla and
PHP.  You are very welcome and I hope we can help you more in your learning.  There are many tutorials in the
net for both begginers and experts:

1.  http://www.zend.com/php/beginners/index.php
2.  http://www.w3schools.com/php/default.asp

I too used and still use C++ and it is close to PHP, most of the syntax are identical and im sure you will
learn it immediately like you learned Joomla which is fast, and you have improved a lot.

And I recommend to use Maguma Studio for your editor in Windows because it has documentation and function reference
on PHP, HTML and CSS,  and Blue Fish or Screem on Linux.  I donot use Dreamweaver because it destroys my coding and support for classes is not that good.  But my its up to you if what ever you prefer. This is the download for Maguma Studio:

http://www.zdnet.de/downloads/prg/1/i/de0F1I-wc.html
Last edited by deathwingpnx on Mon May 22, 2006 12:07 pm, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
chette
Joomla! Explorer
Joomla! Explorer
Posts: 484
Joined: Wed Aug 17, 2005 11:20 pm
Location: Pasig City, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by chette » Mon May 22, 2006 11:48 am

Nice thread, deathwingpnx! Very comprehensive & interesting explanation.

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon May 22, 2006 11:52 am

Thank Chette! But really Im not that good in explaining and PHP for that matter, but I love doing it and I
Hope you too. Thats why I need all of your help, comments and suggestions, and specially ask questions.
Lets do it together and I know our Heroes are here to guide us.  :-[
Last edited by deathwingpnx on Mon May 22, 2006 12:09 pm, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
chette
Joomla! Explorer
Joomla! Explorer
Posts: 484
Joined: Wed Aug 17, 2005 11:20 pm
Location: Pasig City, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by chette » Mon May 22, 2006 1:46 pm

deathwingpnx wrote: Thats why I need all of your help, comments and suggestions, and specially ask questions.
Don't expect a lot of questions, but expect a lot of people to keep on reading your posts ;) A lot of us are feeling overwhelmed looking at it for the first time. Give us a few moments for it to sink in :)

User avatar
Astig
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Wed Nov 30, 2005 2:02 pm
Location: Manila
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by Astig » Mon May 22, 2006 6:17 pm

Very interesting topic. Can we speak tagalog here or do you prefer english so that majority can understand?

Ok, I would like to comment and elaborate more concerning the index.php file.

Code: Select all

define( '_VALID_MOS', 1 );
This means let us create a constant and name it '_VALID_MOS' and set it to 1. In PHP scripting language, 1 means TRUE.

Note: I believe '_VALID_MOS' is gradually being replaced of '_JEXEC' in future versions of Joomla to get rid of former brand name.

If you will notice, almost all PHP files has a line:

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );


That line means if '_VALID_MOS' is not equal to TRUE (or 1) then terminate (die) the script by leaving a message 'Restricted access'. With this line any page cannot be directly accessed from the URL and no hacker may run scripts with these lines.

Code: Select all

// checks for configuration file, if none found loads installation page
if (!file_exists( 'configuration.php' ) || filesize( 'configuration.php' ) < 10) {
   $self = str_replace( '/index.php','', $_SERVER['PHP_SELF'] ). '/';
   header("Location: http://" . $_SERVER['HTTP_HOST'] . $self . "installation/index.php" );
   exit();
}
This IF-BLOCK only checks to see if a configuration doesn't exist OR if the size of configuration file is less than 10 bytes. If the condition is satisfied then it will redirect to the installation page.

If I am not mistaken, the line $self = str_replace( '/index.php','', $_SERVER['PHP_SELF'] ). '/'; will bring issues to some web servers that don't put a '/' infront of $_SERVER['PHP_SELF']. I am not sure if Xitami or Abyss Web Server comply with this or if that bug has already been fixed in their servers.

Code: Select all

include_once( 'globals.php' );
require_once( 'configuration.php' );
require_once( 'includes/joomla.php' );
These lines tell PHP to include the indicated files.

The only difference between include_once and require_once is: If the file to be included in include_once can't be found, it will generate a warning message and proceed with the script. While require_once will generate a fatal error message and terminate the script. I don't know why globals.php uses include_once when it is supposed to be a required file.  ;)

Code: Select all

//Installation sub folder check, removed for work with SVN
if (file_exists( 'installation/index.php' )) {
	define( '_INSTALL_CHECK', 1 );
	include ('offline.php');
	exit();
}
This IF-BLOCK checks if installation directory exists. If TRUE it will set '_INSTALL_CHECK' with a value of 1 and then it will include the 'offline.php' and it will exit. If I understand this right, it is ensuring that the installation folder has been deleted so Joomla can start. Deleting the installation folder after installing Joomla is enforced to make sure that no hacker can run the installation scripts and modify basic configurations.

Code: Select all

// displays offline/maintanance page or bar
if ($mosConfig_offline == 1) {
	require( 'offline.php' );
}
If the variable '$mosConfig_offline' is set to 1 then it will include the file 'offline.php'.

Code: Select all

// load system bot group
$_MAMBOTS->loadBotGroup( 'system' );

// trigger the onStart events
$_MAMBOTS->trigger( 'onStart' );
$_MAMBOTS variable is an object (or resource) that loads stated functions.

Code: Select all

if (file_exists( 'components/com_sef/sef.php' )) {
	require_once( 'components/com_sef/sef.php' );
} else {
	require_once( 'includes/sef.php' );
}
require_once( 'includes/frontend.php' );
I bet you can fully understand this IF-BLOCK now.  ;D

Code: Select all

// retrieve some expected url (or form) arguments
$option = trim( strtolower( mosGetParam( $_REQUEST, 'option' ) ) );
$Itemid = intval( mosGetParam( $_REQUEST, 'Itemid', null ) );
$_REQUEST is an array of data. Those data may came from query strings, submitted forms or cookies. The variables $option and $Itemid are getting the values of those data respectively. I don't know why Itemid's first letter needs to be capitalized when it should be lowecased as far as uniformity is concerned  ;) But anyway, it is not a big deal.

Code: Select all

if ($option == '') {
	if ($Itemid) {
		$query = "SELECT id, link"
		. "\n FROM #__menu"
		. "\n WHERE menutype = 'mainmenu'"
		. "\n AND id = '$Itemid'"
		. "\n AND published = '1'"
		;
		$database->setQuery( $query );
	} else {
		$query = "SELECT id, link"
		. "\n FROM #__menu"
		. "\n WHERE menutype = 'mainmenu'"
		. "\n AND published = 1"
		. "\n ORDER BY parent, ordering LIMIT 1"
		;
		$database->setQuery( $query );
	}
	$menu = new mosMenu( $database );
	if ($database->loadObject( $menu )) {
		$Itemid = $menu->id;
	}
	$link = $menu->link;
	if (($pos = strpos( $link, '?' )) !== false) {
		$link = substr( $link, $pos+1 ). '&Itemid='.$Itemid;
	}
	parse_str( $link, $temp );
	/** this is a patch, need to rework when globals are handled better */
	foreach ($temp as $k=>$v) {
		$GLOBALS[$k] = $v;
		$_REQUEST[$k] = $v;
		if ($k == 'option') {
			$option = $v;
		}
	}
}
These nested IF-BLOCKs checks to see if $option query string has a value. If yes, then it will check to see if $Itemid also has value. If yes again, it will execute an SQL query to get some information from the database or else it will execute another SQL query to get different information from the database.

Code: Select all

if ( !$Itemid ) {
// when no Itemid give a default value
	$Itemid = 99999999;
}
If $Itemid query string is empty, it will put a default value of 99999999 into it. For now, I don't know why.

Code: Select all

// mainframe is an API workhorse, lots of 'core' interaction routines
$mainframe = new mosMainFrame( $database, $option, '.' );
$mainframe->initSession();
This creates an instance of mosMainFrame class and assign it to the variable $mainframe then it calls the initSession() function to initialize the session.  :)


To be continued... I stopped at line 101 and the index.php file has a total lines of 252. And now I discovered that we are dissecting different versions of index.php  :-\
Last edited by Astig on Mon May 22, 2006 6:54 pm, edited 1 time in total.

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Tue May 23, 2006 2:44 am

Thank you very much for explaination, it was most informative.  I am sorry that I did not elaborate more on the description, attributes, and functions of the code, because I was overwhelmed by the size of Joomla.  But I will try to elaborate more in the future.  You post
was most informative and hope you continue to share your information with us.  ;)

It is important to know the summary of the structure and function or purpose of the files and libraries here.  That is why although not
required, it is recommended that upon reading this discussion, the reader familiarize him/ her self with object oriented programming, but
must not neglect the basics of PHP before doing so.
Last edited by deathwingpnx on Tue May 23, 2006 10:45 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
stingrey
Joomla! Hero
Joomla! Hero
Posts: 2756
Joined: Mon Aug 15, 2005 4:36 pm
Location: Marikina, Metro Manila, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by stingrey » Tue May 23, 2006 4:40 am

Astig wrote: I don't know why Itemid's first letter needs to be capitalized when it should be lowecased as far as uniformity is concerned  ;) But anyway, it is not a big deal.
An artifact of time.  Way back in one of the early versions of Mambo Itemid was introduced, and because of the need for backward comaptability through suceeding versions it has stayed Itemid

Astig wrote: If $Itemid query string is empty, it will put a default value of 99999999 into it. For now, I don't know why.
For links that do not have an Itemid it allows you to set modules or templates for it.  Prior to its introduction this was not possible for non-Itemid links to have modules assigned to it.


At some future point, the Itemid system will be replaced and removed as it is one of the most problematic parts of the whole Core system.  It would have been overhauled already if it wasnt so central to the whole operation of the Core.  It was introduced for a specific purpose and through time more functionality was piggy backed to it, beyond its purpose leading to the problems we have now.
Rey Gigataras
http://www.wizmediateam.com <-- great team of talented Web Designers and Programmers!
http://about.me/reygigataras <-- About Me :)
Partner, Business Development & Project Manager, Event Manager, Sports Coach :D

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Tue May 23, 2006 10:03 am

I tried to study how Joomla loads a bot group.  Practically it calls or loads published, group mambot files in the mambots/group directory in this case system dir.  And this is what I stumbled upon.



2.  INDEX.PHP LINE 40

Code: Select all

// load system bot group
$_MAMBOTS->loadBotGroup( 'system' );
The line I will follow.



1.  INCLUDES/JOOMLA.PHP LINE 5452

Code: Select all

/** @global mosPlugin $_MAMBOTS */
$_MAMBOTS = new mosMambotHandler();
Create class instance and assign to $_MAMBOTS


3.  INCLUDES/JOOMLA.PHP LINE 3810

Code: Select all

/**
* Loads all the bot files for a particular group
* @param string The group name, relates to the sub-directory in the mambots directory
*/
mosMambotHandler::loadBotGroup( $group ) {
	global $database, $my;

	$group = trim( $group );
	if (is_object( $my )) {
		$gid = $my->gid;
	} else {
		$gid = 0;
	}

	$group = trim( $group );

	switch ( $group ) {
		default:
			$query = "SELECT folder, element, published, params"
			. "\n FROM #__mambots"
			. "\n WHERE published >= 1"
			. "\n AND access <= $gid"
			. "\n AND folder = '$group'"
			. "\n ORDER BY ordering"
			;
			$database->setQuery( $query );
			if (!($bots = $database->loadObjectList())) {
				//echo "Error loading Mambots: " . $database->getErrorMsg();
				return false;
			}
			break;
	}

	// load bots found by queries
	$n = count( $bots);
	for ($i = 0; $i < $n; $i++) {
		$this->loadBot( $bots[$i]->folder, $bots[$i]->element, $bots[$i]->published, $bots[$i]->params );
	}

	return true;
}
global $database, $my;
$database (database class INCLUDES/DATABASE.PHP LINE 23) $my (user class INCLUDES/DATABASE.PHP LINE 2508)

if (is_object( $my )) {
$gid = $my->gid;
} else {
$gid = 0;
}
Check if $my is an object/ has attibutes.  Basically just asking if the user is logged in what group is he, if not set to default.

default:
$query = "SELECT folder, element, published, params FROM #__mambots WHERE access setQuery( $query );
Sets this query.

4.  INCLUDES/DATABASE.PHP LINE 174

Code: Select all

database:setQuery( $sql, $offset = 0, $limit = 0, $prefix='#__' ) {
	5.  $this->_sql = $this->replacePrefix( $sql, $prefix );
	$this->_limit = intval( $limit );
	$this->_offset = intval( $offset );
}
$this->_sql = $this->replacePrefix( $sql, $prefix ); Set value of sql and replace #__ with jos so query becomes SELECT folder, element, published, params FROM jos_mambots WHERE published >= 1 AND access ".$row->element; under
while ($row = mysql_fetch_object( $cur )) {
and youll see the mambots here mosimage, mosMedia etc.

7.  INCLUDES/DATABASE.PHP LINE 472

Code: Select all

database:query() {
	global $mosConfig_debug;
	if ($this->_debug) {
		$this->_ticker++;
		$this->_log[] = $this->_sql;
	}
	if ($this->_limit > 0 || $this->_offset > 0) {
		$this->_sql .= "\nLIMIT $this->_offset, $this->_limit";
	}
	$this->_errorNum = 0;
	$this->_errorMsg = '';
	$this->_cursor = mysql_query( $this->_sql, $this->_resource );
	if (!$this->_cursor) {
		$this->_errorNum = mysql_errno( $this->_resource );
		$this->_errorMsg = mysql_error( $this->_resource )." SQL=$this->_sql";
		if ($this->_debug) {
			trigger_error( mysql_error( $this->_resource ), E_USER_NOTICE );
			//echo "<pre>" . $this->_sql . "</pre>\n";
			if (function_exists( 'debug_backtrace' )) {
				foreach( debug_backtrace() as $back) {
					if (@$back['file']) {
						echo '<br />'.$back['file'].':'.$back['line'];
					}
				}
			}
		}
		return false;
	}
	return $this->_cursor;
}
Execute the query and check for errors. If in debug mode, count and store queries for future display.  Add limit and offset to sql statement if limit and offset greater than 0. Backtrace Error. Limit is how many rows to fetch and offset is what row to start fetching. Execute the query and return the recordset to $cur = $this->query()

Reminds me of my db error checking:

Code: Select all

   			if ($this->debug) {
    			halt('', $sql_error);
   			} else {
   			    if (SHOW_DB_ERROR) {
    				sayError('', $arg_query, $sql_error);
    				flush();
   			    }
    			if (EMAILERROR) {
				    mailError('GMA SQL Error - ' . $S['empname'], $arg_query . $sql_error);
    			}
   			}
   	  		$this->qid = 0;
                 return $this->qid;

Code: Select all

8.  INCLUDES/JOOMLA.PHP LINE 3879
mosMambotHandler::loadBot( $folder, $element, $published, $params='' ) {
		global $mosConfig_absolute_path;
		global $_MAMBOTS;

		$path = $mosConfig_absolute_path . '/mambots/' . $folder . '/' . $element . '.php';
		if (file_exists( $path )) {
			$this->_loading = count( $this->_bots );
			$bot = new stdClass;
			$bot->folder 	= $folder;
			$bot->element 	= $element;
			$bot->published = $published;
			$bot->lookup 	= $folder . '/' . $element;
			$bot->params 	= $params;
			$this->_bots[] 	= $bot;

			require_once( $path );

			$this->_loading = null;
		}
	}
The last part, if the file exists, set the properties and load the mambot fetch by the
$bots = $database->loadObjectList() // INCLUDES/JOOMLA.PHP LINE 3857
and called by
$this->loadBot( $bots[$i]->folder, $bots[$i]->element, $bots[$i]->published, $bots[$i]->params ); // INCLUDES/JOOMLA.PHP LINE 3867


This is only a sample of what a newbie like me did, while trying to find out how a single line from INDEX.PHP

loadBotGroup( 'system' );
---->

was executed.
I may have missed out on many functions or operations and not clearly state explainations, but the only purpose of this single post is to show how difficult to follow the Joomla code is. They really gave their best in Joomla.  This encorages me more to study and in the future, I hope to understand and share the clearer meaning of the code.

CONFUSED? Me too, but lets not that temporary problem stop us.  Day by day we learn little by little, and that makes us closer to
our goals.

To our Hero Stingrey, Sir I saw your name above the joomla.php file, are you the one who created the joomla.php library? But
doesnt matter cause I salute you anyways.  8)
Last edited by deathwingpnx on Tue May 23, 2006 10:59 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
stingrey
Joomla! Hero
Joomla! Hero
Posts: 2756
Joined: Mon Aug 15, 2005 4:36 pm
Location: Marikina, Metro Manila, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by stingrey » Tue May 23, 2006 4:14 pm

deathwingpnx wrote: To our Hero Stingrey, Sir I saw your name above the joomla.php file, are you the one who created the joomla.php library? But
doesnt matter cause I salute you anyways.  8)
An answer to this slightly incorrect assumption  ;)

Managing the code of Project Joomla!
http://forum.joomla.org/index.php/topic,63937.0.html


And my blog about the thread here
http://dev.joomla.org/component/option, ... ,33/p,110/
There you go Glenn, now your famous  :D
Last edited by stingrey on Tue May 23, 2006 5:07 pm, edited 1 time in total.
Rey Gigataras
http://www.wizmediateam.com <-- great team of talented Web Designers and Programmers!
http://about.me/reygigataras <-- About Me :)
Partner, Business Development & Project Manager, Event Manager, Sports Coach :D

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Wed May 24, 2006 5:20 am

Gosh! :-* Whooa! 11 Countries.  Just the core development team.  I once tried to use a version control system but didnot pursue it because I was busy with coding at the moment and most of the core apps such as operations and hrd modules are assigned to me alone, so no conflicts there.  What we do have here is a scheduled cron job which updates or syncronizes files of local and public servers but not like what Joomla's uses, that creates an entry of who changed what and when and how many changes have been done.  I also noticed that most libraries of the Joomla 1.8 I downladed was last updated by you.  Such dedicated work by people scattered around the world.
Thank you for explaining to us how the Joomla Code is Managed.

Ay oo nga pala...

I have discovered a neat trick that even the Joomla Developers would never imagine.  This is the best I have ever
made and I dont know if I can make any other like it.  Warning!!! Proceed only if you are a Super Dooper Mega
Experienced PHP Programmer and back up your database and files before doing this.

HOW TO MAKE YOUR JOOMLA WEBSITE INVISIBLE AND VISIBLE AGAIN

Make it Invisible
INDEX.PHP LINE 233

Code: Select all

// loads template file
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) {
	echo _TEMPLATE_WARN . $cur_template;
} else {
	require_once( 'templates/'. $cur_template .'/index.php' );
	echo "<!-- ".time()." -->";
}
Replace it with this one

Code: Select all

/*
// loads template file
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) {
	echo _TEMPLATE_WARN . $cur_template;
} else {
	require_once( 'templates/'. $cur_template .'/index.php' );
	echo "<!-- ".time()." -->";
}
*/
Refresh! and Whala!, Wala na ang website mo.  Even view source wala din.
This trick is very useful when you dont want others to view your site.
But dont panic it will be visible again if you replace the code with this

Code: Select all

// loads template file
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) {
	echo _TEMPLATE_WARN . $cur_template;
} else {
	require_once( 'templates/'. $cur_template .'/index.php' );
	echo "<!-- ".time()." -->";
}
Wow! Im a very well pleased with this discovery.  I wonder why no one has ever thought of this?  :laugh:

Comments:

Rabbit Says:  Wow! an Invisible Website! Cool!
Parrot Says: What is the meaning of Invisible?
Garfield Says: This guy is a Crackpot!
Pussy Cat Says:  Why would anybody want an Invisible Website? You must be nuts?
Last edited by deathwingpnx on Thu May 25, 2006 6:56 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
guilliam
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4181
Joined: Thu Aug 18, 2005 10:27 am
Location: Sunny City Cebu, Philippines!
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by guilliam » Wed May 24, 2006 1:33 pm

^^ i think its because there is a core function in joomla to make your joomla site offline. in the global config. :)
but this is another option in manually turning it offlien though :)

- g
"I was one of those who wondered why people would pay so much $$$$ to do something that was so much fun!" -R. Harkrider, Fortran Code Engr.

http://www.joomlaconsultancy.net

User avatar
Astig
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Wed Nov 30, 2005 2:02 pm
Location: Manila
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by Astig » Thu May 25, 2006 1:19 pm

stingrey wrote: An artifact of time.  Way back in one of the early versions of Mambo Itemid was introduced, and because of the need for backward comaptability through suceeding versions it has stayed Itemid

For links that do not have an Itemid it allows you to set modules or templates for it.  Prior to its introduction this was not possible for non-Itemid links to have modules assigned to it.

At some future point, the Itemid system will be replaced and removed as it is one of the most problematic parts of the whole Core system.  It would have been overhauled already if it wasnt so central to the whole operation of the Core.  It was introduced for a specific purpose and through time more functionality was piggy backed to it, beyond its purpose leading to the problems we have now.
The replacement will probably bring a big difference between Mambo and Joomla. I am sure future versions of Joomla will be far better than previous versions. I also hope that the core team will consider speed despite of tons of features to be included in the next releases; speed in terms of lesser database queries and faster page rendering.

User avatar
Astig
Joomla! Intern
Joomla! Intern
Posts: 58
Joined: Wed Nov 30, 2005 2:02 pm
Location: Manila
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by Astig » Thu May 25, 2006 1:29 pm

deathwingpnx wrote: I have discovered a neat trick that even the Joomla Developers would never imagine.  This is the best I have ever
made and I dont know if I can make any other like it.  Warning!!! Proceed only if you are a Super Dooper Mega
Experienced PHP Programmer and back up your database and files before doing this.

Code: Select all

/*
// loads template file
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) {
	echo _TEMPLATE_WARN . $cur_template;
} else {
	require_once( 'templates/'. $cur_template .'/index.php' );
	echo "<!-- ".time()." -->";
}
*/
Neat trick but can be exploited in some ways. Blank page is produced because you have commented the block that produces the _only_ output. But this doesn't mean that the uncommented functions are not being loaded. With tailored query strings in the URL, someone will still get some data based on the loaded functions. But that was only an assumption  ;D

You can also do this king of trick by creating a new Joomla template with a blank index.php  ;)

User avatar
KILLER_AJ
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 183
Joined: Sun Apr 23, 2006 1:41 am
Location: cebu
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by KILLER_AJ » Fri May 26, 2006 3:48 am

:o ??? ???wow grabeh... ala ako maintindhan... nasa looping palang ako now ng PHP...  ??? ??? :o

User avatar
stingrey
Joomla! Hero
Joomla! Hero
Posts: 2756
Joined: Mon Aug 15, 2005 4:36 pm
Location: Marikina, Metro Manila, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by stingrey » Fri May 26, 2006 2:35 pm

Astig wrote: I also hope that the core team will consider speed despite of tons of features to be included in the next releases; speed in terms of lesser database queries and faster page rendering.
Oh we definitely are.  For example in 1.0.8 and 1.0.9 we have been able to work on significantly reducing the number of DB queries generated by the core - up to 50% less compared to 1.0.0  Will blog about this in a bit.

This is also the case in 1.5 and improvements have also been made to caching at several levels.



While not in 1.5 the version after that will include a complete overhaul of the core SQl queries making them more DB neutral allowing full protability to DB's other than MySQL.  During that time a complete analysis of the core DB load will also be analyzed.
Rey Gigataras
http://www.wizmediateam.com <-- great team of talented Web Designers and Programmers!
http://about.me/reygigataras <-- About Me :)
Partner, Business Development & Project Manager, Event Manager, Sports Coach :D

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Sat May 27, 2006 3:17 am

guilliam wrote: ^^ i think its because there is a core function in joomla to make your joomla site offline. in the global config. :)
but this is another option in manually turning it offlien though :)
Yes we could do that, But it will still display a message that our site is down maintenance or what ever reason which still
render our site visible.  By the way, I was just joking about that post, just to make you laugh cause we need not to be serious all of the time.  :P

I have been sick for 2 days, but it was a blessing in disguise cause I spent more time with my 5 month old KaBaby,  and this week I will
be doing an HRD system for Hytech (a company owned by my boses friend) so I cant update this dicussion yet.  But I know our friends
will contribute a lot here, so no worries from me.  I'm still studying the code and hope to post a more clearer and comprehensive topic with regards to this.

Lastly, I want to greet everyone and thanks for the support for our favorite CMS which is Joomla.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

ericb
Joomla! Guru
Joomla! Guru
Posts: 736
Joined: Sat Feb 25, 2006 4:44 pm
Location: Metro Manila
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by ericb » Sat May 27, 2006 6:59 am

chette wrote:
deathwingpnx wrote: Thats why I need all of your help, comments and suggestions, and specially ask questions.
Don't expect a lot of questions, but expect a lot of people to keep on reading your posts ;) A lot of us are feeling overwhelmed looking at it for the first time. Give us a few moments for it to sink in :)
its interesting to read and am glad that we have this kind of thread here so that joomla members will understand 'how joomla really works', and not just 'how to build site using joomla'... right now, i will just read posts from this thread, i will not ask questions this early because i dont know anything yet :P
www.phpugph.com - PHP Users Group Philippines

thewatcher
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Fri Feb 17, 2006 4:30 pm
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by thewatcher » Sat May 27, 2006 11:52 am

well done job deathwingpnx

Cheers,
:)
[ http://www.MOSCOM.COM ] WebHosting 24x7 Phone Support.
[ http://www.KING.NET ] My Project ... converting to 1.6

User avatar
chette
Joomla! Explorer
Joomla! Explorer
Posts: 484
Joined: Wed Aug 17, 2005 11:20 pm
Location: Pasig City, Philippines
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by chette » Sun May 28, 2006 10:38 am

deathwingpnx wrote: Wow! Im a very well pleased with this discovery.  I wonder why no one has ever thought of this?  :laugh:
[me=chette]scratches head[/me]

Well ... just like what gulliam said, its all in the global config. And if I really want it to be not accessed, I just put a username and password in .htaccess

Its like you just taught me how to gargle with my mouth closed? It's neat knowing it, but I wouldn't really use it :)

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Sun May 28, 2006 1:26 pm

KILLER_AJ wrote: :o ??? ???wow grabeh... ala ako maintindhan... nasa looping palang ako now ng PHP...  ??? ??? :o
I think all of us started at the beggining in learning PHP.  Take it one step at a time.  Do not force yourself to learn a lot about PHP in a short period of time because you may experience information overload in which in the hope of learning more, you end up learning a few or nothing, because you force your self into it.  Do not make the mistake I made.  Try to understand first fully what you are learning before proceeding to the next level.  In learning any programming language, my motivation is not because programming is popular and if you know web programming in particular, people treat you at a higher level, but I choose to study this field is because I love doing it and enjoy the experience every time I learn something new.  It's like going to work and not having to work a single day in your life, getting paid for something you enjoy doing.  Mistakes are always part of learning, but each mistake we make, we learn from it and makes us better and do well in the future.  Just remember that the saying is true "Knowing is half the battle, and Experience is the best teacher".


Astig wrote: I also hope that the core team will consider speed despite of tons of features to be included in the next releases; speed in terms of lesser database queries and faster page rendering.
Yes, I agree that database optimization and good query stucture is a major factor in Joomla. Our company caters to cargo, remittance and deliveries of credit cards and bank statements, etc., and has many international offices around the world. In fact for each country we have a average of 4 offices.  Also we have branches scattered all over the Philippines.  Cargo and Remittance averages 500 transactions for each service and each office, credit cards amounts to about 1000 to 2000 transactions every week, so imagine the large amount of data being stored in our database.  We have 3 SQL servers using Postgre SQL and the specifications are mostly HP DL380 Proliant G3 Double Processor 3.0GHZ Zeon and 4GB Memory.  Inspite of this, we still get the database error message, TOO MANY CLIENTS (not using persistent connections).  Our online system almost became unusable because of the slow speed of data access and the database error we often experience specially during peak hours.  This can be easily solved by upgrading our server memory, but was not an option because there are better ways of solving this such as database optimization and good sql query structuring.  The solution we applied was very basic yet effective.  The creation of oftenly used table indexes, vacuum and analyze, and restructured or redesign our sql queries.  Although simple, it was very effective because it reduced the retrieval of data to a fraction of the time compared to the past and the databse error message TOO MANY CLIENTS was history.

In my case using Joomla, I will notice little of Joomla increase of speed because im using it for personal purposes. Business and Large Organizations having great volume of data such as having 500,000 or more members would easily notice and benefit from the new feature Joomla has to offer.
chette wrote: [me=chette]scratches head[/me]

Well ... just like what gulliam said, its all in the global config. And if I really want it to be not accessed, I just put a username and password in .htaccess

Its like you just taught me how to gargle with my mouth closed? It's neat knowing it, but I wouldn't really use it :)
Thanks Sir Guilliam (sounds like a knight of the round table) and Chette for the advice (My Invisible Website Post was a Joke just to make you laugh :D ).  And Chette, I saw your website once and I was impressed.  It was simple yet elegant and very informative.  I noticed that you are also good at shell scripting, could you teach me in the future, cause Im not so good at it, hehehe.


Basic Joomla Directory Structure.  I didnot include all subdirectories but just important ones for us newbies not to get confused with so many and not so important at this time directories.

root joomla directory
ADMINISTRATOR
backups
components
images
includes
...
modules
popups
templates

CACHE
COMPONENTS
EDITOR
HELP
IMAGES
banners
M_images
smiles
stories
INCLUDES
archive
cache
...
domit
js
pattemplate
...
pear
phpinputfilter
phpmailer
INSTALLATION
sql
LANGUAGE
MAMBOTS
content
...
editors
tinymice
...
MEDIA
MODULES
TEMPLATES

ADMINISTRATOR
-  Files used in Admin Interface (Backend)
CACHE
-  Cached files, I see here xml documents from rss feeds.
COMPONENTS
-  This is where componentents are found.
EDITOR
-  The files I saw here are editor preferences of the user.
HELP
-  Help files
IMAGES
-  Where images are stored.
INCLUDES
-  Directory where Core Joomla library resides.
INSTALLATION
-  Installation scrips, whole directory must be deleted after installation.
LANGUAGE
-  Language files.
MAMBOTS
-  Mambot libraries.
MEDIA
-  Media files such as sound and video.  In my case, this is where I stored my MP3s.
MODULES
-  Directory for Modules
TEMPLATES
-  Directory where our templates are located.


Basic Joomla Include Structure not including required and include files under conditional statements, classes and functions at the moment because some operations and conditions must be met before executing the inclusion of these files and to simplify the basic file include structure understanding, but will be discussed in future studies.  This is only for the Frontend Part of Joomla, the back end is not yet included here.  I dont know the right term for it (include structure/ file structure) so I used this for the time being.

index.php
include globals.php
require configuration.php
require includes/joomla.php
require dirname( __FILE__ ) . '/compat.php50x.php
require $mosConfig_absolute_path . '/includes/version.php
require $mosConfig_absolute_path . '/includes/database.php
require $mosConfig_absolute_path . '/includes/gacl.class.php
require $mosConfig_absolute_path . '/includes/gacl_api.class.php
require $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php
require $mosConfig_absolute_path . '/includes/joomla.xml.php
require $mosConfig_absolute_path . '/includes/phpInputFilter/class.inputfilter.php
require includes/sef.php
require includes/frontend.php
include language/' . $mosConfig_lang . '.php
require $mosConfig_absolute_path . '/editor/editor.php
require templates/'. $cur_template .'/index.php


index.php
-  Main Joomla File.

include globals.php
-  Emulates register globals on or off.

require configuration.php
-  Global configuration settings.

require includes/joomla.php
-  Main Joomla Function Library.

require dirname( __FILE__ ) . '/compat.php50x.php
-  Function compatibility with different PHP versions, PHP 5 is assumed version here.

require $mosConfig_absolute_path . '/includes/version.php
-  Joomla version attributes.

require $mosConfig_absolute_path . '/includes/database.php
-  Joomla database library.

require $mosConfig_absolute_path . '/includes/gacl.class.php
-  Generic Access Control List, ACL for individual users.

require $mosConfig_absolute_path . '/includes/gacl_api.class.php
-  Generic Access Control List, ACL for groups and applications.

require $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php
-  Library for handling mail.

require $mosConfig_absolute_path . '/includes/joomla.xml.php
-  Library for handling XML.

require $mosConfig_absolute_path . '/includes/phpInputFilter/class.inputfilter.php
-  Library for handling user input.

require includes/sef.php
-  Search Engine Friendly URL Library.

require includes/frontend.php
-  Front End Functions such as display of main body, modules and components, mostly used by the templates.

include language/' . $mosConfig_lang . '.php
-  Language to be used in your site.  Translation team focus.

require $mosConfig_absolute_path . '/editor/editor.php
-  Handles user editor preferences.

require templates/'. $cur_template .'/index.php
-  Current template used, Main display/ output of Website.

This is still an early and incomplete assumption of the joomla include/ required structure.  More will be discussed as we study the need for it in certain operations and conditions which takes place in using our Joomla CMS.  Comments, Suggestions, Clarifications and Questions are most welcome.

This is the easy part, the hard part is when we explore the files, classes, methods, properties and program flow therein.
Last edited by deathwingpnx on Thu Jun 01, 2006 11:46 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Mon May 29, 2006 12:15 pm

Speaking of .htaccess, I tried renaming the htaccess.txt in the joomla directory as .htaccess. I just cant get it to work properly so I did it the hard way.  Huh! frustrating.  I placed the first three files inside the administration directory and It turned out ok. This works fine in Mandriva and Ubuntu.

.htaccess
======================
AuthUserFile /media/windata/htdocs/administrator/.htpasswd
AuthGroupFile /media/windata/htdocs/administrator/.htgroup
AuthName "Glenn Apolinario - Deathwing Phoenix"
AuthType Basic
require group master_glenn


.htgroup
======================
master_glenn: glenn


.htpasswd
======================
glenn:E2cuAla.F3L9M


httpd.conf
======================

DocumentRoot "/media/windata/htdocs"
ServerName glennapolinario.homelinux.com
AccessFileName .htaccess

allow from all
AllowOverride AuthConfig
Options -Indexes

DirectoryIndex index.html index.htm index.php


After creating and updating these files, type this command in the shell on the joomla administation directory.
htpasswd -b .htpasswd your_username your_password

I still prefer the easy and short way, if I can figure out how to do it?  Could somebody help me on how to to properly use the htaccess in contained in joomla? Thanks.
Last edited by deathwingpnx on Wed Nov 08, 2006 10:27 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Simple data retrieval. Playing with the code.

Post by deathwingpnx » Fri Jun 02, 2006 8:16 am

I made a simple script to retrieve the data of Joomla users.  Lets Play with the code.

1.  First let us disable the template output.  Find the this code in INDEX.PHP line 232

Code: Select all

// loads template file
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) {
	echo _TEMPLATE_WARN . $cur_template;
} else {
	require_once( 'templates/'. $cur_template .'/index.php' );
	echo "<!-- ".time()." -->";
}
Replace it with this code, basically we just commented it.

Code: Select all

/*
// loads template file
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) {
	echo _TEMPLATE_WARN . $cur_template;
} else {
	require_once( 'templates/'. $cur_template .'/index.php' );
	echo "<!-- ".time()." -->";
}
*/
This procedure is somewhat familiar (Invisible).  And I think I will use this most of the time to disable the output but still loading the classes, methods and attributes therein.

2.  After disabling the output, lets rename our index.php index.bak.php

3.  Then create an empty file named index.php and place this code inside of it.

Code: Select all

<?php
	require_once 'index.bak.php' ;
	require_once $mosConfig_absolute_path . '/modules/' . 'mod_login' . '.php';

	// displays a single user
	$query = "SELECT * FROM #__users WHERE id = $my->id";
	$my->_db->setQuery($query);
	$my->_db->loadObject($me);

	echo "<hr>\n";
	echo "DISPLAYS A SINGLE USER<br />\n";
	echo "You are ";

	if ($my->id) {
		echo " logged in " . $me->name;
	} else {
		echo " not logged in guest.";
		$me = new stdClass;
	}

	foreach ($me as $key => $value)
	    echo "<p>$key : $value";



	// displays multiple users if logged in
	if ($my->id) {
		echo "<br /><hr>\n";
		echo "DISPLAYS MULTIPLE USERS\n";
		$query = "SELECT * FROM #__users order by username";
		$my->_db->setQuery($query);
		$us    = $my->_db->loadAssocList();
		echo "<table width='100%' border='1'>\n";
		foreach ($us as $row) {
			echo "<tr>\n";
			foreach ($row as $val)
				echo "<td align='center'>$val</td>\n";
			echo "<tr>\n";
		}
		echo "</tr>\n";
		echo "</table>\n";
	}
?>
Refresh the page, and we see a simple data retrieval of member records in our jos_users table. :P  Try to log in and log out again to see the difference.  There are many ways to retrieve data specially for joomla which has a rich fuction library.  This is only one of them.
Last edited by deathwingpnx on Sat Jun 03, 2006 2:23 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

User avatar
KILLER_AJ
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 183
Joined: Sun Apr 23, 2006 1:41 am
Location: cebu
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by KILLER_AJ » Fri Jun 02, 2006 8:54 am

such an amazing codes u make... wow pare bilib talga ako sayo.. try ko nga rin.. cge gagawa ako next week popost ko dito.. lito pa ako sa ngayun.. hirap me sa sql... hehehe...  :D
Last edited by KILLER_AJ on Fri Jun 02, 2006 9:02 am, edited 1 time in total.

User avatar
deathwingpnx
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 193
Joined: Fri Mar 17, 2006 5:06 pm
Location: Quezon City
Contact:

Re: Let us Study, Learn and Understand the Joomla Code Together

Post by deathwingpnx » Fri Jun 02, 2006 9:24 am

KILLER_AJ wrote: such an amazing codes u make... wow pare bilib talga ako sayo.. try ko nga rin.. cge gagawa ako next week popost ko dito.. lito pa ako sa ngayun.. hirap me sa sql... hehehe...  :D
I would be very happy if I was the one who created those classes and methods or even contributed to it, but they are included in the Joomla library, we have to thank our Joomla Hero kababayans Mr. Stingrey and Mr. Guilliam for their contribution on that.  I only used them for this purpose and added some code and conditions for matters of learning.  Feel free to post what you have learned for all of us will benefit in reading it.

I was reading http://api.joomla.org.&nbsp; Are the information here upto date? Cause I cant find some of the functions here, if not, well Ill just have to continue reading the code itself.

Thanks!
Last edited by deathwingpnx on Sat Jun 03, 2006 2:24 am, edited 1 time in total.
Glenn Miranda Apolinario
Winning is not important!  Giving it your best is what Counts!
http://www.glennapolinario.com

 

Locked

Return to “Pinoy General Discussion & Archives”