Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/indem/pcstore/pcStore/setup/
Upload File :
Current File : /var/www/html/mmishra/indem/pcstore/pcStore/setup/license_info.inc

<?php
echo "<b>License Info</b><br>";

//require_once("setup.php");

$mm_license_info = new license_info($rid,$con);
$mm_license_info->get_form_data();

switch ($_POST["submit"]){
case "SAVE":
  $mm_license_info->insert_update_table();
  break;
case "DELETE":
  $mm_license_info->delete_from_table();
  break;
}
$mm_license_info->show_form();


global $rid;
$rid = $_REQUEST["row_id"];

class license_info {
  var $rid;
  var $tbl;
  var $con;
  var $str;
  var $upload_dir;
  var $rs;

  var $row_id;
  var $firm_name;
  var $contact_address;
  var $phone_no;
  var $email;
  var $logo_file;
  var $signature_file;
  var $installation_path;
  
  function license_info($rid, $con){
    $this->rid = $rid;
    $this->tbl = "license_info";
    $this->con = $con;
  }
   
  function get_form_data(){
    $upload_dir = "/home/mcell/public_html/image/";
    $this->row_id = $_POST["row_id"];
    $this->firm_name = $_POST["firm_name"];
    $this->contact_address = $_POST["contact_address"];
    $this->phone_no = $_POST["phone_no"];
    $this->email = $_POST["email"];

    if ($_FILES["logo_file"]["name"]){
      $this->logo_file = $_FILES["logo_file"]["name"];
      move_uploaded_file($_FILES["logo_file"]["tmp_name"], $upload_dir . $_FILES["logo_file"]["name"]);
    }
    if ($_FILES["signature_file"]["name"]){
      $this->signature_file = $_FILES["signature_file"]["name"];
      move_uploaded_file($_FILES["signature_file"]["tmp_name"], $upload_dir . $_FILES["signature_file"]["name"]);
    }

    $this->installation_path = $_POST["installation_path"];
    if (!$this->installation_path) $this->installation_path = $_SERVER["DOCUMENT_ROOT"];
  }

  function insert_update_table(){
    if (mysql_num_rows(mysql_query("select * from $this->tbl where row_id=$this->rid", $this->con))){
      $sql = "update $this->tbl set firm_name='$this->firm_name',contact_address='$this->contact_address',
              phone_no='$this->phone_no',email='$this->email'";
      if ($this->logo_file) $sql .= ",logo_file='$this->logo_file'";
      if ($this->signature_file) $sql .= ",signature_file='$this->signature_file'";
      $sql .= ",installation_path='$this->installation_path' where row_id=$this->rid";
      mysql_query($sql, $this->con);
    }else{
      $sql = "insert into $this->tbl(firm_name,contact_address,phone_no,email,logo_file,
              signature_file,installation_path) values('$this->firm_name','$this->contact_address',
              '$this->phone_no','$this->email','$this->logo_file','$this->signature_file','$this->installation_path')";
      mysql_query($sql, $this->con);
    }

    if ($this->installation_path){
      $fp = fopen($this->installation_path . "/include/title.inc", "w");
      if($fp){
        $str = "<table cellpadding=0 cellspacing=0 width='98%'><tr valign='center'>
        <td width='10%' align='center'>
        <a href='http://" . $_SERVER["HTTP_HOST"] . "' onMouseOver=\"show('j_dj')\" onMouseOut=\"hide('j_dj')\">
        <img src='image/pc.jpg' width='50' height='50'></a></td>
        <td width='80%' align='center'><font face='verdana' size='+1'>$this->firm_name</font>
        <br><font color='black'>$this->contact_address</font>
        <br><br><font size='3px' color='green'>(A web-based Inventory Management System)</font></td>
        <td width='10%' align='center'>
        <a href='http://www.iiita.ac.in' onMouseOver=\"show('j_dj')\" onMouseOut=\"hide('j_dj')\">
        <img src='image/{$this->logo_file}' width='50' height='50'></a></td>
        </tr></table>
        ";

        if (!fwrite($fp, $str)) $str = "Can not create file";
        fclose($fp);
      }else{
        $str = "Can not open file";
      }
    }
    access_log($sql, $this->con);
  }

  function delete_from_table(){
    $sql = "delete from $this->tbl where row_id=$this->rid";
    mysql_query($sql, $this->con);
    access_log($sql, $this->con);
  }


  function show_form(){
    $rs = mysql_query("select * from $this->tbl", $this->con);
    if(!$rs) echo error_message(sql_error());
    $o = mysql_fetch_object($rs);
    $this->row_id = $o->row_id;
    $this->firm_name = $o->firm_name;
    $this->contact_address = $o->contact_address;
    $this->phone_no = $o->phone_no;
    $this->email = $o->email;
    $this->logo_file = $o->logo_file;
    $this->signature_file = $o->signature_file;
    $this->installation_path = $o->installation_path;
    
    echo "<b>Edit</b><table width='80%'>
    <tr><td>Firm Name</td><td><input type='text' name='firm_name' value='$this->firm_name' size='50'></td></tr>
    <tr valign='top'><td>Contact Address</td><td><textarea name='contact_address' rows='3' cols='50'>$this->contact_address</textarea></td></tr>
    <tr><td>Phone No.</td><td><input type='text' name='phone_no' value='$this->phone_no' size='50'></td></tr>
    <tr><td>Email</td><td><input type='text' name='email' value='$this->email' size='50'></td></tr>
    <tr><td>Logo File</td><td><input type='file' name='logo_file' size='50'>$this->logo_file</td></tr>
    <tr><td>Signature File</td><td><input type='file' name='signature_file' size='50'>$this->signature_file</td></tr>
    <tr><td>Installation Path</td><td><input type='text' name='installation_path' value='$this->installation_path' size='50'></td></tr>
    <tr><td><input type='hidden' name='row_id' value='$this->row_id'></td><td><input type='submit' name='submit' value='SAVE'></td></tr>
    </table>
";
  }
}


?>