para_bellum

update.php - dblp

May 20th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.48 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. function backToPrevious($time) {
  5.     echo '<meta http-equiv="refresh" content="',$time,';url=',$_SERVER['HTTP_REFERER'],'" />';
  6. }
  7.  
  8. if(isset($_SESSION['admin']) && $_SESSION['admin']==true && isset($_POST['entity_search'])) {
  9.  
  10. include_once "db_connect.php";
  11.  
  12. if($_POST['entity_choice']=="author") {
  13.     $sql='UPDATE author SET Name=\''.$_POST['name'].'\' WHERE Name=\''.$_POST['entity_search'].'\'';
  14.     $send=$db->query($sql);
  15.     if($send) {
  16.         echo 'Success';
  17.         backToPrevious(5);
  18.     }
  19.     else {
  20.         echo 'Failure';
  21.         echo $sql;
  22.         backToPrevious(5);
  23.     }
  24. }
  25.  
  26. else if($_POST['entity_choice']=="editor") {
  27.     $sql='UPDATE editor SET Name=\''.$_POST['name'].'\' WHERE Name=\''.$_POST['entity_search'].'\'';
  28.     $send=$db->query($sql);
  29.     if($send) {
  30.         echo 'Success';
  31.         backToPrevious(5);
  32.     }
  33.     else {
  34.         echo 'Failure';
  35.         backToPrevious(5);
  36.     }
  37. }
  38.  
  39. else if($_POST['entity_choice']=="publisher") {
  40.     $sql='UPDATE publisher SET Name=\''.$_POST['name'].'\' WHERE Name=\''.$_POST['entity_search'].'\'';
  41.     $send=$db->query($sql);
  42.     if($send) {
  43.         echo 'Success';
  44.         backToPrevious(5);
  45.     }
  46.     else {
  47.         echo 'Failure';
  48.         backToPrevious(5);
  49.     }
  50. }
  51.  
  52.  
  53. else if($_POST['entity_choice']=="article" || $_POST['entity_choice']=="book" || $_POST['entity_choice']=="incollection" || $_POST['entity_choice']=="master_thesis" || $_POST['entity_choice']=="phd_thesis") {
  54.     $paramArray=array();
  55.     if(isset($_POST['key']))
  56.         $paramArray[]='PubKey=\''.$_POST['key'].'\'';
  57.     if(isset($_POST['title']))
  58.         $paramArray[]='Title=\''.$_POST['title'].'\'';
  59.     if(isset($_POST['year']))
  60.         $paramArray[]='Year=\''.$_POST['year'].'\'';
  61.     if(isset($_POST['url']))
  62.         $paramArray[]='url=\''.$_POST['url'].'\'';
  63.     if(isset($_POST['ee']))
  64.         $paramArray[]='ee=\''.$_POST['ee'].'\'';
  65.     $paramArray[]='mdate=CURDATE()';
  66.  
  67.     if(count($paramArray)>0) {
  68.         $qry_param=implode(', ',$paramArray);
  69.         $sql='UPDATE publication SET '.$qry_param.' WHERE PubKey=\''.$_POST['entity_search'].'\'';
  70.         $send=$db->query($sql);
  71.     }
  72.    
  73.     if($_POST['entity_choice']=="article") {
  74.         $paramArray=array();
  75.         if(isset($_POST['volume']))
  76.             $paramArray[]='Volume=\''.$_POST['volume'].'\'';
  77.         if(isset($_POST['number']))
  78.             $paramArray[]='Number=\''.$_POST['number'].'\'';
  79.         if(isset($_POST['pages']))
  80.             $paramArray[]='Pages=\''.$_POST['pages'].'\'';
  81.  
  82.         if(count($paramArray)>0) {
  83.             $qry_param=implode(', ',$paramArray);
  84.             $sql='UPDATE pub_article SET '.$qry_param.' WHERE PubID=\''.$_POST['entity_search'].'\'';
  85.             $send=$db->query($sql);
  86.             if($send) {
  87.                 echo 'Success';
  88.                 backToPrevious(5);
  89.             }
  90.             else {
  91.                 echo 'Failure';
  92.                 backToPrevious(5);
  93.             }
  94.         }
  95.     }
  96.        
  97.     else if($_POST['entity_choice']=="book") {
  98.         $paramArray=array();
  99.         if(isset($_POST['volume']))
  100.             $paramArray[]='Volume=\''.$_POST['volume'].'\'';
  101.         if(isset($_POST['number']))
  102.             $paramArray[]='Series=\''.$_POST['series'].'\'';
  103.         if(isset($_POST['isbn']))
  104.             $paramArray[]='isbn=\''.$_POST['isbn'].'\'';
  105.  
  106.         if(count($paramArray)>0) {
  107.             $qry_param=implode(', ',$paramArray);
  108.             $sql='UPDATE pub_book SET '.$qry_param.' WHERE PubID=\''.$_POST['entity_search'].'\'';
  109.             $send=$db->query($sql);
  110.             if($send) {
  111.                 echo 'Success';
  112.                 backToPrevious(5);
  113.             }
  114.             else {
  115.                 echo 'Failure';
  116.                 backToPrevious(5);
  117.             }
  118.         }
  119.     }  
  120.    
  121.     else if($_POST['entity_choice']=="incollection") {
  122.         $paramArray=array();
  123.         if(isset($_POST['chapter']))
  124.             $paramArray[]='Chapter=\''.$_POST['chapter'].'\'';
  125.         if(isset($_POST['pages']))
  126.             $paramArray[]='Pages=\''.$_POST['pages'].'\'';
  127.  
  128.         if(count($paramArray)>0) {
  129.             $qry_param=implode(', ',$paramArray);
  130.             $sql='UPDATE pub_incollection SET '.$qry_param.' WHERE PubID=\''.$_POST['entity_search'].'\'';
  131.             $send=$db->query($sql);
  132.             if($send) {
  133.                 echo 'Success';
  134.                 backToPrevious(5);
  135.             }
  136.             else {
  137.                 echo 'Failure';
  138.                 backToPrevious(5);
  139.             }
  140.         }
  141.     }  
  142.  
  143.     else if($_POST['entity_choice']=="master_thesis") {
  144.         $paramArray=array();
  145.         if(isset($_POST['school']))
  146.             $paramArray[]='School=\''.$_POST['school'].'\'';
  147.    
  148.         if(count($paramArray)>0) {
  149.             $qry_param=implode(', ',$paramArray);
  150.             $sql='UPDATE pub_master_thesis SET '.$qry_param.' WHERE PubID=\''.$_POST['entity_search'].'\'';
  151.             $send=$db->query($sql);
  152.             if($send) {
  153.                 echo 'Success';
  154.                 backToPrevious(5);
  155.             }
  156.             else {
  157.                 echo 'Failure';
  158.                 backToPrevious(5);
  159.             }
  160.         }
  161.     }  
  162.    
  163.     else if($_POST['entity_choice']=="phd_thesis") {
  164.         $paramArray=array();
  165.         if(isset($_POST['school']))
  166.             $paramArray[]='School=\''.$_POST['school'].'\'';
  167.         if(isset($_POST['isbn']))
  168.             $paramArray[]='isbn=\''.$_POST['isbn'].'\'';
  169.    
  170.         if(count($paramArray)>0) {
  171.             $qry_param=implode(', ',$paramArray);
  172.             $sql='UPDATE pub_phd_thesis SET '.$qry_param.' WHERE PubID=\''.$_POST['entity_search'].'\'';
  173.             $send=$db->query($sql);
  174.             if($send) {
  175.                 echo 'Success';
  176.                 backToPrevious(5);
  177.             }
  178.             else {
  179.                 echo 'Failure';
  180.                 backToPrevious(5);
  181.             }
  182.         }
  183.     }  
  184. }
  185.  
  186. else if($_POST['entity_choice']=="journal") {
  187.     $paramArray=array();
  188.     if(isset($_POST['journal']))
  189.         $paramArray[]='Title=\''.$_POST['journal'].'\'';
  190.  
  191.     if(count($paramArray)>0) {
  192.         $qry_param=implode(', ',$paramArray);
  193.         $sql='UPDATE journal SET '.$qry_param.' WHERE Title=\''.$_POST['entity_search'].'\'';
  194.         $send=$db->query($sql);
  195.         if($send) {
  196.             echo 'Success';
  197.             backToPrevious(5);
  198.         }
  199.         else {
  200.             echo 'Failure';
  201.             echo $sql;
  202.             backToPrevious(5);
  203.         }
  204.     }
  205. }
  206.  
  207. }//Fin if isset($_session(admin)
  208. else {
  209.     echo 'Only admin can access this area.';
  210.     backToPrevious(5);
  211. }
  212. exit();
  213.  
  214.  
  215. ?>
Advertisement
Add Comment
Please, Sign In to add comment