Jump to content

Recommended Posts

Hi ,

I try to develop a cms ,

i welcome any help or opinion ,

 

 

root file : index.php , .htaccess

 

folders :

 

==>core

--> includes { bootstrap.inc.php , dbconnect.inc.php , patch.inc.php , ...)

--> modules {user , content , menu , sys , box }

 

--> style {css , img , template }

 

==>server

 

--> default {config.php}

--> example.com {config.php , modules , style , files}

 

==>main

 

--> files

--> library

 

--> modules

--> style

---->default {template , css , img }

 

 

 

The index file content :

<?php
define('ROOT', getcwd());
require_once ROOT . '/core/includes/bootstrap.inc.php';
?>

 

 

.htaccess file content :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Edited by alimosavi
Link to comment
https://forums.phpfreaks.com/topic/274560-cms-develop/
Share on other sites

/core/includes/bootstrap.inc.php content :

 

 

<?php
// Load site Config
define('CONFIG', ROOT . '/server/default/config.php');
require_once CONFIG;

$inc = array("dbconnect", "modules", "patch" ,"theme");

foreach ($inc as $value) {
require_once($value . '.inc.php');
}

define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']);

?>

 

 

/core/includes/dbconnect.inc.php content :

 

// Database Variables
$dbhost = $mysql_host;
$dbuser = $mysql_username;
$dbpass = $mysql_password;
$dbname =  $mysql_dbname;

$MYSQL_ERRNO = "";
$MYSQL_ERROR = "";

// Connect To Database
function db_connect() {
 global $dbhost, $dbuser, $dbpass, $dbname;
 global $MYSQL_ERRNO, $MYSQL_ERROR;

 $link_id = mysql_connect($dbhost, $dbuser, $dbpass);

 if(!$link_id) {
   $MYSQL_ERRNO = 0;
   $MYSQL_ERROR = "Connection failed to $dbhost.";
   return 0;
 }
 else if(!mysql_select_db($dbname)) {
   $MYSQL_ERRNO = mysql_errno();
   $MYSQL_ERROR = mysql_error();
   return 0;
 }
 else return $link_id;
}

// Handle Errors
function sql_error() {
 global $MYSQL_ERRNO, $MYSQL_ERROR;

 if(empty($MYSQL_ERROR)) {
   $MYSQL_ERRNO = mysql_errno();
   $MYSQL_ERROR = mysql_error();
 }
 return "$MYSQL_ERRNO: $MYSQL_ERROR";
}

// Print Error Message
function error_message($msg) {
 printf("Error: %s", $msg);
 exit;
}

Edited by alimosavi
Link to comment
https://forums.phpfreaks.com/topic/274560-cms-develop/#findComment-1412765
Share on other sites

/core/includes/patch.inc.php content :

 

<?php

//input patch from other modules or other things and output relative effect

 $base_url = url();
 $parts = parse_url($base_url);
 $main_url = substr($base_url, 0, strlen($base_url) - strlen($parts['path']));
 $request_path = request_uri(TRUE);
 $base_path_len = strlen(rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/'));
 $path = substr(urldecode($request_path), $base_path_len + 1);
 $base_url_dir = substr($base_url, 0, strlen($base_url) - strlen($path));



/* show corrent url */
function url(){
	if(isset($_SERVER['HTTPS'])){
			$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
	}else{
			$protocol = 'http';
	}
	return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}


function request_uri($omit_query_string = FALSE) {
 if (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
 }
 else {
if (isset($_SERVER['argv'][0])) {
  $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['argv'][0];
}
elseif (isset($_SERVER['QUERY_STRING'])) {
  $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
}
else {
  $uri = $_SERVER['SCRIPT_NAME'];
}
 }
 // Prevent multiple slashes to avoid cross site requests via the Form API.
 $uri = '/' . ltrim($uri, '/');

 return $omit_query_string ? strtok($uri, '?') : $uri;
}

?>

Edited by alimosavi
Link to comment
https://forums.phpfreaks.com/topic/274560-cms-develop/#findComment-1412766
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.