SitePoint Sponsor

User Tag List

Page 2 of 4 FirstFirst 1234 LastLast
Results 26 to 50 of 84
  1. #26
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured out how to get it to print the number of rows. But when I try to get it to print paragraph tags around the number, so it will use CSS margins, it breaks. I also figured how to change the default sort order to desc.

    Parse error: parse error, expecting `','' or `';'' in /home/joshuasp/public_html/widescreenadvocate/watchdog.php on line 116
    PHP Code:
    // Print out the data 
    echo '<p>';
    echo 
    'Number of DVD's in database:';
    echo '
    $num_rows';
    echo '
    </p>';
    echo '
    <table>'; 
    echo '
    <thead>'; 
    echo '
    <tr>'; 

  2. #27
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    echo 'Number of DVD\'s in database:'
    You must escape the ' character.

    I'm currently coding a complete rewrite with extended functionality, stay tuned.

  3. #28
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool. I can't believe I had it working! It was a good feeling. I should probably let you know now, that I need to add three fields. oar, method, and format. I have been adding those fields already to the current php files, just have to manually edit them each time. No biggie though.

  4. #29
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    New fields in the database?
    If yes, then please give me some example rows for local testing.

  5. #30
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Gaheris
    New fields in the database?
    If yes, then please give me some example rows for local testing. [img]images/smilies/smile.gif[/img]
    Title > Studio > Year > OAR > Method > Format
    My Neighbor Totoro > 20th Century Fox > 1993 > 1.85:1 > Open Matte >CLV LD
    Matilda > Columbia Tristar > 1996 > 2.35:1 > Pan & Scan > R2 DVD
    Pippi longstocksing > Columbia Tristar > 1998 > 1.85:1 > Pan & Scan > None
    Operation Dumbo Drop > Walt Disney > 1996 > 1.85:1 > Pan & Scan > R2 DVD
    Honey I Shrunk the Kids > Walt Disney > 1994 > 1.85:1 > Pan & Scan > CAV LD



    Hope that is enough.
    Last edited by Joshua Clinard; Nov 4, 2003 at 20:23.

  6. #31
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, what's format though, you only supply it once and there it's 'None'. What fields are required? Title, Studio, Year of course, what about the others?

  7. #32
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Gaheris
    Okay, what's format though, you only supply it once and there it's 'None'. What fields are required? Title, Studio, Year of course, what about the others?
    I added a few more database examples to my previous post. The only required fields are Title, Studio, and Year.

    Thanks again for helping so much. In return for your help, I would like to put $10 in your paypal account.

  8. #33
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whoah! It's done and working. I still want to add a couple of features, but I can give you a sneak preview if you want.

  9. #34
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please do! I'm eager to start beta testing this. I have a few other people that are going to provide feedback on this, so it may need some additional tweaks, but nothing major I don't think.

    Thanks!

  10. #35
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I provided a small and dirty stylesheet, just save it into same directory the php file is in. Then read the installation notes, for a quick setup you want to edit the CONFIG_DB_* and CONFIG_ADMIN_PWD defines.

    Note, I changed the db structure, I added a id field to the dvd table. (int, auto increment). I also created a new table studios (id => int, auto increment, studio => varchar)

    Note that it isn't finished. The features available should work since I tested them. Missing or incomplete are for example the error display functions and some more manage functionality.

    And something for everyone who is disgusted when he sees my code: 'I know. '

    ddb.php
    PHP Code:
    <?php
    /*
    +---------------------------------------------------------------+
    | DVD Database                                                  |
    +---------------------------------------------------------------+
    | Author       : Frederik "Gaheris" Bülthoff                    |
    | Created      : Tuesday, 04 November                           |
    |                                                               |
    | Description  : This script displays a list of dvds, new ent-  |
    |                ries can be added by users. Completly manage-  |
    |                able with a admin interface. For example, new  |
    |                entries must be approved.                      | 
    | Installation : Go trough the configuration defines in the     |
    |                'constants' part. But do not change the sub-   |
    |                part 'Application'. Then simply run the script |
    |                You may have to create the CONFIG_ADMIN_LOG    |
    |                file.
    +---------------------------------------------------------------+
    */

    /*
    +---------------------------------------------------------------+
    | Constants                                                     |
    +---------------------------------------------------------------+
    */

    /* Application */

    define('TAG',                   'DDB');
    define('TITLE',                 'DVD DataBase ('.TAG.')');
    define('VERSION',               '0.0.1');
    define('AUTHOR',                'Frederik "Gaheris" Bülthoff');

    /* Configuration */

    define('CONFIG_DB_HOST',        'localhost');
    define('CONFIG_DB_NAME',        'joshuasp_dvdlist');
    define('CONFIG_DB_USER',        'root');
    define('CONFIG_DB_PWD',         '');

    define('CONFIG_ADMIN_PWD',      'ddb');
    define('CONFIG_ADMIN_LOG',      'log.txt');

    define('DEBUG',                 true);

    /* Available displays */

    define('DISPLAY_MAIN',          'Main');
    define('DISPLAY_LOGIN',         'Login');
    define('DISPLAY_MANAGE',        'Manage');
    define('DISPLAY_THANKS',        'Thanks');

    /* Available error displays */

    define('DISPLAY_ERROR_ERR',     'Error');
    define('DISPLAY_ERROR_FAT',     'Fatal');
    define('DISPLAY_ERROR_DB',      'DB');

    /*
    +---------------------------------------------------------------+
    | Functions                                                     |
    +---------------------------------------------------------------+
    */

    /* Misc functions */

    function array_csort() {
        
    $args func_get_args();
        
    $marray array_shift($args);

        
    $i 0;
        
    $msortline "return(array_multisort(";
        foreach (
    $args as $arg) {
            
    $i++;
            if (
    is_string($arg)) {
                foreach (
    $marray as $row) {
                    
    $sortarr[$i][] = $row[$arg];
                }
            } else {
                
    $sortarr[$i] = $arg;
            }
            
    $msortline .= "\$sortarr[".$i."],";
        }
        
    $msortline .= "\$marray));";

        eval(
    $msortline);
        return 
    $marray;
    }

    function 
    get_isp($ip '') {
        if (empty(
    $ip)) {
            
    $ip $_SERVER['REMOTE_ADDR'];
        }
        
    $longisp gethostbyaddr($ip);
        
    $isp     explode('.'$longisp);
        
    $ispr    array_reverse($isp);
        
    print_r($ispr);
        
    print_r($isp);
        
    $isp     $ispr[1].'.'.$ispr[0];
        return 
    $isp;
    }

    function 
    database_connect()
    {
        static 
    $conn;
        if (!
    $conn) {
            
    $conn mysql_connect(CONFIG_DB_HOSTCONFIG_DB_USERCONFIG_DB_PWD); 
            if (!
    $conn) {
                
    $text = (DEBUG) ? 'Unable to connect to DB host: ' mysql_error()
                                : 
    'There has been an error, please contact our lovely administrator';
                
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                
    display_Error($data);
                exit;
            }
            
            
    $result mysql_select_db(CONFIG_DB_NAME);
            if (!
    $result) {
                
    $text = (DEBUG) ? 'Unable to select DB \'' $db_name ': \'' mysql_error()
                                : 
    'There has been an error, please contact our lovely administrator';
                
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                
    display_Page($data);
                exit;
            }
        }
        
        return 
    $conn;
    }

    /* Display manager */

    function display_Page($_data = array(), $_type DISPLAY_MAIN)
    {
        
    $a_available_defines  get_defined_constants();
        
    $a_available          = array();
        foreach (
    $a_available_defines as $index => $value) {
            if (
    substr($index08)  == 'DISPLAY_' and
                
    substr($index85) != 'ERROR') {
                
    $a_available[] = $value;
            }
        }
        if (
    count($a_available) > 0) {
            if (
    in_array($_type$a_available)) {
                
    $func 'display_' $_type;
                if (
    function_exists($func)) {    
                    
    call_user_func($func$_data);
                } else {
                    
    $msg = array('You called a known page',
                                 
    'The display_'.$_type.' function has not been yet implemented');
                    
    display_Error(array('msg' => $msg));
                    exit;
                }
            } else {
                
    $msg = array('You called an unknown page');
                
    display_Error(array('msg' => $msg));
                exit;
            }
        } else {
            
    $msg = array('No display defined');
            
    display_Error(array('msg' => $msg));
            exit;
        }
    }

    function 
    display_Error($_data = array())
    {
        
    $a_available_defines  get_defined_constants();
        
    $a_available          = array();
        foreach (
    $a_available_defines as $index => $value) {
            if (
    substr($index014)  == 'DISPLAY_ERROR_') {
                
    $a_available[] = $value;
            }
        }
        if (
    count($a_available) > 0) {
            
    $errorName = isset($_data['error']) ? $_data['error']: '';
            if (
    in_array($errorName$a_available)) {
                
    $func 'display_Error_'.$errorName;
                if (
    function_exists($func)) {
                    
    call_user_func($func$_data);
                } else {
                    
    $msg = array('The display function hasn\'t been implemented yet');
                    
    display_Error(array('msg' => $msg));
                    exit;
                }
            } else {
                
    display_Error_Error($_data);
                exit;
            }
        } else {
            
    // Simple die because we haven't gotten any error displays
            
    die('No error displays defined');
        }
    }

    /* Display functions  */

    function display_Main($_data = array())
    {
        
    $main_code  '';
        
    $main_code .= '<?xml version="1.0" encoding="iso-8859-1"?>';
        
    $main_code .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"';
        
    $main_code .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
        
    $main_code .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">';
        
    $main_code .= '    <head>';
        
    $main_code .= '        <title>'TITLE .' 'VERSION .'</title>';
        
    $main_code .= '        <link rel="stylesheet" type="text/css" href="'.TAG.'.css" media="all" />';
        
    $main_code .= '</head>';
        
    $main_code .= '<body>';
        
    $main_code .= '    <a name="top"></a><h1>'.TITLE.'</h1>';
        
    $main_code .= display_Messages(@$_data['msg']);
        
    $main_code .= display_AddForm();
        
    $main_code .= display_List();
        
    $main_code .= '    <p class="biglinks"><a href="#top">Back to the top</a></p>';
        
    $main_code .= display_Creator();
        
    $main_code .= '    <a href="'.$_SERVER['PHP_SELF'].'?action=admin">Admin</a>';
        
    $main_code .= '</body>';
        
    $main_code .= '</html>';
        echo 
    $main_code;
    }

    function 
    display_Login($_data = array())
    {
        
    $login_code  '';
        
    $login_code .= '<?xml version="1.0" encoding="iso-8859-1"?>';
        
    $login_code .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"';
        
    $login_code .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
        
    $login_code .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">';
        
    $login_code .= '    <head>';
        
    $login_code .= '        <title>Login - 'TITLE .' 'VERSION .'</title>';
        
    $login_code .= '        <link rel="stylesheet" type="text/css" href="'.TAG.'.css" media="all" />';
        
    $login_code .= '</head>';
        
    $login_code .= '<body>';
        
    $login_code .= '    <a name="top"></a><h1>'.TITLE.'</h1>';
        
    $login_code .= display_Messages(@$_data['msg']);
        
    $login_code .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?action=login">';
        
    $login_code .= '    <label for="pwd">Password</label>';
        
    $login_code .= '    <input type="password" name="pwd" id="pwd" />';
        
    $login_code .= '    <input type="submit" name="login" id="login" value="Login" />';
        
    $login_code .= '</form>';
        
    $login_code .= display_Creator();
        
    $login_code .= '</body>';
        
    $login_code .= '</html>';
        echo 
    $login_code;
    }

    function 
    display_Manage($_data = array())
    {
        
    $manage_code  '';
        
    $manage_code .= '<?xml version="1.0" encoding="iso-8859-1"?>';
        
    $manage_code .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"';
        
    $manage_code .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
        
    $manage_code .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">';
        
    $manage_code .= '    <head>';
        
    $manage_code .= '        <title>Manage - 'TITLE .' 'VERSION .'</title>';
        
    $manage_code .= '        <link rel="stylesheet" type="text/css" href="'.TAG.'.css" media="all" />';
        
    $manage_code .= '</head>';
        
    $manage_code .= '<body>';
        
    $manage_code .= '    <a name="top"></a><h1>'.TITLE.'</h1>';
        
    $manage_code .= display_Messages(@$_data['msg']);
        
    $manage_code .= '    <h2>Manage '.TITLE.'</h2>';
        
    $manage_code .= '    <p>Welcome, this little admin panel helps you manage the list.</p>';
        
    $manage_code .= display_Unauthorized();
        
    $manage_code .= display_StudioForm();
        
    $manage_code .= display_Creator();
        
    $manage_code .= '    <a href="'.$_SERVER['PHP_SELF'].'">Back to the list</a>';
        
    $manage_code .= '</body>';
        
    $manage_code .= '</html>';
        echo 
    $manage_code;
    }

    function 
    display_Thanks($_data = array())
    {
        
    $thanks_code  '';
        
    $thanks_code .= '<?xml version="1.0" encoding="iso-8859-1"?>';
        
    $thanks_code .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"';
        
    $thanks_code .= '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
        
    $thanks_code .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">';
        
    $thanks_code .= '    <head>';
        
    $thanks_code .= '        <title>Thanks - 'TITLE .' 'VERSION .'</title>';
        
    $thanks_code .= '        <link rel="stylesheet" type="text/css" href="'.TAG.'.css" media="all" />';
        
    $thanks_code .= '</head>';
        
    $thanks_code .= '<body>';
        
    $thanks_code .= '    <a name="top"></a><h1>'.TITLE.'</h1>';
        
    $thanks_code .= display_Messages(@$_data['msg']);
        
    $thanks_code .= '<p>Thanks for adding a new entry, it will have to be approved by a administrator before it will appear</p>';
        
    $thanks_code .= '<a href="'.$_SERVER['PHP_SELF'].'">Return to the the list</a>';
        
    $thanks_code .= display_Creator();
        
    $thanks_code .= '</body>';
        
    $thanks_code .= '</html>';
        echo 
    $thanks_code;
    }


    /* Sub-display functions */

    function display_Messages($_messages = array())
    {
        
    $msg_code '';
        if (
    count($_messages) > 0) {
            
    $msg_code .= '<ul id="msg">';
            foreach (
    $_messages as $message) {
                
    $msg_code .= '<li>'.$message.'</li>';
            }
            
    $msg_code .= '</ul>';
        }
        return 
    $msg_code;
    }

    function 
    display_AddForm()
    {
        
    database_connect();
        
    // Get possible studios
        
    $sql 'SELECT `id`, `studio` FROM `studios`';
        
    $result mysql_query($sql);
        if (!
    $result) {
            
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                            : 
    'There has been an error, please contact our lovely administrator';
            
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
            
    display_Error($data);
            exit;
        }
        
        
    // Generate markup
        
    $form_code  '';
        
    $form_code .= '<h2>Add dvd</h2>';
        
    $form_code .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?action=add" id="adddvd">';
        
    $form_code .= '<table>';
        
    $form_code .= '<tr>';
        
    $form_code .= '<td>Title <span class="req">*</span></td>';
        
    $form_code .= '<td><input type"text" name="title" id="title" size="20"/></td>';    
        
    $form_code .= '</tr><tr>';
        
    $form_code .= '<td>Studio <span class="req">*</span></td>';
        
    $form_code .= '<td><select size="1" name="studio" id="studio">';
        while (
    $row mysql_fetch_assoc($result)) {
        
    $form_code .= '<option value="'.$row['id'].'">'.$row['studio'].'</option>';
        }
        
    $form_code .= '</select></td>';
        
    $form_code .= '</tr><tr>';
        
    $form_code .= '<td>Year <span class="req">*</span> </td>';
        
    $form_code .= '<td><input type"text" name="year" id="year" size="20" maxlenght="4" /></td>';
        
    $form_code .= '</tr><tr>';
        
    $form_code .= '<td>Oar</td>';
        
    $form_code .= '<td><input type"text" name="oar" id="oar" size="20" /></td>';
        
    $form_code .= '</tr><tr>';
        
    $form_code .= '<td>Method</td>';
        
    $form_code .= '<td><input type"text" name="method" id="method" size="20" /></td>';    
        
    $form_code .= '</tr><tr>';
        
    $form_code .= '<td>Format</td>';  
        
    $form_code .= '<td><input type"text" name="format" id="format" size="20" /></td>';
        
    $form_code .= '</tr><tr colspan="2">';
        
    $form_code .= '<td><input type="submit" name="submit" id="submit" value="Add DVD"/></td>';
        
    $form_code .= '</tr>';
        
    $form_code .= '</table>';
        
    $form_code .= '</form>';
        
    $form_code .= '<span><span class="req">*</span> required</span>';
        
        return 
    $form_code;
    }

    function 
    display_List()
    {
        
    database_connect();
        
    // Settings
        
    $a_sortable     = array('title''studio''year''oar''method''format');
        
    $s_sortDefault  'title';
        
    $a_orderable    = array('asc' => SORT_ASC'desc' => SORT_DESC);
        
    $s_orderDefault 'desc';

        
    // Preprocessing
        
    (isset($_GET['sort'])) ? (in_array($_GET['sort'], $a_sortable) ? $sortBy $_GET['sort']
                                                                       : 
    $sortBy $s_sortDefault)
                           : 
    $sortBy $s_sortDefault;
        (isset(
    $_GET['order'])) ? (isset($_GET['order'], $a_orderable) ? $orderBy  $_GET['order']
                                                                       : 
    $orderBy  $s_orderDefault)
                                : 
    $orderBy $s_orderDefault;
        
        
    // Getting the data
        
    $sql  'SELECT `title`, `studio`, `year`, `method`, `format`, `oar` FROM `dvd` WHERE `auth` = 1';
        
    $result mysql_query($sql);
        if (!
    $result) {
            
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                            : 
    'There has been an error, please contact our lovely administrator';
            
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
            
    display_Error($data);
            exit;
        }
        
        
    // We must have data
        
    if (mysql_num_rows($result) == 0) {
            
    $list_code '<p>No entries</p>';
        } else {
            
    // Get rows
            
    $resArray = array();
            while (
    $row mysql_fetch_assoc($result)) {
                
    $resArray[] = $row;
            }
            
            
    // Free the data
            
    mysql_free_result($result);
            
            
    // Get studio data
            
    $sql 'SELECT `id`, `studio` FROM `studios`';
            
    $result mysql_query($sql);
            if (!
    $result) {
                
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                                : 
    'There has been an error, please contact our lovely administrator';
                
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                
    display_Error($data);
                exit;
            }
            
            
    $studios = array();
            while (
    $row mysql_fetch_assoc($result)) {
                
    $studios[$row['id']] = $row['studio'];
            }
            
            
    // Free the data
            
    mysql_free_result($result);
            
            
    // Presort
            
    $orderDiff   = ($orderBy == 'asc')   ? 'desc'      'asc';
            
    $orderTitle  = ($sortBy  == 'title')  ? $orderDiff 'asc';
            
    $orderStudio = ($sortBy  == 'studio') ? $orderDiff 'asc';
            
    $orderYear   = ($sortBy  == 'year')   ? $orderDiff 'asc';
            
    $orderMethod = ($sortBy  == 'method') ? $orderDiff 'asc';
            
    $orderFormat = ($sortBy  == 'format') ? $orderDiff 'asc';
            
    $orderOar    = ($sortBy  == 'oar')    ? $orderDiff 'asc';
            
            
    // Sort the data
            
    $resArray  array_csort($resArray$sortBy$a_orderable[$orderBy]);
            
            
    // Print out the data
            
    $size count($resArray);
            
    $s    = ($size == 1) ? 'y' 'ies';
            
    $list_code  '';
            
    $list_code .= '<h2>DVD list</h2>';
            
    $list_code .= '<p>There are <span class="biglink">'.$size.'</span> entr'.$s.'</p>';
            
    $list_code .= '<table>';
            
    $list_code .= '<thead>';
            
    $list_code .= '<tr>';
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=title&order='.$orderTitle.'" class="biglink">Title</a></th>';
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=studio&order='.$orderStudio.'" class="biglink">Studio</a></th>';
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=year&order='.$orderYear.'" class="biglink">Year</a></th>'
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=oar&order='.$orderOar.'" class="biglink">Oar</a></th>';  
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=method&order='.$orderMethod.'" class="biglink">Method</a></th>';   
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?sort=format&order='.$orderFormat.'" class="biglink">Format</a></th>';   
            
    $list_code .= '</tr>';
            
    $list_code .= '<tbody>';
            foreach (
    $resArray as $value) {
                
    $list_code .= '<tr>';
                
    $list_code .= '<td>' $value['title'] . '</td>';
                
    $list_code .= '<td>' $studios[$value['studio']] . '</td>';
                
    $list_code .= '<td>' $value['year'] . '</td>';
                
    $list_code .= '<td>' $value['oar'] . '</td>';
                
    $list_code .= '<td>' $value['method'] . '</td>';
                
    $list_code .= '<td>' $value['format'] . '</td>';
                
    $list_code .= '</tr>';
            }
            
    $list_code .= '</tbody>';
            
    $list_code .= '</table>';
        }
        return 
    $list_code;
    }

    function 
    display_Unauthorized()
    {
        
    database_connect();
        
    // Settings
        
    $a_sortable     = array('title''studio''year''oar''method''format');
        
    $s_sortDefault  'title';
        
    $a_orderable    = array('asc' => SORT_ASC'desc' => SORT_DESC);
        
    $s_orderDefault 'desc';

        
    // Preprocessing
        
    (isset($_GET['sort'])) ? (in_array($_GET['sort'], $a_sortable) ? $sortBy $_GET['sort']
                                                                       : 
    $sortBy $s_sortDefault)
                           : 
    $sortBy $s_sortDefault;
        (isset(
    $_GET['order'])) ? (isset($_GET['order'], $a_orderable) ? $orderBy  $_GET['order']
                                                                       : 
    $orderBy  $s_orderDefault)
                                : 
    $orderBy $s_orderDefault;
        
        
    // Getting the data
        
    $sql  'SELECT `id`, `title`, `studio`, `year`, `method`, `format`, `oar` FROM `dvd` WHERE `auth` = 0';
        
    $result mysql_query($sql);
        if (!
    $result) {
            
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                            : 
    'There has been an error, please contact our lovely administrator';
            
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
            
    display_Error($data);
            exit;
        }
        
        
    // We must have data
        
    if (mysql_num_rows($result) == 0) {
            
    $list_code '<h2>Unauthorized entries</h2><p>No unauthorized entries</p>';
        } else {
            
    // Get rows
            
    $resArray = array();
            while (
    $row mysql_fetch_assoc($result)) {
                
    $resArray[] = $row;
            }
            
            
    // Free the data
            
    mysql_free_result($result);
            
            
    // Get studio data
            
    $sql 'SELECT `id`, `studio` FROM `studios`';
            
    $result mysql_query($sql);
            if (!
    $result) {
                
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                                : 
    'There has been an error, please contact our lovely administrator';
                
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                
    display_Error($data);
                exit;
            }
            
            
    $studios = array();
            while (
    $row mysql_fetch_assoc($result)) {
                
    $studios[$row['id']] = $row['studio'];
            }
            
            
    // Free the data
            
    mysql_free_result($result);
            
            
    // Presort
            
    $orderDiff   = ($orderBy == 'asc')    ? 'desc'      'asc';
            
    $orderTitle  = ($sortBy  == 'title')  ? $orderDiff 'asc';
            
    $orderStudio = ($sortBy  == 'studio') ? $orderDiff 'asc';
            
    $orderYear   = ($sortBy  == 'year')   ? $orderDiff 'asc';
            
    $orderMethod = ($sortBy  == 'method') ? $orderDiff 'asc';
            
    $orderFormat = ($sortBy  == 'format') ? $orderDiff 'asc';
            
    $orderOar    = ($sortBy  == 'oar')    ? $orderDiff 'asc';
            
            
    // Sort the data
            
    $resArray  array_csort($resArray$sortBy$a_orderable[$orderBy]);
            
            
    // Print out the data
            
    $size count($resArray);
            
    $s    = ($size == 1) ? 'y' 'ies';
            
    $list_code  '';
            
    $list_code .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?action=manage">';
            
    $list_code .= '<h2>Unauthorized entries</h2>';
            
    $list_code .= '<p>There are <span class="biglink">'.$size.'</span> unauthorized entr'.$s.'</p>';
            
    $list_code .= '<table>';
            
    $list_code .= '<thead>';
            
    $list_code .= '<tr>';
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?action=admin&sort=title&order='.$orderTitle.'" class="biglink">Title</a></th>';
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?action=admin&sort=studio&order='.$orderStudio.'" class="biglink">Studio</a></th>';
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?action=admin&sort=year&order='.$orderYear.'" class="biglink">Year</a></th>'
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?action=admin&sort=oar&order='.$orderOar.'" class="biglink">Oar</a></th>';  
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?action=admin&sort=method&order='.$orderMethod.'" class="biglink">Method</a></th>';   
            
    $list_code .= '<th><a href="'.$_SERVER['PHP_SELF'].'?action=admin&sort=format&order='.$orderFormat.'" class="biglink">Format</a></th>'
            
    $list_code .= '<th></th>';  
            
    $list_code .= '</tr>';
            
    $list_code .= '<tbody>';
            foreach (
    $resArray as $value) {
                
    $list_code .= '<tr>';
                
    $list_code .= '<td>' $value['title'] . '</td>';
                
    $list_code .= '<td>' $studios[$value['studio']] . '</td>';
                
    $list_code .= '<td>' $value['year'] . '</td>';
                
    $list_code .= '<td>' $value['oar'] . '</td>';
                
    $list_code .= '<td>' $value['method'] . '</td>';
                
    $list_code .= '<td>' $value['format'] . '</td>';
                
    $list_code .= '<td><input type="checkbox" name="cbutton['.$value['id'].']" value="1" /></td>';
                
    $list_code .= '</tr>';
            }
            
    $list_code .= '<tr><td colspan="6"><input type="submit" name="authorize" value="Authorize" /><input type="submit" name="delete" value="Delete" /></td></tr>';
            
    $list_code .= '</tbody>';
            
    $list_code .= '</table>';
            
    $list_code .= '</form>';
        }
        
         return 
    $list_code;
    }

    function 
    display_StudioForm()
    {
        
    database_connect();
        
    // Get data
        
    $sql    'SELECT `id`, `studio` FROM `studios`';
        
    $result mysql_query($sql);
        if (!
    $result) {
            
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                            : 
    'There has been an error, please contact our lovely administrator';
            
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
            
    display_Error($data);
            exit;
        }
        while (
    $row mysql_fetch_assoc($result))
            
    $data[] = $row;
        
    $cnt count($data);
        if (
    $cnt 10) {
            
    $cnt 10;
        }
        
    // Code
        
    $form_code  '';
        
    $form_code .= '<h2>Edit studios</h2>';
        
    $form_code .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?action=editstudio">';
        
    $form_code .= '<select size="'.$cnt.'" name="studio_list" id="studio">';
        foreach (
    $data as $value) {
        
    $form_code .= '<option value="'.$value['id'].'">'.$value['studio'].'</option>';
        }
        
    $form_code .= '</select><br />';
        
    $form_code .= '<input type="text" name="studio_name" id="studio_name" lenght="20" /><br />';
        
    $form_code .= '<input type="submit" name="edit" value="Change" />';
        
    $form_code .= '<input type="submit" name="new" value="Add" />';
        
    $form_code .= '<input type="submit" name="delete" value="Delete" />';
        
    $form_code .= '</form>';
        
        return 
    $form_code;
    }

    function 
    display_Creator()
    {
        
    $creator_code  '';
        
    $creator_code .= '<p>Created by  '.AUTHOR.', 2003</p>';
        return 
    $creator_code;
    }

    /* Error displays */

    function display_Error_Error($_data)
    {
        
    // Temporary implementation
        
    echo display_Messages($_data['msg']);
    }

    function 
    display_Error_DB($_data)
    {
        
    // Temporary implementation
        
    echo display_Messages($_data['msg']);
    }

    function 
    display_Error_Fatal($_data)
    {
        
    // Temporary implementation
        
    echo display_Messages($_data['msg']);
    }

    /*
    +---------------------------------------------------------------+
    | Main                                                          |
    +---------------------------------------------------------------+
    */

    switch (@$_GET['action']) {
    case 
    'editstudio':
        
    database_connect();
        
    session_start();
        if (!isset(
    $_SESSION['pwd'])) {
            
    $msg  = array('Login required for administration');
            
    $data = array('msg' => $msg);
            
    display_Page($dataDISPLAY_LOGIN);
            exit;
        } else {
            if (
    $_SESSION['pwd'] != CONFIG_ADMIN_PWD) {
                
    $_SESSION = array();
                
    session_destroy();
                
    $msg  = array('Wrong password passed in session');
                
    $data = array('msg' => $msg);
                
    display_Page($dataDISPLAY_LOGIN);
                exit;
            } else {
                if (isset(
    $_POST['edit'])) {
                    if (empty(
    $_POST['studio_list'])) {
                        
    $msg  = array('You must select a studio to edit');
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE);
                        exit;    
                    } else {
                        
    $_POST['studio_name'] = trim($_POST['studio_name']);
                        if (empty(
    $_POST['studio_name'])) {
                            
    $msg  = array('Please enter a studio name');
                            
    $data = array('msg' => $msg);
                            
    display_Page($dataDISPLAY_MANAGE);
                            exit;    
                        }
                        
    $studio_name mysql_escape_string($_POST['studio_name']);
                        
    $studio_id   mysql_escape_string($_POST['studio_list']);
                        
    $sql    'UPDATE `studios` SET `studio` = \''.$studio_name.'\' WHERE id = '.$studio_id;
                        
    $result mysql_query($sql);
                        if (!
    $result) {
                            
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                                            : 
    'There has been an error, please contact our lovely administrator';
                            
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                            
    display_Error($data);
                            exit;
                        }
                        
                        
    $msg  = array('Changed name to '.$studio_name);
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE); 
                        exit;
                    }
                } elseif (isset(
    $_POST['new'])) {
                    if (empty(
    $_POST['studio_name'])) {
                        
    $msg  = array('You must provide a name for the studio');
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE);
                        exit;    
                    } else {
                        
    $studio_name mysql_escape_string($_POST['studio_name']);
                        
    $sql    'INSERT INTO `studios` (studio) VALUES (\''.$studio_name.'\')';
                        
    $result mysql_query($sql);
                        if (!
    $result) {
                            
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                                            : 
    'There has been an error, please contact our lovely administrator';
                            
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                            
    display_Error($data);
                            exit;
                        }
                        
                        
    $msg  = array('Added new studio: '.$studio_name);
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE);
                        exit;
                    }
                } elseif (isset(
    $_POST['delete'])) {
                    if (empty(
    $_POST['studio_list'])) {
                        
    $msg  = array('You must select a studio to delete');
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE);
                        exit;    
                    } else {
                        
    $studio_id   mysql_escape_string($_POST['studio_list']);
                        
    $sql    'DELETE FROM `studios` WHERE id = '.$studio_id;
                        
    $result mysql_query($sql);
                        if (!
    $result) {
                            
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                                            : 
    'There has been an error, please contact our lovely administrator';
                            
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                            
    display_Error($data);
                            exit;
                        }
                        
                        
    $msg  = array('Deleted studio from list');
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE);
                        exit;
                    }
                } else {
                    
    $msg  = array('Unknown action');
                    
    $data = array('msg' => $msg);
                    
    display_Page($dataDISPLAY_MANAGE);
                    exit;
                }
            }
        }     
        break;
    case 
    'manage':
        
    session_start();
        
    database_connect();
        if (isset(
    $_SESSION['pwd'])) {
            if (
    $_SESSION['pwd'] == CONFIG_ADMIN_PWD) {
                if (isset(
    $_POST['authorize'])) {
                    if (
    count($_POST['cbutton']) > 0) {
                        
    $msg = array();
                        foreach (
    $_POST['cbutton'] as $id => $value) {
                            
    $id     mysql_escape_string($id);
                            
    $sql    'UPDATE `dvd` SET `auth` = 1 WHERE `id` = '.$id;
                            
    $result mysql_query($sql);
                            if (!
    $result) {
                                
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                                                : 
    'There has been an error, please contact our lovely administrator';
                                
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                                
    display_Error($data);
                                exit;
                            } else {
                                
    $msg[] = 'Entry '.$id.' has been authorized';
                            }
                        }
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE);
                        exit;                
                    } else {
                        
    $msg  = array('No entries selected');
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE);
                        exit;
                    }
                } else if (isset(
    $_POST['delete'])) {
                    if (
    count($_POST['cbutton']) > 0) {
                        
    $msg = array();
                        foreach (
    $_POST['cbutton'] as $id => $value) {
                            
    $id     mysql_escape_string($id);
                            
    $sql    'DELETE FROM `dvd` WHERE `id` = '.$id;
                            
    $result mysql_query($sql);
                            if (!
    $result) {
                                
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                                                : 
    'There has been an error, please contact our lovely administrator';
                                
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                                
    display_Error($data);
                                exit;
                            } else {
                                
    $msg[] = 'Entry '.$id.' has been deleted';
                            }
                        }
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE);
                        exit;                
                    } else {
                        
    $msg  = array('No entries selected');
                        
    $data = array('msg' => $msg);
                        
    display_Page($dataDISPLAY_MANAGE);
                        exit;
                    }   
                } else {
                    
    $msg  = array('Unknown action');
                    
    $data = array('msg' => $msg);
                    
    display_Page($dataDISPLAY_MANAGE);
                    exit;
                }
            } else {
                
    $_SESSION = array();
                
    session_destroy();
                
    $msg  = array('Wrong password passed in session');
                
    $data = array('msg' => $msg);
                
    display_Page($dataDISPLAY_LOGIN);
                exit;
            }
        } else {
            
    $msg  = array('Login required for administration');
            
    $data = array('msg' => $msg);
            
    display_Page($dataDISPLAY_LOGIN);
            exit;
        }
        break;
    case 
    'add':
        
    database_connect();
        
    // Some entries are required
        
    $msg = array();
        if (empty(
    $_POST['title'])) {
            
    $msg[] = 'You must provide the title';
        } else {
            
    $title mysql_escape_string($_POST['title']);
        }
        if (empty(
    $_POST['studio'])) {
            
    $msg[] = 'You must provide the studio';
        } else {
            
    $studio mysql_escape_string($_POST['studio']);
        }
        if (empty(
    $_POST['year'])) {
            
    $msg[] = 'You must provide the year';
        } else {
            
    $year mysql_escape_string($_POST['year']);
        }
        if (
    count($msg) == 0) {
            
    // Does the entry already exist
            
    $sql    'SELECT `title` FROM `dvd` WHERE `title` = \''.$title.'\' AND `studio` = \''.$studio.'\' AND `year` = \''.$year.'\'';
            
    $result mysql_query($sql);
            if (!
    $result) {
                
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                                : 
    'There has been an error, please contact our lovely administrator';
                
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                
    display_Error($data);
                exit;
            } else {
                
    // No dublicates please
                
    if (mysql_num_rows($result) == 0) {
                    
    $oar    = (!empty($_POST['oar']))    ? $_POST['oar']    : '';
                    
    $method = (!empty($_POST['method'])) ? $_POST['method'] : '';
                    
    $format = (!empty($_POST['format'])) ? $_POST['format'] : '';
                    
    $sql  'INSERT INTO `dvd` (title, studio, year, oar, method, format)';
                    
    $sql .= 'VALUES (\''.$title.'\', \''.$studio.'\', \''.$year.'\', \''.$oar.'\', \''.$method.'\', \''.$format.'\')';
                    
    $result mysql_query($sql);
                    if (!
    $result) {
                        
    $text = (DEBUG) ? 'Could not successfully run query ('.$sql.'): ' mysql_error()
                                        : 
    'There has been an error, please contact our lovely administrator';
                        
    $data = array('msg' => array($text), 'error' => DISPLAY_ERROR_DB);
                        
    display_Error($data);
                        exit;
                    } else {
                        
    $data = array('title' => $title);
                        
    display_Page($dataDISPLAY_THANKS);
                        exit;
                    }
                } else {
                    
    $msg  = array('This entry already exists');
                    
    $data = array('msg' => $msg);
                    
    display_Page($dataDISPLAY_MAIN);
                    exit;
                }
            }      
        } else {
            
    $data = array('msg' => $msg);
            
    display_Page($dataDISPLAY_MAIN);
            exit;
        }
        break;
    case 
    'admin':
        
    session_start();
        if (isset(
    $_SESSION['pwd'])) {
            if (
    $_SESSION['pwd'] == CONFIG_ADMIN_PWD) {
                
    display_Page(nullDISPLAY_MANAGE);
                exit;
            } else {
                
    $_SESSION = array();
                
    session_destroy();
                
    $msg  = array('Wrong password passed in session');
                
    $data = array('msg' => $msg);
                
    display_Page($dataDISPLAY_LOGIN);
                exit;
            }
        } else {
            
    $msg  = array('Login required for administration');
            
    $data = array('msg' => $msg);
            
    display_Page($dataDISPLAY_LOGIN);
            exit;
        }
        break;
    case 
    'login':
        if (isset(
    $_POST['pwd'])) {
            if (
    trim($_POST['pwd']) == CONFIG_ADMIN_PWD) {
                
    session_start();
                
    $_SESSION['pwd'] = $_POST['pwd'];
                
    display_Page(nullDISPLAY_MANAGE);
                exit;
            } else {
                
    $line  strftime('(%m/%d/%y %H:%M:%S)');
                
    $line .= ' '.$_SERVER['REMOTE_ADDR'].' ('.get_isp().') ';
                
    $line .= 'login failed with \''.$_POST['pwd'].'\''."\n";
                if (!
    file_exists(CONFIG_ADMIN_LOG)) {
                    
    $fp = @file(CONFIG_ADMIN_LOG'w+');
                    if (
    $fp) {
                        
    fclose($fp);
                    } else {
                        
    $msg  = array('Could not create log file, check file permissions');
                        
    $data = array('msg' => $msg'error' => DISPLAY_ERROR_FAT );
                        
    display_Error($data);
                        exit;
                    }
                }
                
    $fp fopen(CONFIG_ADMIN_LOG'a+');
                if (
    $fp) {
                    if (
    flock($fpLOCK_EX)) {
                        
    fwrite($fp$line);
                        
    flock($fpLOCK_UN);
                        
    fclose($fp);
                    } else {
                        
    fclose($fp);
                        
    $msg  = array('Could not lock log file');
                        
    $data = array('msg' => $msg'error' => DISPLAY_ERROR_FAT);
                        
    display_Error($data);
                        exit;    
                    }
                } else {
                    
    $msg  = array('Could not open log file');
                    
    $data = array('msg' => $msg'error' => DISPLAY_ERROR_FAT );
                    
    display_Error($data);
                    exit;
                }
                
    $msg  = array('You have entered a wrong password');
                
    $data = array('msg' => $msg);
                
    display_Page($dataDISPLAY_LOGIN);
                exit;
            }
        } else {
            
    $msg  = array('No password transmitted');
            
    $data = array('msg' => $msg);
            
    display_Page($dataDISPLAY_LOGIN);
            exit;
        }
        break;
    case 
    'main'
    default:
        
    display_Page();
        exit;
    }
    ?>
    ddb.css
    Code:
    body
     {
       font-family : Verdana, Helvetica, sans-serif;
       font-size   : 10pt;
       color       : #355768;
       background: white;
     }
    
    h2
     {
      font-size: 13pt;
      color: #F97C00;
      border-bottom: 1px black solid;
     }
    
    li
     {
      padding-top: 5px;
     }
    
    li span
     {
      padding-left: 5px;
      font-size: 8pt;
     }
    
    a:link
     {
       color      : black;
       background : transparent;
     }
    
    a:visited
     {
      color      : #355768;
      background : transparent;
     }
    
    a:hover
     {
      color      : black;
      background : #d8e8f0;
     }
    
    small
     {
      color: #808080;
      background: transparent;
      font-size: 7pt;
     }
    
    #inhalt
     {
      margin-left: 200px;
     }
    
    #navigation
     {
      position: absolute;
      top: 10px;
      left:-5px;
      color: white;
      background: transparent;
     }
    
    #navigation a
     {
      text-decoration: none;
      color: White;
     }
    
    #navigation a:visited
     {
      text-decoration: none;
      color: White;
      background: transparent;
     }
    
    #navigation a:hover
     {
      text-decoration: underline;
      color: White;
      background: transparent;
     }
    
    #navigation center span
     {
      font-size: 2em;
     }
    
    #navigation ul
     {
      list-style-type: none;
      font-weight: bold;
      background: transparent;
     }
    
    #navigation li ul
     {
      font-size: 8pt;
      list-style: square;
      font-weight: normal;
      background: transparent;
      color: white;
      padding-left: -10px;
      position: relative;
      left: -15px;
     }
    
    .gb
     {
      color: #FFFFFF;
      background-color: #5A758C;
      border: 1px black solid;
      width: 450px;
     }
    
    .schrift
     {
      font-size: 8pt;
     }
    
    .gbblat
     {
      width: 465px;
      text-align: center;
      font-size: 8pt;
     }
    
    hr { 
      border: none;
      border-top: 1px solid #355768;
    }
    
    .biglinks p {
      font-size: 12pt;
      color: #F97C00;
    }
    
    .biglinks a {
      font-weight: bold;
      text-decoration: none;
      font-size: 12pt;
      color: #F97C00;
    }
    
    .biglink {
      font-weight: bold;
      text-decoration: none;
      font-size: 12pt;
      color: #F97C00;
    }
    
    a:link.biglink
     {
       color: #F97C00;
       background : transparent;
     }
    
    a:visited.biglink
     {
      color: #F97C00;
      background : transparent;
     }
    
    a:hoverbiglink
     {
      color: #F97C00;
      background : #d8e8f0;
     }
    
    #msg li {
      color: #F97C00;
    }
    
    #adddvd input, select {
      margin-top: 5px;
    }
    
    .req {
      color: #F97C00;
    }
    
    #studio_name {
      margin-top: 5px;
      margin-bottom: 5px;
    }

  11. #36
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow! That sure looks like a lot of work. Looks great from the looks of it, even though I haven't seen it in action yet. Like the sounds of the admin interface. Would you provide an installation script that will set up the database? I would appreciate that.

    A few comments. I noticed you set up a stylesheet, and that was a nice thought, but I want to make sure this will work with my current layout.

    I have uploaded a copy of my current layout for testing. The css is available as well. The first thing I noticed is that the doctype is different. I just don't want to have your css overiding mine, unless they work better. Anyway, I think it may be a good idea to have all the styles in one stylesheet as well.

    Talk to you soon.

  12. #37
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    install.php
    PHP Code:
    <?php
    $conn 
    mysql_connect('localhost''joshuasp_dvdlistt''');
    if (
    $conn) {
        
    mysql_select_db('joshuasp_dvdlist');
        
    // DVD table
        
    $sql "CREATE TABLE `dvd` (
                    `id` int(11) NOT NULL auto_increment,
                    `title` varchar(225) NOT NULL default '',
                    `studio` int(11) NOT NULL default '0',
                    `year` varchar(4) NOT NULL default '',
                    `oar` varchar(10) NOT NULL default '',
                    `method` varchar(25) NOT NULL default '',
                    `format` varchar(25) NOT NULL default '',
                    `auth` tinyint(1) NOT NULL default '0',
                PRIMARY KEY  (`id`),
                KEY `title` (`title`,`studio`,`year`),
                KEY `auth` (`auth`)
                ) TYPE=MyISAM ;"
    ;
        
    $result mysql_query($sql
            or die(
    'Query failed: '.mysql_error());
            
        
    // Example data
        
    $sql "INSERT INTO `dvd` (`id`, `title`, `studio`, `year`, `oar`, `method`, `format`, `auth`) VALUES (1, 'Operation Dumbo Drop', 3, '1997', '1.85:1', 'Pan & Scan', 'R2 DVD', 1);";
        
    $result mysql_query($sql
            or die(
    'Query failed: '.mysql_error());
        
    $sql "INSERT INTO `dvd` (`id`, `title`, `studio`, `year`, `oar`, `method`, `format`, `auth`) VALUES (2, 'Matilda', 2, '1995', '2.35:1', 'Pan & Scan', 'R2 DVD', 1);";
        
    $result mysql_query($sql
            or die(
    'Query failed: '.mysql_error());
        
    $sql "INSERT INTO `dvd` (`id`, `title`, `studio`, `year`, `oar`, `method`, `format`, `auth`) VALUES (3, 'My Neighbor Totoro', 1, '1993', '1.85:1', 'Open Matte', 'CLV LD', 1);";
        
    $result mysql_query($sql
            or die(
    'Query failed: '.mysql_error());
            
        
    // Studios table
        
    $sql "CREATE TABLE `studios` (
                    `id` int(5) NOT NULL auto_increment,
                    `studio` varchar(254) NOT NULL default '',
                PRIMARY KEY  (`id`),
                UNIQUE KEY `studio` (`studio`)
                ) TYPE=MyISAM;"
    ;
        
    $result mysql_query($sql
            or die(
    'Query failed: '.mysql_error());
        
        
    // Example data
        
    $sql "INSERT INTO `studios` (`id`, `studio`) VALUES (1, '20th Century Fox');";
        
    $result mysql_query($sql
            or die(
    'Query failed: '.mysql_error());
        
    $sql "INSERT INTO `studios` (`id`, `studio`) VALUES (2, 'Columbia Tristar');";
        
    $result mysql_query($sql
            or die(
    'Query failed: '.mysql_error());
        
    $sql "INSERT INTO `studios` (`id`, `studio`) VALUES (3, 'Disney');";
        
    $result mysql_query($sql
            or die(
    'Query failed: '.mysql_error());
        
        echo 
    'All tables created, example data has been added.';          
    } else {
        die(
    'Connect failed: '.mysql_error());
    }
    ?>

  13. #38
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Upon looking at the code, I see you set up a database for the studio's. So that I could set names of the studio's to use in the unput form. That is exactly what I wanted! And it looks like your stylsheet would make some of the text smaller, so that it will all fit. By the way, my website is designed for 800x600.

    Maybe if I explained exaclty what this is for, then you would be able to see where I'm trying to go with it. It is designed to be a list of DVD's that are not available in widescreen, and thus need to be made available. It's a list of DVD's to "watch out" for so to speak, by people who only watch widescreen. The fields of course, specify the title, year, distribution studio, original aspect ratio, method that it uses to be shown full screen, and if it is available in widescreen in another format, such as laserdisc, or Reigon 2 DVD. I am not sure if I made that clear in my post last night, just wanted to let you know so you understand the purpose of the list. I already have such a list on my site, but it only includes the titlle, not the other information, and it hasn't been updated in a year, because it is so hard to update a text list. I do have an updated list with the other information in a thread at a DVD forum that I am a member of. I guess that's it in a nutshell. I, and the members of the Home Theater Forum thank you for your hard work on this project.

    While I am writing this post, I see you have added the install script. Thanks so much.

  14. #39
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are very welcome. And if there are any features you would like to see in it, post here.
    Thanks for providing the explanation, I hope it will help some people.

  15. #40
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's looking great so far! I would like the input form below the list however.

    I'll have to test it inside my layout later. Also, what other functions did you want to add? Because you said it wasn't completely finished yet.

    The only other thing I need is a way to remove titles once they have an oar release. I have thought of two ways to do this.

    The first option is to have a way to mark a title as "Available" by adding another field, and putting a star in that field or something like that when it is released in widescreen.

    Another way is to have the "now available" titles in a seperate list. Would have to add another field, and change it from 1 to 0 or something like that.

    I'll let you know once I get some feedback about how I want to do it.

    Could we change the title: DDB to Oar Watchdog. Any other places where is says dvd database should be changed to that as well.

    Thanks.

  16. #41
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's easy to change. I just changed the order of the functions being called.
    PHP Code:
    $main_code .= display_Messages(@$_data['msg']);
    $main_code .= display_List();
    $main_code .= display_AddForm(); 
    Well, I wanted to add some remove functionality, so it good that's you're getting feedback on how to implement that. And of course, adding nicer error templates (display_Error_* functions) is a must do.
    Changing the name is no problem either, just alter the TITLE and TAG define.
    PHP Code:
    define('TAG',   'OWD');
    define('TITLE''Oar Watchdog ('.TAG.')'); 

  17. #42
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've added my template around the php code. Here's a few thoughts that I have. I'd like all code that includes header tags to be removed, since the code is already in my template. This includes everything from the doctype to the body tag. If it would be better to add my template code to each section, that would be acceptable, or maybe even preferrable. I just think it's wise to get rid of unneccesary code. The file is already quite large. I will add some of the syles from your sheet to my own stylesheet as well. I know you worked hard on this, but I think it will look the best this way. If you think it's best to add my layout code to each section, let me know, and I will give you the exact code I want used.

    Thanks.

  18. #43
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this one for integration in your site. (Attachment)
    Have you got any feedback yet?
    Attached Files Attached Files

  19. #44
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't see the attatchment yet. It usually takes a while for an attatchment to be approved. Can you e-mail it to me at webmaster@joshuasplace.net?

    I haven't gotten any feedback yet. If I don't get any by tonight, I will make the decision myself.

    Thanks.

  20. #45
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The attatchment showed up, but that code is so jumbled up, I can't read it at all. I like the nice clean, readable code you posted before.

  21. #46
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a ZIP archive file. Use tools like WinZIP, WinRAR or UltimateZIP to open it (Windows IMO can even open it by default).

  22. #47
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had to use a different program to open it this time. Notepad usually works with PHP files, so I don't know why it didn't this time. Can you tell me what makes this code different from before, because I really don't see any changes. I examined the part that has the header code for each section, and noticed no difference.

  23. #48
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I commented out some of the HTML lines, it should know be ready to be integrated into your page.

  24. #49
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    New feature added, the hip 'page-ination'.
    Check out the attachment!
    Attached Files Attached Files

  25. #50
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm getting an xml error when I try to login to the admin panel. I think it means that the doctype has to be changed. And I still think it would be best to just remove the doctype and any other header tags, down to, and including the body tags, since I have my own template and stylesheet.

    Also, please remove all current classes. I have my own classes set up. I would like the "Add a DVD" title to have a class called "title3"

    I really like the pagination. How do I set how many will show up on one page. Right now it is showing two per page. I'd like to set it to about 25.

    Ok, in regards to the removal of the titles, just make it so I can move them to another list when they are released oar. Put a link to that list at the top of the page somewhere.


    After all that is done, let me know your paypal account, so I can send you some cash. Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •