topical media & game development
[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

talk show tell print

portal-cms-post.php



  <html>
  <body>
  <?php
  include(<config.php>);
  
  title = _POST['title'];
  date = _POST['date'];
  description = _POST['description'];
  binary = _POST['binary'];
  sourcename = _POST['sourcename'];
  sourceurl = _POST['sourceurl'];
  contenttype = _POST['contenttype'];
  contentstate = _POST['contentstate'];
  audioformat = _POST['audioformat'];
  audiolength = _POST['audiolength'];
  audiobitrate = _POST['audiobitrate'];
  audiosize = _POST['audiosize'];
  videoformat = _POST['videoformat'];
  videoresolution = _POST['videoresolution'];
  videolength = _POST['videolength'];
  videocode = _POST['videocode'];
  videosize = _POST['videosize'];
  articlelanguages = _POST['articlelanguages'];
  pictureformat = _POST['pictureformat'];
  pictureresolution = _POST['pictureresolution'];
  picturesize = _POST['picturesize'];
  health = _POST['health'];
  politics = _POST['politics'];
  wildlife = _POST['wildlife'];
  energy = _POST['energy'];
  business = _POST['business'];
  climate = _POST['climate'];
  pollution = _POST['pollution'];
  technology = _POST['technology'];
  lifestyle = _POST['lifestyle'];
  region = _POST['region'];
  environment = _POST['environment'];
  keywords = _POST['keywords'];
  upload = _POST['upload'];
  
  /* Dit gedeelte van de code is verantwoordelijk voor de upload.
  De file die geupload word, word verplaatst naar de worldwritable map uploads/
  */
  
  if(upload) {
  target_path = "uploads/";
  target_path = target_path . basename(
  _FILES['uploadedfile']['name']);
  
  echo "<tr><td>";
  if(move_uploaded_file(_FILES['uploadedfile']['tmp_name'],
  target_path)) {
      file_upload_name =  basename( _FILES['uploadedfile']['name']);
      binary = "uploads/".file_upload_name;
      echo "The file ".  file_upload_name .
      " has been uploaded";
  } else{
      echo "There was an error uploading the file, please try again!";
  }
  echo "</td></tr>";
  }
  
  /* De content word hier in de database gestopt. Voor elk item zijn de basis velden  hetzelfde */
  
          if(get_magic_quotes_gpc()==1) {
            query = "INSERT INTO content (content_id, content_title, content_date, content_date_added,
  content_binary, content_source_name, content_sourceurl, content_state, content_type, content_description) VALUES ('',
  'title', 'date', UNIX_TIMESTAMP(), 'binary', 'sourcename', 'sourceurl', 'contentstate', 'contenttype', 
  'description')";
          } else {
            title = addslashes(title);
            description = addslashes(description);
            binary = addslashes(binary);
            date = addslashes(date);
            sourcename = addslashes(sourcename);
            sourceurl = addslashes(sourceurl);
            query = "INSERT INTO content (content_id, content_title, content_date, content_date_added,
  content_binary, content_source_name, content_sourceurl, content_state, content_type, content_description) VALUES (
  '', 'title', 'date', UNIX_TIMESTAMP(), 'binary', 'sourcename', 'sourceurl', 'contentstate', 'contenttype',
  'description')";
          }
          result = mysql_query(query);
          lastid = mysql_insert_id();
  
          if(!result) {
                  die('Invalid query: ' . mysql_error());
          }
  
  /* Er word hier een onderscheid gemaakt tussen de vier verschillende contenttypes. Elk contenttype heeft zn eigen 
  individuele velden die ingevuld moeten worden */
  
  if(contenttype == 1) {
   query = "INSERT INTO content_type_audio (content_type_audio_id, audio_format, audio_length, audio_bitrate, audio_size, content_id) VALUES ('', 'audioformat', 'audiolength','audiobitrate', 'audiosize', 'lastid')";
  } elseif(contenttype == 2) {
   query = "INSERT INTO content_type_video (content_type_video_id, video_format, video_resolution, video_length, video_size, content_id, video_code)VALUES ('', 'videoformat', 'videoresolution','videolength', 'videosize', 'lastid', 'videocode')";
  } elseif(contenttype == 3) {
   query = "INSERT INTO content_type_article (content_type_article_id, article_languages, content_id) VALUES ('', 'articlelanguages', 'lastid')";
  } elseif(contenttype == 4) {
   query = "INSERT INTO content_type_picture (content_type_picture_id, picture_format, picture_resolution, 
  picture_size, content_id) VALUES ('', 'pictureformat', 'pictureresolution', 'picturesize', 'lastid')";
  }
  
  result = mysql_query(query);
          if(!result) {
                  die('Invalid query: ' . mysql_error());
          }
  
  /* De categorieen waaronder een item valt, worden hier in de database gestopt */
  
  query = "INSERT into content_matrix (health, politics, wildlife, energy, business, climate, pollution, 
  technology, lifestyle, environment, region, content_id) VALUES ('health', 'politics', 'wildlife', 'energy', 'business', 
  'climate', 'pollution', 'technology', 'lifestyle', 'environment', 'region', 'lastid')";
  
  result = mysql_query(query);
          if(!result) {
                  die('Invalid query: ' . mysql_error());
          }
  
  /* De keyword string word gesplitst in individuele keywords door te splitten op een spatie. Vervolgens worden alle 
  keywords met de 'ignore' vlag in de database gestopt. Doordat het keyword_name veld uniek is, zullen alleen 
  keywords die nog niet in de database staan opgeslagen worden */
  
  keywords = split(' ', strtolower(keywords));
  foreach (keywords as keyword) {
  word = trim(keyword);
  query = "INSERT ignore into keywords (keyword_id, keyword_name) values ('', 'word')";
  result = mysql_query(query);
          if(!result) {
                  die('Invalid query: ' . mysql_error());
          }
  
  /* Wanneer keywords worden toegevoegd die al in de database staan, zal het niet duidelijk zijn welk keyword_id bij 
  elk item hoort. Daarom word hier voor elk keyword het keyword_id opgezocht en opgeslagen */
  
  query = "SELECT * from keywords WHERE keyword_name = 'word'";
  result = mysql_query(query);
          if(!result) {
                  die('Invalid query: ' . mysql_error());
          }
  row = mysql_fetch_array(result);
  keywordid = row['keyword_id'];
  
  query = "INSERT into content_keywords (content_keyword_id, content_id, keyword_id) values ('', 'lastid', 'keywordid')";
  result = mysql_query(query);
          if(!result) {
                  die('Invalid query: ' . mysql_error());
          }
  }
  
  ?>
  
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <!-- DW6 -->
  <head>
  <!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
  <title>Climate Portal Content Management System</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="cms.css" type="text/css" />
  <style type="text/css">
  <!--
  .style1 {color: #FFFFFF}
  .style3 {color: #CCFFCC}
  .style5 {font-size: 24px}
  .style6 {color: #D4D0C8}
  -->
  </style>
  </head>
  <body bgcolor="#cccccc">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  
          <tr>
          <td width="15" nowrap="nowrap"><img 
  src="file: 

D|/Program%20Files/%5Bwebdesign%5D/dreamweaver%208/Dreamweaver%208/StarterPages/mm_spacer.gif" alt=""


width="15" height="1" border="0" /></td> <td height="74" colspan="3" class="logo" nowrap="nowrap"><br /> <span class="style1"> CLIMATE<span class="style3">PORTAL</span> <span class="style5">CMS</span></span> </td> <td width="4">&nbsp;</td> <td width="574">&nbsp;</td> </tr> <tr bgcolor="#ffffff"> <td colspan="6"></td> </tr> <tr bgcolor="#a4c2c2"> <td width="15" nowrap="nowrap">&nbsp;</td> <td height="36" colspan="3" id="navigation" class="navText"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="style6">ADD ITEM </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="edit_item.php">EDIT ITEM </a>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CATEGORIES </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; USER MANAGEMENT</a></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RSS ADMIN</a></span></td> <td width="4">&nbsp;</td> <td width="574">&nbsp;</td> </tr> <tr bgcolor="#ffffff"> <td colspan="6"><img src="file:

D|/Program%20Files/%5Bwebdesign%5D/dreamweaver%208/Dreamweaver%208/Configuration/BuiltIn/StarterPages/mm_spacer.gif"


alt="" width="1" height="1" border="0" /></td> </tr> <tr bgcolor="#ffffff"> <td colspan="2" valign="top" bgcolor="#a4c2c2">&nbsp;</td> <td width="50" valign="top"><img src="file:

D|/Program%20Files/%5Bwebdesign%5D/dreamweaver%208/Dreamweaver%208/Configuration/BuiltIn/StarterPages/mm_spacer.gif"


alt="" width="50" height="1" border="0" /> <td width="536" valign="top"><br /> <br /> <table border="0" cellspacing="0" cellpadding="0" width="600"> <tr> <td width="600" class="pageName"><p>Add Item </p></td> </tr> <tr> <td class="bodyText"> Thanks for posting! Returning you back to the admin.. <meta HTTP-EQUIV="refresh" content=2;url=<index.php>> <p><br /> </p></td> </tr> </table> </td> <td width="4">&nbsp;</td> <td width="574">&nbsp;</td> </tr> <tr> <td colspan="6"> <img src="file:

D|/Program%20Files/%5Bwebdesign%5D/dreamweaver%208/Dreamweaver%208/Configuration/


BuiltIn/StarterPages/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr> <td width="15">&nbsp;</td> <td width="4">&nbsp;</td> <td width="50">&nbsp;</td> <td width="536">&nbsp;</td> <td width="4">&nbsp;</td> <td width="574">&nbsp;</td> </tr> </table> </body> </html>


(C) A. Eliëns 2/9/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.