public function importAction() { if ($this->post('submit')) { $i = $j = $k = 0; $file = $_FILES['txt']; if ($file['type'] != 'text/plain') { $this->adminMsg(lang('a-tag-3', array('1' => $file['type']))); } if ($file['error']) { $this->adminMsg(lang('a-tag-4')); } if (!file_exists($file['tmp_name'])) { $this->adminMsg(lang('a-tag-5')); } $data = file_get_contents($file['tmp_name']); $data = explode(PHP_EOL, $data); foreach ($data as $t) { $t = explode(' ', trim($t)); $name = trim($t[0]); $url = trim($t[count($t) - 1]); if ($name && check::is_url($url)) { $row = $this->relatedlink->getOne('name=?', $name); if (empty($row)) { $id = $this->relatedlink->insert(array('name' => $name, 'url' => $url)); if ($id) { $i++; } } else { $j++; } } else { $k++; } } $this->adminMsg($this->getCacheCode('relatedlink') . lang('a-tag-6', array('1' => $i, '2' => $k, '3' => $j)), url('admin/relatedlink/index'), 3, 1, 1); } $this->view->display('admin/relatedlink_import'); }