コード例 #1
0
 /**
  * Генерация имени таблицы с префиксом и алиасом
  *
  * @param string $name имя таблицы
  * @param string $alias желаемый алиас таблицы
  * @return string имя таблицы с префиксом и алиасом
  */
 public function getTable($name, $alias = '')
 {
     if (!isset($this->_table[$name])) {
         $this->_table[$name] = $this->modx->getFullTableName($name);
     }
     $table = $this->_table[$name];
     if (!empty($alias) && is_scalar($alias)) {
         $table .= " as `" . $alias . "`";
     }
     return $table;
 }
コード例 #2
0
ファイル: controller.class.php プロジェクト: bagi091/Selector
 public static function prepare(array $data = array(), \DocumentParser $modx, $_DL, \prepare_DL_Extender $_extDocLister)
 {
     if (($data['parentName'] = $_extDocLister->getStore('parentName' . $data['parent'])) === null) {
         $q = $modx->db->query("SELECT pagetitle FROM " . $modx->getFullTableName('site_content') . " WHERE id = '" . $data['parent'] . "'");
         $data['parentName'] = $modx->db->getValue($q);
         $_extDocLister->setStore('parentName' . $data['parent'], $data['parentName']);
     }
     if (($docCrumbs = $_extDocLister->getStore('currentParents' . $data['parent'])) === null) {
         $modx->documentObject['id'] = $data['id'];
         $docCrumbs = rtrim($modx->runSnippet('DLcrumbs', array('ownerTPL' => '@CODE:[+crumbs.wrap+]', 'tpl' => '@CODE: [+title+] /', 'tplCurrent' => '@CODE: [+title+] /', 'hideMain' => '1')), ' /');
         $_extDocLister->setStore('currentParents' . $data['parent'], $docCrumbs);
     }
     $html = preg_replace("/(" . preg_quote($_DL->getCFGDef('search'), "/") . ")/iu", "<b>\$0</b>", $data['pagetitle']);
     $data['text'] = "{$data['id']}. {$data['pagetitle']}";
     $data['html'] = "<div><small>{$docCrumbs}</small><br>{$data['id']}. {$html}</div>";
     return $data;
 }
