Mgigs Sandbox

Started on the old forum in May 2012 · view the original in the archive · old links redirect here

7 replies · 890 views · started 14 years ago · 1 min read

6 participants
CreativityKills Lead · 833 posts #1

So i am creating the whole mgigs script again and im at my very conceptual stage but i decided to go open source on this one. Reasons being that contributed code will not only help the codes grow faster but it will help keep a lid on the security from inception.

What now? Im going to be attaching the script to this thread a bit later but before then i want to know those that may be interested in contributing. If the users interested in this are huge enough i will post the script.

What stage am i now? I finished the structuring and i have started working through the pages one after another. So far i have just the index and login page coded, the register page is undergoing coding.

The architecture I used a single front controller method, meaning that all requests pass through the index file. The index file includes a bootstrap file that fetches the correct page nased on the _GET request, and serves the function associated with the said page. All pages are actually functions. Its something like the MVC pattern only that its a really scaled down version that has no models, and the controllers are functions instead.

What you should do? The first step is tp look at the coding and try to understand how it handles requests and serve pages. Also look at each function and understand how it works. This way everyone can understand whats going on and can contribute.

So for now, i'd like to know those interested. Please note that though everyone can contribute, all codes will be well thought out before being added.

Attachments: mgigs.zip mgigs.sql
antony2kx Developer · 94 posts #3

I can help if you need

i suggest that you are doing somethings similar to this

<?php

$page = isset($_GET['page']) ? trim($_GET['page']) : '';

swicth($page)
{
  default: 
  case 'index':
   $pageCatcher->fetch('index'); //where index is a function 
   break;

  case 'login':
  pageCatcher->fetch('login');  //where login is a function
   break;
   

}

?>
Ghost Senior · 366 posts #4

though im not firmiliar with this mgigs sandbox you talk about. this project still sounds pretty interesting.

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
morse Senior · 364 posts #5

Count me in

I already own a mobile social portal, but its been putting too much load on my server. I would like to be part of this venture, learn, contribute and share. The function page idea is an interesting one.

tinyurl.com/earnbymobile Easy earning for Indians

Alternative mobile advertising network .. Minimum 100 USD pay / NET15 pay cycle, Good Brand, Best targeting for Android goo.gl/6vub3

CreativityKills Lead · 833 posts #6

antony2kx wrote: I can help if you need

i suggest that you are doing somethings similar to this

<?php

$page = isset($_GET['page']) ? trim($_GET['page']) : '';

swicth($page)
{
  default: 
  case 'index':
   $pageCatcher->fetch('index'); //where index is a function 
   break;

  case 'login':
  pageCatcher->fetch('login');  //where login is a function
   break;
   


}



?>

Yeah but more like...

<?php define('MGIGS_START', microtime(TRUE));
/**
 * MobileGigs Mobile Community.
 *
 * Simple mobile community script.
 *
 * @author	Neo Ighodaro
 * @copyright	CreativityKills Web Development
 * @license	LICENSE.txt
 */

// Start session
session_start();

// Directory separator
define('DS', DIRECTORY_SEPARATOR);

// Document root
define('DOCROOT', realpath(dirname(__FILE__)).DS);

// System and Application directory
define('SYSPATH', DOCROOT.'system'.DS);
define('APPPATH', DOCROOT.'application'.DS);

// Include the bootstrap file
include DOCROOT.'bootstrap.php';

// Set default language
I18n::set_lang('en-us');

// Requested action/page
$action = arrGet($_GET, 'ac', 'index');

if ( ! Mgigs::valid_page($action))
{
	// The page was not found :P
	call_user_func('mg_action_error', '404');
	exit();
}

if (mg_db_connect() === FALSE)
{
	// Could not connect to database O_o
	call_user_func('mg_action_error', '3000');
	exit();
}

// Launch the page
call_user_func('mg_action_'.$action);

Thats the index that handles the requests. Though im thinking of actually making it totally OOP, but just for the sake of simplicity, im leaving it this way. Though categorizing the functions into classes sounds like another good plan.

I think there are enough users interested in contributing to post the source codes. So i will be attaching it now.

Added after 27 minutes:

The title text has been updated and the source attached. Before we start suggesting codes, we will just take some time to study the script shall we? 🙂

Architechture. . .File: index.php I commented on the codes as much as i can so it should not be too hard to follow it. But then lets just explain how requests are handled. Pages are loaded from the $_GET['ac']. All pages are stored in the pages.php under system and applications folders.

Why application and system folders? I decided to separate the core libraries and the custom made application libraries and files. The system has classes that are extensible by creating a duplicate and extending it. For example, to extend the View class, create a file in the classes directory of the application folder named view.php and extend the original core class...

<?php
class View extends Core_View {
    // Extension code goes here...
}

There are many other things to consider before suggesting codes. I place alot of imoportance to coding styles. Let me share a few...

//------------------------------------

<?php echo $var ?> [okay] <?=$var?> [not okay] ...some servers disable the short start tags for PHP by default.

//------------------------------------

This also applies to pretty much any codes with { curly braces } ...foreach, for, if, while etc.

if (1===1) { echo 'hi'; [okay] ...its really readable }

if (1===1) echo 'hi'; [not ok]

if (1===1){ echo 'hi'; [not okay] }

//------------------------------------

I cant really cover everything im currently tired. if you have any questions about how it works feel free to ask. Next we will start reviewing the existing codes for security.

ven0m_ Junior · 26 posts #7

sounds interesting.. i hope i can also contribute to this great project.. but i have only limited knowledge about php coding..:D

Wap4Loadz.Tk - Search Video | Ringtones | Mp3 Search | Applications | Themes | Softwares | Wallpapers | Games | Adults --->http://wap4loadz.tk

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close