321 lines
9.8 KiB
PHP
321 lines
9.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* AVE.cms - Модуль Gmap
|
|
*
|
|
* @package AVE.cms
|
|
* @subpackage module_gmap
|
|
* @filesource
|
|
*/
|
|
|
|
if(!defined('BASE_DIR')) exit;
|
|
|
|
if (defined('ACP'))
|
|
{
|
|
$modul['ModuleName'] = 'GMap';
|
|
$modul['ModuleSysName'] = 'gmap';
|
|
$modul['ModuleVersion'] = '1.0.9b';
|
|
$modul['ModuleDescription'] = 'Gmap<br/>Для того, чтобы осуществить просмотр карты, необходимо разместить системный тег <strong>[mod_gmap:XXX]</strong> в теле какого-либо документа';
|
|
$modul['ModuleAutor'] = 'OcPh | Project Manager Duncan | Upgrade module 2016-2017 Repellent';
|
|
$modul['ModuleCopyright'] = '© 2016-2017 AVE.cms Team';
|
|
$modul['ModuleIsFunction'] = 1;
|
|
$modul['ModuleAdminEdit'] = 1;
|
|
$modul['ModuleFunction'] = 'mod_gmap';
|
|
$modul['ModuleTag'] = '[mod_gmap:XXX]';
|
|
$modul['ModuleTagLink'] = null;
|
|
$modul['ModuleAveTag'] = '#\\\[mod_gmap:([\\\d-]+)]#';
|
|
$modul['ModulePHPTag'] = "<?php mod_gmap(''$1''); ?>";
|
|
}
|
|
|
|
/**
|
|
* Функция вывода карты
|
|
*
|
|
* @param string $gmap_id идентификатор карты
|
|
*/
|
|
function mod_gmap($gmap_id)
|
|
{
|
|
global $AVE_Template;
|
|
|
|
require_once(BASE_DIR . '/modules/gmap/class.gmap.php');
|
|
$gmap = new Gmap;
|
|
|
|
$tpl_dir = BASE_DIR . '/modules/gmap/templates/';
|
|
$lang_file = BASE_DIR . '/modules/gmap/lang/' . $_SESSION['user_language'] . '.txt';
|
|
|
|
$AVE_Template->config_load($lang_file);
|
|
|
|
$gmap->gmapShow($tpl_dir, $gmap_id);
|
|
}
|
|
|
|
//=======================================================
|
|
// Действия в админ-панели
|
|
//=======================================================
|
|
if (defined('ACP') && !empty($_REQUEST['moduleaction']))
|
|
{
|
|
require_once(BASE_DIR . '/modules/gmap/class.gmap.php');
|
|
$gmap = new Gmap;
|
|
|
|
$tpl_dir = BASE_DIR . '/modules/gmap/templates/';
|
|
$lang_file = BASE_DIR . '/modules/gmap/lang/' . $_SESSION['admin_language'] . '.txt';
|
|
|
|
$AVE_Template->config_load($lang_file, 'admin');
|
|
|
|
switch($_REQUEST['moduleaction'])
|
|
{
|
|
case '1': // Просмотр списка карт
|
|
$gmap->gmapListShow($tpl_dir);
|
|
break;
|
|
|
|
case 'show': // Просмотр маркеров карты
|
|
$_SESSION['use_editor'] = get_settings('use_editor');
|
|
$gmap->gmapMarkersShow($tpl_dir, intval($_REQUEST['id']));
|
|
break;
|
|
|
|
case 'showcategory': // Просмотр категорий
|
|
$gmap->gmapCategoryShow($tpl_dir);
|
|
break;
|
|
case 'editmarker': // Редактирование маркера
|
|
$gmap->gmapMarkerEdit($tpl_dir, intval($_REQUEST['id']));
|
|
break;
|
|
|
|
case 'saveeditmarker': // Сохранение отредактированного маркера
|
|
$gmap->gmapMarkerEditSave(intval($_REQUEST['id']));
|
|
break;
|
|
|
|
case 'addnewcategory': // Добавление новой категории
|
|
$gmap->gmapCategoryNewAdd(intval($_REQUEST['id']));
|
|
break;
|
|
|
|
case 'gcatdel': // Удаление категории
|
|
$gmap->gmapCategoryDel(intval($_REQUEST['id']));
|
|
break;
|
|
|
|
case 'addmarker': // Добавление маркера
|
|
$gmap->gmapMarkersAdd(intval($_REQUEST['id']));
|
|
break;
|
|
case 'savemarker': // Сохранение маркера
|
|
$gmap->gmapMarkerSave(intval($_REQUEST['id']));
|
|
break;
|
|
case 'getmarker': // Получение описания маркера
|
|
$gmap->gmapMarkersGet(intval($_REQUEST['id']));
|
|
break;
|
|
case 'delmarker': // Удаление маркера
|
|
$gmap->gmapMarkersDel(intval($_REQUEST['id']));
|
|
break;
|
|
|
|
case 'new': // Создать новую карту
|
|
$gmap->gmapNew();
|
|
break;
|
|
|
|
case 'delgmap': // Удаление карты
|
|
$gmap->gmapDelete(intval($_REQUEST['id']));
|
|
break;
|
|
|
|
case 'editgmap': // Редактирование карты
|
|
$gmap->gmapEdit($tpl_dir, intval($_REQUEST['id']));
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
// подключаем файловый менеджер проверяем , если файла нет - создаем, если есть ничего не делаем
|
|
$filename = BASE_DIR . '/lib/redactor/elfinder/php/connector_module_gmap.php';
|
|
if (!file_exists($filename)) {
|
|
$gmfmen = '<?php
|
|
error_reporting(E_ALL); // Set E_ALL for debuging
|
|
if (function_exists("date_default_timezone_set")) {
|
|
date_default_timezone_set("Europe/Moscow");
|
|
}
|
|
include_once dirname(__FILE__).DIRECTORY_SEPARATOR."elFinderConnector.class.php";
|
|
include_once dirname(__FILE__).DIRECTORY_SEPARATOR."elFinder.class.php";
|
|
include_once dirname(__FILE__).DIRECTORY_SEPARATOR."elFinderVolumeDriver.class.php";
|
|
include_once dirname(__FILE__).DIRECTORY_SEPARATOR."elFinderVolumeLocalFileSystem.class.php";
|
|
include_once dirname(__FILE__).DIRECTORY_SEPARATOR."elFinderVolumeMySQL.class.php";
|
|
include_once "../../../../inc/config.php";
|
|
include_once "../../../../inc/config.inc.php";
|
|
function debug($o) {
|
|
echo "<pre>";
|
|
print_r($o);
|
|
}
|
|
function logger($cmd, $voumes, $result) {
|
|
$log = $cmd.": [".date("d.m H:s")."] ".$voumes[0]->id()." ";
|
|
|
|
if (isset($voumes[1])) {
|
|
$log .= $voumes[1]->id()." ";
|
|
}
|
|
switch ($cmd) {
|
|
case "mkdir":
|
|
case "mkfile":
|
|
case "upload":
|
|
$log .= $result["added"][0]["name"];
|
|
break;
|
|
case "rename":
|
|
$log .= "from ".$result["removedDetails"][0]["name"]." to ".$result["added"][0]["name"];
|
|
break;
|
|
case "duplicate":
|
|
$log .= "src: ".$result["src"]["name"]." copy: ".$result["added"][0]["name"];
|
|
break;
|
|
case "rm":
|
|
$log .= $result["removedDetails"][0]["name"];
|
|
break;
|
|
default:
|
|
$log = "";
|
|
}
|
|
if ($log && is_dir("../../../../cache/redactor") || @mkdir("../../../../cache/redactor")) {
|
|
$fp = fopen("../../../../cache/redactor/log.txt", "a");
|
|
if ($fp) {
|
|
fwrite($fp, $log."\n");
|
|
fclose($fp);
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
class elFinderSimpleLogger {
|
|
public function write($cmd, $voumes, $result) {
|
|
$log = $cmd.": [".date("d.m H:s")."] ".$voumes[0]->id()." ";
|
|
|
|
if (isset($voumes[1])) {
|
|
$log .= $voumes[1]->id()." ";
|
|
}
|
|
switch ($cmd) {
|
|
case "mkdir":
|
|
case "mkfile":
|
|
case "upload":
|
|
case "paste":
|
|
$log .= $result["added"][0]["name"];
|
|
break;
|
|
case "rename":
|
|
$log .= "from ".$result["removedDetails"][0]["name"]." to ".$result["added"][0]["name"];
|
|
break;
|
|
case "duplicate":
|
|
$log .= "src: ".$result["src"]["name"]." copy: ".$result["added"][0]["name"];
|
|
break;
|
|
case "rm":
|
|
$log .= $result["removedDetails"][0]["name"];
|
|
break;
|
|
default:
|
|
$log = "";
|
|
}
|
|
if ($log && is_dir("../../../../cache/redactor") || @mkdir("../../../../cache/redactor")) {
|
|
$fp = fopen("../../../../cache/redactor/log.txt", "a");
|
|
if ($fp) {
|
|
fwrite($fp, $log."\n");
|
|
fclose($fp);
|
|
}
|
|
}
|
|
return $result;
|
|
}
|
|
} // END class
|
|
function access($attr, $path, $data, $volume) {
|
|
return strpos(basename($path), ".") === 0
|
|
? !($attr == "read" || $attr == "write")
|
|
: $attr == "read" || $attr == "write";
|
|
}
|
|
class elFinderTestACL {
|
|
public function fsAccess($attr, $path, $data, $volume) {
|
|
|
|
if ($volume->name() == "localfilesystem") {
|
|
return strpos(basename($path), ".") === 0
|
|
? !($attr == "read" || $attr == "write")
|
|
: $attr == "read" || $attr == "write";
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
$acl = new elFinderTestACL();
|
|
function validName($name) {
|
|
return strpos($name, ".") !== 0;
|
|
}
|
|
$opts = array(
|
|
"locale" => "en_US.UTF-8",
|
|
"bind" => array(
|
|
"mkdir mkfile rename duplicate upload rm paste" => array(new elFinderSimpleLogger(), "write"),
|
|
),
|
|
"debug" => true,
|
|
"roots" => array(
|
|
array(
|
|
// "id" => "x5",
|
|
"driver" => "LocalFileSystem", // driver for accessing file system (REQUIRED)
|
|
"path" => "../../../../".UPLOAD_DIR, // path to files (REQUIRED)
|
|
"URL" => "/".UPLOAD_DIR."/", // URL to files (REQUIRED)
|
|
"alias" => UPLOAD_DIR,
|
|
"disabled" => array(),
|
|
"acceptedName" => "validName",
|
|
"uploadAllow" => array("all"),
|
|
"uploadDeny" => array("all"),
|
|
"uploadOrder" => "deny,allow",
|
|
"uploadOverwrite" => false,
|
|
"uploadMaxSize" => "128m",
|
|
"copyOverwrite" => false,
|
|
"copyJoin" => true,
|
|
"mimeDetect" => "internal",
|
|
"tmbCrop" => false,
|
|
"imgLib" => "gd",
|
|
"utf8fix" => true,
|
|
"attributes" => array(
|
|
array(
|
|
"pattern" => "/^\/\./",
|
|
"read" => false,
|
|
"write" => false,
|
|
"hidden" => true,
|
|
"locked" => true
|
|
),
|
|
array(
|
|
"pattern" => "/.tmb/",
|
|
"read" => false,
|
|
"write" => false,
|
|
"hidden" => true,
|
|
"locked" => false
|
|
),
|
|
array(
|
|
"pattern" => "/\.php$/",
|
|
"read" => false,
|
|
"write" => false,
|
|
"hidden" => true,
|
|
"locked" => false
|
|
),
|
|
array(
|
|
"pattern" => "/.quarantine/",
|
|
"read" => false,
|
|
"write" => false,
|
|
"hidden" => true,
|
|
"locked" => false
|
|
),
|
|
array(
|
|
"pattern" => "/\.htaccess$/",
|
|
"write" => false,
|
|
"locked" => false,
|
|
"hidden" => true
|
|
),
|
|
array(
|
|
"pattern" => "/.uploader/",
|
|
"read" => false,
|
|
"write" => false,
|
|
"hidden" => true,
|
|
"locked" => false
|
|
),
|
|
array(
|
|
"pattern" => "/.temp/",
|
|
"read" => false,
|
|
"write" => false,
|
|
"hidden" => true,
|
|
"locked" => false
|
|
)
|
|
),
|
|
)
|
|
)
|
|
);
|
|
header("Access-Control-Allow-Origin: *");
|
|
$connector = new elFinderConnector(new elFinder($opts), true);
|
|
$connector->run();
|
|
?>';
|
|
|
|
$gfo = fopen(BASE_DIR . "/lib/redactor/elfinder/php/connector_module_gmap.php", "w");
|
|
flock($gfo,2);
|
|
fwrite($gfo, $gmfmen);
|
|
flock($gfo,3);
|
|
fclose($gfo);
|
|
chmod(BASE_DIR . "/lib/redactor/elfinder/php/connector_module_gmap.php", 0755);
|
|
}
|
|
|
|
?>
|