コード例 #3
0
                 $answer['msg'] = $language['connector.noconfig'];
             }
         } else {
             $answer['error'] = true;
             $answer['msg'] = $language['connector.illegal'];
         }
     } else {
         $answer['error'] = true;
         $answer['msg'] = $language['connector.rights'];
     }
     break;
 case 'datatable':
 default:
     if ($action && $tvid) {
         // document exists?
         $res = $modx->db->select('*', $modx->getFullTableName('site_content'), 'id=' . $docid);
         if ($modx->db->getRecordCount($res)) {
             // document with docId editable?
             $docObj = $modx->getPageInfo($docid, 0, '*');
             if ($docObj) {
                 // get the settings for the multiTV
                 $tvSettings = $modx->getTemplateVar($tvid, '*', $docid, $docObj['published']);
                 if ($tvSettings && ($tvSettings['elements'] = '@INCLUDE' . MTV_PATH . 'multitv.customtv.php')) {
                     $multiTV = new multiTV($modx, array('type' => 'tv', 'tvDefinitions' => $tvSettings, 'tvUrl' => MTV_PATH));
                     $includeFile = $multiTV->includeFile($action, 'processor');
                     // processor available?
                     if ($includeFile) {
                         include $includeFile;
                     } else {
                         $answer['error'] = true;
                         $answer['msg'] = $language['connector.noprocessor'];
コード例 #4
0
 /**
  * build siteCache file
  * @param  DocumentParser $modx
  * @return boolean success
  */
 function buildCache($modx)
 {
     $tmpPHP = "<?php\n";
     // SETTINGS & DOCUMENT LISTINGS CACHE
     // get settings
     $sql = 'SELECT * FROM ' . $modx->getFullTableName('system_settings');
     $rs = $modx->db->query($sql);
     $limit_tmp = $modx->db->getRecordCount($rs);
     $config = array();
     $tmpPHP .= '$c=&$this->config;' . "\n";
     while (list($key, $value) = $modx->db->getRow($rs, 'num')) {
         $tmpPHP .= '$c[\'' . $key . '\']' . ' = "' . $this->escapeDoubleQuotes($value) . "\";\n";
         $config[$key] = $value;
     }
     // get aliases modx: support for alias path
     $tmpPath = '';
     $tmpPHP .= '$this->aliasListing = array();' . "\n";
     $tmpPHP .= '$a = &$this->aliasListing;' . "\n";
     $tmpPHP .= '$d = &$this->documentListing;' . "\n";
     $tmpPHP .= '$m = &$this->documentMap;' . "\n";
     $sql = 'SELECT IF(alias=\'\', id, alias) AS alias, id, contentType, parent FROM ' . $modx->getFullTableName('site_content') . ' WHERE deleted=0 ORDER BY parent, menuindex';
     $rs = $modx->db->query($sql);
     $limit_tmp = $modx->db->getRecordCount($rs);
     for ($i_tmp = 0; $i_tmp < $limit_tmp; $i_tmp++) {
         $tmp1 = $modx->db->getRow($rs);
         if ($config['friendly_urls'] == 1 && $config['use_alias_path'] == 1) {
             $tmpPath = $this->getParents($tmp1['parent']);
             $alias = (strlen($tmpPath) > 0 ? "{$tmpPath}/" : '') . $tmp1['alias'];
             $alias = $modx->db->escape($alias);
             $tmpPHP .= '$d[\'' . $alias . '\']' . " = " . $tmp1['id'] . ";\n";
         } else {
             $tmpPHP .= '$d[\'' . $modx->db->escape($tmp1['alias']) . '\']' . " = " . $tmp1['id'] . ";\n";
         }
         $tmpPHP .= '$a[' . $tmp1['id'] . ']' . " = array('id' => " . $tmp1['id'] . ", 'alias' => '" . $modx->db->escape($tmp1['alias']) . "', 'path' => '" . $modx->db->escape($tmpPath) . "', 'parent' => " . $tmp1['parent'] . ");\n";
         $tmpPHP .= '$m[]' . " = array('" . $tmp1['parent'] . "' => '" . $tmp1['id'] . "');\n";
     }
     // get content types
     $sql = 'SELECT id, contentType FROM ' . $modx->getFullTableName('site_content') . " WHERE contentType != 'text/html'";
     $rs = $modx->db->query($sql);
     $limit_tmp = $modx->db->getRecordCount($rs);
     $tmpPHP .= '$c = &$this->contentTypes;' . "\n";
     for ($i_tmp = 0; $i_tmp < $limit_tmp; $i_tmp++) {
         $tmp1 = $modx->db->getRow($rs);
         $tmpPHP .= '$c[' . $tmp1['id'] . ']' . " = '" . $tmp1['contentType'] . "';\n";
     }
     // WRITE Chunks to cache file
     $sql = 'SELECT * FROM ' . $modx->getFullTableName('site_htmlsnippets');
     $rs = $modx->db->query($sql);
     $limit_tmp = $modx->db->getRecordCount($rs);
     $tmpPHP .= '$c = &$this->chunkCache;' . "\n";
     for ($i_tmp = 0; $i_tmp < $limit_tmp; $i_tmp++) {
         $tmp1 = $modx->db->getRow($rs);
         $tmpPHP .= '$c[\'' . $modx->db->escape($tmp1['name']) . '\']' . " = '" . $this->escapeSingleQuotes($tmp1['snippet']) . "';\n";
     }
     // WRITE snippets to cache file
     $sql = 'SELECT ss.*,sm.properties as `sharedproperties` ' . 'FROM ' . $modx->getFullTableName('site_snippets') . ' ss ' . 'LEFT JOIN ' . $modx->getFullTableName('site_modules') . ' sm on sm.guid=ss.moduleguid';
     $rs = $modx->db->query($sql);
     $limit_tmp = $modx->db->getRecordCount($rs);
     $tmpPHP .= '$s = &$this->snippetCache;' . "\n";
     for ($i_tmp = 0; $i_tmp < $limit_tmp; $i_tmp++) {
         $tmp1 = $modx->db->getRow($rs);
         $tmpPHP .= '$s[\'' . $modx->db->escape($tmp1['name']) . '\']' . " = '" . $this->escapeSingleQuotes($tmp1['snippet']) . "';\n";
         // Raymond: save snippet properties to cache
         if ($tmp1['properties'] != "" || $tmp1['sharedproperties'] != "") {
             $tmpPHP .= '$s[\'' . $tmp1['name'] . 'Props\']' . " = '" . $this->escapeSingleQuotes($tmp1['properties'] . " " . $tmp1['sharedproperties']) . "';\n";
         }
         // End mod
     }
     // WRITE plugins to cache file
     $sql = 'SELECT sp.*,sm.properties as `sharedproperties`' . 'FROM ' . $modx->getFullTableName('site_plugins') . ' sp ' . 'LEFT JOIN ' . $modx->getFullTableName('site_modules') . ' sm on sm.guid=sp.moduleguid ' . 'WHERE sp.disabled=0';
     $rs = $modx->db->query($sql);
     $limit_tmp = $modx->db->getRecordCount($rs);
     $tmpPHP .= '$p = &$this->pluginCache;' . "\n";
     for ($i_tmp = 0; $i_tmp < $limit_tmp; $i_tmp++) {
         $tmp1 = $modx->db->getRow($rs);
         $tmpPHP .= '$p[\'' . $modx->db->escape($tmp1['name']) . '\']' . " = '" . $this->escapeSingleQuotes($tmp1['plugincode']) . "';\n";
         if ($tmp1['properties'] != '' || $tmp1['sharedproperties'] != '') {
             $tmpPHP .= '$p[\'' . $tmp1['name'] . 'Props\']' . " = '" . $this->escapeSingleQuotes($tmp1['properties'] . ' ' . $tmp1['sharedproperties']) . "';\n";
         }
     }
     // WRITE system event triggers
     $sql = 'SELECT sysevt.name as `evtname`, pe.pluginid, plugs.name
             FROM ' . $modx->getFullTableName('system_eventnames') . ' sysevt
             INNER JOIN ' . $modx->getFullTableName('site_plugin_events') . ' pe ON pe.evtid = sysevt.id
             INNER JOIN ' . $modx->getFullTableName('site_plugins') . ' plugs ON plugs.id = pe.pluginid
             WHERE plugs.disabled=0
             ORDER BY sysevt.name,pe.priority';
     $events = array();
     $rs = $modx->db->query($sql);
     $limit_tmp = $modx->db->getRecordCount($rs);
     $tmpPHP .= '$e = &$this->pluginEvent;' . "\n";
     for ($i = 0; $i < $limit_tmp; $i++) {
         $evt = $modx->db->getRow($rs);
         if (!$events[$evt['evtname']]) {
             $events[$evt['evtname']] = array();
         }
         $events[$evt['evtname']][] = $evt['name'];
     }
     foreach ($events as $evtname => $pluginnames) {
         $tmpPHP .= '$e[\'' . $evtname . '\'] = array(\'' . implode("','", $this->escapeSingleQuotes($pluginnames)) . "');\n";
     }
     // close and write the file
     $tmpPHP .= "\n";
     $filename = $this->cachePath . 'siteCache.idx.php';
     $somecontent = $tmpPHP;
     // invoke OnBeforeCacheUpdate event
     if ($modx) {
         $modx->invokeEvent('OnBeforeCacheUpdate');
     }
     if (!($handle = fopen($filename, 'w'))) {
         echo 'Cannot open file (', $filename, ')';
         exit;
     }
     // Write $somecontent to our opened file.
     if (fwrite($handle, $somecontent) === FALSE) {
         echo 'Cannot write main MODx cache file! Make sure the assets/cache directory is writable!';
         exit;
     }
     fclose($handle);
     // invoke OnCacheUpdate event
     if ($modx) {
         $modx->invokeEvent('OnCacheUpdate');
     }
     return true;
 }
コード例 #5
0
ファイル: tv.ajax.php プロジェクト: jgrau/MODx-CMS
/**
 * This file includes slightly modified code from the MODx core distribution.
 */
require_once '../../../manager/includes/protect.inc.php';
include_once '../../../manager/includes/config.inc.php';
include_once MODX_BASE_PATH . 'manager/includes/document.parser.class.inc.php';
include_once MODX_BASE_PATH . 'assets/modules/docmanager/classes/docmanager.class.php';
$modx = new DocumentParser();
$modx->getSettings();
$dm = new DocManager($modx);
$dm->getLang();
$dm->getTheme();
$output = '';
if (isset($_POST['tplID']) && is_numeric($_POST['tplID'])) {
    $sql = "SELECT * FROM " . $modx->getFullTableName('site_tmplvars') . " tv LEFT JOIN " . $modx->getFullTableName('site_tmplvar_templates') . " ON tv.id = " . $modx->getFullTableName('site_tmplvar_templates') . ".tmplvarid WHERE " . $modx->getFullTableName('site_tmplvar_templates') . ".templateid ='" . $_POST['tplID'] . "'";
    $rs = $modx->db->query($sql);
    $limit = $modx->db->getRecordCount($rs);
    if ($limit > 0) {
        require MODX_BASE_PATH . '/manager/includes/tmplvars.commands.inc.php';
        $output .= "<table style='position:relative' border='0' cellspacing='0' cellpadding='3' width='96%'>";
        for ($i = 0; $i < $limit; $i++) {
            $row = $modx->db->getRow($rs);
            if ($i > 0 && $i < $limit) {
                $output .= '<tr><td colspan="2"><div class="split"></div></td></tr>';
            }
            $output .= '<tr style="height: 24px;">
				<td align="left" valign="top" width="150">
					<span class=\'warning\'>' . $row['caption'] . '</span><br /><span class=\'comment\'>' . $row['description'] . '</span>
				</td>
				<td valign="top" style="position:relative">';
コード例 #6
0
ファイル: login.processor.php プロジェクト: rthrash/evolution
    if (version_compare(PHP_VERSION, '5.2', '<')) {
        setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
    } else {
        setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
    }
} else {
    $_SESSION['modx.mgr.session.cookie.lifetime'] = 0;
    // Remove the Remember Me cookie
    setcookie('modx_remember_manager', "", time() - 3600, MODX_BASE_URL);
}
$log = new logHandler();
$log->initAndWriteLog("Logged in", $modx->getLoginUserID(), $_SESSION['mgrShortname'], "58", "-", "MODx");
// invoke OnManagerLogin event
$modx->invokeEvent("OnManagerLogin", array("userid" => $internalKey, "username" => $username, "userpassword" => $givenPassword, "rememberme" => $rememberme));
// check if we should redirect user to a web page
$tbl = $modx->getFullTableName("user_settings");
$id = $modx->db->getValue("SELECT setting_value FROM {$tbl} WHERE user='******' AND setting_name='manager_login_startup'");
if (isset($id) && $id > 0) {
    $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full');
    if ($_POST['ajax'] == 1) {
        echo $header;
    } else {
        header($header);
    }
} else {
    $header = 'Location: ' . $modx->config['site_url'] . 'manager/';
    if ($_POST['ajax'] == 1) {
        echo $header;
    } else {
        header($header);
    }
コード例 #7
0
$length_eng_lang = count($_lang);
if ($manager_language != "english" && file_exists(MODX_MANAGER_PATH . "includes/lang/" . $manager_language . ".inc.php")) {
    include_once "lang/" . $manager_language . ".inc.php";
}
// include the logger
include_once "log.class.inc.php";
// include the crypto thing
include_once "crypt.class.inc.php";
// Initialize System Alert Message Queque
if (!isset($_SESSION['SystemAlertMsgQueque'])) {
    $_SESSION['SystemAlertMsgQueque'] = array();
}
$SystemAlertMsgQueque =& $_SESSION['SystemAlertMsgQueque'];
// initiate the content manager class
// for backward compatibility
$tbl_user_settings = $modx->getFullTableName('user_settings');
$tbl_manager_users = $modx->getFullTableName('manager_users');
$tbl_user_attributes = $modx->getFullTableName('user_attributes');
$username = $modx->db->escape($_REQUEST['username']);
$givenPassword = $modx->db->escape($_REQUEST['password']);
$captcha_code = $_REQUEST['captcha_code'];
$rememberme = $_REQUEST['rememberme'];
$failed_allowed = $modx->config["failed_login_attempts"];
// invoke OnBeforeManagerLogin event
$modx->invokeEvent("OnBeforeManagerLogin", array("username" => $username, "userpassword" => $givenPassword, "rememberme" => $rememberme));
$fields = 'mu.*, ua.*';
$from = "{$tbl_manager_users} AS mu, {$tbl_user_attributes} AS ua";
$where = "BINARY mu.username='******' and ua.internalKey=mu.id";
$rs = $modx->db->select($fields, $from, $where);
$limit = $modx->db->getRecordCount($rs);
if ($limit == 0 || $limit > 1) {
コード例 #8
0
    /**
     * build siteCache file
     * @param  DocumentParser $modx
     * @return boolean success
     */
    function buildCache($modx)
    {
        $tmpPHP = "<?php\n";
        // SETTINGS & DOCUMENT LISTINGS CACHE
        // get settings
        $rs = $modx->db->select('*', $modx->getFullTableName('system_settings'));
        $config = array();
        $tmpPHP .= '$c=&$this->config;' . "\n";
        while (list($key, $value) = $modx->db->getRow($rs, 'num')) {
            $tmpPHP .= '$c[\'' . $this->escapeSingleQuotes($key) . '\']' . ' = "' . $this->escapeDoubleQuotes($value) . "\";\n";
            $config[$key] = $value;
        }
        // get aliases modx: support for alias path
        $tmpPath = '';
        $tmpPHP .= '$this->aliasListing = array();' . "\n";
        $tmpPHP .= '$a = &$this->aliasListing;' . "\n";
        $tmpPHP .= '$d = &$this->documentListing;' . "\n";
        $tmpPHP .= '$m = &$this->documentMap;' . "\n";
        $rs = $modx->db->select('IF(alias=\'\', id, alias) AS alias, id, parent, isfolder', $modx->getFullTableName('site_content'), 'deleted=0', 'parent, menuindex');
        while ($tmp1 = $modx->db->getRow($rs)) {
            if ($config['friendly_urls'] == 1 && $config['use_alias_path'] == 1) {
                $tmpPath = $this->getParents($tmp1['parent']);
                $alias = (strlen($tmpPath) > 0 ? "{$tmpPath}/" : '') . $tmp1['alias'];
                $tmpPHP .= '$d[\'' . $this->escapeSingleQuotes($alias) . '\']' . " = " . $tmp1['id'] . ";\n";
            } else {
                $tmpPHP .= '$d[\'' . $this->escapeSingleQuotes($tmp1['alias']) . '\']' . " = " . $tmp1['id'] . ";\n";
            }
            $tmpPHP .= '$a[' . $tmp1['id'] . ']' . " = array('id' => " . $tmp1['id'] . ", 'alias' => '" . $this->escapeSingleQuotes($tmp1['alias']) . "', 'path' => '" . $this->escapeSingleQuotes($tmpPath) . "', 'parent' => " . $tmp1['parent'] . ", 'isfolder' => " . $tmp1['isfolder'] . ");\n";
            $tmpPHP .= '$m[]' . " = array('" . $tmp1['parent'] . "' => '" . $tmp1['id'] . "');\n";
        }
        // get content types
        $rs = $modx->db->select('id, contentType', $modx->getFullTableName('site_content'), "contentType != 'text/html'");
        $tmpPHP .= '$c = &$this->contentTypes;' . "\n";
        while ($tmp1 = $modx->db->getRow($rs)) {
            $tmpPHP .= '$c[' . $tmp1['id'] . ']' . " = '" . $this->escapeSingleQuotes($tmp1['contentType']) . "';\n";
        }
        // WRITE Chunks to cache file
        $rs = $modx->db->select('*', $modx->getFullTableName('site_htmlsnippets'));
        $tmpPHP .= '$c = &$this->chunkCache;' . "\n";
        while ($tmp1 = $modx->db->getRow($rs)) {
            $tmpPHP .= '$c[\'' . $this->escapeSingleQuotes($tmp1['name']) . '\']' . " = '" . $this->escapeSingleQuotes($tmp1['snippet']) . "';\n";
        }
        // WRITE snippets to cache file
        $rs = $modx->db->select('ss.*, sm.properties as sharedproperties', $modx->getFullTableName('site_snippets') . ' ss
				LEFT JOIN ' . $modx->getFullTableName('site_modules') . ' sm on sm.guid=ss.moduleguid');
        $tmpPHP .= '$s = &$this->snippetCache;' . "\n";
        while ($tmp1 = $modx->db->getRow($rs)) {
            $tmpPHP .= '$s[\'' . $this->escapeSingleQuotes($tmp1['name']) . '\']' . " = '" . $this->escapeSingleQuotes($tmp1['snippet']) . "';\n";
            if ($tmp1['properties'] != '' || $tmp1['sharedproperties'] != '') {
                $tmpPHP .= '$s[\'' . $this->escapeSingleQuotes($tmp1['name']) . 'Props\']' . " = '" . $this->escapeSingleQuotes($tmp1['properties'] . " " . $tmp1['sharedproperties']) . "';\n";
            }
        }
        // WRITE plugins to cache file
        $rs = $modx->db->select('sp.*, sm.properties as sharedproperties', $modx->getFullTableName('site_plugins') . ' sp
				LEFT JOIN ' . $modx->getFullTableName('site_modules') . ' sm on sm.guid=sp.moduleguid', 'sp.disabled=0');
        $tmpPHP .= '$p = &$this->pluginCache;' . "\n";
        while ($tmp1 = $modx->db->getRow($rs)) {
            $tmpPHP .= '$p[\'' . $this->escapeSingleQuotes($tmp1['name']) . '\']' . " = '" . $this->escapeSingleQuotes($tmp1['plugincode']) . "';\n";
            if ($tmp1['properties'] != '' || $tmp1['sharedproperties'] != '') {
                $tmpPHP .= '$p[\'' . $this->escapeSingleQuotes($tmp1['name']) . 'Props\']' . " = '" . $this->escapeSingleQuotes($tmp1['properties'] . ' ' . $tmp1['sharedproperties']) . "';\n";
            }
        }
        // WRITE system event triggers
        $events = array();
        $rs = $modx->db->select('sysevt.name as evtname, pe.pluginid, plugs.name', $modx->getFullTableName('system_eventnames') . ' sysevt
				INNER JOIN ' . $modx->getFullTableName('site_plugin_events') . ' pe ON pe.evtid = sysevt.id
				INNER JOIN ' . $modx->getFullTableName('site_plugins') . ' plugs ON plugs.id = pe.pluginid', 'plugs.disabled=0', 'sysevt.name,pe.priority');
        $tmpPHP .= '$e = &$this->pluginEvent;' . "\n";
        while ($evt = $modx->db->getRow($rs)) {
            if (!$events[$evt['evtname']]) {
                $events[$evt['evtname']] = array();
            }
            $events[$evt['evtname']][] = $evt['name'];
        }
        foreach ($events as $evtname => $pluginnames) {
            $tmpPHP .= '$e[\'' . $this->escapeSingleQuotes($evtname) . '\'] = array(\'' . implode("','", $this->escapeSingleQuotes($pluginnames)) . "');\n";
        }
        // close and write the file
        $tmpPHP .= "\n";
        $filename = $this->cachePath . 'siteCache.idx.php';
        $somecontent = $tmpPHP;
        // invoke OnBeforeCacheUpdate event
        if ($modx) {
            $modx->invokeEvent('OnBeforeCacheUpdate');
        }
        if (!($handle = fopen($filename, 'w'))) {
            echo 'Cannot open file (', $filename, ')';
            exit;
        }
        if (!is_file($this->cachePath . '/.htaccess')) {
            file_put_contents($this->cachePath . '/.htaccess', "order deny,allow\ndeny from all\n");
        }
        // Write $somecontent to our opened file.
        if (fwrite($handle, $somecontent) === FALSE) {
            echo 'Cannot write main MODX cache file! Make sure the assets/cache directory is writable!';
            exit;
        }
        fclose($handle);
        // invoke OnCacheUpdate event
        if ($modx) {
            $modx->invokeEvent('OnCacheUpdate');
        }
        return true;
    }
コード例 #9
0
$modx->getSettings();
$txt = $_POST[txt];
// Приводим сниппеты к единному знаменателю
$txt = str_replace('!]', ']]', $txt);
$txt = str_replace('[!', '[[', $txt);
//Сниппеты
if (strpos($txt, '[[') > -1) {
    $matches = array();
    preg_match_all('~\\[\\[(.*?)\\]\\]~s', $txt, $matches);
    $snippets = array();
    foreach ($matches[1] as $snip) {
        $snipName = explode('?', $snip);
        $snippets[] = '"' . $snipName[0] . '"';
    }
    $snippets = array_unique($snippets);
    $tblSnip = $modx->getFullTableName('site_snippets');
    $sql = 'select `id`,`name` from ' . $tblSnip . ' where name in (' . implode(',', $snippets) . ') order by `name` asc';
    $res = $modx->db->query($sql);
    $out .= '<optgroup label=\'Сниппеты\'>';
    while ($row = $modx->db->getRow($res)) {
        echo 'index.php?id=".$row[id]."&a=22';
    }
}
// Чанки
if (strpos($txt, '{{') > -1) {
    $matches = array();
    preg_match_all('~\\{\\{(.*?)\\}\\}~s', $txt, $matches);
    $chunks = array();
    foreach ($matches[1] as $chu) {
        $chunks[] = '"' . $chu . '"';
    }
コード例 #10
0
ファイル: tv.ajax.php プロジェクト: foxcoonn/modx.evo.custom
/**
 * This file includes slightly modified code from the MODX core distribution.
 */
include_once "../../cache/siteManager.php";
require_once '../../../' . MGR_DIR . '/includes/protect.inc.php';
include_once '../../../' . MGR_DIR . '/includes/config.inc.php';
include_once MODX_MANAGER_PATH . 'includes/document.parser.class.inc.php';
include_once MODX_BASE_PATH . 'assets/modules/docmanager/classes/docmanager.class.php';
$modx = new DocumentParser();
$modx->getSettings();
$dm = new DocManager($modx);
$dm->getLang();
$dm->getTheme();
$output = '';
if (isset($_POST['tplID']) && is_numeric($_POST['tplID'])) {
    $rs = $modx->db->select('*', $modx->getFullTableName('site_tmplvars') . " tv\n\t\t\tLEFT JOIN " . $modx->getFullTableName('site_tmplvar_templates') . " AS tvt ON tv.id = tvt.tmplvarid", "tvt.templateid ='{$_POST['tplID']}'");
    $limit = $modx->db->getRecordCount($rs);
    if ($limit > 0) {
        require MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php';
        $output .= "<table style='position:relative' border='0' cellspacing='0' cellpadding='3' width='96%'>";
        $i = 0;
        while ($row = $modx->db->getRow($rs)) {
            if ($i++ > 0) {
                $output .= '<tr><td colspan="2"><div class="split"></div></td></tr>';
            }
            $output .= '<tr style="height: 24px;">
				<td align="left" valign="top" width="200">
					<span class=\'warning\'><input type=\'checkbox\' name=\'update_tv_' . $row['id'] . '\' id=\'cb_update_tv_' . $row['id'] . '\' value=\'yes\' />&nbsp;' . $row['caption'] . '</span><br /><span class=\'comment\'>' . $row['description'] . '</span>
				</td>
				<td valign="top" style="position:relative">';
            $base_url = str_replace("assets/modules/docmanager/", "", MODX_BASE_URL);
コード例 #11
0
ファイル: action.php プロジェクト: KiPa187/EvoGallery
<?php

$path_to_modx_config = '../../../manager/includes/config.inc.php';
include_once $path_to_modx_config;
if (isset($_REQUEST[$site_sessionname])) {
    session_id($_REQUEST[$site_sessionname]);
}
//without this always generate new session
startCMSSession();
include_once "../../../manager/includes/document.parser.class.inc.php";
$modx = new DocumentParser();
$modx->loadExtension("ManagerAPI");
$modx->getSettings();
// get module data
$rs = $modx->db->select('properties', $modx->getFullTableName('site_modules'), 'id = ' . intval($_REQUEST['id']), '', '1');
if ($modx->db->getRecordCount($rs) > 0) {
    $properties = $modx->db->getValue($rs);
}
// load module configuration
$parameters = array();
if (!empty($properties)) {
    $tmpParams = explode("&", $properties);
    for ($x = 0; $x < count($tmpParams); $x++) {
        $pTmp = explode("=", $tmpParams[$x]);
        $pvTmp = explode(";", trim($pTmp[1]));
        if ($pvTmp[1] == 'list' && $pvTmp[3] != "") {
            $parameters[$pTmp[0]] = $pvTmp[3];
        } else {
            if ($pvTmp[1] != 'list' && $pvTmp[2] != "") {
                $parameters[$pTmp[0]] = $pvTmp[2];
            }
コード例 #12
0
$dbase = "";
$table_prefix = "";
$base_url = "";
$base_path = "";
$dir = dirname(__FILE__);
if (isset($dir) && file_exists($dir . '/manager/includes/protect.inc.php')) {
    require_once $dir . '/manager/includes/protect.inc.php';
    if (!($rt = @(include_once $dir . "/manager/includes/config.inc.php"))) {
        return;
    }
} else {
    return;
}
define('MODX_API_MODE', true);
require_once MODX_BASE_PATH . 'manager/includes/document.parser.class.inc.php';
$modx = new DocumentParser();
$modx->db->connect();
$modx->getSettings();
startCMSSession();
$mode = isset($_GET['mode']) ? $_GET['mode'] : 'country';
$r = array();
switch ($mode) {
    case 'country':
        $r = $modx->db->makeArray($modx->db->select('id, title', $modx->getFullTableName('country'), '', 'title ASC'));
        break;
    case 'city':
        $country_id = isset($_GET['country_id']) ? intval($_GET['country_id']) : 0;
        $r = $modx->db->makeArray($modx->db->select('id, title', $modx->getFullTableName('city'), 'country_id = ' . $country_id, 'title ASC'));
        break;
}
return json_encode($r);