Beispiel #1
0
	}elseif(defined('CONFIG_UPLOAD_MAXSIZE') && CONFIG_UPLOAD_MAXSIZE && $upload->isSizeTooBig(CONFIG_UPLOAD_MAXSIZE))
	{		
		 $error = sprintf(ERROR_FILE_TOO_BID, transformFileSize(CONFIG_UPLOAD_MAXSIZE));
	}else
	{
							include_once(CLASS_FILE);
							$path = $upload->getFilePath();
							$obj = new file($path);
							$tem = $obj->getFileInfo();							
							if(sizeof($tem))
							{	
								include_once(CLASS_MANAGER);
							
								$manager = new manager($upload->getFilePath(), false);			
															
								$fileType = $manager->getFileType($upload->getFileName());

								foreach($fileType as $k=>$v)
								{
									$tem[$k] = $v;
								}
								
								$tem['path'] = backslashToSlash($path);		
								$tem['type'] = "file";
								$tem['size'] = transformFileSize($tem['size']);
								$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
								$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
								$tem['short_name'] = shortenFileName($tem['name']);						
								$tem['flag'] = 'noFlag';
								$obj->close();
								foreach($tem as $k=>$v)
 public function updateKontrak()
 {
     if (isset($_POST['update_kontrak'])) {
         $kontrak = new Kontrak();
         $kontrak->kd_kontrak = $_POST['kd_kontrak'];
         $kontrak->no_kontrak = $_POST['nomor'];
         $kontrak->kd_jurusan = $_POST['jur'];
         $kontrak->tgl_kontrak = date('Y-m-d', strtotime($_POST['tanggal']));
         $kontrak->thn_masuk_kontrak = $_POST['tahun_masuk'];
         $kontrak->jml_pegawai_kontrak = $_POST['jml_peg'];
         $kontrak->lama_semester_kontrak = $_POST['lama_semester'];
         $kontrak->nilai_kontrak = str_replace(',', '', $_POST['nilai_kontrak']);
         $kontrak->kontrak_lama = $_POST['kontrak_lama'];
         $upload = new Upload();
         $upload->init('fupload');
         //var_dump($kontrak);
         if ($upload->getFileName() != "") {
             $upload->setDirTo('files/');
             $nama = array($kontrak->no_kontrak, $kontrak->tgl_kontrak);
             $upload->changeFileName($upload->getFileName(), $nama);
             $file_baru = $upload->getFileTo();
             $kontrak->file_kontrak = $file_baru;
         } else {
             $file_lama = $_POST['fupload_lama'];
             $kontrak->file_kontrak = $file_lama;
         }
         if ($kontrak->isEmpty($kontrak) == false) {
             //var_dump($kontrak);
             $kontrak->update($kontrak);
             if ($file_baru != "") {
                 $upload->uploadFile();
             }
             header('location:' . URL . 'kontrak/display');
         } else {
             $url = URL . 'kontrak/editKontrak/' . $kontrak->kd_kontrak;
             header("refresh:1;url=" . $url);
             echo "Isian form belum lengkap";
             //header('location:' . URL . 'kontrak/editKontrak/');
         }
     } else {
         header('location:' . URL . 'kontrak/display');
     }
 }
 public function updateUangSkripsi()
 {
     if (isset($_POST['ubah_uskripsi'])) {
         if (isset($_POST['js']) && $_POST['js'] == 1) {
             header('location:' . URL . 'elemenBeasiswa/viewSkripsi');
         }
         if ($_POST['kd_el'] && $_POST['setuju'] != "" && $_POST['r_elem'] != "" && $_POST['kode_jur'] != "" && $_POST['tahun_masuk'] != "" && $_POST['biaya_skripsi'] != "" && $_POST['total_bayar'] != "") {
             $elem = new ElemenBeasiswa();
             $pb = $_POST['setuju'];
             $jml_peg = count($pb);
             $elem->set_kd_d($_POST['kd_el']);
             $elem->set_jml_peg($jml_peg);
             $elem->set_kd_r($_POST['r_elem']);
             $elem->set_kd_jur($_POST['kode_jur']);
             $elem->set_thn_masuk($_POST['tahun_masuk']);
             $elem->set_biaya_per_peg(str_replace(',', '', $_POST['biaya_skripsi']));
             $elem->set_total_bayar(str_replace(',', '', $_POST['total_bayar']));
             $elem->set_no_sp2d($_POST['no_sp2d']);
             $elem->set_tgl_sp2d(date('Y-m-d', strtotime($_POST['tgl_sp2d'])));
             //var_dump($elem);
             //echo $kd_elemen_beasiswa;
             //exit();
             //var_dump($elem);
             $upload = new Upload();
             $upload->init('fupload');
             if ($upload->getFileName() != "") {
                 $upload->setDirTo("files/sp2d/");
                 $nama = array($elem->get_no_sp2d(), $elem->get_tgl_sp2d());
                 //$upload->uploadFile2("", $nama);
                 if ($upload->uploadFile2("", $nama) == false) {
                     $url = URL . 'elemenBeasiswa/editJadup/' . $elem->get_kd_d();
                     echo '<script> alert("File gagal diupload.") </script>';
                     echo '<script language="JavaScript"> window.location.href ="' . $url . '" </script>';
                     exit;
                 }
                 $elem->set_file_sp2d($upload->getFileTo());
                 //echo $upload->getFileName();
                 if ($_POST['fupload_lama'] != "") {
                     $file = "files/sp2d/" . $_POST['fupload_lama'];
                     //echo $file;
                     if (file_exists($file)) {
                         unlink($file);
                     }
                 }
                 //echo $upload->getFileName();
             } else {
                 if ($_POST['fupload_lama'] != "") {
                     $elem->set_file_sp2d($_POST['fupload_lama']);
                     //echo $_POST['fupload_lama'];
                 } else {
                     $elem->set_file_sp2d("");
                 }
             }
             $elem->update_elem($elem);
             $penerima = new PenerimaElemenBeasiswa();
             $penerima->delete($elem->get_kd_d());
             foreach ($pb as $val) {
                 $penerima_elemen = new PenerimaElemenBeasiswa();
                 $penerima_elemen->kd_elemen_beasiswa = $elem->get_kd_d();
                 $penerima_elemen->kd_pb = $val;
                 $penerima_elemen->add($penerima_elemen);
             }
             ClassLog::write_log("elemen beasiswa", "ubah uang penelitian", "kd_el." . $elem->get_kd_d());
             //$url = URL . 'elemenBeasiswa/editSkripsi/' . $elem->get_kd_d();
             $url = URL . 'elemenBeasiswa/viewSkripsi';
             echo '<script> alert("Data berhasil disimpan") </script>';
             echo '<script language="JavaScript"> window.location.href ="' . $url . '" </script>';
         } else {
             header('location:' . URL . 'elemenBeasiswa/editSkripsi/' . $elem->get_kd_d());
         }
     } else {
         header('location:' . URL . 'elemenBeasiswa/viewSkripsi');
     }
 }
Beispiel #4
0
function saveuser($uid, $name, $uname, $email, $femail, $url, $pass, $vpass, $bio, $user_avatar, $user_icq, $user_occ, $user_from, $user_intrest, $user_sig, $user_viewemail, $user_aim, $user_yim, $user_msnm, $attach, $usend_email, $uis_visible, $user_lnl, $C1, $C2, $C3, $C4, $C5, $C6, $C7, $C8, $M1, $M2, $T1, $T2, $B1, $MAX_FILE_SIZE, $raz_avatar)
{
    global $NPDS_Prefix;
    global $user, $userinfo, $system, $minpass;
    $cookie = cookiedecode($user);
    $check = $cookie[1];
    $result = sql_query("SELECT uid, email FROM " . $NPDS_Prefix . "users WHERE uname='{$check}'");
    list($vuid, $vemail) = sql_fetch_row($result);
    if ($check == $uname and $uid == $vuid) {
        if (isset($pass) && "{$pass}" != "{$vpass}") {
            message_error("<i class=\"fa fa-exclamation\"></i>&nbsp;" . translate("Both passwords are different. They need to be identical.") . "<br /><br />", "");
        } elseif ($pass != "" && strlen($pass) < $minpass) {
            message_error("<i class=\"fa fa-exclamation\"></i>&nbsp;" . translate("Sorry, your password must be at least") . " <strong>{$minpass}</strong> " . translate("characters long") . "<br /><br />", "");
        } else {
            $stop = userCheck("edituser", $email);
            if (!$stop) {
                if ($bio) {
                    $bio = FixQuotes(strip_tags($bio));
                }
                if ($attach) {
                    $t = 1;
                } else {
                    $t = 0;
                }
                if ($user_viewemail) {
                    $a = 1;
                } else {
                    $a = 0;
                }
                if ($usend_email) {
                    $u = 1;
                } else {
                    $u = 0;
                }
                if ($uis_visible) {
                    $v = 0;
                } else {
                    $v = 1;
                }
                if ($user_lnl) {
                    $w = 1;
                } else {
                    $w = 0;
                }
                if ($url != "") {
                    if (!substr_count($url, "http://")) {
                        $url = "http://" . $url;
                    }
                    if (trim($url) == "http://") {
                        $url = "";
                    }
                }
                include_once "modules/upload/upload.conf.php";
                global $avatar_size;
                if (!$avatar_size) {
                    $avatar_size = "80*100";
                }
                $avatar_limit = explode("*", $avatar_size);
                if ($DOCUMENTROOT != "") {
                    $rep = $DOCUMENTROOT;
                } else {
                    global $DOCUMENT_ROOT;
                    if ($DOCUMENT_ROOT) {
                        $rep = $DOCUMENT_ROOT;
                    } else {
                        $rep = $_SERVER['DOCUMENT_ROOT'];
                    }
                }
                if ($B1 != "none") {
                    global $language;
                    include_once "modules/upload/lang/upload.lang-{$language}.php";
                    include_once "modules/upload/clsUpload.php";
                    $upload = new Upload();
                    $upload->maxupload_size = $MAX_FILE_SIZE;
                    $field1_filename = trim($upload->getFileName("B1"));
                    $suffix = strtoLower(substr(strrchr($field1_filename, '.'), 1));
                    if ($suffix == "gif" or $suffix == "jpg" or $suffix == "png") {
                        $field1_filename = removeHack(preg_replace('#[/\\\\:\\*\\?"<>|]#i', '', rawurldecode($field1_filename)));
                        $field1_filename = preg_replace('#\\.{2}|config.php|/etc#i', '', $field1_filename);
                        if ($field1_filename) {
                            if ($autorise_upload_p) {
                                $user_dir = $racine . "/users_private/" . $uname . "/";
                                if (!is_dir($rep . $user_dir)) {
                                    @umask("0000");
                                    if (@mkdir($rep . $user_dir, 0777)) {
                                        $fp = fopen($rep . $user_dir . "index.html", 'w');
                                        fclose($fp);
                                    } else {
                                        $user_dir = $racine . "/users_private/";
                                    }
                                }
                            } else {
                                $user_dir = $racine . "/users_private/";
                            }
                            if ($upload->saveAs($uname . "." . $suffix, $rep . $user_dir, "B1", true)) {
                                $old_user_avatar = $user_avatar;
                                $user_avatar = $user_dir . $uname . "." . $suffix;
                                $img_size = @getimagesize($rep . $user_avatar);
                                if ($img_size[0] > $avatar_limit[0] or $img_size[1] > $avatar_limit[1]) {
                                    $raz_avatar = true;
                                }
                                if ($racine == "") {
                                    $user_avatar = substr($user_avatar, 1);
                                }
                            }
                        }
                    }
                }
                if ($raz_avatar) {
                    if (strstr($user_avatar, "/users_private")) {
                        @unlink($rep . $user_avatar);
                        @unlink($rep . $old_user_avatar);
                    }
                    $user_avatar = "blank.gif";
                }
                if ($pass != '') {
                    cookiedecode($user);
                    if (!$system) {
                        $pass = crypt($pass, $pass);
                    }
                    sql_query("UPDATE " . $NPDS_Prefix . "users SET name='{$name}', email='{$email}', femail='" . removeHack($femail) . "', url='" . removeHack($url) . "', pass='******', bio='" . removeHack($bio) . "', user_avatar='{$user_avatar}', user_icq='" . removeHack($user_icq) . "', user_occ='" . removeHack($user_occ) . "', user_from='" . removeHack($user_from) . "', user_intrest='" . removeHack($user_intrest) . "', user_sig='" . removeHack($user_sig) . "', user_aim='" . removeHack($user_aim) . "', user_yim='" . removeHack($user_yim) . "', user_msnm='" . removeHack($user_msnm) . "', user_viewemail='{$a}', send_email='{$u}', is_visible='{$v}', user_lnl='{$w}' WHERE uid='{$uid}'");
                    $result = sql_query("SELECT uid, uname, pass, storynum, umode, uorder, thold, noscore, ublockon, theme FROM " . $NPDS_Prefix . "users WHERE uname='{$uname}' AND pass='******'");
                    if (sql_num_rows($result) == 1) {
                        $userinfo = sql_fetch_assoc($result);
                        docookie($userinfo['uid'], $userinfo['uname'], $userinfo['pass'], $userinfo['storynum'], $userinfo['umode'], $userinfo['uorder'], $userinfo['thold'], $userinfo['noscore'], $userinfo['ublockon'], $userinfo['theme'], $userinfo['commentmax'], "");
                    }
                } else {
                    sql_query("UPDATE " . $NPDS_Prefix . "users SET name='{$name}', email='{$email}', femail='" . removeHack($femail) . "', url='" . removeHack($url) . "', bio='" . removeHack($bio) . "', user_avatar='{$user_avatar}', user_icq='" . removeHack($user_icq) . "', user_occ='" . removeHack($user_occ) . "', user_from='" . removeHack($user_from) . "', user_intrest='" . removeHack($user_intrest) . "', user_sig='" . removeHack($user_sig) . "', user_aim='" . removeHack($user_aim) . "', user_yim='" . removeHack($user_yim) . "', user_msnm='" . removeHack($user_msnm) . "', user_viewemail='{$a}', send_email='{$u}', is_visible='{$v}', user_lnl='{$w}' WHERE uid='{$uid}'");
                }
                sql_query("UPDATE " . $NPDS_Prefix . "users_status SET attachsig='{$t}' WHERE uid='{$uid}'");
                $result = sql_query("SELECT uid FROM " . $NPDS_Prefix . "users_extend WHERE uid='{$uid}'");
                if (sql_num_rows($result) == 1) {
                    sql_query("UPDATE " . $NPDS_Prefix . "users_extend SET C1='" . removeHack($C1) . "', C2='" . removeHack($C2) . "', C3='" . removeHack($C3) . "', C4='" . removeHack($C4) . "', C5='" . removeHack($C5) . "', C6='" . removeHack($C6) . "', C7='" . removeHack($C7) . "', C8='" . removeHack($C8) . "', M1='" . removeHack($M1) . "', M2='" . removeHack($M2) . "', T1='" . removeHack($T1) . "', T2='" . removeHack($T2) . "', B1='{$B1}' WHERE uid='{$uid}'");
                } else {
                    $result = sql_query("INSERT INTO " . $NPDS_Prefix . "users_extend VALUES ('{$uid}','" . removeHack($C1) . "', '" . removeHack($C2) . "', '" . removeHack($C3) . "', '" . removeHack($C4) . "', '" . removeHack($C5) . "', '" . removeHack($C6) . "', '" . removeHack($C7) . "', '" . removeHack($C8) . "', '" . removeHack($M1) . "', '" . removeHack($M2) . "', '" . removeHack($T1) . "', '" . removeHack($T2) . "', '{$B1}')");
                }
                if ($pass != "") {
                    logout();
                } else {
                    header("location: user.php?op=edituser");
                }
            } else {
                message_error($stop, "");
            }
        }
    } else {
        Header("Location: index.php");
    }
}
Beispiel #5
0
$param_picid = isset($_GET['p']) ? $_GET['p'] : '';
$param_page = isset($_GET['start']) ? $_GET['start'] : '';
/********************************************************
 * Post d'un fichier
 */
if ($op == "upload") {
    /*** verification securite ***/
    //verif_admin_general($s_joueur);
    if ($grade['a'] != 'a' && $grade['b'] != 'b' && $grade['q'] != 'q') {
        js_goto($PHP_SELF);
    }
    include_once "include/class.upload.php";
    $uploadc = new Upload();
    $uploadc->maxupload_size = $config['gallery_max_filesize'];
    $destination = $config['gallery_path'] . "/{$param_galid}/";
    $field_filename = trim($uploadc->getFileName("userfile"));
    if ($field_filename && (eregi(".jpg\$", $field_filename) || eregi(".png\$", $field_filename) || eregi(".gif\$", $field_filename))) {
        if ($uploadc->save($destination, "userfile", true)) {
            is_picture($field_filename, $param_galid);
            js_goto("?page=galerie&g={$param_galid}");
        } else {
            show_warning($uploadc->errors);
        }
    } else {
        show_warning("{$strFichierInvalide} : {$field_filename}");
    }
} elseif ($op == 'delete') {
    /*** verification securite ***/
    //verif_admin_general($s_joueur);
    if ($grade['a'] != 'a' && $grade['b'] != 'q' && $grade['c'] != 'q') {
        js_goto($PHP_SELF);
Beispiel #6
0
if (substr(@php_uname(), 0, 7) == "Windows") {
    $log_dir = str_replace($basedir_fma, '', $base);
} else {
    $log_dir = str_replace("\\", "/", str_replace($basedir_fma, "", $base));
}
include_once "modules/upload/upload.conf.php";
settype($op, 'string');
switch ($op) {
    case "upload":
        if ($ficcmd_fma[0]) {
            if ($userfile != "none") {
                global $language;
                include_once "modules/upload/lang/upload.lang-{$language}.php";
                include_once "modules/upload/clsUpload.php";
                $upload = new Upload();
                $filename = trim($upload->getFileName("userfile"));
                if ($filename) {
                    $upload->maxupload_size = $max_size;
                    $auto = fma_filter('f', $filename, $obj->Extension);
                    if ($auto[0]) {
                        if (!$upload->saveAs($auto[2], $base . '/', 'userfile', true)) {
                            $Err = $upload->errors;
                        } else {
                            Ecr_Log("security", "Upload File", $log_dir . "/" . $filename . " IP=>" . getip());
                        }
                    } else {
                        $Err = $auto[1];
                    }
                }
            }
        }
Beispiel #7
0
function AddImgs($imgscat, $newcard1, $newdesc1, $newcard2, $newdesc2, $newcard3, $newdesc3, $newcard4, $newdesc4, $newcard5, $newdesc5)
{
    global $language, $MaxSizeImg, $MaxSizeThumb, $ModPath, $ModStart, $NPDS_Prefix;
    include_once "modules/upload/lang/upload.lang-{$language}.php";
    include_once "modules/upload/clsUpload.php";
    $year = date("Y");
    $month = date("m");
    $day = date("d");
    $hour = date("H");
    $min = date("i");
    $sec = date("s");
    $i = 1;
    while ($i <= 5) {
        $img = "newcard{$i}";
        $tit = "newdesc{$i}";
        if (!empty(${$img})) {
            $newimg = stripslashes(removeHack(${$img}));
            if (!empty(${$tit})) {
                $newtit = addslashes(removeHack(${$tit}));
            } else {
                $newtit = "";
            }
            $upload = new Upload();
            $upload->maxupload_size = 200000 * 100;
            $origin_filename = trim($upload->getFileName("newcard" . $i));
            $filename_ext = strtolower(substr(strrchr($origin_filename, "."), 1));
            if ($filename_ext == "jpg" or $filename_ext == "gif" or $filename_ext == "png") {
                $newfilename = $year . $month . $day . $hour . $min . $sec . "-" . $i . "." . $filename_ext;
                if ($upload->saveAs($newfilename, "modules/{$ModPath}/imgs/", "newcard" . $i, true)) {
                    if (function_exists('gd_info') or extension_loaded('gd')) {
                        @CreateThumb($newfilename, "modules/{$ModPath}/imgs/", "modules/{$ModPath}/imgs/", $MaxSizeImg, $filename_ext);
                        @CreateThumb($newfilename, "modules/{$ModPath}/imgs/", "modules/{$ModPath}/mini/", $MaxSizeThumb, $filename_ext);
                    }
                    if (sql_query("INSERT INTO " . $NPDS_Prefix . "tdgal_img VALUES ('','{$imgscat}','{$newfilename}','{$newtit}','','0','0')")) {
                        echo '<p class="lead"><i class="fa fa-info-circle"></i> ' . gal_trans("Image ajoutée avec succès") . '</p>';
                    } else {
                        echo '<p class="lead text-danger">' . gal_trans("Impossible d'ajouter l'image en BDD") . '</p>';
                        @unlink("modules/{$ModPath}/imgs/{$newfilename}");
                        @unlink("modules/{$ModPath}/mini/{$newfilename}");
                    }
                } else {
                    echo '<p class="lead text-danger">' . $upload->errors . '</p>';
                }
            } else {
                if ($filename_ext != "") {
                    echo '<p class="lead text-danger">' . gal_trans("Ce fichier n'est pas un fichier jpg ou gif") . '</p>';
                }
            }
        }
        $i++;
    }
}
 public function uploadFileSurat()
 {
     $upload = new Upload('upload');
     $upload->setDirTo('arsip/');
     $tipe = 'M';
     $satker = $_POST['satker'];
     $nomor = $_POST['nomor'];
     //nama baru akan terdiri dari tipe naskah_nomor surat_asal(asal/tetapi asal terlaku kepanjangan)
     $ubahNama = array($tipe, $nomor, $satker);
     $upload->setUbahNama($ubahNama);
     $upload->changeFileName($upload->getFileName(), $ubahNama);
     $namafile = $upload->getFileTo();
     $where = ' id_suratmasuk=' . $_POST['id'];
     $data = array('file' => $namafile);
     if ($upload->uploadFile()) {
         $this->model->uploadFile($data, $where);
         $datastat = array('stat' => '14');
         @Session::createSession();
         $user = Session::get('user');
         $log = new Log();
         $log->addLog($user, 'UPLOAD', 'user ' . $user . ' upload file surat no agenda ' . $this->model->getNomorAgenda($_POST['id']) . ' file:' . $namafile);
         unset($log);
         $this->model->update('suratmasuk', $datastat, $where);
         //update status -> pelaksana
         echo "<div id=success>Upload file berhasil</div>";
     } else {
         echo "<div id=error>Upload file berhasil</div>";
     }
     //        return true;
     //header('location:'.URL.'suratmasuk');
 }
Beispiel #9
0
 public function editprofile()
 {
     $this->data['title'] = 'Edit Profile';
     $user_model = new \Models\User();
     $this->data['user'] = Session::get('user');
     $this->data['user'] = $user_model->find(Session::get('user')->user_id);
     if (isset($_POST['user_firstname']) && !empty($_POST['user_firstname'])) {
         if (count($_POST['dance_category']) > 3) {
             $this->data['error'] = 'Dance category cannot exceed 3, Please correct';
         } else {
             $user_firstname = $_POST['user_firstname'];
             $user_lastname = $_POST['user_lastname'];
             $user_email = $_POST['user_email'];
             $user_phone = $_POST['user_phone'];
             $user_gender = $_POST['user_gender'];
             $user_bio = $_POST['user_bio'];
             $dance_category = $_POST['dance_category'];
             $user_slug = Url::generateSafeSlug($user_firstname . $this->data['user']->user_id . $user_lastname);
             //delete all user's dancer's category first
             $delete = $userdance_model->delete(array('user_dance_user_id' => $this->data['user']->user_id), 5);
             //insert dance category
             if (count($_POST['dance_category']) > 0) {
                 foreach ($dance_category as $value) {
                     $dance_category_count = 0;
                     $insert_dance_category = $userdance_model->create(array('user_dance_user_id' => $this->data['user']->user_id, 'user_dance_category_id' => $value));
                     $dance_category_count++;
                 }
             }
             //update user db
             $update_array = array('user_firstname' => $user_firstname, 'user_lastname' => $user_lastname, 'user_email' => $user_email, 'user_bio' => $user_bio, 'user_gender' => $user_gender, 'user_slug' => $user_slug, 'user_phone' => $user_phone);
             $update_array = Gump::xss_clean($update_array);
             $update_array = Gump::sanitize($update_array);
             $update_id = $user_model->updateId($update_array, $this->data['user']->user_id);
             //UPLOAD ATTACHMENT
             if ($_FILES["image"]["tmp_name"] != '') {
                 //upload image into uploads folder
                 Upload::setName($slug . uniqid());
                 Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px');
                 $image_name = Upload::getFileName('images');
                 $update_data = array('user_image' => $image_name);
                 $update_img = $this->user_model->updateId($update_data, $this->data['user']->user_id);
                 if ($update_img > 0) {
                     Session::set('success', 'Profile Updated!');
                     Url::redirect('user');
                 } else {
                     $this->data['error'] = 'Operation Fails!';
                 }
             }
             if ($update_id > 0) {
                 Session::set('success', 'Profile Updated!');
                 Url::redirect('user');
             } else {
                 $this->data['error'] = 'Operation Fails!';
             }
             if (isset($dance_category_count) && $dance_category_count > 0) {
                 Session::set('success', 'Dance Category Updated!');
                 Url::redirect('user');
             } else {
                 $this->data['error'] = 'Operation Fails!';
             }
         }
     }
     $this->data['dance_category'] = \models\category::section('dance');
     $user_dance_category = \models\userdance::category($this->data['user']->user_id);
     foreach ($user_dance_category as $item) {
         $this->data['user_dance_category'][] = $item->category_id;
     }
     View::rendertemplate('header', $this->data);
     View::render('workspace/workspace.editprofile', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Beispiel #10
0
function AddImgs($imgscat, $newcard1, $newdesc1, $newcard2, $newdesc2, $newcard3, $newdesc3, $newcard4, $newdesc4, $newcard5, $newdesc5, $user_connecte)
{
    global $language, $MaxSizeImg, $MaxSizeThumb, $ModPath, $ModStart, $NPDS_Prefix, $ThisFile, $adminmail, $nuke_url, $notif_admin;
    include_once "modules/upload/lang/upload.lang-{$language}.php";
    include_once "modules/upload/clsUpload.php";
    $newdesc1 = $newdesc1 . gal_trans(" proposé par ") . $user_connecte;
    $newdesc2 = $newdesc2 . gal_trans(" proposé par ") . $user_connecte;
    $newdesc3 = $newdesc3 . gal_trans(" proposé par ") . $user_connecte;
    $newdesc4 = $newdesc4 . gal_trans(" proposé par ") . $user_connecte;
    $newdesc5 = $newdesc5 . gal_trans(" proposé par ") . $user_connecte;
    $year = date("Y");
    $month = date("m");
    $day = date("d");
    $hour = date("H");
    $min = date("i");
    $sec = date("s");
    echo '<h4 class="breadcrumb"><a href="' . $ThisFile . '">' . gal_trans("Accueil") . '</a></h4>';
    echo '<p>' . gal_trans("Proposer des images") . '</p>';
    echo "<ul>";
    $soumission = false;
    $i = 1;
    while ($i <= 5) {
        $img = "newcard{$i}";
        $tit = "newdesc{$i}";
        if (!empty(${$img})) {
            $newimg = stripslashes(removeHack(${$img}));
            if (!empty(${$tit})) {
                $newtit = addslashes(removeHack(${$tit}));
            } else {
                $newtit = "";
            }
            $upload = new Upload();
            $upload->maxupload_size = 200000 * 100;
            $origin_filename = trim($upload->getFileName("newcard" . $i));
            $filename_ext = strtolower(substr(strrchr($origin_filename, "."), 1));
            if ($filename_ext == "jpg" or $filename_ext == "gif") {
                $newfilename = $year . $month . $day . $hour . $min . $sec . "-" . $i . "." . $filename_ext;
                if ($upload->saveAs($newfilename, "modules/{$ModPath}/imgs/", "newcard" . $i, true)) {
                    if (function_exists('gd_info') or extension_loaded('gd')) {
                        @CreateThumb($newfilename, "modules/{$ModPath}/imgs/", "modules/{$ModPath}/imgs/", $MaxSizeImg, $filename_ext);
                        @CreateThumb($newfilename, "modules/{$ModPath}/imgs/", "modules/{$ModPath}/mini/", $MaxSizeThumb, $filename_ext);
                    }
                    if (sql_query("INSERT INTO " . $NPDS_Prefix . "tdgal_img VALUES ('','{$imgscat}','{$newfilename}','{$newtit}','','0','1')")) {
                        echo "<li>" . gal_trans("Photo envoyée avec succès, elle sera traitée par le webmaster") . " : {$origin_filename}</li>";
                        $soumission = true;
                    } else {
                        echo "<li><span class=\"text-danger\">" . gal_trans("Impossible d'ajouter l'image en BDD") . " : {$origin_filename}</span></li>";
                        @unlink("modules/{$ModPath}/imgs/{$newfilename}");
                        @unlink("modules/{$ModPath}/mini/{$newfilename}");
                    }
                } else {
                    echo "<li><span class=\"text-danger\">" . $upload->errors . "</span></li>";
                }
            } else {
                if ($filename_ext != "") {
                    echo "<li><span class=\"text-danger\">" . gal_trans("Ce fichier n'est pas un fichier jpg ou gif") . " : {$origin_filename}</span></li>";
                }
            }
        }
        $i++;
    }
    echo "</ul>";
    if ($notif_admin and $soumission) {
        $subject = gal_trans("Nouvelle soumission de Photos");
        $message = gal_trans("Des photos viennent d'être proposées dans la galerie photo du site ") . $nuke_url . gal_trans(" par ") . $user_connecte;
        send_email($adminmail, $subject, $message, "", true, "html");
    }
}
Beispiel #11
0
        $uploadErrors[] = "name";
    } else {
        $name = $_POST['name'];
        echo $name;
    }
    if (count($uploadErrors) == 0) {
        $upload = new Upload("uploadBtn", "uploads/{$category}/");
        // If the upload was not successful display errors for user
        if (!$upload->upload()) {
            foreach ($upload->errors() as $error) {
                echo "<hr>";
                echo $error . " <BR/>";
            }
        } else {
            // Store in DB
            $controller->addItem($upload->getFileName(), $name, $category);
        }
    }
}
?>

<div class="container">
    <div class="starter-template">
        <h1>Upload</h1>
        <form action="" method="post" enctype="multipart/form-data">

            Category:
            <select name="category">
            <?php 
$categories = $controller->allCategories();
if (count($categories) > 0) {
Beispiel #12
0
 function add()
 {
     if (!$this->haveAccessTo('edit')) {
         return $this->showAccessDenied();
     }
     $aData = $this->input->postm(array('position' => TYPE_STR, 'cat' => TYPE_ARRAY_UINT, 'enabled' => TYPE_BOOL, 'banner_type' => TYPE_UINT, 'show_limit' => TYPE_UINT, 'resize_img' => TYPE_BOOL, 'code' => TYPE_STR, 'show_start' => TYPE_STR, 'show_finish' => TYPE_STR, 'clickurl' => TYPE_STR, 'showurl' => TYPE_STR, 'showurl_recursive' => TYPE_BOOL, 'flash_width' => TYPE_UINT, 'flash_height' => TYPE_UINT, 'flash_key' => TYPE_STR, 'title' => TYPE_STR, 'alt' => TYPE_STR, 'description' => TYPE_STR));
     if (bff::$isPost) {
         if (!$aData['position']) {
             $this->errors->set('position');
         }
         if (!$this->checkRotation($aData['position'])) {
             $this->errors->set('no_rotation');
         }
         $aData['clickurl'] = preg_replace("[^http://|www\\.|https://|ftp://]", '', $aData['clickurl']);
         $aData['showurl'] = preg_replace("[^http://|www\\.|https://|ftp://]", '', $aData['showurl']);
         $sFlashAddFields = '';
         $sFlashAddValues = '';
         if ($aData['banner_type'] == BANNERS_TYPE_FLASH) {
             if (!$aData['flash_width'] || !$aData['flash_height']) {
                 $this->errors->set('no_flash_size');
             }
             $sFlashAddValues = $this->db->str2sql(serialize(array('width' => $aData['flash_width'], 'height' => $aData['flash_height'], 'key' => $aData['flash_key']))) . ', ';
             $sFlashAddFields = 'flash,';
         }
         Func::setSESSION('banner_position', $aData['position']);
         if ($this->errors->no()) {
             $this->db->execute('INSERT INTO ' . TABLE_BANNERS . ' 
                        ( banner_type, position, cat, clickurl, showurl, showurl_recursive, show_limit, show_start, show_finish, ' . $sFlashAddFields . ' enabled, title, alt, description)
                         VALUES(' . $aData['banner_type'] . ', :position, :cat, :clickurl, :showurl, ' . $aData['showurl_recursive'] . ',  
                                 ' . $aData['show_limit'] . ', :show_start, :show_finish,
                                 ' . $sFlashAddValues . '
                                 ' . $aData['enabled'] . ', :title, :alt, :description)', array(':position' => $aData['position'], ':cat' => join(',', $aData['cat']), ':clickurl' => $aData['clickurl'], ':showurl' => $aData['showurl'], ':show_start' => date("Y-m-d H:i", strtotime($aData['show_start'])), ':show_finish' => date("Y-m-d H:i", strtotime($aData['show_finish'])), ':title' => $aData['title'], ':alt' => $aData['alt'], ':description' => $aData['description']));
             $nRecordID = $this->db->insert_id(TABLE_BANNERS, 'id');
             if ($aData['banner_type'] == BANNERS_TYPE_IMG) {
                 $oUpload = new Upload('bnrimg', false);
                 $oUpload->checkIsIMG();
                 if ($oUpload->isSuccessfull()) {
                     $aPositionInfo = $this->positions[$aData['position']];
                     $aImgInfo = getimagesize($_FILES['bnrimg']['tmp_name']);
                     $sExtension = image_type_to_extension($aImgInfo[2], false);
                     $sFilename = Func::generateRandomName(5, true, true) . '.' . $sExtension;
                     if (!isset($aPositionInfo['height']) || !$aPositionInfo['height']) {
                         $aPositionInfo['height'] = false;
                     }
                     if (!$aData['resize_img']) {
                         $aWorkingImg = array('filename' => BANNERS_PATH . $nRecordID . '_work_' . $sFilename, 'width' => $aImgInfo[0], 'height' => $aImgInfo[1], 'autofit' => true, 'crop_v' => 'center', 'crop_h' => 'center');
                     } else {
                         $aWorkingImg = array('filename' => BANNERS_PATH . $nRecordID . '_work_' . $sFilename, 'width' => $aPositionInfo['width'], 'height' => $aPositionInfo['height'], 'autofit' => true, 'crop_v' => 'center', 'crop_h' => 'center');
                     }
                     $aParams = array(array('filename' => BANNERS_PATH . $nRecordID . '_th_' . $sFilename, 'width' => 100, 'height' => false, 'autofit' => true, 'crop_v' => 'center', 'crop_h' => 'center'), $aWorkingImg ? $aWorkingImg : '');
                     $oThumb = new CThumbnail($_FILES['bnrimg']['tmp_name'], false);
                     $oThumb->setSaveMethod('gd');
                     $oThumb->save($aParams);
                     $this->db->execute('UPDATE ' . TABLE_BANNERS . '
                                SET banner=' . $this->db->str2sql($sFilename) . '
                                WHERE id=' . $nRecordID);
                 }
             } elseif ($aData['banner_type'] == BANNERS_TYPE_FLASH) {
                 $fUpload = new Upload('flash', false);
                 $fUpload->save(BANNERS_PATH, $nRecordID . '_src_');
                 $this->db->execute('UPDATE ' . TABLE_BANNERS . '
                            SET banner=' . $this->db->str2sql($fUpload->getFileName()) . '
                            WHERE id=' . $nRecordID);
             } else {
                 $this->db->execute('UPDATE ' . TABLE_BANNERS . '
                            SET banner=' . $this->db->str2sql($aData['code']) . '
                            WHERE id=' . $nRecordID);
             }
             $this->adminRedirect(Errors::SUCCESSFULL);
         }
     }
     if (empty($aData['position'])) {
         $aData['position'] = Func::SESSION('banner_position');
     }
     // подготавливаем линк
     $aData['id_from'] = (int) $this->db->one_data('SELECT MAX(id)+1 FROM ' . TABLE_BANNERS);
     if ($aData['id_from'] == 0) {
         $aData['id_from']++;
     }
     if ($aData['id_from'] > 0) {
         $aData['link'] = $this->prepareClickURL($aData['id_from']);
     }
     $aData['id'] = 0;
     $aData['img_big'] = '';
     $aData['banner'] = '';
     //defaults
     $aData['resize_img'] = 1;
     $aData['flash'] = array('key' => '', 'width' => '', 'height' => '');
     $aData['date_min'] = date('Y,n,d', mktime(0, 0, 0, date('n') - 1, date('d'), date('y')));
     if (empty($aData['cat'])) {
         $aData['cat'][] = 1;
     }
     $this->includeJS(array('datepicker'));
     $this->tplAssign('aCategories', $this->getBBSCategories($aData['cat'], false));
     $this->tplAssign('aPosOptions', $this->positions);
     $this->tplAssign('aData', $aData);
     return $this->tplFetch('admin.form.tpl');
 }
 public function editSurat()
 {
     $temp = explode(' ', $_POST['tujuan']);
     $tujuan = $temp[0];
     $upload = new Upload('upload');
     //        cek nomor ada yg sama di db ato gak
     if ($_POST['nomor'] != '') {
         $bagian = Session::get('bagian');
         $sql = "SELECT kd_bagian FROM r_bagian WHERE id_bagian=" . $bagian;
         $datab = $this->model->select($sql);
         foreach ($datab as $val) {
             $bagian = $val['kd_bagian'];
         }
         $nomor = $this->model->cekIfExistNomor($_POST['nomor'], $_POST['tipe'], $bagian);
     } else {
         $nomor = $_POST['nomor'];
     }
     $data = array("tipe" => $_POST['tipe'], "tgl_surat" => Tanggal::ubahFormatTanggal($_POST['tgl_surat']), "no_surat" => $nomor, "tujuan" => $tujuan, "perihal" => $_POST['perihal'], "sifat" => $_POST['sifat'], "jenis" => $_POST['jenis'], "lampiran" => $_POST['lampiran']);
     $id = $_POST['id'];
     $where = "id_suratkeluar = '" . $id . "'";
     //        var_dump($data);
     //        var_dump($where);
     //        var_dump($_FILES);
     //echo $where;
     $update = $this->model->editSurat($data, $where);
     if ($update) {
         //status net
         if ($_POST['nomor'] != '') {
             $data = array('status' => 22);
             $this->model->editSurat($data, $where);
         }
         echo "<div id=success>Ubah data surat berhasil</div>";
         //upload file
         if (end(explode('.', $upload->getFileName())) == 'pdf') {
             $upload->setDirTo('arsip/');
         } elseif (end(explode('.', $upload->getFileName())) == 'docx' or end(explode('.', $upload->getFileName())) == 'doc') {
             $upload->setDirTo('arsip/temp/');
         }
         $tipe = 'K';
         $satker = substr($_POST['tujuan'], 0, 8);
         //            $id = 0;
         $sql = "SELECT MAX(id_suratkeluar) as id FROM suratkeluar";
         $did = $this->model->select($sql);
         foreach ($did as $valid) {
             $id_max = $valid['id'];
         }
         //nama baru akan terdiri dari tipe naskah_nomor surat_asal(asal/tetapi asal terlaku kepanjangan)
         $ubahNama = array($tipe, $id, $satker);
         $upload->setUbahNama($ubahNama);
         $upload->changeFileName($upload->getFileName(), $ubahNama);
         $namafile = $upload->getFileTo();
         $where = ' id_suratkeluar=' . $id;
         $data = array('file' => $namafile);
         if ($_FILES['upload']['tmp_name'] != '') {
             $upload->uploadFile();
             $this->model->uploadFile($data, $where);
         }
         @Session::createSession();
         $user = Session::get('user');
         $log = new Log();
         $log->addLog($user, 'UBAH SK', 'user ' . $user . ' ubah surat keluar tujuan: ' . $id . ' perihal:' . $_POST['perihal']);
         unset($log);
         //        return true;
     } else {
         echo "<div id=error>Ubah data surat gagal</div>";
     }
 }
 public function ubahLampiran()
 {
     $id_lamp = $_POST['id'];
     $id_surat = $_POST['id_surat'];
     $tgl = $_POST['tanggal'];
     $jns = $_POST['jenis'];
     $tipe = $_POST['tipe'];
     $nomor = $_POST['nomor'];
     $asal = $_POST['asal'];
     $hal = $_POST['hal'];
     $ket = $_POST['keterangan'];
     //nama baru akan terdiri dari tipe naskah_nomor surat_asal(asal/tetapi asal terlaku kepanjangan)
     if ($_FILES['upload']['name'] != '') {
         $upload = new Upload('upload');
         $upload->setDirTo('arsip/');
         $ubahNama = array($tipe, $nomor);
         $upload->setUbahNama($ubahNama);
         $upload->changeFileName($upload->getFileName(), $ubahNama);
         $namafile = $upload->getFileTo();
     } else {
         $filex = $_POST['file'];
         $file = explode("_", $filex);
         $j = count($file);
         $ext = explode('.', $file[$j - 1]);
         //            var_dump($ext);
         //            var_dump($file);
         //            $namafile = explode("_", $file);
         //            var_dump($namafile);
         $file[0] = $tipe;
         $namafile = '';
         for ($i = 0; $i < $j - 1; $i++) {
             $namafile .= '_' . $file[$i];
             echo $file[$i] . '</br>';
         }
         $namafile = trim($namafile, "_") . '_' . $ext[0] . '.' . $ext[1];
         //            var_dump($namafile);
         //            $namafile = implode("_", $namafile);
         rename('arsip/' . $filex, 'arsip/' . $namafile);
     }
     //$upload->init('upload');
     $lamp = new Lampiran_Model();
     $lamp->set('id_lamp', $id_lamp);
     $lamp->set('jns_surat', $jns);
     $lamp->set('id_surat', $id_surat);
     $lamp->set('tipe', $tipe);
     $lamp->set('nomor', $nomor);
     $lamp->set('tanggal', $tgl);
     $lamp->set('asal', $asal);
     $lamp->set('hal', $hal);
     $lamp->set('keterangan', $ket);
     $lamp->set('file', $namafile);
     /*$data = array(
           'jns_surat'=>$jns,
           'id_surat'=>$_POST['id'],
           'tipe'=>$tipe,
           'nomor'=>$nomor,
           'tanggal'=>  Tanggal::ubahFormatTanggal($_POST['tanggal']),
           'hal'=>$_POST['hal'],
           'asal'=>$asal,
           'keterangan'=>$_POST['keterangan'],
           'file'=>$namafile//upload belom diurus
       );*/
     //var_dump($data);
     if ($lamp->editLampiran()) {
         if ($_FILES['upload']['name'] != '') {
             $upload->uploadFile();
         }
         echo "<div id=success>Ubah data lampiran berhasil</div>";
     } else {
         echo "<div id=error>Ubah data lampiran gagal!</div>";
     }
     /*if($jns=='SM'){
           header('location:'.URL.'suratmasuk/detil/'.$data['id_surat']);
       }elseif ($jns=='SK') {
           header('location:'.URL.'suratkeluar/detil/'.$data['id_surat']);
       }*/
     //        return true;
 }