Total Pageviews

Sunday, June 19, 2011

Assignment 12 - Rich Text Editor (Ability to modify text from a database file directly)

Definition:  An RTE adds WYSIWYG (What You See Is What You Get) editing to our web pages. 

TO DO: 
1) Created RTE table in phpMinAdmin


I uploaded the files listed in the folder: 
sprokets > fckeditor  (FOLDER)
sprokets > rte_test.php (requires admin login)

    When I log in as admin and go to this page it looks like this after I finished editing in the box: 
 2) Change line 37 in fckconfig.js

FCKConfig.BaseHref = 'http://zephir.seattlecentral.edu/~horsey01/sprockets/';
  (now test with rte_test.php)

Reaching the config.php: 

fckeditor/editor/filemanager/connectors/php/config.php

3) changes to the file lie on line 46: 
require_once '/home/classes/horsey01/public_html/sprockets/inc_0700/config_inc.php';  


// Path to user files relative to the document root.
//$Config['UserFilesPath'] = '/userfiles/' ;
$Config['UserFilesPath'] = VIRTUAL_PATH . 'upload/rte/';

// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Useful if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = PHYSICAL_PATH . 'upload/rte/';  

3a) then in fckconfig.js file, line 31
FCKConfig.EditorAreaCSS = 'http://zephir.seattlecentral.edu/~dpham004/foo/themes/DarkRitual/default.css'';  

   3b)Then modified the default Dark Ritual stylesheet (style.css) and renamed it to  fckeditor.css
 Made the following changes in lines 38-44: 
body {
    /*background: #333 url('img/bg.gif');*/
    color: #333;
    /*font: normal 62.5% "Lucida Sans Unicode",sans-serif; */
    font: normal 75% "Lucida Sans Unicode",sans-serif;
    margin: 3% 0;
 } 

4) Then I changed line 99 in fckconfig.js from 

FCKConfig.ToolbarSets["Default"] = [...  to  FCKConfig.ToolbarSets["Goldilocks"] = [
 
5) Now, I just have to upload the files in the appropriate places:
sprockets > fckeditor/editor/filemanager/connectors/php/config.php
sprockets > fckeditor > fckconfig.js
sprockets > themes > Dark Ritual > fckeditor.css

file description here: 

--------------TROUBLESHOOTING ----------------------

Somehow the Editor stopped working after these changes took place. I must have made changes that I should not have made

Backtracking and got the editor to work again but not the stylesheet to show up properly... See below:
File uploading logging here:
________________

HOURLY LOG: 
6-18-2011 -- 3 hours implementing instructions and back tracking 
6-19-2011 -- 2.5 hours trying to figure out what I did wrong in the fckconfig.js (backtracked)

Assignment 11 - Upload Image

Confused about the file upload_image.php file... was not able to find this file

I'm not sure where to add the following code: 

<?php
      startSession(); # wrapper for session_start()
      if(isset($_SESSION["AdminID"]))
      {# only admins can see 'peek a boo' link:
            echo '<div align="center"><a href="' . VIRTUAL_PATH . 'upload_form.php?' . $_SERVER['QUERY_STRING'] . '">UPLOAD IMAGE</a></div>';
            /*
            # if you wish to overwrite any of these options on the view page,
            # you may uncomment this area, and provide different parameters:                               
            echo '<div align="center"><a href="' . VIRTUAL_PATH . 'upload_form.php?' . $_SERVER['QUERY_STRING'];
            echo '&imagePrefix=m';
            echo '&uploadFolder=upload/';
            echo '&extension=.jpg';
            echo '&createThumb=TRUE';
            echo '&thumbWidth=50';
            echo '&thumbSuffix=_thumb';
            echo '&sizeBytes=100000';
            echo '">UPLOAD IMAGE</a></div>';
            */                                 
           
      }
      if(isset($_GET['msg']))
      {# msg on querystring implies we're back from uploading new image
            $msgSeconds = (int)$_GET['msg'];
            $currSeconds = time();
            if(($msgSeconds + 2)> $currSeconds)
            {//link only visible once, due to time comparison of qstring data to current timestamp
                  echo '<div align="center"><script type="text/javascript">';
                  echo 'document.write("<form><input type=button value=\'IMAGE UPLOADED! CLICK TO VIEW!\' onClick=history.go()></form>")</scr';
                  echo 'ipt></div>';
            }
      }
?>
  Was I supposed to drop it directly below the <td> in the view page? Here's what it looks like anyway...
I also recently had to drop the upload_form.php & upload_form_execute.php in order for the hyperlink "Upload Image" to work properly. Images will reside in the "upload" folder 

Looks like it is working properly
extension should match with the BookId so that the image corresponds with the item. 


Looks like error testing works. It did not allow me to add animated .gif files and files that exceed 1000000 kbs. 


Viola! Image uploading works!




NOTES: 
Although the upload_form.php and the upload_execute.php have the "upload" extension, these files do NOT reside in the "upload" folder. 

- Only thumbnails will show when admin modifies the image in image upload executor.... 




Hourly Log: 
6-18-2011 -- .5 hour spent on uploading files and making sure they show up
                     1.5 hours troubleshooting and trying out code (dropping php code into the right file!!!)
                     1 hour implementing the thumbnail next to the list view page

Saturday, June 18, 2011

Assignment 10 - Admin Login

Added the files to the server and updated the config_inc.php file to include "Admin" login link. It now links to Admin login page. Please see the HW construction page for password.

Looks like everything is linked in order. I dropped the admin folder into the main root of the web application and everything seems to be in order!

Extra Credit: nmEdit is a table editor
1) edit line 25 in nmEdit.php


