function upload($option, $file, $dest_dir) { global $mainframe; $format = substr($file['name'], -3); $allowable = array('xls'); //only support excel file (2003) $noMatch = 0; foreach ($allowable as $ext) { if (strcasecmp($format, $ext) == 0) { $noMatch = 1; } } if (!$noMatch) { $mainframe->redirect('index.php?option=' . $option, $format . ' file type is not supported'); } else { /////////////////////////////////////////// $tableName = "#__deneme"; $user =& JFactory::getUser(); $firmId = $user->id; /////////////////////////////////////////// if (JRequest::getInt('files') == 0) { // New File $examId = findExamId($tableName, $firmId); } else { $examId = JRequest::getInt('files'); deleteRecords($tableName, $firmId, $examId); } $filename = "sinav_" . $firmId . "_" . $examId; $uf = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tempdata' . DIRECTORY_SEPARATOR . $filename . '.' . $format; //uploaded file name $upTemp = move_uploaded_file($file['tmp_name'], $uf); chmod($uf, 0755); if ($upTemp) { do_import($uf, $option, $firmId, $examId); //after upload file, proceed data import. } else { $mainframe->redirect('index.php?option=' . $option, 'Fail to import data'); } } }
function callDB() { $option = $_REQUEST['operation']; $table = $_REQUEST['target']; $selectSQL = ''; $loadSql = ''; $newSql = ''; $updateSql = ''; $name = ''; $id = ''; $param = ''; switch ($table) { case 2: $tableName = 'project_info'; if ($option == 'read') { $loadSql = "select p.ID, p.IMAGE,p.IMAGE_PATH, c.Name, p.CAPTION,p.CREATED, p.UPDATED from project_info p inner join category c on p.IMAGE_CATEGORY = c.ID where p.DELETED=0 and c.DELETED=0"; } if ($option == 'select') { $id = $_REQUEST['RecId']; $selectSQL = "select p.ID,p.IMAGE,p.IMAGE_PATH, c.NAME, p.CAPTION from project_info p inner join category c on p.IMAGE_CATEGORY = c.ID where p.ID = {$id}"; } if ($option == 'new') { $param = $_REQUEST['name']; $newSql = "insert into project_info (IMAGE, IMAGE_CATEGORY, CAPTION, IMAGE_PATH) VALUES ('{$param['0']}',(select ID from category where NAME= '{$param['1']}' and DELETED = 0),'{$param['2']}', '{$param['3']}')"; } if ($option == 'update') { $param = $_REQUEST['name']; $id = $_REQUEST['id']; if (empty($param[3])) { $updateSql = "update project_info set IMAGE='{$param['0']}',IMAGE_CATEGORY = (select ID from category where Name='{$param['1']}'), CAPTION ='{$param['2']}', UPDATED = now() where ID = {$id} and DELETED=0"; } else { $updateSql = "update project_info set IMAGE='{$param['0']}',IMAGE_CATEGORY = (select ID from category where Name='{$param['1']}'), CAPTION ='{$param['2']}', IMAGE_PATH = '{$param['3']}', UPDATED = now() where ID = {$id} and DELETED=0"; } } break; case 4: $tableName = 'slider'; if ($option == 'read') { $loadSql = "select * from slider where DELETED = 0"; } if ($option == 'select') { $id = $_REQUEST['RecId']; $selectSQL = "select * from slider where ID={$id}"; } if ($option == 'new') { $param = $_REQUEST['name']; $newSql = "insert into slider (IMAGE, HEAD_CAPTION, SUB_CAPTION, IMAGE_PATH) VALUES ('{$param['0']}','{$param['1']}','{$param['2']}', '{$param['3']}')"; //print_r($newSql); } if ($option == 'update') { $param = $_REQUEST['name']; $id = $_REQUEST['id']; if (empty($param[3])) { $updateSql = "update slider set IMAGE = '{$param['0']}', HEAD_CAPTION = '{$param['1']}' , SUB_CAPTION = '{$param['2']}' , UPDATED = now() where ID = {$id} and DELETED= 0 "; } else { $updateSql = "update slider set IMAGE = '{$param['0']}', HEAD_CAPTION = '{$param['1']}' , SUB_CAPTION = '{$param['2']}', IMAGE_PATH = '{$param['3']}' , UPDATED = now() where ID = {$id} and DELETED= 0 "; } } break; } switch ($option) { case "read": //callread(); echo json_encode(readRecords($loadSql)); break; case "select": echo json_encode(readRecords($selectSQL)); break; case "update": //$date = now(); //echo($date); updateRecords($updateSql); if ($table == 2) { echo "<script>window.location = 'portfolio.php';</script>"; } else { if ($table == 4) { echo "<script>window.location = 'slider.php';</script>"; } } break; case "delete": $id = $_REQUEST['RecId']; $sql = "update {$tableName} set DELETED = 1 where ID={$id} "; echo deleteRecords($sql); break; case "new": WriteRecords($newSql); if ($table == 2) { echo "<script>window.location = 'portfolio.php';</script>"; } else { if ($table == 4) { echo "<script>window.location = 'slider.php';</script>"; } } break; } }
?> "> <div style="<?php echo $style2; ?> "><b>Info</b></div> ** ERROR POSTING MESSAGE ** </div> <br> <?php } } } else { if ($action == "mb_nuke") { $id = rt("mb_id"); deleteRecords($mb_table, "where id={$id}"); } } if (!$mb_nopost) { ?> <div style="<?php echo $style1; ?> "> <div style="<?php echo $style2; ?> "><b>Post a Message </b></div> <table style="padding-top: 10px"> <form method=post >
if (isset($_GET["pcuri"])) { if ($_GET["pcuri"] == "Show") { $result = showTableAll($connection, "pc_uri"); } else { deleteRecords($connection, "pc_uri", $_GET["drecord"]); $result = showTableAll($connection, "pc_uri"); } } else { if (isset($_GET["laptopuri"])) { if ($_GET["laptopuri"] == "Show") { $result = showTableAll($connection, "laptop_uri"); } else { deleteRecords($connection, "laptop_uri", $_GET["drecord"]); $result = showTableAll($connection, "laptop_uri"); } } else { if ($_GET["imprimante"] == "Show") { $result = showTableAll($connection, "imprimante"); } else { deleteRecords($connection, "imprimante", $_GET["drecord"]); $result = showTableAll($connection, "imprimante"); } } } } printQueryResult($result); ?> </div> </form> </body> </html>
function callDB() { $option = $_REQUEST['operation']; //echo('option choosed'.$option); //$option="update"; //$tableName=$_GET['table']; //$tableName='category'; $table = $_REQUEST['target']; $selectSQL; $loadSql; $newSql; $updateSql; $name; $id; $param; switch ($table) { case 1: $tableName = 'category'; //echo ' '.$tableName.' '.$option; if ($option == 'read') { $loadSql = "select * from category where DELETED = 0"; } if ($option == 'select') { $id = $_REQUEST['RecId']; $selectSQL = "select * from category where ID={$id}"; } if ($option == 'update') { $name = $_REQUEST['name']; //check same name for current record $match = "select NAME from category where NAME= '{$name}' and DELETED= 0 "; $result = readRecords($match); if ($result) { echo 'duplicate'; return; } else { $id = $_REQUEST['RecId']; $match = "select NAME from category where NAME = '{$name}' and ID != {$id} and DELETED = 0 "; $result = readRecords($match); //print_r($result); if ($result) { //echo('in second update'); echo 'duplicate'; return; } else { //print_r('in update'); $updateSql = "update category set NAME='{$name}', UPDATED = now() where ID = {$id} and deleted=0"; //print_r($updateSql); } } } if ($option == "new") { $name = $_REQUEST['name']; //check same name for current record $match = "select NAME from category where NAME= '{$name}' and DELETED= 0 "; $result = readRecords($match); if ($result) { echo 'duplicate'; return; } else { $newSql = "insert into category(NAME) values('{$name}')"; } } break; case 3: $tableName = 'footer_info'; //echo ' '.$tableName.' '.$option; if ($option == 'read') { $loadSql = "select * from footer_info where DELETED = 0"; } if ($option == 'select') { $id = $_REQUEST['RecId']; $selectSQL = "select * from footer_info where ID={$id}"; } if ($option == 'new') { $name = $_REQUEST['name']; //echo($name); $newSql = "insert into footer_info(ABOUT) values('{$name}')"; } if ($option == 'update') { $name = $_REQUEST['name']; $id = $_REQUEST['RecId']; $updateSql = "update footer_info set ABOUT='{$name}', UPDATED = now() where ID = {$id} and deleted=0"; } break; } //echo($table); switch ($option) { case "read": //callread(); echo json_encode(readRecords($loadSql)); break; case "select": echo json_encode(readRecords($selectSQL)); break; case "update": //$date = now(); //echo($date); //echo('in update'); die(); echo updateRecords($updateSql); //echo "<script>window.location = 'fileUpload.php';</script>"; break; case "delete": $id = $_REQUEST['RecId']; $sql = "update {$tableName} set DELETED = 1 where ID={$id} "; echo deleteRecords($sql); break; case "new": echo json_encode(WriteRecords($newSql)); break; } }