Jump to content

Просмотр документа как в ВК


Recommended Posts

Небольшое дополнение для модуля "Документы"

Идём в system/modules/doc.php, ищем там следующий код:


//################### Скачивание документа с сервера ###################//
		case "download";
			NoAjaxQuery();
			
			$did = intval($_GET['did']);
			
			$row = $db->super_query("SELECT duser_id, ddownload_name, dname FROM `".PREFIX."_doc` WHERE did = '{$did}'");
			
			if($row){
								
				$filename = str_replace(array('/', '\\', 'php', 'tpl'), '', $row['ddownload_name']);
				define('FILE_DIR', "uploads/doc/{$row['duser_id']}/");
				
				include ENGINE_DIR . '/classes/download.php';
				
				$config['files_max_speed'] = 0;
				
				$format = end(explode('.', $filename));
				
				$row['dname'] = str_replace('.'.$format, '', $row['dname']).'.'.$format;

				if(file_exists(FILE_DIR.$filename) AND $filename){
				
					$file = new download(FILE_DIR.$filename, $row['dname'], 1, $config['files_max_speed']);
					$file->download_file();
				
				}
			
			} else
				header("Location: /index.php");
			
			exit;
		break;

И полностью заменяем его на:

 

//################### Скачивание документа с сервера ###################//
		case "download";
			//NoAjaxQuery();
			
			$did = intval($_GET['did']);
			
			$row = $db->super_query("SELECT duser_id, ddownload_name, dname FROM `".PREFIX."_doc` WHERE did = '{$did}'");
			
			$filenam = str_replace(array('/', '\\', 'php', 'tpl'), '', $row['ddownload_name']);
			$type = end(explode(".", $filenam)); // формат файла
			if($row){
			if($type == "jpg" or $type == "png" or $type == "jpeg" or $type == "gif") {
			
			    
			    
			    echo <<<HTML
                
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>
<link rel="shortcut icon" href="http://senapse.ru/fav.png">
<link media="screen" href="/templates/Default/style/style.css" type="text/css" rel="stylesheet">
<meta name="robots" content="noindex,nofollow"><title>{$row["dname"]}</title>
<style>
html, body {
  padding: 0px;
  margin: 0px;
  height: 100%;
  border: none;
}
.iframe {
  border: none;
}
.docs_panel_wrap {
  height: 45px;
}
.docs_panel {
  background: #F1F1F1;
  position: fixed;
  width: 100%;
  height: 45px;
  -webkit-box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
  -moz-box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
  box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
}
.can_zoom {
  max-width: 100%;
  cursor: -webkit-zoom-in;
  cursor: -moz-zoom-in;
  cursor: -zoom-in;
}
.can_zoom_out {
  min-width: 100%;
  cursor: -webkit-zoom-out;
  cursor: -moz-zoom-out;
  cursor: -zoom-out;
}
</style>
<script>
function saveDoc() {
  var src = '/index.php?go=doc&act=download&did={$did}&dl=1';
 
  location.replace(src);
  return false;
}
function imgZoom(obj) {
  if (obj.className == 'can_zoom') {
    obj.className = 'can_zoom_out';
  } else {
    obj.className = 'can_zoom';
    window.scroll(0, 0);
  }
}
function onload() {
  var iframe = document.getElementById('iframe');
  if (iframe) {
    if(window.innerWidth) {
      var h = window.innerHeight;
    } else {
      var h = document.body.clientHeight;
    }
    iframe.style.height = (h - 45 - 2) +'px';
  }

}
</script>
</head>
<body onkeydown="if (event.keyCode == 83 && (event.ctrlKey || event.metaKey)) return saveDoc(event);" onload="onload();">
<noindex>
<div class="docs_panel_wrap">
  <div class="docs_panel">
    <div style="padding: 10px 20px;">
      <div class="button_div fl_r" style="  margin-top: -3px;"><button  onclick="return saveDoc();">Сохранить документ на диск</button></div>
      <div class="fl_r" style="padding: 6px 10px 0px; color: #888888;"></div>
      <a style="padding-top: 6px; display: block;" class="fl_l" onclick="return saveDoc();"><b>{$row["dname"]}</b></a> 
    </div>
  </div>
</div><center><img src="/uploads/doc/{$row["duser_id"]}/{$row["ddownload_name"]}" class="can_zoom" onclick="imgZoom(this);"></center>
</noindex>

</body></html>
HTML;
			
			    
				if($_GET["dl"] == 1){				
				$filename = str_replace(array('/', '\\', 'php', 'tpl'), '', $row['ddownload_name']);
				define('FILE_DIR', "uploads/doc/{$row['duser_id']}/");
				
				include ENGINE_DIR . '/classes/download.php';
				
				$config['files_max_speed'] = 0;
				
				$format = end(explode('.', $filename));
				
				$row['dname'] = str_replace('.'.$format, '', $row['dname']).'.'.$format;

				if(file_exists(FILE_DIR.$filename) AND $filename){
				
					$file = new download(FILE_DIR.$filename, $row['dname'], 1, $config['files_max_speed']);
					$file->download_file();
				
				}
				}
			
			} else {
			    $filename = str_replace(array('/', '\\', 'php', 'tpl'), '', $row['ddownload_name']);
				define('FILE_DIR', "uploads/doc/{$row['duser_id']}/");
				
				include ENGINE_DIR . '/classes/download.php';
				
				$config['files_max_speed'] = 0;
				
				$format = end(explode('.', $filename));
				
				$row['dname'] = str_replace('.'.$format, '', $row['dname']).'.'.$format;

				if(file_exists(FILE_DIR.$filename) AND $filename){
				
					$file = new download(FILE_DIR.$filename, $row['dname'], 1, $config['files_max_speed']);
					$file->download_file();
				
				}
			}
			} else {
				header("Location: /index.php");
			}
			exit;
			
		break; 

 

 

 

f1d285171a290175d5df.png

 

bdea4ebfeaddd10bfef6.png

 


Автор Я

Edited by kolyan22region
  • Upvote 5
Link to comment
Share on other sites

Опять же.. что за оформление без скрина?Это так же как продавать что то на рынке, не имея его при себе...А говоря, что после покупки вы увидите что купили..

Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...