Location: PHPKode > projects > TVEz - Media Library > tvez-0.2.1/html/admin/show_config.php
<?php 

# ------------------------------------------------------------------------------
#
# This is the configurator for the TVEz shows.
#
# ------------------------------------------------------------------------------
#
# Copyright (C) 2003 Christian Eheim and Alex Pachikov
#                                                                               
# This file is part of TVEz (tvez.sourceforge.net).
#                                                                               
# TVEz is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#                                                                               
# TVEz is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#                                                                               
# You should have received a copy of the GNU General Public License
# along with TVEz; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#                                                                               
# ------------------------------------------------------------------------------
#
# Created on 02/12/2003 by Alex Pachikov
#
# LAST MODIFIED:
# $Date: 2004/01/22 06:49:53 $
# $Revision: 1.2 $
# $Author: eheim $
#
# ---------------------------------------------------------------------

$DEMO = false;
                                                                                
if ($DEMO) {
    $config_file_php = "../config/shows_config-fake.php";
    $config_file = "../config/config_file-fake.php";
} else {
    $config_file_php = "../config/shows_config.php";
    $config_file = "../config/config_file.php";
}

require "admin/admin_access.php";
require $config_file_php;
require $config_file;
require "configurator.php";

global $config_text, $HTTP_POST_VARS;
$config_text_php = "?php \n#TVEZ Shows Config File for PHP.  -- CAN BE CHANGED BY HAND --\n\n";

print "<form name=tvezconfig action=\"".$_SERVER["PHP_SELF"]."\" method=POST>\n";
print '<table width=100% cellpadding=8 cellspacing=0 border=0 align=center>
<tr><td align=left>
<h1>TVEZ Shows Configurator</h1>
<table width=100% cellpadding=8 cellspacing=0 border=1 align=center>
<tr><td colspan=2>
';
  print "<input name=content type=hidden value='admin'></p>";
  print "<input name=page type=hidden value='showsconfig'></p>";

# check if the file is readable
print "<p><b>Shows Config File: </b>";
if (is_writable($config_file_php)) {
   print "<span class=configgood>$config_file_php <b>is writable.</b></span><br>";
} else {
   print "<span class=configbad>$config_file_php is <b>NOT writable.</b></b></span><br>";
   $ok = no;
}


# check if we are adding or deleting
$save = ($_REQUEST['save']) ? $_REQUEST['save'] : $save;
$addone = ($_REQUEST['addone']) ? $_REQUEST['addone'] : $addone;
$addingone = ($_REQUEST['addingone']) ? $_REQUEST['addingone'] : $addingone;
$delone = ($_REQUEST['delone']) ? $_REQUEST['delone'] : $delone;
$deletedone = ($_REQUEST['deletedone']) ? $_REQUEST['deletedone'] : $deletedone;

$size = sizeof($shows);
if ($debug) print "<p>Size of included shows array: $size";

print "</td></tr><tr><td>";

# print status and buttons
if ($addone) {

  # ADDING
  $next = $size+1;
  print '<p>Appended to the bottom of the page: <a href=#'.($next).'>Goto '.$next.'</a></p>';
  $shows[$next] = "New Show";
  print '<p>Go modify the show. <input type=hidden name=addingone value='.$next.'>';

}elseif ($delone){

  # DELETING
  print "<p>Deleting show listing: $delone) ".$shows[$delone]."</p>";
  print "<p>Submit the file to write the changes:"; 
  print "<input name=save type=submit value='Delete'></p>";
#  print "='Delete'></p>";

  print "<p>Deleting the show: ".$shows[$delone]." <input type=hidden name=deletedone value=$delone>";
#  $shows{$delone} = "Deleted";

}else{

  # LISTING
  print '
  <p><select name=delone>
  <option value=0> (select one) </option>
  ';
  foreach ($shows as $key => $delshow){
    print "<option value=$key>$key: $delshow</option>";
  }
  print '</select>';
  print "<input name=save type=submit value='Show to Delete'></p>";
  if ($addingone) {
    print"<p><b>Added: $addingone</b>";
    $shows[$size+1] = "New Show";
    if ($debug) print "<p>Size of added shows array: ".sizeof($shows);
  }
  print "<p><b>Additional Listings:</b> <a href=?content=admin&page=showsconfig&addone=1>Add one more</a><br>";
  if ($deletedone) {
    print '<p>Deleted a show: '.$shows{$deletedone};
    # renumber
  }
}