$myDB = "horsey01"; #identify current database
$defaultTable = "test_Customers";  #identify which table you wish to show by default

Logging on as admin to access the table editor on the menu:
Initially, the table looks like this, now after modifying the nmEdit file: 
$myDB = "dpham004"; #identify current database
$defaultTable = "test_Books";  #identify which table you wish to show by default
$allowEdit = 1; #1 allows add/edit/delete capabilities, zero disallows and hides
$allowDelete = 0; #1 allows deletes (no effect on update) zero disallows and hides
$allowQuery = 1; #1 allows SQL queries but no commands.  Zero disallows and hides
$allowCommand = 0; #1 allows raw SQL commands (update, alter) zero disallows
$useSandwich = TRUE; #If true will attempt to load sandwich_header_inc.php & sandwich_footer_inc.php from current theme
#$config->theme = "DarkRitual"; #Want to override the current theme on a single page basis?  Uncomment this!

uploaded the sandwich folders into Dark Ritual and testing now...

Looks like it works! Horray!
File Description:

Assignment 9 - Paging

 Couple confusions: I'm not sure if I've come across this error but when first reading this, it was a bit confusing...

# Create instance of new 'pager' class
$myPager = new Pager(2,'',$prev,$next,'');
$sql = $myPager->loadSQL($sql);  #load SQL, add offset – be sure to run SQL through the Pager, or it will error!

 TROUBLESHOOTING: I've included the Pager.php into the inc_700 folder and it seemed to work now

Link to pager for Books (list form) 

The view pager is slightly different from the book_view page. I've included the metaDescription next to the image of the book rather than just the title. 

  however, book_view_pager looks identical to that of book_view page. Is that supposed to happen?

See Descriptions page here, 

HOURLY LOG: 
6-18-2011 - 2 hours editing class file to fit assignment
                    1.5 hours troubleshooting

Assignment 8 Encounters & bugs

Onto Assignment 8
Current problems: I am not sure what this error means... It looks like my links are named correctly.

Is it because there is something there that doesn't match?

--------------------------------------------------------
Looks like I changed some things since the last time I had this error. I had to change the following line:
number_format((float)$row['Price'],2) to dbOut($row['ISBN']) since ISBN is no longer a float, but rather it is text. Now I'm facing this error:
So, the following error I encountered above is kind of linked to to top section of my list page, line 17-18. Originally, I modified it from
# SQL statement
$sql = "select MuffinName, MuffinID, Price from test_Muffins";

to this:

# SQL statement
$sql = "select BookID, Title, Author, ISBN, Description, MetaDescriptions, MetaKeywords from test_Books";

