Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc3f69b

Browse files
committed
first upload
1 parent ac9cfd4 commit fc3f69b

File tree

8 files changed

+177
-0
lines changed

8 files changed

+177
-0
lines changed

.htaccess

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<IfModule mod_rewrite.c>
2+
#=========================================================================
3+
#Core - URLs Friendly - DO NOT CHANGE ONLY IF YOU KNOW WHAT ARE YOU DOING.
4+
#=========================================================================
5+
RewriteEngine On
6+
Options -Indexes
7+
8+
#=========================================================================
9+
#Use this section to Custom URL's for individual files if you need
10+
#=========================================================================
11+
RewriteRule ^individual-page/?$ individual-page.php
12+
RewriteRule ^individual-page/(.*)/?$ individual-page.php?id=$1
13+
14+
#=========================================================================
15+
#Core - URLs Friendly - DO NOT CHANGE ONLY IF YOU KNOW WHAT ARE YOU DOING.
16+
#=========================================================================
17+
#files and folders
18+
RewriteCond %{SCRIPT_FILENAME} !-d
19+
RewriteCond %{SCRIPT_FILENAME} !-f
20+
RewriteCond %{REQUEST_FILENAME} !-f
21+
RewriteRule ^(.*)$ index.php [L,QSA]
22+
</IfModule>

_routes.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/*
3+
* =====================================================================
4+
* HOME PAGE
5+
* =====================================================================
6+
*/
7+
if( is_homepage() ){
8+
$the_title = 'Bienvenido';
9+
$the_description = 'Esta es la descripcion';
10+
$the_keywords = 'Estas, Son, Las, Keywords';
11+
$the_fb_image = 'admin/uploads/page_algo/foto.jpg';
12+
include $theme_url.'/home.php';
13+
exit;
14+
}
15+
16+
17+
/*
18+
* =====================================================================
19+
* EXAMPLE PROPERTIES
20+
* =====================================================================
21+
*/
22+
//http://www.phpliveregex.com/p/eHz
23+
if( match_url('/nomames/propiedades/{str}/{str}/{int}') ){
24+
echo '<h1>Propiedades</h1>';
25+
//Property ID
26+
$id = get_param('/nomames/propiedades/{str}/{str}/{this}');
27+
echo '<h4>Property ID: '.$id.'</h4><br>';
28+
exit;
29+
}
30+
31+
/*
32+
* =====================================================================
33+
* BLOG POST
34+
* =====================================================================
35+
*/
36+
if( match_url('post/{str}/{int}') ){
37+
38+
//Post Slug
39+
$slug = get_param('post/{this}/{int}');
40+
echo '<h4>Post Slug: '.$slug.'</h4><br>';
41+
42+
//Post ID
43+
$id = get_param('post/{str}/{this}');
44+
echo '<h4>Post ID: '.$id.'</h4><br>';
45+
46+
include $theme_url.'/post.php';
47+
exit;
48+
}
49+
50+
51+
/*
52+
* =====================================================================
53+
* ERROR 404
54+
* Do not remove anything below this line, keep this code at bottom.
55+
* =====================================================================
56+
*/
57+
file_exists('404.php') ? include '404.php' : include 'core/defaults/errors/404.php';
58+
?>

core/defaults/errors/404.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>Error 404!</h1>
2+
<p>Page not found<p>
3+
<em>Default messages (defaults/errors/)</em>

core/define-path.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
//Define Path
3+
$base_domain = $_SERVER['HTTP_HOST'];
4+
$base_uri = "//" . $base_domain . $_SERVER['PHP_SELF'];
5+
$base_path_info = pathinfo($base_uri);
6+
//As variables
7+
$domain_name = $base_domain;
8+
$base_href = $base_path_info['dirname']."/";
9+
$current_url = "//".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
10+
//As constants
11+
define("DOMAIN_NAME", $base_domain);
12+
define("BASE_HREF", $base_href);
13+
define("CURRENT_URL", $current_url);
14+
?>

core/functions-built-in.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/*
3+
================================================================================================
4+
┬─┐┌─┐┬ ┬┌┬┐┌─┐┌─┐ ┌─┐┌┐┌┌┬┐ ┬ ┬┬─┐┬ ┌─┐
5+
├┬┘│ ││ │ │ ├┤ └─┐ ├─┤│││ ││ │ │├┬┘│ └─┐
6+
┴└─└─┘└─┘ ┴ └─┘└─┘ ┴ ┴┘└┘─┴┘ └─┘┴└─┴─┘└─┘
7+
================================================================================================
8+
*/
9+
10+
function match_url($custom_url){
11+
global $requested_url;
12+
$custom_url = ltrim($custom_url,'/');
13+
$custom_url = '/'.$custom_url;
14+
$regexp = str_replace('/','\/', $custom_url);
15+
$regexp = str_replace('{str}', '.*', $regexp);
16+
$regexp = str_replace('{int}', '[0-9]', $regexp);
17+
$regexp = '/^'.$regexp.'+$/'; //http://www.phpliveregex.com/p/eHz
18+
if( preg_match($regexp, $requested_url) ){
19+
return true;
20+
}else{
21+
return false;
22+
}
23+
}
24+
25+
function get_param($custom_url){
26+
global $requested_url;
27+
$custom_url = ltrim($custom_url,'/');
28+
$custom_url = '/'.$custom_url;
29+
$regexp = str_replace('/','\/', $custom_url);
30+
$regexp = str_replace('{this}', '(.*)', $regexp);
31+
$regexp = str_replace('{str}', '.*', $regexp);
32+
$regexp = str_replace('{int}', '[0-9]', $regexp);
33+
$regexp = '/^'.$regexp.'/'; //http://www.phpliveregex.com/p/eHz
34+
if( preg_match($regexp, $requested_url, $output) ){
35+
return $output[1];
36+
}else{
37+
return '';
38+
}
39+
}
40+
41+
//Home page
42+
function is_homepage(){
43+
global $requested_url_params; //This variable is declared at core/init.php
44+
if( empty( $requested_url_params ) && is_array( $requested_url_params ) ){
45+
return true;
46+
}else{
47+
return false;
48+
}
49+
}
50+
51+
?>

core/init.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Define charset for plain-text outputs
4+
* This doesn't have nothing to do with database utf, the database utf is set in admin/classes/DatabaseClass.php
5+
*/
6+
header('Content-Type: text/html; charset=utf-8');
7+
8+
9+
//Load core files & config
10+
require 'core/define-path.php';
11+
require 'core/functions-built-in.php';
12+
$admin_dirname = 'admin';
13+
14+
15+
//Defaults
16+
//Put your database user and password into admin/conex.php
17+
$install_dirname = dirname($_SERVER['PHP_SELF']); //The dirname where app is running, this facilitate the change of the website folder without headaches, just move to another folder and your website will be ready automatically.
18+
19+
//Prepare routes
20+
$requested_url_params = array();
21+
$requested_url = str_replace($install_dirname, '', $_SERVER['REQUEST_URI']); //Remove install dirname to get the real requested url: domain-name-com/[this] or domain-name-com/installdirname/[this]
22+
$requested_url_params = array_merge(array_filter(explode('/',$requested_url)));
23+
24+
25+
//Load content
26+
require '_routes.php';
27+
?>

home.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HOME

index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php require 'core/init.php'; ?>

0 commit comments

Comments
 (0)