public function __construct() { // the constructor function $this->settings = Settings::init(); // load settings file new SessionSaveHandler(getrootdirsrv().$this->settings->sessionsavepath); date_default_timezone_set($this->settings->timezone); // set the default timezone. may be we need to customize it for particular user $this->model = new Model($this->settings); // instantiate the Model class $this->less = new lessc; $this->StringForge = new StringForge($this->settings); }
function backup() { // $sql = "show tables;"; // $tables = $this->db->query_flat($sql); $tables = array('objects', 'customers', 'users'); // ajax_echo_r ($tables); $timestamp = date("Y-m-d-H-i-s"); $dir = "data/backups"; mkdirr(getrootdirsrv().$dir); $filename = getrootdirsrv().$dir."/izum-rel-".$timestamp.".xls"; $filename_client = getrootdir() .$dir."/izum-rel-".$timestamp.".xls"; $output = new PHPExcel; // Create new PHPExcel object $output->getProperties()->setCreator("Izum by Creative Force") ->setLastModifiedBy("Izum by Creative Force") ->setTitle("Izum Backup File - ".date("Y-m-d H:i:s")) ->setSubject("Office 2007 XLS Test Document") ->setDescription("Test document for Office 2007 XLS, generated using PHP classes.") ->setKeywords("Creative Force Izum backup") ->setCategory("Test result file"); $i = 0; $n = 1; $si = 0; $srcrow = array(); foreach ($tables as $tableName) { // $tableName = 'accounts'; // ajax_echo_r ($tableName); if (!in_array($tableName, array('visits', 'events'))) { $sql = "SELECT * FROM `".$tableName."` ORDER BY `DateAdded`;"; $ret = $this->db->query_first($sql); $col=0; if ($si) { // Add new sheet $output->createSheet($si)->setTitle($tableName); //Setting index when creating } else { $output->setActiveSheetIndex($si)->setTitle($tableName); } $colnames = getColNames(); foreach (array_keys((array)$ret) as $itm) { // for ($col=0; $col<$colCount; $col++) { // echo $itm; if ($colnames[$itm]) { $itm = $colnames[$itm]; } else { // echo $itm."-"; } $output->setActiveSheetIndex($si)->setCellValueByColumnAndRow($col, 1, $itm); // $srcrow[] = $xls->getCellByColumnAndRow($col,2)->getValue(); $col++; } // $colnames = getColNames(); $i=2; $sql = "SELECT * FROM `".$tableName."`;"; $ret = $this->db->query($sql); $subtables = array('districts' , 'customersubtypes' , 'methodsofpayment' , 'sources' , 'users' , 'directions' , 'housetypes' , 'markets' , 'mediators' , 'overlappingtypes' , 'layouttypes' , 'toilettypes' , 'conditions' , 'finishings' , 'floorsurfaces' , 'stovetypes' , 'doorstypes' , 'wallssurfaces' , 'wallsmaterials' , 'bathroomequipments' , 'windowstypes' , 'rightssources' , 'rightstransmissions' ); $subcolumns = array('DistrictID', 'CustomerSubtypeID', 'MethodOfPaymentID', 'SourceID', 'UserID', 'DirectionID', 'HouseTypeID', 'MarketID', 'MediatorID', 'OverlappingTypeID', 'LayoutTypeID', 'ToiletTypeID', 'ConditionID', 'FinishingID', 'FloorSurfaceID', 'StoveTypeID', 'DoorsTypeID', 'WallsSurfaceID', 'WallsMaterialID', 'BathroomEquipmentID', 'WindowsTypeID', 'RightsSourceID', 'RightsTransmissionID'); $ret = $this->fillSubtables($ret, $subtables, $subcolumns); // ajax_echo_r ($ret); // return false; foreach ($ret as $itm) { $col=0; $thisrecord = $this->cache[(string)$id]; foreach ($itm as $c) { $output->setActiveSheetIndex($si)->setCellValueByColumnAndRow($col, $i, $c); $col++; } $i++; } } $si++; } $output->setActiveSheetIndex(0); $objWriter = PHPExcel_IOFactory::createWriter($output, 'Excel5'); $objWriter->save($filename); return ($filename_client); /* $tableName = 'accounts'; $sql = "SELECT * FROM `".$tableName."`;"; $ret = $this->db->query_first($sql); ajax_echo_r ($ret); $buf = "INSERT INTO `` "; foreach (array_keys((array)$ret as $itm) { } // file_put_contents ($backupFile, implode())."\n", FILE_APPEND); $sql = "SELECT * FROM `".$tableName."`;"; $r = $this->db->query($sql); ajax_echo_r ($r); */ }
public function util() { $action = getvariablereq ('action'); // get action from the request $data = getvariablereq ('data' ); // get JSON data from the request switch ($action) { case ('latestversion'): $ret = sdir('data/dbconvert','*.zip'); $latestversion = 0; // ajax_echo_r ($ret); if ($ret) { foreach ($ret as $file) { $p0 = strpos($file,".")+1; $p1 = strrpos($file,"."); $thisversion = substr($file, $p0, $p1-$p0); $thisver = explode(".",$thisversion); $ma = (int)$thisver[0]; $mi = (int)$thisver[1]; $re = (int)$thisver[2]; $v = $ma*100000 + $mi*1000 + $re; if ($v>$latestversion) $latestversion = $v; } echo $latestversion; } break; case ('getlatestversion'): $ret = sdir('data/dbconvert','*.zip'); $latestversion = 0; if ($ret) { foreach ($ret as $file) { $p0 = strpos($file,".")+1; $p1 = strrpos($file,"."); $thisversion = substr($file, $p0, $p1-$p0); $thisver = explode(".",$thisversion); $ma = (int)$thisver[0]; $mi = (int)$thisver[1]; $re = (int)$thisver[2]; $v = $ma*100000 + $mi*1000 + $re; if ($v==$data) { $fileext = strtolower(substr($file,strrpos($file,".")+1)); $type = mimetype($fileext); header("Content-type: ".$type); $today = date("F j, Y, g:i a"); $time = time(); header("Content-Disposition: attachment;filename=".$file); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($file)); header('Pragma: no-cache'); header('Expires: 0'); echo file_get_contents(getrootdirsrv().$file); } } // echo $latestversion; } break; } // ajax_echo_r ($ret); }
<? include_once('model/legacy.php'); $file = $_GET['name']; $allowedfileext = array('jpg', 'jpeg', 'png', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'js', 'htm', 'html', 'css', 'svg'); $fileext = strtolower(substr($file,strrpos($file,".")+1)); if (in_array($fileext, $allowedfileext)) { $type = mimetype($fileext); header("Content-type: ".$type); $today = date("F j, Y, g:i a"); $time = time(); header("Content-Disposition: attachment;filename=".$file); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($file)); header('Pragma: no-cache'); header('Expires: 0'); echo file_get_contents(getrootdirsrv().$file); } ?>