473,382 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

CMS, login

103 100+
I am looking through the book:
https://www.packtpub.com/web-develop...php-and-jquery
On chapter two they give simple CMS example, but i am getting errors when loging.

Could you please explain, which part of code checks username and password i submit with the form.

I do not understand program flow.
I visit: "http://localhost/cms2/ww.admin/"
It has a form with username and password and submit button. If i check cms2/ww.admin/index.php it does not contain the form, captcha and submit button, neither none of included files. The question is how this website works?

{
By the way, it does not work, because it complains that password is wrong, although it is correct.
I go to http://localhost/cms2/ww.admin

input username, password and captcha.

I am redirected to: http://localhost/cms2/ww.admin/index...sg=loginfailed

and javascript message pops-it: login incorrect. if you've forgotten your password, please use the Forgotten Password form.

}

The content of files is below. The form file and many other captcha and login related files exists in this CMS. But they, as i wrote are not included in cms2/ww.admin/index.php.

I feel i miss some powerfull programming concept, when forms are included and files are loaded, although it is not described in script.

Could you please look through the files below and point-out at which place form and captcha is included?

apache2\htdocs\cms2\ww.admin\index.php
requires "apache2\htdocs\cms2\ww.admin\header.php"
which requires "apache2\htdocs\cms2\ww.admin\admin_libs.php"
which requires "/cms2/ww.incs/basics.php" .


I visit: "http://localhost/cms2/ww.admin/"
This loads
apache2\htdocs\cms2\ww.admin\index.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //apache2\htdocs\cms2\ww.admin\index.php
  3. require 'header.php';
  4. echo 'you are logged in!';
this requires "apache2\htdocs\cms2\ww.admin\header.php"
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //apache2\htdocs\cms2\ww.admin\header.php
  3. header('Content-type: text/html; Charset=utf-8');
  4. require 'admin_libs.php';
  5. ?>
  6. <html>
  7.     <head>
  8.         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  9.         <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
  10.         <link rel="stylesheet" href="/ww.admin/theme/admin.css" type="text/css" />
  11.         <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/south-street/jquery-ui.css" type="text/css" />
  12.     </head>
  13.     <body>
  14.         <div id="header"> 
  15.             <div id="menu-top">
  16.                 <ul>
  17.                     <li><a href="/cms2/ww.admin/users.php">Users</a></li>
  18.                     <li><a href="/cms2/ww.incs/logout.php?redirect=/ww.admin/">Log Out</a></li>
  19.                 </ul>
  20.             </div>
  21.         </div>
  22.         <div id="wrapper">
  23.  
this requires "apache2\htdocs\cms2\ww.admin\admin_libs.php"
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // apache2\htdocs\cms2\ww.admin\admin_libs.php
  3. require $_SERVER['DOCUMENT_ROOT'].'/cms2/ww.incs/basics.php';
  4.  
  5. function is_admin(){
  6.     if(!isset($_SESSION['userdata']))return false;
  7.     if(
  8.         isset($_SESSION['userdata']['groups']['_administrators']) ||
  9.         isset($_SESSION['userdata']['groups']['_superadministrators'])
  10.     )return true;
  11.     if(!isset($_REQUEST['login_msg']))$_REQUEST['login_msg']='permissiondenied';
  12.     return false;
  13. }
  14. if(!is_admin()){
  15.        /* print_r('SCRIPTBASE'.SCRIPTBASE);
  16.         // SCRIPTBASEC:/Bitnami/wampstack-5.4.38-0/apache2/htdocs/cms2/ */
  17.  
  18.     require SCRIPTBASE.'ww.admin/login/login.php';
  19.     exit;
  20. }
