function deleteByGallery($gid)
 {
     global $db;
     $q = "SELECT * FROM {$this->table_name} WHERE gallery_id = '{$gid}'";
     $arr = $db->query($q, 2);
     $gw = new GalleryWeb();
     foreach ($arr as $car) {
         //delete di server
         $sc = unlink(_PHOTOPATH . $car->photo_filename);
         if ($sc) {
             unlink(_PHOTOPATH . "thumbnail/" . $car->photo_filename);
             //delete inputfilehistory
             $if = new InputFileModel();
             $arr = $if->getWhere("file_filename = '" . $car->photo_filename . "' LIMIT 0,1");
             $if = $arr[0];
             $if->delete($if->file_id);
         }
     }
     $q = "DELETE FROM {$this->table_name}  WHERE gallery_id = '{$gid}'";
     $db->query($q, 0);
 }
 public function uploadfiles()
 {
     //apakah ada file
     $adafile = isset($_GET['adafile']) ? $_GET['adafile'] : '';
     //cek if ada file
     if ($adafile) {
         $if = new InputFileModel();
         $uploadpath = $if->upload_location;
         if (file_exists($uploadpath . $adafile)) {
             //delete old file
             if (unlink($uploadpath . $adafile)) {
                 $arrf = $if->getWhere("file_filename = '{$adafile}' LIMIT 0,1");
                 if (count($arrf) > 0) {
                     $if->delete($arrf[0]->file_id);
                 }
                 //delete from log
                 PortalFileLogger::deleteFileLog($uploadpath . $adafile);
                 /*if(file_exists(_PHOTOPATH.'thumbnail/' . $adafile))
                   {
                       //delete old thumb file
                       unlink(_PHOTOPATH.'thumbnail/' . $adafile);
                   }*/
             }
         }
     }
     $data = array();
     //$tid = (isset($_GET['tid'])?addslashes($_GET['tid']):die('no ID'));
     $t = isset($_GET['t']) ? addslashes($_GET['t']) : die('no t');
     $data['files'] = $_GET['files'];
     $data['bool'] = 0;
     $dc = new InputFileModel();
     if (isset($_GET['files'])) {
         $error = false;
         $files = array();
         $uploaddir = $dc->upload_location;
         foreach ($_FILES as $file) {
             $f = new InputFileModel();
             $q = "INSERT INTO {$f->table_name} SET file_folder_id = '0',file_author = '" . Account::getMyID() . "'";
             global $db;
             $fid = $db->qid($q);
             $f->getByID($fid);
             if ($fid) {
                 $newname = $fid;
                 $f->file_url = basename($file['name']);
                 $ext = end(explode(".", $file['name']));
                 $f->file_ext = $ext;
                 $f->file_filename = $fid . "." . $ext;
                 $f->file_date = leap_mysqldate();
                 // if pdf
                 if (move_uploaded_file($file['tmp_name'], $uploaddir . $f->file_filename)) {
                     $files[] = $uploaddir . $file['name'];
                     $f->file_size = filesize($uploaddir . $f->file_filename);
                     if ($f->file_ext == "pdf") {
                         $a = new PDF2Text();
                         $a->setFilename($uploaddir . $f->file_filename);
                         $a->decodePDF();
                         $f->file_isi = preg_replace("/\r|\n/", " ", $a->output());
                         //the path to the PDF file
                         $strPDF = $uploaddir . $f->file_filename;
                         $thumb = $uploaddir . "thumbs/" . $fid . ".jpg";
                         exec("convert \"{$strPDF}[0]\" \"{$thumb}\"");
                     }
                     $f->load = 1;
                     $data['bool'] = $f->save();
                     $data['isImage'] = Leap\View\InputFile::isImage($f->file_filename);
                     $data['filename'] = $f->file_filename;
                     if (isset($_SESSION['target_id']['obj'])) {
                         $target = get_class($_SESSION['target_id']['obj']);
                     } else {
                         $target = "inputfile_unknown";
                     }
                     PortalFileLogger::save2log($uploaddir . $f->file_filename, $target, $f->file_url);
                     die(json_encode($data));
                 } else {
                     $error = true;
                 }
             }
         }
         $data = $error ? array('error' => 'There was an error uploading your files') : array('files' => $files);
     } else {
         $data = array('success' => 'Form was submitted', 'formData' => $_POST);
     }
     echo json_encode($data);
 }
 public function uploadfiles_gallery()
 {
     $data = array();
     //$tid = (isset($_GET['tid'])?addslashes($_GET['tid']):die('no ID'));
     $t = isset($_GET['t']) ? addslashes($_GET['t']) : die('no t');
     $dc = new InputFileModel();
     if (isset($_GET['files'])) {
         $error = false;
         $files = array();
         $uploaddir = $dc->upload_location;
         $arrSuc = array();
         $arrSucAsli = array();
         foreach ($_FILES as $file) {
             $f = new InputFileModel();
             $q = "INSERT INTO {$f->table_name} SET file_folder_id = '0',file_author = '" . Account::getMyID() . "'";
             global $db;
             $fid = $db->qid($q);
             $f->getByID($fid);
             if ($fid) {
                 $newname = $fid;
                 $f->file_url = basename($file['name']);
                 $ext = end(explode(".", $file['name']));
                 $f->file_ext = $ext;
                 $f->file_filename = $fid . "." . $ext;
                 $f->file_date = leap_mysqldate();
                 $ifn = new \Leap\View\InputFile();
                 if (in_array($ext, $ifn->arrImgExt)) {
                     $isImage = 1;
                 } else {
                     $isImage = 0;
                     $error = true;
                 }
                 if ($isImage) {
                     if (move_uploaded_file($file['tmp_name'], $uploaddir . $f->file_filename)) {
                         $files[] = $uploaddir . $file['name'];
                         $f->file_size = filesize($uploaddir . $f->file_filename);
                         /*
                          * thumbnail
                          */
                         $src = $uploaddir . $f->file_filename;
                         $dest = $uploaddir . 'thumbnail/' . $f->file_filename;
                         //                                $this->make_thumb($src, $dest, 570);
                         $up = new Uploader();
                         //                                        $up->make_thumb_new()
                         $up->make_thumb_new($src, $dest, 570);
                         $f->load = 1;
                         $f->save();
                         $arrSuc[] = $f->file_filename;
                         $fil = trim(rtrim($f->file_filename));
                         $fil2 = explode(".", $fil);
                         $fil3 = $fil2[0];
                         $arrSucAsli[] = "<div id='file_" . $fid . "_{$t}' class='mlt_item_gal'><div id='gal_{$fil3}' class='foto100gal'><span class='helper'></span><img ondblclick='makeasmainpic_" . $t . "(\"{$fil}\");' src='" . _SPPATH . $f->upload_url . $f->file_filename . "'></div>" . $f->file_url . " <i onclick=\"deleteFromList_{$t}('" . $f->file_filename . "');\" class='glyphicon glyphicon-remove'></i></div>";
                         if (isset($_SESSION['target_id']['obj'])) {
                             $target = get_class($_SESSION['target_id']['obj']);
                         } else {
                             $target = "inputfile_unknown";
                         }
                         PortalFileLogger::save2log($uploaddir . $f->file_filename, $target, $f->file_url);
                     } else {
                         $error = true;
                     }
                 }
             }
         }
         $data = $error ? array('error' => 'There was an error uploading your files, make sure your file is an image file') : array('files' => $files, 'ftext' => implode(",", $arrSuc), 'ftextAsli' => implode(" ", $arrSucAsli));
     } else {
         $data = array('success' => 'Form was submitted', 'formData' => $_POST);
     }
     echo json_encode($data);
 }
    function p()
    {
        $id = isset($_GET['id']) ? addslashes($_GET['id']) : 0;
        if ($id) {
            $page = new Page();
            $page->getByID($id);
            if (!isset($page->post_title) || $page->post_title == '') {
                die('Not Found');
            }
            //add channel feb 2015
            $a = NewsChannel::myChannels();
            if ($page->page_channel_id > 0) {
                if (!in_array($page->page_channel_id, $a)) {
                    echo 'Not Authorize To View';
                    return "";
                }
            }
            $pc = new PageContainer();
            if ($page->post_gallery_id > 0) {
                $pc->getByID($page->post_gallery_id);
            }
            $page->setSEO();
            $gw = new GalleryWeb();
            ?>
			<style>
				.pl_file_item {
					padding          : 10px;
					clear            : both;
					text-decoration  : underline;
					color            : #0072b1;
					cursor           : pointer;
					margin           : 5px;
					background-color : #efefef;
				}

				.if_text {
					height      : 30px;
					line-height : 30px;
					float       : left;
					margin-left : 10px;
				}

				.fotoIF {
					width    : 30px;
					height   : 30px;
					overflow : hidden;
					float    : left;
				}

				.fotoIF img {
					width : 30px;
				}

				.h3pv {
					font-size      : 18px;
					border-bottom  : 1px dashed #333;
					padding-bottom : 10px;
					margin-bottom  : 0px;
				}
			</style>
			<h1 style="padding-bottom: 0; margin-bottom: 0; margin-bottom: 10px;"><?php 
            echo stripslashes($page->post_title);
            ?>
</h1>
			<div class="breadcrumbs">Pages
				<?php 
            if ($page->post_gallery_id > 0) {
                ?>
/
					<a href="<?php 
                echo _SPPATH;
                ?>
pagecontainer?mode=<?php 
                echo $pc->container_id;
                ?>
"><?php 
                echo $pc->container_name;
                ?>
</a><?php 
            }
            ?>
			</div>

			<small style="font-size: 12px;"><?php 
            echo indonesian_date($page->post_modified);
            ?>
</small>

			<?php 
            if ($page->post_image != "") {
                ?>
				<div class="bigimage"
				     style="padding-bottom: 10px;">
					<img style="width: 100%; padding-top: 20px;"
					     src="<?php 
                echo _SPPATH . $gw->uploadURL . $page->post_image;
                ?>
">
				</div>
			<?php 
            }
            ?>

			<div class="postcontent">
				<?php 
            $content = stripslashes($page->post_content);
            $content = str_replace('#tbs_video#', '<video id="player_normal" width="100%" controls src="', $content);
            $content = str_replace('#/tbs_video#', '"></video>', $content);
            echo $content;
            ?>
			</div>
			<?php 
            if ($page->post_files != "") {
                ?>
				<div class="clearfix"
				     style="padding:  10px;">

					<h3 class="h3pv"><?php 
                echo Lang::t('Attachments');
                ?>
</h3>
				</div>
				<div style="">
				<?php 
                $exp = explode(",", trim(rtrim($page->post_files)));
                $arrNames = array();
                foreach ($exp as $fil) {
                    // echo $fil."<br>";
                    if ($fil == "") {
                        continue;
                    }
                    $exp2 = explode(".", $fil);
                    $if = new \InputFileModel();
                    // echo $exp2[0]."<br>";
                    $if->getByID($exp2[0]);
                    $arrNames[] = $if;
                    $text .= $if->printLink();
                }
                echo $text;
                ?>
</div><?php 
            }
            ?>
			<?php 
            if ($page->comment_allowed) {
                ?>
				<div class="clearfix"
				     style="padding:  10px;"></div>
				<?php 
                PageCommentWeb::beginComment($id);
            }
            // pr($page);
            /* $str = '';
            			 global $template;
            			 if($page->post_gallery_id != 0 || $page->post_event_id != 0){
            
            				 if($page->post_event_id!=0){
            					 $event = new Event();
            					 $event->getByID($page->post_event_id);
            					// pr($event);
            					 $str .= '<div class="event-item"><div class="event-name">'.$event->cal_name.'</div></div>';
            					 $efi = new EfiHome();
            					 $_GET['eid'] = $page->post_event_id;
            					 $efi->eventview(1);
            				 }
            				 if($page->post_gallery_id!=0){
            					 $gal = new Gallery();
            					 $gal->getByID($page->post_gallery_id);
            					 //pr($gal);
            					 $str .= '<div class="gallery-item"><div class="gallery-name">'.$gal->gallery_name.'</div></div>';
            					 $efi = new EfiHome();
            					 $_GET['gid'] = $page->post_gallery_id;
            					 $efi->galleryview(1);
            				 }
            				 //$template->useSidebar = 1;
            				 //$template->sideBar = $str;
            			 }*/
            /*
            			 ?>
            			 <div class="fb-comments" data-href="http://developers.facebook.com/docs/plugins/comments/" data-width="100%" data-numposts="5" data-colorscheme="light"></div>
            			 <?*/
        }
    }
    public function p()
    {
        $t = time() + rand(0, 1000);
        $startTID = rand(0, 10);
        $this->id = $this->id . "_" . $t;
        // get asli
        $text = '';
        $exp = explode(",", trim(rtrim($this->value)));
        $arrNames = array();
        $sudah = array();
        foreach ($exp as $fil) {
            if (in_array($fil, $sudah)) {
                continue;
            }
            $sudah[] = $fil;
            $fil = trim(rtrim($fil));
            // echo $fil."<br>";
            if ($fil == "") {
                continue;
            }
            $exp2 = explode(".", $fil);
            $if = new \InputFileModel();
            // echo $exp2[0]."<br>";
            $if->getByID($exp2[0]);
            $fil2 = explode(".", $fil);
            $fil3 = $fil2[0];
            $arrNames[] = $if;
            //  $text .= "<div id='file_".$exp2[0]."_{$t}' class='mlt_item'>".$if->file_url." <i onclick=\"deleteFromList_{$t}('".$fil."');\" class='glyphicon glyphicon-remove'></i></div>";
            $text .= "<div id='file_" . $exp2[0] . "_{$t}' class='mlt_item_gal'><div id='gal_{$fil3}' class='foto100gal'><span class='helper'></span><img ondblclick='makeasmainpic_" . $t . "(\"{$fil}\");' src='" . _SPPATH . $if->upload_url . $if->file_filename . "'></div>" . $if->file_url . " <i onclick=\"deleteFromList_{$t}('" . $if->file_filename . "');\" class='glyphicon glyphicon-remove'></i></div>";
        }
        ?>
<input type="hidden" name="<?php 
        echo $this->name;
        ?>
"  value="<?php 
        echo $this->value;
        ?>
" id="<?php 
        echo $this->id;
        ?>
" class="form-control">
<div id="multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
" ><?php 
        echo $text;
        ?>
</div>
<div id="hidupload_<?php 
        echo $t;
        ?>
" style="padding-top: 10px;clear:both;">
    <input class="form-control" type="file" id="uploadfolder_<?php 
        echo $t;
        ?>
" name="upl_<?php 
        echo $this->name;
        ?>
" value="<?php 
        echo $this->value;
        ?>
"  multiple  />
</div>
<small>double click on the thumbnail to make it a mainpic</small>
<style>
    
.helper {
    display: inline-block;
    height: 100%;
    vertical-align: middle;
}

    .mlt_item_gal{
        float:left;
        width: 100px;
        
    }
    .foto100gal{
        mwidth: 100px;
        height: 100px;
        overflow: hidden;
        border: 1px solid #efefef;
        white-space: nowrap;
        text-align: center; 
        margin: 1em 0;
    }
    .foto100gal img{
        max-width: 100px;
        vertical-align: middle;
        cursor: pointer;
    }
    .gal_mainpic{
        border:1px solid red;
    }
</style>

<script>
// Variable to store your files
var files;
$(document).ready(function(){
   setMainPic_<?php 
        echo $t;
        ?>
(); 
}); 
// Add events
$('#hidupload_<?php 
        echo $t;
        ?>
 input[type=file]').on('change', uploadFiles_<?php 
        echo $t;
        ?>
);

//make as mainpic
/*
 * fungsi mainpic 
 * dipakai dengan cara memakai dua kali untuk di fieldnya
 */
function makeasmainpic_<?php 
        echo $t;
        ?>
(id){
    /*
     * getmain pic first, cari yang dobel
     * abis itu hapus, dan tambahkan di depan
     */
    var dulunya2 = $('#<?php 
        echo $this->id;
        ?>
').val();
    var arr =dulunya2.split(',');
    var adalahthumb;
    console.log(arr);
    arr = jQuery.unique( arr );
    //hilangkan thumb yang lama
    /*for(var key in arr){
       var nex = key;
       console.log("pos : "+pos+" |  key : "+key);
       var pos = jQuery.inArray( arr[key], arr, nex+1 );
       
       if(pos !== -1){
           adalahthumb = arr[key];
           console.log(pos);
           arr.splice(pos,1);
        }
    }*/
    arr.push(id);
    mainpic_inputgallery = id;
    $('#<?php 
        echo $this->id;
        ?>
').val(arr.join());
    console.log(arr);
    setMainPic_<?php 
        echo $t;
        ?>
();
}
var mainpic_inputgallery;
function setMainPic_<?php 
        echo $t;
        ?>
(){
    var dulunya2 = $('#<?php 
        echo $this->id;
        ?>
').val();
    var arr =dulunya2.split(',');
    //var arr = [9, 9, 111, 2, 3, 4, 4, 5, 7];
    var sorted_arr = arr.sort(); // You can define the comparing function here. 
                                 // JS by default uses a crappy string compare.
    var results = [];
    var pilihan;
    
    for (var i = 0; i < arr.length; i++) {
        var xxx = arr[i].split('.');
        $('#gal_'+xxx[0]).removeClass('gal_mainpic');
    }
    
    for (var i = 0; i < arr.length - 1; i++) {
        var xxx = sorted_arr[i].split('.');
        if (sorted_arr[i + 1] == sorted_arr[i]) {
            results.push(sorted_arr[i]);
            pilihan = xxx[0];
        }        
    }    
    $('#gal_'+pilihan).addClass('gal_mainpic');
    //alert(results);
}

// Grab the files and set them to our variable
function deleteFromList_<?php 
        echo $t;
        ?>
(id)
{
  //alert('in'+id);
  var bagi = id.split(".");
  var id_asli = bagi[0];
  var id_ext = bagi[1];
  //kalau yang dihapus mainpic
  if(id == mainpic_inputgallery){
        var dulunya2 = $('#<?php 
        echo $this->id;
        ?>
').val();
        var arr =dulunya2.split(',');
        var adalahthumb;
        console.log(arr);
        arr = jQuery.unique( arr );
        $('#<?php 
        echo $this->id;
        ?>
').val(arr.join());
  }
  if(confirm('<?php 
        echo Lang::t('Are You Sure? This will delete the file');
        ?>
')){
      var str = $('#<?php 
        echo $this->id;
        ?>
').val();
      var res = str.split(",");
      for(var key in res){
          if(res[key] == id){
              res.splice(key,1);
          }
      }
      $('#<?php 
        echo $this->id;
        ?>
').val(res.join());
      $('#file_'+id_asli+'_<?php 
        echo $t;
        ?>
').hide();
      //delete on server .. later
      $.post("<?php 
        echo _LANGPATH;
        ?>
UploaderMultiples/del",{id:id});
  }
}  
// Catch the form submit and upload the files
function uploadFiles_<?php 
        echo $t;
        ?>
(event)
{
    files = event.target.files;
    event.stopPropagation(); // Stop stuff happening
    event.preventDefault(); // Totally stop stuff happening
 
    // START A LOADING SPINNER HERE
 
    // Create a formdata object and add the files
	var data = new FormData();
	$.each(files, function(key, value)
	{
		data.append(key, value);
	});
    
    $.ajax({
        url: '<?php 
        echo _LANGPATH;
        ?>
UploaderMultiples/uploadfiles_gallery?t=<?php 
        echo $t;
        ?>
&files=1',
        type: 'POST',
        data: data,
        cache: false,
        dataType: 'json',
        processData: false, // Don't process the files
        contentType: false, // Set content type to false as jQuery will tell the server its a query string request
        success: function(data, textStatus, jqXHR)
        {
                console.log(data);
        	if(typeof data.error === 'undefined')
        	{
        		// Success so call function to process the form
        		//submitForm(event, data);
                        console.log("success");
                        //loadfolder_<?php 
        echo $t;
        ?>
(activeTID_<?php 
        echo $t;
        ?>
);
                       /* var fs = data.files;
                        var fstext = fs.split();
                        $('#<?php 
        echo $this->id;
        ?>
').val(fstext);
                        */
                           var dulunya = $('#<?php 
        echo $this->id;
        ?>
').val();
                           if(dulunya != "")
                               $('#<?php 
        echo $this->id;
        ?>
').val(dulunya+","+data.ftext);
                           else
                               $('#<?php 
        echo $this->id;
        ?>
').val(data.ftext);
                           
                           var dulunya2 = $('#multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
').html();
                           if(dulunya2 != "")
                               $('#multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
').html(dulunya2+" "+data.ftextAsli);
                           else
                               $('#multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
').html(data.ftextAsli);
                           //$('#<?php 
        echo $this->id;
        ?>
').val($('#multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
').text());
        	}
        	else
        	{
        		// Handle errors here
        		console.log('ERRORS: ' + data.error);
        	}
        },
        error: function(jqXHR, textStatus, errorThrown)
        {
        	// Handle errors here
        	console.log('ERRORS: ' + textStatus);
        	// STOP LOADING SPINNER
        }
    });
}
</script>            
        <?php 
    }
    public function p()
    {
        $t = time() + rand(0, 1000);
        $startTID = rand(0, 10);
        $this->id = $this->id . "_" . $t;
        // get asli
        $text = '';
        $exp = explode(",", trim(rtrim($this->value)));
        $arrNames = array();
        foreach ($exp as $fil) {
            // echo $fil."<br>";
            if ($fil == "") {
                continue;
            }
            $exp2 = explode(".", $fil);
            $if = new \InputFileModel();
            // echo $exp2[0]."<br>";
            $if->getByID($exp2[0]);
            $arrNames[] = $if;
            $text .= "<div id='file_" . $exp2[0] . "_{$t}' class='mlt_item'>" . $if->file_url . " <i onclick=\"deleteFromList_{$t}('" . $fil . "');\" class='glyphicon glyphicon-remove'></i></div>";
        }
        ?>
<input type="hidden" name="<?php 
        echo $this->name;
        ?>
" value="<?php 
        echo $this->value;
        ?>
" id="<?php 
        echo $this->id;
        ?>
" class="form-control">
<div id="multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
" ><?php 
        echo $text;
        ?>
</div>
<div id="hidupload_<?php 
        echo $t;
        ?>
" style="padding-top: 10px;">
    <input class="form-control" type="file" id="uploadfolder_<?php 
        echo $t;
        ?>
" name="upl_<?php 
        echo $this->name;
        ?>
" value="<?php 
        echo $this->value;
        ?>
"  multiple  />
</div>
<script>
// Variable to store your files
var files;
 
// Add events
$('#hidupload_<?php 
        echo $t;
        ?>
 input[type=file]').on('change', uploadFiles_<?php 
        echo $t;
        ?>
);
 
// Grab the files and set them to our variable
function deleteFromList_<?php 
        echo $t;
        ?>
(id)
{
  //alert('in'+id);
  var bagi = id.split(".");
  var id_asli = bagi[0];
  var id_ext = bagi[1];
  if(confirm('<?php 
        echo Lang::t('Are You Sure? This will delete the file');
        ?>
')){
      var str = $('#<?php 
        echo $this->id;
        ?>
').val();
      var res = str.split(",");
      for(var key in res){
          if(res[key] == id){
              res.splice(key,1);
          }
      }
      $('#<?php 
        echo $this->id;
        ?>
').val(res.join());
      $('#file_'+id_asli+'_<?php 
        echo $t;
        ?>
').hide();
      //delete on server .. later
      $.post("<?php 
        echo _SPPATH;
        ?>
UploaderMultiples/del",{id:id});
  }
}  
// Catch the form submit and upload the files
function uploadFiles_<?php 
        echo $t;
        ?>
(event)
{
    files = event.target.files;
    event.stopPropagation(); // Stop stuff happening
    event.preventDefault(); // Totally stop stuff happening
 
    // START A LOADING SPINNER HERE
 
    // Create a formdata object and add the files
	var data = new FormData();
	$.each(files, function(key, value)
	{
		data.append(key, value);
	});
    
    $.ajax({
        url: '<?php 
        echo _SPPATH;
        ?>
UploaderMultiples/uploadfiles?t=<?php 
        echo $t;
        ?>
&files=1',
        type: 'POST',
        data: data,
        cache: false,
        dataType: 'json',
        processData: false, // Don't process the files
        contentType: false, // Set content type to false as jQuery will tell the server its a query string request
        success: function(data, textStatus, jqXHR)
        {
                console.log(data);
        	if(typeof data.error === 'undefined')
        	{
        		// Success so call function to process the form
        		//submitForm(event, data);
                        console.log("success");
                        //loadfolder_<?php 
        echo $t;
        ?>
(activeTID_<?php 
        echo $t;
        ?>
);
                       /* var fs = data.files;
                        var fstext = fs.split();
                        $('#<?php 
        echo $this->id;
        ?>
').val(fstext);
                        */
                           var dulunya = $('#<?php 
        echo $this->id;
        ?>
').val();
                           if(dulunya != "")
                               $('#<?php 
        echo $this->id;
        ?>
').val(dulunya+","+data.ftext);
                           else
                               $('#<?php 
        echo $this->id;
        ?>
').val(data.ftext);
                           
                           var dulunya2 = $('#multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
').html();
                           if(dulunya2 != "")
                               $('#multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
').html(dulunya2+" "+data.ftextAsli);
                           else
                               $('#multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
').html(data.ftextAsli);
                           //$('#<?php 
        echo $this->id;
        ?>
').val($('#multfile_<?php 
        echo $startTID;
        ?>
_<?php 
        echo $t;
        ?>
').text());
        	}
        	else
        	{
        		// Handle errors here
        		console.log('ERRORS: ' + data.error);
        	}
        },
        error: function(jqXHR, textStatus, errorThrown)
        {
        	// Handle errors here
        	console.log('ERRORS: ' + textStatus);
        	// STOP LOADING SPINNER
        }
    });
}
</script>            
        <?php 
    }
 function pictureDelete()
 {
     $pid = isset($_GET['pid']) ? addslashes($_GET['pid']) : 0;
     if ($pid == 0) {
         die('No ID');
     }
     $car = new Galleryphoto();
     $car->getByID($pid);
     $car->delete($pid);
     //delete di server
     unlink(_PHOTOPATH . $car->photo_filename);
     unlink(_PHOTOPATH . "thumbnail/" . $car->photo_filename);
     //delete inputfilehistory
     $if = new InputFileModel();
     $arr = $if->getWhere("file_filename = '" . $car->photo_filename . "' LIMIT 0,1");
     $if = $arr[0];
     $if->delete($if->file_id);
 }
    function p()
    {
        $id = isset($_GET['id']) ? addslashes($_GET['id']) : 0;
        if ($id) {
            $page = new Page();
            $page->getByID($id);
            if (!isset($page->post_title) || $page->post_title == '') {
                die('Not Found');
            }
            //add channel feb 2015
            //                        $a = NewsChannel::myChannels();
            //                        if($page->page_channel_id>0)
            //                        if(!in_array($page->page_channel_id, $a)){
            //                            echo 'Not Authorize To View';
            //                            return "";
            //                        }
            $pc = new PageContainer();
            if ($page->post_gallery_id > 0) {
                $pc->getByID($page->post_gallery_id);
            }
            $page->setSEO();
            //			$gw = new GalleryWeb();
            ?>
            <div class="container attop"  >
            <div class="col-md-8 col-md-offset-2">

			<h1 style="padding-bottom: 0; margin-bottom: 0; margin-bottom: 10px;"><?php 
            echo stripslashes($page->post_title);
            ?>
</h1>
<!--			<div class="breadcrumbs">Pages-->
<!--				--><?php 
            // if ($page->post_gallery_id > 0) {
            ?>
<!--/-->
<!--					<a href="--><?php 
            //= _SPPATH;
            ?>
<!--pagecontainer?mode=--><?php 
            //= $pc->container_id;
            ?>
<!--">--><?php 
            //= $pc->container_name;
            ?>
<!--</a>--><?php 
            // }
            ?>
<!--			</div>-->

<!--			<small style="font-size: 12px;">--><?php 
            //= indonesian_date($page->post_modified);
            ?>
<!--</small>-->

			<?php 
            if ($page->post_image != "") {
                ?>
				<div class="bigimage"
				     style="padding-bottom: 10px;">
					<img style="width: 100%; padding-top: 20px;"
					     src="<?php 
                echo _SPPATH . _PHOTOURL . $page->post_image;
                ?>
">
				</div>
			<?php 
            }
            ?>

			<div class="postcontent">
				<?php 
            $content = stripslashes($page->post_content);
            $content = str_replace('#tbs_video#', '<video id="player_normal" width="100%" controls src="', $content);
            $content = str_replace('#/tbs_video#', '"></video>', $content);
            echo $content;
            ?>
			</div>
			<?php 
            if ($page->post_files != "") {
                ?>
				<div class="clearfix"
				     style="padding:  10px;">

					<h3 class="h3pv"><?php 
                echo Lang::t('Attachments');
                ?>
</h3>
				</div>
				<div style="">
				<?php 
                $exp = explode(",", trim(rtrim($page->post_files)));
                $arrNames = array();
                foreach ($exp as $fil) {
                    // echo $fil."<br>";
                    if ($fil == "") {
                        continue;
                    }
                    $exp2 = explode(".", $fil);
                    $if = new \InputFileModel();
                    // echo $exp2[0]."<br>";
                    $if->getByID($exp2[0]);
                    $arrNames[] = $if;
                    $text .= $if->printLink();
                }
                echo $text;
                ?>
</div><?php 
            }
            ?>
			<?php 
            if ($page->comment_allowed) {
                ?>
				<div class="clearfix"
				     style="padding:  10px;"></div>
				<?php 
                PageCommentWeb::beginComment($id);
            }
            // pr($page);
            /* $str = '';
            			 global $template;
            			 if($page->post_gallery_id != 0 || $page->post_event_id != 0){
            
            				 if($page->post_event_id!=0){
            					 $event = new Event();
            					 $event->getByID($page->post_event_id);
            					// pr($event);
            					 $str .= '<div class="event-item"><div class="event-name">'.$event->cal_name.'</div></div>';
            					 $efi = new EfiHome();
            					 $_GET['eid'] = $page->post_event_id;
            					 $efi->eventview(1);
            				 }
            				 if($page->post_gallery_id!=0){
            					 $gal = new Gallery();
            					 $gal->getByID($page->post_gallery_id);
            					 //pr($gal);
            					 $str .= '<div class="gallery-item"><div class="gallery-name">'.$gal->gallery_name.'</div></div>';
            					 $efi = new EfiHome();
            					 $_GET['gid'] = $page->post_gallery_id;
            					 $efi->galleryview(1);
            				 }
            				 //$template->useSidebar = 1;
            				 //$template->sideBar = $str;
            			 }*/
            /*
            			 ?>
            			 <div class="fb-comments" data-href="http://developers.facebook.com/docs/plugins/comments/" data-width="100%" data-numposts="5" data-colorscheme="light"></div>
            			 <?*/
            ?>
</div></div><?php 
        }
    }