コード例 #1
0
ファイル: reports.php プロジェクト: Nyamai/Ushahidi_Web
 function upload()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->template->content = new View('admin/reports_upload');
         $this->template->content->title = 'Upload Reports';
         $this->template->content->form_error = false;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $errors = array();
         $notices = array();
         if (!$_FILES['csvfile']['error']) {
             if (file_exists($_FILES['csvfile']['tmp_name'])) {
                 if ($filehandle = fopen($_FILES['csvfile']['tmp_name'], 'r')) {
                     $importer = new ReportsImporter();
                     if ($importer->import($filehandle)) {
                         $this->template->content = new View('admin/reports_upload_success');
                         $this->template->content->title = 'Upload Reports';
                         $this->template->content->rowcount = $importer->totalrows;
                         $this->template->content->imported = $importer->importedrows;
                         $this->template->content->notices = $importer->notices;
                     } else {
                         $errors = $importer->errors;
                     }
                 } else {
                     $errors[] = Kohana::lang('ui_admin.file_open_error');
                 }
             } else {
                 $errors[] = Kohana::lang('ui_admin.file_not_found_upload');
             }
         } else {
             $errors[] = $_FILES['csvfile']['error'];
         }
         if (count($errors)) {
             $this->template->content = new View('admin/reports_upload');
             $this->template->content->title = Kohana::lang('ui_admin.upload_reports');
             $this->template->content->errors = $errors;
             $this->template->content->form_error = 1;
         }
     }
     // _POST
 }
コード例 #2
0
ファイル: reports.php プロジェクト: rootz/Ushahidi_Web
 public function upload()
 {
     // If user doesn't have access, redirect to dashboard
     if (!admin::permissions($this->user, "reports_upload")) {
         url::redirect(url::site() . 'admin/dashboard');
     }
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->template->content = new View('admin/reports_upload');
         $this->template->content->title = 'Upload Reports';
         $this->template->content->form_error = false;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $errors = array();
         $notices = array();
         if (!$_FILES['csvfile']['error']) {
             if (file_exists($_FILES['csvfile']['tmp_name'])) {
                 if ($filehandle = fopen($_FILES['csvfile']['tmp_name'], 'r')) {
                     $importer = new ReportsImporter();
                     if ($importer->import($filehandle)) {
                         $this->template->content = new View('admin/reports_upload_success');
                         $this->template->content->title = 'Upload Reports';
                         $this->template->content->rowcount = $importer->totalrows;
                         $this->template->content->imported = $importer->importedrows;
                         $this->template->content->notices = $importer->notices;
                     } else {
                         $errors = $importer->errors;
                     }
                 } else {
                     $errors[] = Kohana::lang('ui_admin.file_open_error');
                 }
             } else {
                 $errors[] = Kohana::lang('ui_admin.file_not_found_upload');
             }
         } else {
             $errors[] = $_FILES['csvfile']['error'];
         }
         if (count($errors)) {
             $this->template->content = new View('admin/reports_upload');
             $this->template->content->title = Kohana::lang('ui_admin.upload_reports');
             $this->template->content->errors = $errors;
             $this->template->content->form_error = 1;
         }
     }
 }