I'm not sure if I wrote this section of the book_list page right:
if(mysqli_num_rows($result) > 0)
{          #records exist - process
    while($row = mysqli_fetch_assoc($result))
    {      # process each row
         echo '<div align="center"><a href="' . VIRTUAL_PATH . 'book_view.php?id=' . (int)$row['BookID'] . '">' . dbOut($row['Title']) . '</a>';
         echo ' <i>Here with this ISBN:</i> <font color="red">$' . dbOut($row['ISBN'])  . '</font></div>';
    }
-------------------------------COMPLETED WORK------------------------------------
Looks like my List page is working finally! I just had the link to the subfolder wrong

   # '../' works for a sub-folder.  use './' for the root 
  require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials 

I had to update the extension... After I uploaded the pictures, my View page looks good to go as well!

Here is a link to my Descriptions page

Hourly Log:
6-05-2011-- 2 hours on writing sql statement & editing book_list & book_view php files
6-18-2011 -- 5 hours on troubleshooting

Thursday, June 16, 2011

Assignment 7 Woes

Currently trying to fix my A7 to include the dynamic meta tags and title pages. I've already encountered a fundamental problem:

Left-side nav links seem to replicate themselves rather than replace the links listed in the theme. See here

The problems lies in my config_inc.php file:
// DECLARING ARRAY IN ADVANCE SHOULD BE UNNECESSARY - TRIP HAZARD!!$nav1 = array(); #nav1 is the current left nav - tilde separator below splits text of link from title attribute

//$nav1 = array(); #nav1 is the current left nav - tilde separator below splits text of link from title attribute
if(startSession() && isset($_SESSION['AdminID'])){$nav1[ADMIN_DASHBOARD] = "ADMIN~Go to Administrative Page";}#admin page added to link only if logged in
$nav1['index.php'] = "Home~A model for building largely static web pages";
$nav1['models/demo_contact.php'] = "Contact~A demo for building postback forms";
$nav1['models/demo_mysql.php'] = "mysql Classic~A demo for building mysql (classic) web applications";
$nav1['models/demo_mysqli.php'] = "mysqli Improved~A demo for building mysqli (improved) web applications";
$nav1['models/demo_shared.php'] = "MySQL Shared~A demo page for building mysqli shared connection based applications.";
$nav1['error_test.php'] = "Error Test~Click to see how errors are currently being handled";
$config->nav1 = $nav1; #add to global config object - now available in all header/footers


//echo makeLinks($config->nav1,'<li>','</li>');  #link arrays are created in config_inc.php file
echo makeLinks($config->nav1,'<li>','</li>'); #link arrays are created in config_inc.php file
# CONTENT CONFIGURATION AREA (theme, content areas & nav arrays for header/footer )-----------------------------------------


I'm not sure whether to write the makeLinks config written this way or the other. The latter just repeats the nav hyperlinks.

Also, I noticed that the index that went with the original Dark Ritual theme is being overwritten; is that supposed to happen? I don't have any of the lorem ipsum that I was expecting nor do I know how to make it come back up.

----------------------BREAK THROUGH ON A7-----------------------------------
Looks like I had to trace back where the sidebars resided (in this case, in the footer >.< not the header) and I had to paste the echo makeLinks statement in the footer_inc.php, not in config_inc.php file

Now would be nice to figure out how to have phpMinAdmin log in follow the theme that I currently have...

Monday, May 23, 2011

Sessions/Login Class Notes: 5-23-11

Cookies know the exact path; on the machine, there’s a place where they are stored
            they store the string that looks like the server address
   NOTE: multiple browsers have their own mechanism for their cookies
  • cookies are associated to the browser, (if you shut the window down, it doesn’t change what’s going on in the server…. When you hit a button on the site, it then connects to the server and then logs a user off)

Sessions requires:
1)     Cookie matching data on the server (if the cookie stays on the machine
2)     Log on status (log in/out)
Sessions are stored file-based, stored outside of the web root (safest place it could be)
·        you don’t want hackers to see sessions information, don’t want that accessible to anyone else

What can be hacked:
-         Number that is part of the session (unique self-incremented by server)
-         Time: uniqueness of the session 

Concept of “back ups”:
School makes these “tapes”: daily backed up, in case there are old worms (buried deep from back when)
Encrypting the password:
– passes the data onto the sessions page
session_start( ): high annoyance, every one of them may or may not need this
  gets a nasty error msg (to tell you that you’re already started)
  some use @ in front of session_start( )
if(!isset($_SESSION)){session_start();}  // superglobal here, if session hasn't start, start here

$sCustomerID = trim($row['CustomerID']); //Grab the Customer's unique ID, from a database
$_SESSION["sCustomerID"] = $sCustomerID; //Enter variable into session variable
$_SESSION["FirstName"] = $FirstName;
$_SESSION["Email"] = $Email;

echo $_SESSION["Email"]; // to see what comes in

session_data: when you store it here, it is accessible
cookie_data: 

config file: loads the constants (gets called every time and cannot be changed)
 everything that the pages use are now totally wiped cleaned

Application level:


To banish/lock someone from a web page: (NOTE: this goes in the private page, not in public)
if(!isset($_SESSION)){session_start();}
if(!isset($_SESSION['sCustomerID'])) // do they have a customerID, do they exist?
{ //no session var
    myRedirect("login.php?msg=5");
//send user back to login page, as session has timed out
}     // puts a msg back to the log in page, gotta be a “doorstep”
session would have a time-out, so that it rules out hackers… makes it private
 
NOTE: rounded ones are NOT pages (they are doorstep “process” prompts)
All orange (are protected, yellow is log-in protected)

  HOW to LOG IN:
1)     Username: usually an email (guaranteed uniqueness, domain, contactable to send msg test)
                     developer@example.com
