-rwxrwxrwx read, write, & execute for owner, group and others mkdir($directoryName, 0777); } // create visitor log file date wise $visitorLogFileName = date('Y-m-d').'.txt'; // get ip address of visitor $visitorIP = $_SERVER['REMOTE_ADDR']; $visitorLogFileFullDirectory = $directoryName.'/'.$visitorLogFileName; $visitorVisitedURL = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $visitorInfoToWrite = ' =========================== IP: '.$visitorIP .' Time: '.date('Y/m/d H:i:s a').' Filename: '.basename($_SERVER['PHP_SELF']).' URL: '.$visitorVisitedURL.' '; // put the file in under visitor directory file_put_contents($visitorLogFileFullDirectory, $visitorInfoToWrite, FILE_APPEND); /************************* END **************************** */ /**Smarty Object */ $smarty = new Smarty(); /**Smarty Templating Related Directories */ $smarty->template_dir = dirname(__FILE__).'/templates'; $smarty->compile_dir = dirname(__FILE__).'/templates_c'; /**Database Object */ $db_disk_info = new Disk_Info_Rifayet($db); $data_inserted = false; // avoid XSS attack function get_data($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } /**Create Data in disk_info table */ // check if the request is post method or not // prevent form-resubmission using javascript [check script.js] if ($_SERVER["REQUEST_METHOD"] == "POST") { if(isset($_POST['disk_info_add'])) { //echo "
";
            //print_r($_POST);
            //echo "
"; // create a array to store form informations $singleRowData = array(); $allRowData = array(); // All ID's inserted in DB $allIdInserted = array(); // get all the form fields information as key value pair $count = 0; $disk_info_count = 0; // today $todays_date = date("Y-m-d"); // echo "

Date: $todays_date

"; // check how many columns needed to be inserted as one row $disk_info_num_of_columns_in_one_row = 5; // keys for the disk informations $disk_info_keys = array( "0" => "disk_model", "1" => "disk_serial", "2" => "disk_type", "3" => "disk_size", "4" => "disk_manufacturer" ); // Get all the post value as key value pair foreach ($_POST as $key=>$value) { // echo "

$count. $key => $value

"; if($count != $disk_info_num_of_columns_in_one_row && $key != "disk_info_add") { // still single form $disk_info_column_key = $disk_info_keys[$count]; $singleRowData[$disk_info_column_key] = get_data($value); // increment count by 1 $count += 1; } // check if it is a single row if($count == $disk_info_num_of_columns_in_one_row) { // new disk info found // increment disk info count $disk_info_count += 1; // add the current date $singleRowData["date_added"] = $todays_date; // single row complete //echo "
";
                    //echo "Disk Information $disk_info_count: 
"; //print_r($singleRowData); //echo "
"; // Insert into database if(DATA_CREATE_CONTROL == "0") { // data create enabled $create_success = $db_disk_info->createSingle($singleRowData); $allRowData["disk_info_$disk_info_count"] = $singleRowData; $allIdInserted["$create_success"] = $create_success; $smarty->assign("data_inserted", true); } else { // data create disabled $message = "[New data creation is disabled for Disk_info.]
But it can be enabled by module's specified define file."; $smarty->assign("data_inserted", false); $smarty->assign("create_failed", $message); } // reset singleRowData array $singleRowData = array(); // set count to 0 $count = 0; } } // end of foreach // all row Data // this can be used to show all inserted rows //echo "
";
            //echo "All Disk Informations
"; // print_r($allRowData); //foreach ($allRowData as $key=>$singleRow) { //print_r($singleRow); //} //echo "
"; // TEST // $insertMultpleAtOnce = $db_disk_info->createMultiple($allRowData); // TEST END $smarty->assign("allIdInserted", $allIdInserted); $smarty->assign("allRowData", $allRowData); } } // Read All Disk Informations $read_all_disk_info = $db_disk_info->readAll(); // Search date wise if($_SERVER["REQUEST_METHOD"] == "POST") { if(isset($_POST["disk_info_search"])) { //echo "
";
            //print_r($_POST);
            //echo "
"; if(isset($_POST["start_date"]) && isset($_POST["end_date"])) { $start_date = $_POST["start_date"]; $end_date = $_POST["end_date"]; if($end_date != null) { // $serachDateWise = true; $read_all_disk_info = $db_disk_info->readAllDateWise($start_date, $end_date); } else { $read_all_disk_info = $db_disk_info->readAllDateWiseSingleDate($start_date); } } } } // Get all data if($_SERVER["REQUEST_METHOD"] == "POST") { if(isset($_POST["disk_info_get_all"])) { $read_all_disk_info = $db_disk_info->readAll(); } } //echo "All Data From [disk_info] table
"; // echo "
";
    // print_r($read_all_disk_info);
    // echo "
"; $smarty->assign("all_disk_info", $read_all_disk_info); /**Module Program Start */ $smarty->assign("appName", APP_NAME); $smarty->assign("dbName", DB_NAME); $smarty->assign("dbTableName", TABLE_NAME); $smarty->assign("moduleName", MODULE_NAME); $smarty->assign("title", MODULE_HTML_TITLE); $smarty->assign("name", MODULE_HTML_TITLE_NAME); $smarty->display('./templates/index.tpl'); /**Module Program End */ ?>