Пример #1
0
    public function template($c, $page)
    {
        $conn = $this->conn($c);
        // connection
        $cache = new cache();
        $welcomepage_categories = $cache->index($c, "welcomepage_categories");
        $data["welcomepage_categories"] = json_decode($welcomepage_categories, true);
        /* language variables */
        $language_data = $cache->index($c, "language_data");
        $language_data = json_decode($language_data);
        $model_template_makevars = new model_template_makevars();
        $data["language_data"] = $model_template_makevars->vars($language_data);
        $sql = 'SELECT `namelname`,`picture` FROM `studio404_users` WHERE `id`=:id';
        $prepare = $conn->prepare($sql);
        $prepare->execute(array(":id" => $_SESSION["batumi_id"]));
        if ($prepare->rowCount() > 0) {
            $fetch = $prepare->fetch(PDO::FETCH_ASSOC);
            $data["userdata"] = $fetch;
        } else {
            redirect::url(WEBSITE);
        }
        $data["cataloglist_names"] = new cataloglist_names();
        $data["getusername"] = new getusername();
        $labellists = new labellists();
        $data["labellists"] = $labellists->loadlabels($c);
        $sql2 = 'SELECT 
		`studio404_module_item`.* 
		FROM `studio404_module_item` WHERE 
		`module_idx`=25 AND 
		`studio404_module_item`.`idx`=:idx AND 
		`studio404_module_item`.`lang`=:lang AND 
		`studio404_module_item`.`status`!=:status';
        $prepare2 = $conn->prepare($sql2);
        $prepare2->execute(array(":idx" => Input::method("GET", "view"), ":lang" => LANG_ID, ":status" => 1));
        if ($prepare2->rowCount() > 0) {
            $data["fetch"] = $prepare2->fetch(PDO::FETCH_ASSOC);
        } else {
            redirect::url(WEBSITE . LANG . "/welcomesystem");
        }
        $include = WEB_DIR . "/monacemisnaxva.php";
        if (file_exists($include)) {
            @(include $include);
        } else {
            $controller = new error_page();
        }
    }
	<!-- Content Wrapper. Contains page content -->
	<div class="content-wrapper">
		<section class="content">
			<div class="box box-default">
            <div class="box-header with-border">
              <h3 class="box-title"><?php 
echo $data["language_data"]["val84"];
?>
</h3>
            </div>
           <div class="box-body">
                <div class="row">
                	<div class="col-md-12 form-message-output" style="display:none"><p></p></div> 
                    <div class="col-md-9 catalog-add-form-data">
                    	<?php 
$labellists = new labellists();
$data["labellists"] = $labellists->loadlabels($c);
?>
                   <form action=""  method="post" enctype="multipart/form-data" name="monacemisdamatebaform" id="monacemisdamatebaform">
					<?php 