# Print the Forms

# General Shows Vars 
 config_table("General Variables for Show");
# config_input("Show Image Path:",$showimages,"showimages","Path the images that represent the shows.");
  config_check("Debug:",$debug,"debug","Print the config files for debuging.");

$i = 1;
if (sizeof($shows) > 0) {
foreach ($shows as $skey => $show) {
# if ($delone != 0 && $skey > $delone) $key = $skey + 1; 
# else 
  $key = $skey;
  if ($skey != $delone) {
  # Shows Vars 
  print "<a name=$i></a>";
  config_table("Show Vars: $show key:".$shows{$key}." (SKey: $skey) (Key: $key) (Order: $i) <a href=?delone=$key&save=1>Delete this listing</a> ");
  config_input("Short Name:",$shows{$key},"shows\{$i}","Short name for this listing. It will be used in the shortcut links in the top frame and to display an image of that filename (plus .gif or .jpg)  in the main shows page instead of the link.");
  config_input("Show Title:",$title{$key},"title\{$i}","Title of this listing.");
  config_input("Show Path:",$showpath{$key},"showpath\{$i}","Absolute path to the directory contating video files or subfolders of video files.");
  config_textarea("Seasons:",$seasons{$key},"seasons\{$i}","List of sub-directories that contain video files, i.e. tv series organized by seasons. Leave blank to list all subfolders with video files.");
  config_input("Script URL:",$scripturl{$key},"scripturl\{$i}","URL to the episode scripts. XXX replaces the episode number. E.g. http://www.snpp.com/episodes/XXX.html for the Simpsons. The episode number in the file name must be the one listed on the site.");
  config_check("Anchors:",$anchors{$key},"anchors\{$i}","Build and show anchor links for the subdirectories. i.e. seasons 1, 2, 3..");
  config_check("Shortcut:",$shortcut{$key},"shortcut\{$i}","Show a link in the top frame as a shortcut to this show listing.");
 }else{
  config_table("Deleting $skey");
  print "<tr><td><input type=hidden name=deletedone value=$delone></td></tr>";
  print "<tr><td>Deleted $skey</td></tr>";
 }
 $i++;
}
}
print '
</table>
';

# this is a note to remind me that the <> tags have to added on the write.
$config_text_php .= "?";

# write the files
#if ($ok != no) {
   if ($save) {
    # Write the files.
    if (!$handle = fopen($config_file_php, 'w')) {
	  echo "<span class=configbad><b>Unable to write to file $config_file_php</b></span>";
    } else {
    	if (!fwrite($handle, "<".$config_text_php.">")) {
	  echo "<span class=configbad><b>Unable to write to file $config_file_php</b></span>";
    	} else {
	  echo "<span class=configgood><b>Success writing to $config_file_php</b></span>";
        }
    	fclose($handle);
    }
   } 
   print ' <input type=submit name=save value="Write the Changes" class=configform><br><br>';

   print '<a name=bottom></a>';

if ($debug) {
   
   print "<h2>PHP Config File </h2>
   <pre> <blockquote>'
   &lt;".$config_text_php."&gt;
   </blockquote> </pre>";

 if ($HTTP_POST_VARS) {
    
   print "<table align=left cellpadding=4 cellspacing=4 border=0>";
   function debug_post($string,$value) {
     print "
   <tr>
    <td align=left valign=top bgcolor=dddddd>
     $value 
    </td>
    <td align=left valign=top> 
     $string
    </td>
   </tr> ";
   }

   print "<h2>Debuging the Post Vars</h2>";
   array_walk($HTTP_POST_VARS, 'debug_post');
   print "</table>";
 }
}


# finish
print "
     </form>
    </td>
   </tr>
  </table>
";

?>
Return current item: TVEz - Media Library