} foreach ($paths as $kp2 => $path2) { if ($kp2 > $kp) { $fail = $path2 . get_filename($ku, $kp); @unlink($fail); print_r($fail . ' => fail.png' . "\n"); if ($create) { symlink(get_path_image($kp2, 'fail.png'), $fail); } } } $pass = $paths[$expected[chr(65 + $ku)][$kp + 1] - 1] . get_filename($ku, $kp); @unlink($pass); print_r($pass . ' => pass.png' . "\n"); if ($create) { symlink(get_path_image($kp, 'pass.png'), $pass); } } } if ($create) { echo ' -->'; } else { die('Bye! <em>(or <a href="test_rewriterule.php">run the tests</a> again)</em>'); } // display the matrix to see the status in one glance echo '<table>'; foreach ($urls as $ku => $url) { echo '<tr>'; foreach ($paths as $kp => $path) { $filename = get_filename($ku, $kp); echo '<td>';
function ch_profil() { $this->must_login(); $content_file = 'admin_akun/ch_profil.html'; $data = array('web_title' => 'Ubah Profil | Administrator', 'module_title' => 'Profil', 'login' => $this->session_data['login'], 'pengajar' => $this->session_data['pengajar']); $config['upload_path'] = get_path_image(); $config['allowed_types'] = 'jpg|jpeg|png'; $config['max_size'] = '0'; $config['max_width'] = '0'; $config['max_height'] = '0'; $config['file_name'] = 'admin-' . url_title($this->input->post('nama', TRUE), '-', true); $this->load->library('upload', $config); if (!empty($_FILES['userfile']['tmp_name']) and !$this->upload->do_upload()) { $data['error_upload'] = '<span class="text-error">' . $this->upload->display_errors() . '</span>'; $error_upload = true; } else { $data['error_upload'] = ''; $error_upload = false; } if ($this->form_validation->run() == TRUE and !$error_upload) { $username = $this->input->post('username', TRUE); $nama = $this->input->post('nama', TRUE); $alamat = $this->input->post('alamat', TRUE); //update username $this->login_model->update($this->session_data['login']['id'], $username, null, $this->session_data['pengajar']['id'], 1, null); if (!empty($_FILES['userfile']['tmp_name'])) { //hapus dulu file sebelumnya $pisah = explode('.', $this->session_data['pengajar']['foto']); if (is_file(get_path_image($this->session_data['pengajar']['foto']))) { unlink(get_path_image($this->session_data['pengajar']['foto'])); } if (is_file(get_path_image($pisah[0] . '_small.' . $pisah[1]))) { unlink(get_path_image($pisah[0] . '_small.' . $pisah[1])); } if (is_file(get_path_image($pisah[0] . '_medium.' . $pisah[1]))) { unlink(get_path_image($pisah[0] . '_medium.' . $pisah[1])); } $upload_data = $this->upload->data(); //create thumb small $this->create_img_thumb(get_path_image($upload_data['file_name']), '_small', '50', '50'); //create thumb medium $this->create_img_thumb(get_path_image($upload_data['file_name']), '_medium', '150', '150'); $foto = $upload_data['file_name']; } else { $foto = $this->session_data['pengajar']['foto']; } //update pengajar $this->pengajar_model->update($this->session_data['pengajar']['id'], $this->session_data['pengajar']['nip'], $nama, $alamat, $foto, $this->session_data['pengajar']['status_id']); $this->refresh_session_data(); $this->session->set_flashdata('akun', get_alert('success', 'Profil berhasil di perbaharui')); redirect('admin/ch_profil'); } $data = array_merge(default_parser_item(), $data); $this->twig->display($content_file, $data); }
function pengaturan() { must_login(); if (!is_admin()) { redirect('welcome'); } if (!is_demo_app()) { # bagian hapus gambar if (!empty($_GET['delete-img'])) { $img_id = (int) $_GET['delete-img']; if ($img_id > 0 and $img_id <= 4) { $key = 'img-slide-' . $img_id; $retrieve = $this->config_model->retrieve($key); if (!empty($retrieve) and !empty($retrieve['value'])) { # hapus file if (is_file(get_path_image($retrieve['value']))) { unlink(get_path_image($retrieve['value'])); } $this->config_model->update($key, $key, ''); } } redirect('welcome/pengaturan'); } if ($this->form_validation->run('pengaturan') == true) { foreach ($_POST as $key => $val) { # cek ada tidak, kalo ada update $retrieve = $this->config_model->retrieve($key); if (!empty($retrieve)) { $this->config_model->update($key, $retrieve['nama'], $val); } else { $this->config_model->create($key, $key, $val); } } # untuk upload gambar foreach ($_FILES as $key => $val) { if (!empty($val['tmp_name'])) { $config = array(); $config['upload_path'] = get_path_image(); $config['allowed_types'] = 'jpg|jpeg|png'; $config['max_size'] = '0'; $config['max_width'] = '0'; $config['max_height'] = '0'; $config['file_name'] = $key; $this->upload->initialize($config); if ($this->upload->do_upload($key)) { # hapus file sebelumnya $old_file = get_pengaturan($key, 'value'); if (is_file(get_path_image($old_file))) { unlink(get_path_image($old_file)); } $upload_data = $this->upload->data(); $retrieve = $this->config_model->retrieve($key); if (!empty($retrieve)) { $this->config_model->update($key, $key, $upload_data['file_name']); } else { $this->config_model->create($key, $key, $upload_data['file_name']); } } } } $this->session->set_flashdata('pengaturan', get_alert('success', 'Pengaturan berhasil diperbaharui.')); redirect('welcome/pengaturan'); } } $data['comp_js'] = get_tinymce('tinymce, textarea.tinymce'); $this->twig->display('pengaturan.html', $data); }
function edit_picture($segment_3 = '', $segment_4 = '') { # siswa tidak diijinkan if (is_siswa()) { exit('Akses ditolak'); } $status_id = (int) $segment_3; $pengajar_id = (int) $segment_4; $retrieve_pengajar = $this->pengajar_model->retrieve($pengajar_id); if (empty($retrieve_pengajar)) { exit('Data Pengajar tidak ditemukan'); } # jika sebagai pengajar, hanya profilnya dia yang bisa diupdate if (is_pengajar() and get_sess_data('user', 'id') != $retrieve_pengajar['id']) { exit('Akses ditolak'); } $data['status_id'] = $status_id; $data['pengajar_id'] = $pengajar_id; $data['pengajar'] = $retrieve_pengajar; $config['upload_path'] = get_path_image(); $config['allowed_types'] = 'jpg|jpeg|png'; $config['max_size'] = '0'; $config['max_width'] = '0'; $config['max_height'] = '0'; $config['file_name'] = 'pengajar-' . url_title($retrieve_pengajar['nama'], '-', true); $this->upload->initialize($config); if ($this->upload->do_upload()) { if (is_file(get_path_image($retrieve_pengajar['foto']))) { unlink(get_path_image($retrieve_pengajar['foto'])); } if (is_file(get_path_image($retrieve_pengajar['foto'], 'medium'))) { unlink(get_path_image($retrieve_pengajar['foto'], 'medium')); } if (is_file(get_path_image($retrieve_pengajar['foto'], 'small'))) { unlink(get_path_image($retrieve_pengajar['foto'], 'small')); } $upload_data = $this->upload->data(); # create thumb small $this->create_img_thumb(get_path_image($upload_data['file_name']), '_small', '50', '50'); # create thumb medium $this->create_img_thumb(get_path_image($upload_data['file_name']), '_medium', '150', '150'); # update pengajar $this->pengajar_model->update($pengajar_id, $retrieve_pengajar['nip'], $retrieve_pengajar['nama'], $retrieve_pengajar['jenis_kelamin'], $retrieve_pengajar['tempat_lahir'], $retrieve_pengajar['tgl_lahir'], $retrieve_pengajar['alamat'], $upload_data['file_name'], $retrieve_pengajar['status_id']); $this->session->set_flashdata('edit', get_alert('success', 'Foto pengajar berhasil diperbaharui.')); redirect('pengajar/edit_picture/' . $status_id . '/' . $pengajar_id); } else { if (!empty($_FILES['userfile']['tmp_name'])) { $data['error_upload'] = '<span class="text-error">' . $this->upload->display_errors() . '</span>'; } } $this->twig->display('edit-pengajar-picture.html', $data); }
function edit_picture($segment_3 = '', $segment_4 = '') { $status_id = (int) $segment_3; $siswa_id = (int) $segment_4; $retrieve_siswa = $this->siswa_model->retrieve($siswa_id); if (empty($retrieve_siswa)) { exit('Data siswa tidak ditemukan'); } $data['status_id'] = $status_id; $data['siswa_id'] = $siswa_id; $data['siswa'] = $retrieve_siswa; $config['upload_path'] = get_path_image(); $config['allowed_types'] = 'jpg|jpeg|png'; $config['max_size'] = '0'; $config['max_width'] = '0'; $config['max_height'] = '0'; $config['file_name'] = 'siswa-' . url_title($retrieve_siswa['nama'], '-', true) . '-' . url_title($retrieve_siswa['nis'], '-', true); $this->upload->initialize($config); if ($this->upload->do_upload()) { if (is_file(get_path_image($retrieve_siswa['foto']))) { unlink(get_path_image($retrieve_siswa['foto'])); } if (is_file(get_path_image($retrieve_siswa['foto'], 'medium'))) { unlink(get_path_image($retrieve_siswa['foto'], 'medium')); } if (is_file(get_path_image($retrieve_siswa['foto'], 'small'))) { unlink(get_path_image($retrieve_siswa['foto'], 'small')); } $upload_data = $this->upload->data(); # create thumb small $this->create_img_thumb(get_path_image($upload_data['file_name']), '_small', '50', '50'); # create thumb medium $this->create_img_thumb(get_path_image($upload_data['file_name']), '_medium', '150', '150'); # update siswa $this->siswa_model->update($siswa_id, $retrieve_siswa['nis'], $retrieve_siswa['nama'], $retrieve_siswa['jenis_kelamin'], $retrieve_siswa['tempat_lahir'], $retrieve_siswa['tgl_lahir'], $retrieve_siswa['agama'], $retrieve_siswa['alamat'], $retrieve_siswa['tahun_masuk'], $upload_data['file_name'], $retrieve_siswa['status_id']); $this->session->set_flashdata('edit', get_alert('success', 'Foto siswa berhasil diperbaharui.')); redirect('siswa/edit_picture/' . $status_id . '/' . $siswa_id); } else { if (!empty($_FILES['userfile']['tmp_name'])) { $data['error_upload'] = '<span class="text-error">' . $this->upload->display_errors() . '</span>'; } } $this->twig->display('edit-siswa-picture.html', $data); }