2011-04-26 16:12:10 +00:00
< ? php
2006-12-02 04:36:16 +00:00
/*
2009-09-28 19:17:59 +00:00
* e107 website system
*
2011-12-02 16:33:31 +00:00
* Copyright ( C ) 2008 - 2011 e107 Inc ( e107 . org )
2009-09-28 19:17:59 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* News frontend
*
2011-12-02 16:33:31 +00:00
* $URL $
* $Id $
2009-09-28 19:17:59 +00:00
*/
2013-06-02 23:00:59 -04:00
/*! \mainpage e107 Content Management System ( CMS ) - v2
*
* \section intro_sec What is e107 ?
*
* e107 is a free ( open - source ) content management system which allows you to easily manage and publish your content online . Developers can save time in building websites and powerful online applications . Users can avoid programming completely ! Blogs , Websites , Intranets - e107 does it all .
*
* \section requirements_sec Requirements
*
* - PHP v5 . 3 or higher
* - MySQL 4. x or higher
*
* \section install_sec Installation
*
* - Point your browser to the http :// localhost / YOUR FOLDER / install . php ( depending on your webserver setup )
* - Follow the installation wizard
*
* \section reporting_bugs_sec Reporting Bugs
*
* Be sure you are using the most recent version prior to reporting an issue . You may report any bugs or feature requests on GitHub ( https :// github . com / e107inc / e107 / issues )
*
* \section pull_requests_sec Pull - Requests
*
* - Please submit 1 pull - request for each Github #issue you may work on.
* - Make sure that only the lines you have changed actually show up in a file - comparison ( diff ) ie . some text - editors alter every line so this should be avoided .
*
* \section license_sec License
*
* e107 is released under the terms and conditions of the GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
*/
2011-12-01 22:08:23 +00:00
// BOOTSTRAP START
2009-09-28 19:17:59 +00:00
2011-04-26 16:12:10 +00:00
2011-12-01 22:08:23 +00:00
define ( 'e_SINGLE_ENTRY' , TRUE );
$_E107 [ 'single_entry' ] = true ; // TODO - notify class2.php
define ( 'ROOT' , dirname ( __FILE__ ));
set_include_path ( ROOT . PATH_SEPARATOR . get_include_path ());
require_once ( " class2.php " );
2014-06-02 20:58:42 -07:00
// ----------------------------
/**
* Simple URL ReWrite ( experimental ) //TODO test, discuss, benchmark, enhance and include in eFront etc. if all goes well.
* Why ? :
* - To make simple url rewrites as quick and easy for plugin developers to implement as it currently is to do the same with . htaccess
* - To use the same familiar standard as used by e_cron , e_status , e_rss etc . etc . so even a novice developer can understand it .
*
* @ example ( . httaccess ) :
* RewriteRule ^ ref - ( .* ) / ? $ e107_plugins / myplugin / myplugin . php ? ref = $ 1 [ NC , L ]
*
* @ example ( e_url . php file - in the 'myplugin' folder )
*
* class myplugin_url // plugin-folder + '_url'
{
function config ()
{
$config = array ();
$config [] = array (
'regex' => '^ref-(.*)/?$' ,
'redirect' => '{e_PLUGIN}myplugin/myplugin.php?ref=$1' ,
);
return $config ;
}
}
*/
$sql -> db_Mark_Time ( " Start Simple URL-ReWrite Routine " );
$tmp = e107 :: getAddonConfig ( 'e_url' );
2014-06-06 02:39:44 -07:00
2014-10-19 14:42:29 -07:00
$req = ( e_HTTP === '/' ) ? ltrim ( e_REQUEST_URI , '/' ) : str_replace ( e_HTTP , '' , e_REQUEST_URI ) ;
2014-06-02 20:58:42 -07:00
if ( count ( $tmp ))
{
2014-10-19 14:42:29 -07:00
2014-06-02 20:58:42 -07:00
foreach ( $tmp as $plug => $cfg )
{
2014-10-19 14:42:29 -07:00
2014-06-02 20:58:42 -07:00
foreach ( $cfg as $k => $v )
{
2014-06-06 02:39:44 -07:00
2014-06-02 20:58:42 -07:00
$regex = '#' . $v [ 'regex' ] . '#' ;
2014-06-06 02:39:44 -07:00
2014-10-19 14:42:29 -07:00
if ( empty ( $v [ 'redirect' ]))
{
continue ;
}
2014-06-06 02:39:44 -07:00
2014-10-19 14:42:29 -07:00
$newLocation = preg_replace ( $regex , $v [ 'redirect' ], $req );
2014-06-06 02:39:44 -07:00
if ( $newLocation != $req )
2014-06-02 20:58:42 -07:00
{
$redirect = e107 :: getParser () -> replaceConstants ( $newLocation );
list ( $file , $query ) = explode ( " ? " , $redirect , 2 );
2014-10-22 14:00:08 -07:00
if ( ! empty ( $query ))
{
parse_str ( $query , $_GET );
}
2014-10-19 14:42:29 -07:00
2015-01-28 02:29:26 -08:00
e107 :: getMessage () -> addDebug ( 'e_URL in <b>' . $plug . '</b> with key: <b>' . $k . '</b> matched <b>' . $v [ 'regex' ] . '</b> and included: <b>' . $file . '</b> with $_GET: ' . print_a ( $_GET , true ));
2014-10-19 14:42:29 -07:00
if ( file_exists ( $file ))
{
include_once ( $file );
exit ;
}
elseif ( getperms ( '0' ))
{
echo " File missing: " . $file ;
exit ;
}
2014-06-02 20:58:42 -07:00
}
}
}
unset ( $tmp , $redirect , $regex );
}
2014-10-19 14:42:29 -07:00
2014-06-02 20:58:42 -07:00
// -----------------------------------------
$sql -> db_Mark_Time ( " Start regular eFront Class " );
2011-12-01 22:08:23 +00:00
$front = eFront :: instance ();
$front -> init ()
-> run ();
2011-12-05 15:12:56 +00:00
$request = $front -> getRequest ();
2014-06-02 20:58:42 -07:00
2011-12-05 15:12:56 +00:00
// If not already done - define legacy constants
$request -> setLegacyQstring ();
$request -> setLegacyPage ();
2011-12-01 22:08:23 +00:00
$inc = $front -> isLegacy ();
if ( $inc )
2006-12-02 04:36:16 +00:00
{
2011-12-01 22:08:23 +00:00
// last chance to set legacy env
2011-12-05 15:12:56 +00:00
$request -> populateRequestParams ();
2011-12-01 22:08:23 +00:00
if ( ! is_file ( $inc ) || ! is_readable ( $inc ))
2008-08-25 15:25:19 +00:00
{
2011-12-01 22:08:23 +00:00
echo 'Bad request - destination unreachable - ' . $inc ;
2008-08-25 15:25:19 +00:00
}
2011-12-01 22:08:23 +00:00
include ( $inc );
exit ;
2006-12-02 04:36:16 +00:00
}
2011-12-01 22:08:23 +00:00
$response = $front -> getResponse ();
if ( e_AJAX_REQUEST )
2006-12-02 04:36:16 +00:00
{
2011-12-01 22:08:23 +00:00
$response -> setParam ( 'meta' , false )
-> setParam ( 'render' , false )
-> send ( 'default' , false , true );
exit ;
2009-09-28 19:17:59 +00:00
}
2011-12-01 22:08:23 +00:00
$response -> sendMeta ();
2012-06-14 04:11:52 +00:00
// -------------- Experimental -----------------
2012-06-18 13:00:47 +00:00
// unset($_SESSION['E:SOCIAL']);
2012-06-14 04:11:52 +00:00
2012-06-14 11:16:13 +00:00
if ( vartrue ( $_GET [ 'provider' ]) && ! isset ( $_SESSION [ 'E:SOCIAL' ]) && e107 :: getPref ( 'social_login_active' , false ) && ( e_ADMIN_AREA !== true ))
2012-06-14 04:11:52 +00:00
{
require_once ( e_HANDLER . " hybridauth/Hybrid/Auth.php " );
$config = array (
" base_url " => SITEURL . $HANDLERS_DIRECTORY . " hybridauth/ " ,
" providers " => e107 :: getPref ( 'social_login' , array ())
);
2012-06-14 11:16:13 +00:00
// print_a($config);
2012-06-14 04:11:52 +00:00
// $params = array("hauth_return_to" => e_SELF);
$hybridauth = new Hybrid_Auth ( $config );
$prov = ( ! isset ( $config [ 'providers' ][ $_GET [ 'provider' ]])) ? " Facebook " : $_GET [ 'provider' ];
$adapter = $hybridauth -> authenticate ( $prov );
$user_profile = $adapter -> getUserProfile ();
$prov_id = $prov . " _ " . $user_profile -> identifier ;
if ( $user_profile -> identifier > 0 )
{
if ( ! $sql -> db_Select ( " user " , " * " , " user_xup = ' " . $prov_id . " ' " )) // New User
{
$user_join = time ();
$user_pass = md5 ( $user_profile -> identifier . $user_join );
$user_loginname = " xup_ " . $user_profile -> identifier ;
$insert = array (
'user_name' => $user_profile -> displayName ,
'user_email' => $user_profile -> email ,
'user_loginname' => $user_loginname ,
'user_password' => $user_pass ,
'user_login' => $user_profile -> displayName ,
'user_join' => $user_join ,
'user_xup' => $prov_id
);
if ( $newid = $sql -> db_Insert ( 'user' , $insert , true ))
{
e107 :: getEvent () -> trigger ( 'usersup' , $insert );
if ( ! USERID )
{
require_once ( e_HANDLER . 'login.php' );
$usr = new userlogin ( $user_loginname , $user_pass , 'signup' , '' );
}
}
}
else // Existing User.
{
}
}
// echo "CHECKING";
$_SESSION [ 'E:SOCIAL' ] = ( array ) $user_profile ;
echo " USERNAME= " . USERNAME ;
echo " <br />USEREMAIL= " . USEREMAIL ;
echo " <br />USERIMAGE= " . USERIMAGE ;
// print_a($_SESSION['E:SOCIAL']);
}
// -------------------------------------------
2011-12-01 22:08:23 +00:00
include_once ( HEADERF );
eFront :: instance () -> getResponse () -> send ( 'default' , false , true );
include_once ( FOOTERF );
2009-09-28 19:17:59 +00:00
exit ;
2008-01-12 16:51:43 +00:00
2011-12-01 22:08:23 +00:00
// BOOTSTRAP END
2006-12-02 04:36:16 +00:00