This requires "/cms2/ww.incs/basics.php"
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // apache2\htdocs\cms2\ww.incs\basics.php
  3. session_start();
  4. function __autoload($name) {
  5.     require $name . '.php';
  6. }
  7.  
  8. /* added http://php.net/manual/en/function.spl-autoload-register.php */
  9. spl_autoload_register("__autoload");
  10.  
  11.  
  12. function dbAll($query,$key='') {
  13.     $q = dbQuery($query);
  14.     $results=array();
  15.     while($r=$q->fetch(PDO::FETCH_ASSOC))$results[]=$r;
  16.     if(!$key)return $results;
  17.     $arr=array();
  18.     foreach($results as $r)$arr[$r[$key]]=$r;
  19.     return $arr;
  20. }
  21. function dbInit(){
  22.     if(isset($GLOBALS['db']))return $GLOBALS['db'];
  23.     global $DBVARS;
  24.     $db=new PDO('mysql:host='.$DBVARS['hostname'].';dbname='.$DBVARS['db_name'],$DBVARS['username'],$DBVARS['password']);
  25.     $db->query('SET NAMES utf8');
  26.     $db->num_queries=0;
  27.     $GLOBALS['db']=$db;
  28.     return $db;
  29. }
  30. function dbOne($query, $field='') {
  31.     $r = dbRow($query);
  32.     return $r[$field];
  33. }
  34. function dbLastInsertId() {
  35.     return dbOne('select last_insert_id() as id','id');
  36. }
  37. function dbQuery($query){
  38.     $db=dbInit();
  39.     $q=$db->query($query);
  40.     $db->num_queries++;
  41.     return $q;
  42. }
  43. function dbRow($query) {
  44.     $q = dbQuery($query);
  45.     return $q->fetch(PDO::FETCH_ASSOC);
  46. }
  47. define('SCRIPTBASE', $_SERVER['DOCUMENT_ROOT'] . '/cms2/');
  48. print_r ($_SERVER['DOCUMENT_ROOT']);
  49. require SCRIPTBASE . 'private/config.php';
  50. if(!defined('CONFIG_FILE'))define('CONFIG_FILE',SCRIPTBASE.'private/config.php');
  51. set_include_path(SCRIPTBASE.'ww.php_classes'.PATH_SEPARATOR.get_include_path());
  52.  
Oct 17 '15 #1
1 9545
gintare
103 100+
I am sorry, seems i was too tired to notice text. The reply is
that there is a line in the last file "cms2\ww.admin\admin_libs.php" which loads form and captcha:
Expand|Select|Wrap|Line Numbers
  1. require SCRIPTBASE.'ww.admin/login/login.php';
Oct 18 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: koolyio | last post by:
Hey, could you please tell me what is wrong with my login script. I just started learning php. CODE: login.php <? session_start(); header("Cache-Control: private"); ?>
5
by: Simon | last post by:
Hi, I have a Login.php page that logs the user in and out. I has two forms within the page, (depending on what we are trying to do), either one to log in or out. The form calls itself using a...
1
by: Tom Jones | last post by:
Hi, I am using the HttpWebRequest and HttpWebResponse classes to pull information from a web server on the internet. I have an account on one of the webservers that I need to log into...
2
by: Beginner | last post by:
I know this is an old question, but searching all over the internet plus several MS security conferences, still haven't got a straight anwser. Basically, the login.aspx is on one dedicated server...
4
by: nicholas | last post by:
Hi, Got an asp.net application and I use the "forms" authentication mode defined in the web.config file. Everything works fine. But now I would like to add a second, different login page for...
2
by: IdleBrain | last post by:
Hello All: I used a Login control to authenticate a user to login. The problem is that when I login with good username & password, the login view would say that the login was successful. But...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
4
by: Freedolen | last post by:
Hi All, I had a perl script which is used to login in a web page, but it gives the error as "301 Moved Permanently". What does this means and how can it be rectified? Can anyone help on this? ...
3
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it...
13
by: Apostle | last post by:
Hi all, after thinking for sometimes, I thought it will be great opportunity to learn if I will start from scratch and build my own register/login system. Here is the thread that I will be posting...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.