if ($data["fetch"]["visibility"] == 1) {
    ?>
                   	<div class="alert alert-danger alert-dismissible">
		                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
		                <h4><i class="icon fa fa-ban"></i> <?php 
    echo $data["language_data"]["val94"];
    ?>
</h4>
		                <?php 
    echo $data["language_data"]["val121"];
    ?>
    public function template($c, $page)
    {
        $conn = $this->conn($c);
        // connection
        $cache = new cache();
        $welcomepage_categories = $cache->index($c, "welcomepage_categories");
        $data["welcomepage_categories"] = json_decode($welcomepage_categories, true);
        /* language variables */
        $language_data = $cache->index($c, "language_data");
        $language_data = json_decode($language_data);
        $model_template_makevars = new model_template_makevars();
        $data["language_data"] = $model_template_makevars->vars($language_data);
        $sql = 'SELECT `namelname`,`picture` FROM `studio404_users` WHERE `id`=:id';
        $prepare = $conn->prepare($sql);
        $prepare->execute(array(":id" => $_SESSION["batumi_id"]));
        if ($prepare->rowCount() > 0) {
            $fetch = $prepare->fetch(PDO::FETCH_ASSOC);
            $data["userdata"] = $fetch;
        } else {
            redirect::url(WEBSITE);
        }
        $data["cataloglist_names"] = new cataloglist_names();
        $data["getusername"] = new getusername();
        $labellists = new labellists();
        $data["labellists"] = $labellists->loadlabels($c);
        $form = $cache->index($c, "form");
        $data["form"] = json_decode($form, true);
        if (Input::method("POST", "file")) {
            $gallery_idx_post = Input::method("POST", "galleryidxpost");
            $model_admin_selectLanguage = new model_admin_selectLanguage();
            $lang_query = $model_admin_selectLanguage->select_languages($c);
            for ($input_file_count = 0; $input_file_count < count($_FILES["file"]["name"]); $input_file_count++) {
                foreach ($_FILES["file"]["name"][$input_file_count] as $key => $value) {
                    if ($value != "") {
                        $insert_admin = $_SESSION["batumi_id"];
                        $filenumber = $_POST['filenumber'];
                        $filenumber = $filenumber[$input_file_count];
                        $inputname = Input::method("POST", "form-name-" . $filenumber);
                        $attach = Input::method("POST", "form-attach-" . $filenumber);
                        $important = Input::method("POST", "form-important-" . $filenumber);
                        $multiple = Input::method("POST", "form-multiple-" . $filenumber);
                        $format = explode(",", Input::method("POST", "form-format-" . $filenumber));
                        //$format = end($format);
                        $filename = $_FILES["file"]["name"][$input_file_count][$key];
                        $filesize = $_FILES["file"]["size"][$input_file_count][$key];
                        $filetype_arr = explode(".", $filename);
                        $filetype = end($filetype_arr);
                        if (in_array($filetype, $format)) {
                            $sqlm = 'SELECT MAX(`idx`)+1 AS maxid FROM `studio404_gallery_file`';
                            $querym = $conn->query($sqlm);
                            $rowm = $querym->fetch(PDO::FETCH_ASSOC);
                            $max_idx = $rowm['maxid'] ? $rowm['maxid'] : 1;
                            $sql_max_posm = 'SELECT MAX(`position`)+1 AS maxpos FROM `studio404_gallery_file` WHERE `status`!=:status';
                            $preparem = $conn->prepare($sql_max_posm);
                            $preparem->execute(array(":status" => 1));
                            $row2m = $preparem->fetch(PDO::FETCH_ASSOC);
                            $max_pos = $row2m['maxpos'] ? $row2m['maxpos'] : 1;
                            $filename_new = $filetype_arr[0] . md5(sha1(time())) . "." . $filetype;
                            $target_file = DIR . "files/document/" . $filename_new;
                            if (move_uploaded_file($_FILES["file"]["tmp_name"][$input_file_count][$key], $target_file)) {
                                foreach ($lang_query as $lang_row) {
                                    $insert_into_gallery = 'INSERT INTO `studio404_gallery_file` SET 
									`idx`=:idx, 
									`date`=:date, 
									`gallery_idx`=:gallery_idx_post, 
									`file`=:file, 
									`fileinputname`=:fileinputname, 
									`media_type`=:media_type, 
									`title`=:title, 
									`description`=:description, 
									`filesize`=:filesize, 
									`insert_admin`=:insert_admin, 
									`position`=:position, 
									`lang`=:lang';
                                    $prepare_insert = $conn->prepare($insert_into_gallery);
                                    $prepare_insert->execute(array(":idx" => $max_idx, ":date" => time(), ":gallery_idx_post" => $gallery_idx_post, ":file" => $filename_new, ":fileinputname" => $inputname, ":media_type" => $filetype, ":title" => "Not Defined", ":description" => "Not Defined", ":filesize" => $filesize, ":insert_admin" => $insert_admin, ":position" => $max_pos, ":lang" => $lang_row["id"]));
                                }
                            }
                        }
                    }
                }
            }
            $files = glob(DIR . '_cache/*');
            // get all file names
            foreach ($files as $file) {
                // iterate files
                if (is_file($file)) {
                    @unlink($file);
                }
                // delete file
            }
        }
        $sql2 = 'SELECT 
		`studio404_module_item`.* 
		FROM `studio404_module_item` WHERE 
		`module_idx`=25 AND 
		`studio404_module_item`.`idx`=:idx AND 
		`studio404_module_item`.`lang`=:lang AND 
		`studio404_module_item`.`status`!=:status';
        $prepare2 = $conn->prepare($sql2);
        $prepare2->execute(array(":idx" => Input::method("GET", "idx"), ":lang" => LANG_ID, ":status" => 1));
        if ($prepare2->rowCount() > 0) {
            $data["fetch"] = $prepare2->fetch(PDO::FETCH_ASSOC);
        } else {
            redirect::url(WEBSITE . LANG . "/welcomesystem");
        }
        $include = WEB_DIR . "/monacemisredaqtireba.php";
        if (file_exists($include)) {
            @(include $include);
        } else {
            $controller = new error_page();
        }
    }