2)     password: asdfasdf
Folder for application:
One table & one folder: easy to get rid/move or install somewhere else
root should be reserved to client’s actual pages
Prefix “admin” indictor for which files can make it locked out (with the “if” statement)
 
One-way encryption: put data in, no one can get it back (password “SHA” will jumble it up)
            Password gets asked, then compared with mangled version to allow access

 
admin_login:
Application root:

NOTES:
ENUM -
Privilege ENUM('admin','superadmin','developer') DEFAULT 'admin',


Note: superadmin: client
            admin: you the developer
           
In-class DIRECTIONS:
·        Drag admin folder into the application folder
·        Copy admin_only_inc.php into “inc_700” folder
·        Look at nmAdmin.sql > 
·        inc_700 implies that there is ONLY 1 folder that contains these sets of info
line 41 in config_inc is commented out since we don’t want to keep it permanently


Wednesday, May 18, 2011

Assignments 4-6

Currently my Construction page should have Assignment 1-3 up to date. Assignment 4 is currently being re-demolished to match my theme.

----------------------------------------

RECAPTCHA for A4 currently takes the theme used for A2.  I tweaked with the stylesheet so that it would fit like how it should. Recaptcha site

TROUBLES with A4:
The only problems that I run into is setting the position to "fixed" and not being able to access the links on my sidebar menu. When I don't set the position to be fixed, pieces of the table align too far to the left and covers the side bar. File Description here.

A6:
I have db_test but not sure how to create the database in mySQL very well. Seeking tutor ATM

RECENT UPDATES:
Just recently got my username and password set up with dreamhost. To make my life a little easier, my log in information should match whatever horsey01 I am using for my email. Cyberduck finally took my password after several frustrating attempts.

------------------------------------------------------ HW Construction page
Link to Assignment 6 is here!
There was some confusion with the database that showed up. Only the first name of the database showed up. I need to relook at the the database contents.

ITC 280 Classes/ Paging Class Notes 5-18-11


Review: assignment folders end on A7, everything is in your application folder (funky_fresh_test)
List/View: A8 is done indicator (link to your developing         Noun_List.php (plural)/noun_view.php (singular)
  Ex: Records_List.php

Demo folder – is the demolished version of the file (DO NOT put all your files in this folder)
Roots: Lowest Level of (horsey01, is the physical root server root)
public_html: web root on zephyr
Application root: web root (so index.php)
Class is a “blue print of an object”, represent an entire new world of how to program
            powerful applications use this, out of flow
(“property” is like a quality) – must caps the first letter of the class
  ex:
   
class Car
{
  public $color; //the color of the car
  public $mph; //the maximum speed (integer)
  public $price; //the price of the car, in dollars (float)
  public $model; //the model of the car

  function go($hours) (METHODS)
  {
    return ($this->mph * $hours); //returns miles traveled given time
  }
}
    Functions & Classes: both out of flow of the code
   Constructor Function: constructor allows us to set the ground rules for the creation of an object
     requires __ (two underscores)
      EX:
function __construct($model,$color,$price,$mph) //constructor function, w/o $ sign, it thinks it is a constant
   {
      $this->model = $model; //assigning data to properties via the constructor
      $this->color = $color;
      $this->price= $price;
      $this->mph= $mph;
   }
}
constructor is the parentheses of the class (how the stuff gets put into the class)
  in other classes (in C#, class name is class, can have only 1 constructor per class)
Object is an example of a class [in action”], but sometimes a class can be used separately from an object.
NOTE: name of the object needs to be generic, nothing specific
  $myCar = new Car();
  $myCar->color = "red"; 
In every other language, there is a period here (“My car ‘dot’ color”), period is concatenation
  $myCar->price = 60000;
  $myCar->model = "Ferrari";
  $myCar->mph = 140;
  echo "My " . $myCar->model . " can go " . $myCar->go(.5) . " in half an hour!";
  NOTE: in objects (assigning it to the property), use “->
                 in class (declaring properties), use “$
Paging: trick at the bottom of the page, to be able to go through multiple records
    Pager: # icon at the bottom the list page, that lets users navigate between the list pages
            designed for the “list” page, not the “view” page
         ex:
$myPager = new Pager(10);  --- how many number of records on a page
 $myPager = new Pager(20,'','<img src="images/arrow_prev.gif" border="0" />','<img src="images/arrow_next.gif" border="0" />','');
 ORDER: 1st, previous, next, last
Methods: Function within a class, used to manipulate the class properties and produce results, things that manipulate data… ( a term called, not a term used in the actual programming php language)
Properties: things that store pieces of data
Instantiation: is “creation”
Child Classes: born from the original, creating something sort of new but incorporates some of previous class
Encapsulation: “hiding” complex code in the class
autoload: will look for any number of pages for a particular name of a file