Location: PHPKode > projects > Communication Kit > programs/live/page_submit_inc.php
<?php
  class ck_page_submit {
    var $page_ref = '';
    var $ob = "" ; //order by
    var $ob_dir = "" ; //order by direction
    var $ob_next = "" ; //order by next
    var $update_actions = Array('del');
    var $display_actions = Array('dummy');
    function update_page($action){
      global $error_text;
      $new_page_type = "P";
      $new_page_title_text = addslashes($_POST['new_page_title_text']);
      if (isset($_SESSION['sess_first_name'])){
        $name_text = "Submitted by ".$_SESSION['sess_first_name']." ".$_SESSION['sess_last_name'];
      } else {
        $name_text = "Submitted by unregistered user.";
      }
      $new_page_ed_notes = $name_text.addslashes($_POST['new_page_ed_notes']);
      $new_page_title_show = (isset($_POST['new_page_title_show'])) ? 1 : 0 ;
      $new_page_time_ltd = (isset($_POST['new_page_time_ltd'])) ? 1 : 0 ;
      if ($new_page_time_ltd){
        $new_page_start_date = addslashes($_POST['new_page_start_date']);
        $year = substr($new_page_start_date,6,4);
        $mnd = substr($new_page_start_date,3,2);
        $day = substr($new_page_start_date,0,2);
        if(checkdate ($mnd,$day,$year)){
          $start=TRUE;
          $new_page_start_date="$year/$mnd/$day";
        } elseif ($new_page_start_date=="Select:") {
          $start=TRUE;
          $new_page_start_date="";
        } else {
          $start=FALSE;
        }
        $new_page_end_date = addslashes($_POST['new_page_end_date']);
        $year = substr($new_page_end_date,6,4);
        $mnd = substr($new_page_end_date,3,2);
        $day = substr($new_page_end_date,0,2);
        if(checkdate ($mnd,$day,$year)){
          $end=TRUE;
          $new_page_end_date="$year/$mnd/$day";
        } elseif ($new_page_end_date=="Select:") {
          $end=TRUE;
          $new_page_end_date="";
        } else {
          $end=FALSE;
        }
      } else {
        $start=TRUE;
        $end=TRUE;
        $new_page_start_date = "";
        $new_page_end_date = "";
      }
      $new_page_text = addslashes($_POST['new_page_text']);
      $new_page_menu_block=(isset($_POST['new_page_menu_block'])) ? $_POST['new_page_menu_block'] : $page_menu_block ;

      if (($new_page_title_text == "")||($new_page_text == "")) {
        $error_text .= "Error - Missing Fields, all fields marked ** must be completed...";
      } elseif ((!$start)||(!$end)) {
        $error_text .= "Error - Invalid Date Entry...";
      } else {
        $error_text.="";
      }
      // process data, (if a form has been submitted)
      if ($error_text==""){
        $sql = mysql_query("INSERT INTO ".PAGES." (page_menu_block,
        page_title_text,
        page_title_show,
        page_type,
        page_text,
        page_link_text,
        page_ed_notes,
        page_last_edit,
        page_start_date,
        page_end_date,
        page_status)
        VALUES ('$new_page_menu_block',
        '$new_page_title_text',
        '$new_page_title_show',
        '$new_page_type',
        '$new_page_text',
        '$new_page_title_text',
        '$new_page_ed_notes',
        '".now()."',
        '$new_page_start_date',
        '$new_page_end_date',
        '1') ")
        or die (mysql_error());
      }
    }
    function display_page($action){
      global $error_text;
      $sql = mysql_query("SELECT use_editor,font_select,size_select,style_select,para_select FROM ".SITE." WHERE site_id = '".SITE_ID."'");
      $row = mysql_fetch_array($sql);
      foreach( $row AS $key => $val ){
        $$key = stripslashes( $val );
      }
      $error_flag = ($error_text=="") ? "" : "<span class=error>**</span>";
?>
<STYLE type="text/css">
  <!--
  #time_ltd {display:none;}
  -->
</STYLE>
<script language="JavaScript" type="text/javascript">
function time_ltd_f(){
    if (document.form.new_page_time_ltd.checked) {
    time_ltd.style.display='block' ;
    } else {
        time_ltd.style.display='none' ;
        document.form.new_page_start_date.value="Select:" ;
        document.form.new_page_end_date.value="Select:" ;
    }
}
</script>
<?
      print "<form name='form' method='post' action='".$_SERVER['PHP_SELF']."?page_ref=$this->page_ref'>\n";
      print "<table border='0' cellpadding='4' cellspacing='0'>\n";
      print " <tr><td class='small_text' align='right'>Title</td>\n";
      print "     <td class='reset' colspan='2'><input name='new_page_title_text' type='text' class='text' maxlength='40' size='30' value=''>$error_flag\n";
      print "  <span class='small_text'>Display Title?</span>\n";
      print "    <input type='checkbox' class='checkbox' name='new_page_title_show' checked='checked'></td></tr>\n";

      print "<tr><td class='small_text' align='right' valign='top'>Page Text";
      print "</td><td colspan=4><textarea class='area' name='new_page_text' rows='20' cols='80'></textarea>$error_flag</td>\n";
      print "</tr>\n";

      print "<tr><td class='small_text' align='right'>Suggested Menu Block</td>\n";
      print "<td class='reset' colspan='2'>\n";
      print "<select name='new_page_menu_block'>";
      $sql_blocks = mysql_query("SELECT * FROM ".MENU_BLOCKS."
      WHERE block_type='P'
      ORDER BY block_pos DESC,block_text");
      while($row = mysql_fetch_array($sql_blocks)){
        foreach( $row AS $key => $val ){
          $$key = stripslashes( $val );
        }
        switch ($block_pos) {
          case "T":
            $text = "Top Menu: ";
          break;
          case "B":
            $text = "Bottom Menu: ";
          break;
          case "L":
            $text = "Left Menu: ";
          break;
          case "R":
            $text = "Right Menu: " ;
          break;
        }
        print "<OPTION value=$block_id>".$text.$block_text."</OPTION>\n";
      }
      print "</select>";
      print "</td></tr>\n";

      $sql = mysql_query("SELECT allow_time_ltd_pages FROM ".APPLICATION." WHERE site = '001'");
      $row = mysql_fetch_array($sql);
      foreach( $row AS $key => $val ){
        $$key = stripslashes( $val );
      }
      if ($allow_time_ltd_pages){
        print "<tr><td class='small_text' align='right'>Time Limited?</td>";
        print "<td class='small_text'><input type='checkbox' class='checkbox' name='new_page_time_ltd' onclick=\"time_ltd_f()\"></td>\n";
        print "<td><table id='time_ltd'><tr><td class='small_text' align='right'>Publish Date</td>\n";
        print "<td class='reset'><input type='text' class='text' id='page_start_date' name='new_page_start_date' value='Select:' size='10' readonly='1'/></td>\n";
        print "<td><img src='".WEBROOT."images/site/cal.gif' id='page_start_date_trigger' style='cursor: pointer; border: 1px solid red;' title='Date selector'
          onmouseover=\"this.style.background='red';\" onmouseout=\"this.style.background=''\" /></td>\n";
          print "<td class='small_text' align='right'>Expiry Date</td>\n";
          print "<td class='reset'><input type='text' class='text' id='page_end_date' name='new_page_end_date' value='Select:' size='10' readonly='1'/></td>\n";
          print "<td><img src='".WEBROOT."images/site/cal.gif' id='page_end_date_trigger' style='cursor: pointer; border: 1px solid red;' title='Date selector'
            onmouseover=\"this.style.background='red';\" onmouseout=\"this.style.background=''\" /></td>\n";
            print "</tr></table></td></tr>\n";
          }

          print "<tr><td class='small_text' align='right' valign='top'>Editor Notes<br />(Only displayed to Editors)</td>";
          print "    <td class='reset' colspan=2><textarea name='new_page_ed_notes' class='text' rows='2' cols='60'></textarea></td>";
          print "</tr>\n";

          print "<tr><td class='reset'><input type='hidden' name='hidden_field' value='entered'></td>\n";
          print "    <td class='reset' colspan='2'><input class='button' type='submit' value='Update'>\n";
          print "    </td></tr></table></form>\n";
          if ($allow_time_ltd_pages){
?>
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "page_start_date",     // id of the input field
        ifFormat       :    "%d/%m/%Y",      // format of the input field
        button         :    "page_start_date_trigger",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true,
        weekNumbers    :    false
    });
    Calendar.setup({
        inputField     :    "page_end_date",     // id of the input field
        ifFormat       :    "%d/%m/%Y",      // format of the input field
        button         :    "page_end_date_trigger",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true,
        weekNumbers    :    false
    });
</script>
<?
          }
          if ($use_editor) {
?>
<script language='javascript1.2'>
var config = new Object(); // create new config object

config.width = "auto";
config.height = "auto";
config.bodyStyle = 'background-color: white; font-family: "Verdana"; font-size: x-small;';
config.debug = 0;
config.toolbar = [
//File
  ['separator'],
  ['openfile','save','spell','preview','htmlmode','popupeditor','print'],
//Tables
  ['separator'],
  ['inserttable','showborder','TableProperties',
  //Table Rows
  'RowProperties','InsertRowBefore','InsertRowAfter','DeleteRow','SplitRow',
  //Table Columns
  'InsertColumnBefore','InsertColumnAfter','DeleteColumn',
  //Table Cells
  'CellProperties','InsertCellBefore','InsertCellAfter','DeleteCell','SplitCell','MergeCells'],
  ['line','specchar','marquee'],
  ['about','help'],
  ['linebreak'],
  //Edit
    ['separator'],
  ['selectall','cut','copy','paste','delete','remove','undo','redo','find'],
  //Format Text Style
  ['bold','italic','underline','strikethrough','subscript','superscript',
  // Format Text Alignment
  'justifyleft','justifycenter','justifyright','justifyfull','justifynone'],
  ['forecolor','backcolor',
  //Format Text Block
  'OrderedList','UnOrderedList','Outdent','Indent'],
  //Row 3: Insert/Modify Tools
  //Hyperlinks and Images
  ['separator'],
  ['insertlink','unlink','InsertImage','multipleselect'],
<?
            if ($font_select) {
              print  "  ['separator','fontname'],";
            }
            if ($size_select) {
              print  "['separator'],['fontsize'],";
            }
            if ($style_select) {
              print  "  ['separator'],  ['fontstyle'],";
            }
            if ($para_select) {
              print  "['separator'],['formatblock'],";
            }
            print "];\n  config.fontnames = {\n";
            $sql = mysql_query("SELECT font_size_adj FROM ".SITE." WHERE site_id = '".SITE_ID."'")
                or die("Bad query: ".mysql_error());
            $row = mysql_fetch_array($sql);
            foreach($row AS $key => $val){
                  $$key = stripslashes($val);
            }
            $sql = mysql_query("SELECT * FROM ".FONTS."
            WHERE 1 ORDER BY font_name");
            $first_time=TRUE;
            while($row = mysql_fetch_array($sql)){
              foreach( $row AS $key => $val ){
                $$key = stripslashes( $val );
              }
              print (!$first_time) ? ",\n" : "" ;
              $first_time=FALSE;
              print "\"$font_name\":  \"$font_family\"";
            }
            print "};\n  config.fontstyles = [\n";     // make sure these exist in the header of page the content is being display as well in or they won't work!
            $sql = mysql_query("SELECT * FROM ".STYLES."
            WHERE 1 ORDER BY style_name");
            while($row = mysql_fetch_array($sql)){
              foreach( $row AS $key => $val ){
                $$key = stripslashes( $val );
              }
              $size_def=82+($font_size_adj*4);
              $sub_header_number=(140+($font_size_adj*5))*100/$size_def;
              $sub_header_font_size=$sub_header_number."%";
              $size_number=(82+($font_size_adj*4))*100/$size_def;
              $size=$size_number."%";
              $size_number=(90+($font_size_adj*4))*100/$size_def;
              $size_bigger=$size_number."%";
              $size_number=(74+($font_size_adj*4))*100/$size_def;
              $size_smaller=$size_number."%";
              $size_number=(66+($font_size_adj*3))*100/$size_def;
              $size_even_smaller=$size_number."%";
              switch ($style_size) {
                case 1:
                  $style_font_size = $size_even_smaller;
                break;
                case 2:
                  $style_font_size = $size_smaller;
                break;
                case 3:
                  $style_font_size = $size;
                break;
                case 4:
                  $style_font_size = $size_bigger;
                break;
                case 5:
                  $style_font_size = $sub_header_font_size;
                break;
              }
              print "{ name: \"$style_name\", className: \"$style_id\", classStyle: \"font-family: $style_font; font-size=$style_font_size; font-weight:$style_type;\" },\n";
            }
            print "];\n   config.fontsizes = {
              \"1 (8 pt)\":  \"1\",
              \"2 (10 pt)\": \"2\",
              \"3 (12 pt)\": \"3\",
              \"4 (14 pt)\": \"4\",
              \"5 (18 pt)\": \"5\",
              \"6 (24 pt)\": \"6\",
              \"7 (36 pt)\": \"7\"
            };\n";
?>
 // inserted by lvn
    config.formatblocks = [
      {tag: "",        formatblocklangs: [{lang: "en", name: "Normal"}]},
      {tag: "<address>", formatblocklangs: [{lang: "en", name: "Address"}]},
      {tag: "<dd>",      formatblocklangs: [{lang: "en", name: "Definition"}]},
      {tag: "<dt>",      formatblocklangs: [{lang: "en", name: "Definition Term"}]},
      {tag: "<ol>",      formatblocklangs: [{lang: "en", name: "Numbered List"}]},
      {tag: "<dir>",     formatblocklangs: [{lang: "en", name: "Directory List"}]},
      {tag: "<h1>",      formatblocklangs: [{lang: "en", name: "Heading 1"}]},
      {tag: "<h2>",      formatblocklangs: [{lang: "en", name: "Heading 2"}]},
      {tag: "<h3>",      formatblocklangs: [{lang: "en", name: "Heading 3"}]},
      {tag: "<h4>",      formatblocklangs: [{lang: "en", name: "Heading 4"}]},
      {tag: "<h5>",      formatblocklangs: [{lang: "en", name: "Heading 5"}]},
      {tag: "<ul>",      formatblocklangs: [{lang: "en", name: "Bulleted List"}]},
      {tag: "<menu>",    formatblocklangs: [{lang: "en", name: "Menu List"}]},
      {tag: "<pre>",     formatblocklangs: [{lang: "en", name: "Formatted"}]}
    ];
    editor_generate('new_page_text',config);
    WriteMenuItems('new_page_text');
    </script>
<?
          }
        }
      }
?>
Return current item: Communication Kit