session_start();
//print_r($_POST);
//print_r($_SESSION);
if ($_GET['set'] == 'session') {
$pg = $_GET['page'];
$pg = str_replace("____AND____", "&", $pg);
//$_SESSION['currentpage'] = ($_GET['page']) ? $pg : $_SESSION['currentpage'];
//$_SESSION['currentpage'] = $_GET['table'];
$_SESSION['currentpage'] = strtok($pg,'?');
echo '';
exit;
}
if ($_GET['log'] == 'out') {
session_destroy();
header("location: /");
}
$root = '/home/frontlin/domains/flnr.nl/private_html/';
require_once $root.'lib/class.flnr.php';
require_once $root.'lib/fbsdk/src/facebook.php';
require_once $root.'lib/fbsdk/src/ffb_frontliner_global.php';
$flnr = new flnr('localhost', 'frontlin_a', 'BDnd9121', 'frontlin_flnr', $root);
$mobile = $flnr->checkMobile();
$js = new js($root);
$css = new css($root);
$smartmenu = new smartmenu($flnr, $mobile, 'pages/');
$links = new links($flnr);
$forms = new forms($flnr, $links);
$post = new post($flnr);
if (!$_SESSION['tableinformation']) {
$_SESSION['tableinformation'] = $forms->tblIdentification();
}
if ($_GET['export'] == 'csv') {
$forms->exportCsv($_GET['table']);
exit;
}
if ($_GET['export'] == 'csvtemplate') {
$forms->exportCsv($_GET['table'], true);
exit;
}
if ($_FILES['csv_file']) {
$table = $_POST['csv_table'];
$scheme = $flnr->getSqlSchemeTable($table);
$tinfo = $forms->tblIdentification($table);
$csvfile = $_FILES['csv_file']['tmp_name'];
$handle = fopen($csvfile, "r");
$r = 0;
$startrow = 1;
$col = 0;
$datacolc = 0;
foreach ($scheme as $colv) {
$colArr[$col] = $colv['COLUMN_COMMENT'];
$colArrDf[$col] = $colv['COLUMN_DEFAULT'];
$col++;
}
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
if ($r >= $startrow) {
$dstr = 'NULL,';
$datacolc = 0;
foreach ($data as $v) {
$c_comment = $colArr[($datacolc+1)];
$c_default = $colArrDf[($datacolc+1)];
$e = explode(":", str_replace("!", "", str_replace(".", "", $c_comment)));
$c = ($e[0]) ? $e[0] : 'txt';
$sfld = $e[1];
if ($c == 'sf' || $c == 'lsf' || $c == 'ac') {
$tinfoSf = $forms->tblIdentification($sfld);
$srcSqlStr = "SELECT * FROM `".$sfld."` WHERE `".$tinfoSf[4]."` = '".$v."'";
$sfxsql = $flnr->getSql($srcSqlStr);
$id = $sfxsql['array'][0][$tinfoSf[0]];
$code = $sfxsql['array'][0][$tinfoSf[4]];
$saveValue = ($c == 'ac') ? $code : $id;
}
else {
$finddate = explode("-", $v);
$mktime = mktime(0, 0, 0, $finddate[1], $finddate[0], $finddate[2]);
$saveValue = ($mktime) ? $mktime : $forms->csvSafeName($v);
}
$saveValue = ($saveValue != '') ? $saveValue : $colArrDf[$col];
$dstr .= "'".addslashes($saveValue)."',";
$datacolc++;
}
$sqlstr="INSERT INTO ".$table." VALUES (".substr($dstr, 0, -1).")";
//echo $sqlstr.'
';
$flnr->qSql($sqlstr);
}
$r++;
}
fclose($handle);
//echo $result;
//echo '
'.print_r($tinfo, true).''; //exit; $_SESSION['postsuccess'] = 'CSV import completed.'; header("location: /"); } if ($_POST) { if (!$_POST['nothing']) { $a = explode("_", $_POST['action']); $action = $a[0]; $table = str_replace($action."_", "", $_POST['action']); //echo '
'.print_r($_POST, true).''; //echo '
'.print_r($_FILES, true).''; //exit; $editSql = $post->postToMysql($table, $_POST, $_FILES, $action, $root.'files/'); } } if ($_GET['dialog']) { $html = ''; echo $html; exit; } // start html $html = ''."\n"; $html .= ''."\n"; $html .= ''."\n"; $html .= $css->htmlHeadCssSrc(); $html .= $js->htmlHeadJsSrc(); $html .= ''; $html .= ''."\n"; $html .= ''."\n"; $html .= ($_GET['table'] != 'flnr_links') ? '' : ''; $html .= ''."\n"; $html .= ''; $html .= ''; $html .= ''; $scale = '0.7'; $html .= ''; //$html .= ''; $html .= '