Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.17.78.184
<?php
function getDegreeCodes($str)
{
$posh = strripos($str,'-');
// $posd = strripos($str,'.');
$degree = substr($str, $posh+1, -4);
$degree = strtoupper($degree);
return $degree;
}
function loadTimeTable($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$deggrp = $aobj_context->mobj_data["deggrp"];
$filename = $aobj_context->mobj_data["gfilename"];
$source = $_FILES["file"]["tmp_name"];
$file = substr($filename,15);
// var_dump($filename);
$query = "SELECT fdbname, ffolder FROM dbname WHERE funivcode = $univcode";
$result = $aobj_context->mobj_db->GetRow($query);
$db = $result['fdbname'];
$folder = $result['ffolder'];
// var_dump( dirname ( __FILE__ ));
// var_dump($aobj_context->main_src);
// $ds = DIRECTORY_SEPARATOR;
$full_path = $aobj_context->main_src.'uploadTT/'.$filename;
// var_dump($full_path);
$target_path = dirname(dirname($_SERVER['SCRIPT_FILENAME']));
// var_dump($target_path);
$target_folder = $target_path.'/'.$folder.'/timetable';
if(!file_exists($target_folder))
{
mkdir($target_folder);
}
$target_path = $target_folder.'/'.$file;
// var_dump($target_path);
$f = array();
if(copy($full_path, $target_path)) {
echo "file moved";
$zip = new ZipArchive();
$x = $zip->open($target_path);
if ($x === true) {
$zip->extractTo($target_folder); // change this to the correct site path
$zip->close();
unlink($target_path);
$filenames = scandir($target_folder);
$fpath = basename($target_folder).PHP_EOL;
// var_dump($fpath);
foreach($filenames as $files){
if(is_dir($files)){
}else{
$f[] = $files;
}
}
$degree = array_map("getDegreeCodes",$f);
$sep = "'" .implode("','",$degree). "'";
$query = "INSERT IGNORE INTO {$db}.deg_timetable(fdegree, fdescpn,ffilename,fpath,factive)
SELECT fdegree, fdescpn,CONCAT('bcu-tt-2018-2-',LCASE(fdegree),'.pdf'), '{$fpath}', 'F' FROM {$db}.degree WHERE fdegree IN ($sep)";
// var_dump($query);
$results = $aobj_context->mobj_db->Execute($query);
// var_dump($results);
}
}
else
{
$message = "There was a problem with the upload. Please try again.";
echo $message;
}
}
?>
|