Exemplo n.º 1
0
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 {
        $uf = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tempdata' . DIRECTORY_SEPARATOR . date("YmdGhis") . '.' . $format;
        //uploaded file name
        $upTemp = move_uploaded_file($file['tmp_name'], $uf);
        chmod($uf, 0755);
        if ($upTemp) {
            do_import($uf, $option);
            //after upload file, proceed data import.
        } else {
            $mainframe->redirect('index.php?option=' . $option, 'Fail to import data');
        }
    }
}
Exemplo n.º 2
0
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');
        }
    }
}
Exemplo n.º 3
0
}
$action = param_integer('action', PRINTUPLOADFORM_ACT);
switch ($action) {
    case PRINTUPLOADFORM_ACT:
    default:
        print_upload_form();
        break;
    case PRINTIMPORTITEMSFORM_ACT:
        print_import_items_form();
        break;
    case DOIMPORT_ACT:
        db_begin();
        if (isset($_POST['import_submit'])) {
            save_decisions();
            // Do import and print the results
            do_import();
        } else {
            if (isset($_POST['cancel_import_submit'])) {
                cancel_import();
            }
        }
        db_commit();
        break;
}
function print_upload_form()
{
    $form = pieform(array('name' => 'import', 'method' => 'post', 'plugintype ' => 'core', 'pluginname' => 'import', 'elements' => array('leap2afile' => array('type' => 'file', 'title' => get_string('uploadleap2afile', 'admin'), 'rules' => array('required' => true)), 'submit' => array('type' => 'submit', 'value' => get_string('Import', 'import')))));
    $smarty = smarty();
    $smarty->assign('PAGEHEADING', get_string('importyourportfolio', 'import'));
    $smarty->assign('pagedescription', get_string('importportfoliodescription', 'import'));
    $smarty->assign('form', $form);
Exemplo n.º 4
0
 if (db_connect('nodie')){
    $time_start=microtime_float();

    if ($_REQUEST['phpinfo']){
       ob_start();phpinfo();$sqldr='<div style="font-size:130%">'.ob_get_clean().'</div>';
    }else{
     if ($DB['db']){
      if ($_REQUEST['shex']){
       print_export();
      }elseif ($_REQUEST['doex']){
       check_xss();do_export();
      }elseif ($_REQUEST['shim']){
       print_import();
      }elseif ($_REQUEST['doim']){
       check_xss();do_import();
      }elseif ($_REQUEST['dosht']){
       check_xss();do_sht();
      }elseif (!$_REQUEST['refresh'] || preg_match('/^select|show|explain|desc/i',$SQLq) ){
       if ($SQLq)check_xss();
       do_sql($SQLq);#perform non-select SQL only if not refresh (to avoid dangerous delete/drop)
      }
     }else{
        if ( $_REQUEST['refresh'] ){
           check_xss();do_sql($SHOW_D);
        }elseif ($_REQUEST['crdb']){
          check_xss();do_sql('CREATE DATABASE `'.$_REQUEST['new_db'].'`');do_sql($SHOW_D);
        }elseif ( preg_match('/^(?:show\s+(?:databases|status|variables|process)|create\s+database|grant\s+)/i',$SQLq) ){
           check_xss();do_sql($SQLq);
        }else{
           $err_msg="Select Database first";