示例#1
1
function throwErrorPage($code)
{
    if ($code == "404") {
        $header = $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found';
    } else {
        if ($code == "403") {
            $header = $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden';
        } else {
            $header = $_SERVER['SERVER_PROTOCOL'] . ' ' . $code;
        }
    }
    header($header);
    $errorPage = sConfig()->getVar('CONFIG/ERRORPAGES/ERROR_' . $code);
    if ($errorPage && $errorPage != '') {
        $request_path_string = getRequestPathString(explode('/', 'page' . $errorPage));
        $request_path = getRequestPathArray($request_path_string);
        $psite = $request_path[1];
        if ((int) $psite > 0) {
            $sinfo = sSites()->get($psite);
            $siteID = (int) $psite;
        } else {
            $sinfo = sSites()->getByPName($psite);
            $siteID = $sinfo['ID'];
        }
        $pageMgr = new PageMgr($siteID);
        $pageID = $pageMgr->getPageIdByPname($request_path[count($request_path) - 1]);
        $page = $pageMgr->getPage($pageID);
        $pageInfo = $page->get();
        $version = $page->getLatestVersion();
        renderPage($page, $version, $pageInfo, $pageMgr, $sinfo);
    } else {
        echo $header;
    }
    die;
}
示例#2
0
 /**
  * Gets a specific Page instance
  *
  * @param int $pageId Page Id
  * @param int $version (optional) Page version
  * @return Page|false New instance of Page object or FALSE if an error has occured
  */
 public function getPage($pageId, $version = 0)
 {
     if (sSites()->siteExists($this->_site) == false) {
         return false;
     }
     if ($this->permissions->checkInternal($this->_uid, $pageId, "RREAD")) {
         try {
             return new Page($this->_site, $pageId, $version);
         } catch (Exception $e) {
             return false;
         }
     } else {
         return false;
     }
 }
示例#3
0
 /**
  * Removes the specified Template
  *
  * @param int $templateId Template Id
  *
  * @return array Array with all elements which were successfully deleted
  */
 function remove($templateId)
 {
     $templateId = $origTemplateId = (int) $templateId;
     $rootNode = $this->tree->getRoot();
     if ($templateId == $rootNode) {
         return array();
     }
     // Get all nodes
     $successNodes = array();
     $allNodes = $this->tree->get($templateId, 1000);
     foreach ($allNodes as $allNodesItem) {
         $templateId = (int) $allNodesItem['ID'];
         if (sUsergroups()->permissions->check($this->_uid, 'RTEMPLATES') && $this->permissions->checkInternal($this->_uid, $templateId, "RDELETE")) {
             // Remove template
             $templateFile = $this->getFullPath($templateId);
             $sql = "UPDATE `yg_mailing_properties` SET TEMPLATEID = 0 WHERE TEMPLATEID = ?;";
             sYDB()->Execute($sql, $templateId);
             $sites = sSites()->getList();
             foreach ($sites as $curr_site) {
                 $sql = "UPDATE `yg_site_" . (int) $curr_site['ID'] . "_properties` SET TEMPLATEID = 0 WHERE TEMPLATEID = ?;";
                 sYDB()->Execute($sql, $templateId);
             }
             $sql = "UPDATE `yg_site` SET TEMPLATEROOT = 0 WHERE TEMPLATEROOT = ?;";
             sYDB()->Execute($sql, $templateId);
             $sql = "UPDATE `yg_site` SET DEFAULTTEMPLATE = 0 WHERE DEFAULTTEMPLATE = ?;";
             sYDB()->Execute($sql, $templateId);
             $sql = "UPDATE `yg_mailing_settings` SET TEMPLATEROOT = 0 WHERE TEMPLATEROOT = ?;";
             sYDB()->Execute($sql, $templateId);
             $sql = "UPDATE `yg_mailing_settings` SET DEFAULTTEMPLATE = 0 WHERE DEFAULTTEMPLATE = ?;";
             sYDB()->Execute($sql, $templateId);
             $sql = "DELETE FROM `yg_templates_properties` WHERE OBJECTID = ?;";
             sYDB()->Execute($sql, $templateId);
             $sql = "DELETE FROM `yg_templates_contentareas` WHERE TEMPLATE = ?;";
             sYDB()->Execute($sql, $templateId);
             $sql = "DELETE FROM `yg_templates_navis` WHERE TEMPLATE = ?;";
             sYDB()->Execute($sql, $templateId);
             $this->permissions->clear($templateId);
             @unlink($templateFile);
             $successNodes[] = $templateId;
         }
     }
     if (in_array($origTemplateId, $successNodes)) {
         $this->tree->remove($origTemplateId);
     }
     return $successNodes;
 }
示例#4
0
<?php

$jsQueue = new JSQueue(NULL);
$templateMgr = new Templates();
$tagMgr = new Tags();
switch ($action) {
    case 'deleteTemplate':
        $template = $this->params['template'];
        $confirmed = $this->params['confirmed'];
        $positive = $this->params['positive'];
        // Check if template is still used
        $stillInUse = false;
        $sites = sSites()->getList();
        foreach ($sites as $curr_site) {
            $pageMgr = new PageMgr($curr_site['ID']);
            $pages = $pageMgr->getPagesByTemplate($template);
            if (count($pages) > 0) {
                $stillInUse = true;
            }
        }
        $mailings = sMailingMgr()->getMailingsByTemplate($template);
        if (count($pages) > 0) {
            $stillInUse = true;
        }
        $tmpTemplateInfo = $templateMgr->getTemplate($template);
        if ($stillInUse) {
            // Still used!
            if ($confirmed != 'true') {
                $parameters = array('template' => $template);
                $koala->callJSFunction('Koala.yg_confirm', $itext['TXT_DELETE_USED_TEMPLATE_TITLE'] != '' ? $itext['TXT_DELETE_USED_TEMPLATE_TITLE'] : '$TXT_DELETE_USED_TEMPLATE_TITLE', $itext['TXT_DELETE_USED_TEMPLATE'] != '' ? $itext['TXT_DELETE_USED_TEMPLATE'] : '$TXT_DELETE_USED_TEMPLATE', $action, json_encode($parameters));
            } else {
示例#5
0
 /**
  * Removes a Usergroup
  *
  * @param int $usergroupId Usergroup Id
  * @return bool TRUE on success or FALSE in case of an error
  */
 function remove($usergroupId)
 {
     if ($this->permissions->check($this->_uid, 'RUSERGROUPS')) {
         $usergroupId = (int) $usergroupId;
         if ($usergroupId == (int) sConfig()->getVar('CONFIG/SYSTEMUSERS/ROOTGROUPID')) {
             return false;
         }
         // do not allow root Usergroup to be deleted
         $sql = "DELETE FROM " . $this->_table . " WHERE ID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_user_lnk_usergroups WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_contentblocks_permissions WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_entrymasks_permissions WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_files_permissions WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_filetypes_permissions WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_mailing_permissions WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_tags_permissions WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_templates_permissions WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_usergroups_permissions WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_views_permissions WHERE USERGROUPID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $sql = "DELETE FROM yg_mailing_lnk_usergroups WHERE RID = ?;";
         sYDB()->Execute($sql, $usergroupId);
         $allSites = sSites()->getList();
         foreach ($allSites as $allSitesItem) {
             $sql = "DELETE FROM yg_site_" . $allSitesItem['ID'] . "_permissions WHERE USERGROUPID = ?;";
             sYDB()->Execute($sql, $usergroupId);
         }
         return true;
     } else {
         return false;
     }
 }
示例#6
0
                    $pagePName = $currPage['PNAME'];
                }
            }
            $newUrl = $webroot_path_string . '/' . $sites[0]['PNAME'] . '/' . $pagePName . '/';
            // Throw status 301 and redirect
            $header = $_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently';
            header($header);
            header('Location: ' . $newUrl);
            die;
        }
    } else {
        // Throw status 404
        throwErrorPage('404');
    }
} elseif (strlen($psite) > 1) {
    $sinfo = sSites()->getByPName($psite);
    if ((int) $psite > 0) {
        $siteID = (int) $psite;
    } else {
        $siteID = $sinfo['ID'];
    }
    if ($siteID > 0) {
        $pageMgr = new PageMgr($siteID);
        $pname = $request_path[count($request_path) - 1];
        if (strlen($pname) > 0 && count($request_path) > 2 && strlen($request_path[count($request_path) - 1]) > 0) {
            $pageID = $pageMgr->getPageIdByPname($pname);
        }
        if ($pageID < 1 && $sinfo['ID'] > 0 && count($request_path) == 2) {
            // Use first page in that site
            $pagesList = $pageMgr->getTree($pageMgr->tree->getRoot(), 2);
            foreach ($pagesList as $currPage) {
示例#7
0
 /**
  * Saves content to a Formfield
  *
  * @param int $linkId Entrymask Formfield Link Id
  * @param string $value01 Content for Formfield parameter 1
  * @param string $value02 Content for Formfield parameter 2
  * @param string $value02 Content for Formfield parameter 3
  * @param string $value04 Content for Formfield parameter 4
  * @param string $value05 Content for Formfield parameter 5
  * @param string $value06 Content for Formfield parameter 6
  * @param string $value07 Content for Formfield parameter 7
  * @param string $value08 Content for Formfield parameter 8
  * @return bool TRUE on success or FALSE in case of an error
  * @throws Exception
  */
 function setFormfield($linkId, $value01, $value02, $value03, $value04, $value05, $value06, $value07, $value08)
 {
     $cbId = $this->_id;
     $linkId = (int) $linkId;
     if ($this->permissions->checkInternal($this->_uid, $cbId, "RWRITE")) {
         $value01 = sYDB()->escape_string($value01);
         $value02 = sYDB()->escape_string($value02);
         $value03 = sYDB()->escape_string($value03);
         $value04 = sYDB()->escape_string($value04);
         $value05 = sYDB()->escape_string($value05);
         $value06 = sYDB()->escape_string($value06);
         $value07 = sYDB()->escape_string($value07);
         $value08 = sYDB()->escape_string($value08);
         // Check if an URL needs to be generated
         $sql = "SELECT\n\t\t\t\t\t\tt.TYPE\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`yg_contentblocks_lnk_entrymasks_c` AS c,\n\t\t\t\t\t\t`yg_formfields` AS t\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(c.FORMFIELD = t.ID) AND\n\t\t\t\t\t\t(c.ID = ?);";
         $ra = $this->cacheExecuteGetArray($sql, $linkId);
         $webRoot = (string) sConfig()->getVar("CONFIG/DIRECTORIES/WEBROOT");
         switch ($ra[0]['TYPE']) {
             case 'PAGE':
                 if (strlen(trim($value02)) && strlen(trim($value01))) {
                     $siteMgr = new Sites();
                     $sitePName = $siteMgr->getPName($value02);
                     $pageMgr = sPageMgr($value02);
                     $tmpPage = $pageMgr->getPage($value01);
                     $tmpPageInfo = $tmpPage->get();
                     $value03 = $webRoot . $sitePName . '/' . $tmpPageInfo['PNAME'] . '/';
                     $value04 = $tmpPageInfo['PNAME'];
                     $value05 = $sitePName;
                 } else {
                     $value01 = $value02 = $value03 = $value04 = '';
                 }
                 break;
             case 'FILE':
                 if (strlen(trim($value01))) {
                     $tmpFile = sFileMgr()->getFile($value01);
                     if ($tmpFile) {
                         $tmpFileInfo = $tmpFile->get();
                         $value02 = $webRoot . 'download/' . $tmpFileInfo['PNAME'] . '/';
                         $value03 = $tmpFileInfo['PNAME'];
                         $value04 = $webRoot . 'image/' . $tmpFileInfo['PNAME'] . '/';
                     }
                 } else {
                     $value01 = $value02 = $value03 = '';
                 }
                 break;
         }
         $sql = "UPDATE `yg_contentblocks_lnk_entrymasks_c` SET\n\t\t\t\t\t\tVALUE01 = ?,\n\t\t\t\t\t\tVALUE02 = ?,\n\t\t\t\t\t\tVALUE03 = ?,\n\t\t\t\t\t\tVALUE04 = ?,\n\t\t\t\t\t\tVALUE05 = ?,\n\t\t\t\t\t\tVALUE06 = ?,\n\t\t\t\t\t\tVALUE07 = ?,\n\t\t\t\t\t\tVALUE08 = ?\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(ID = ?);";
         $result = sYDB()->Execute($sql, $value01, $value02, $value03, $value04, $value05, $value06, $value07, $value08, $linkId);
         if ($result === false) {
             throw new Exception(sYDB()->ErrorMsg());
         }
         // Check to which object this entrymask belongs to
         $CblockInfo = $this->get();
         // Check if it is an embedded entrymask
         if ($CblockInfo['EMBEDDED']) {
             $sql = "SELECT PID, PVERSION FROM yg_mailing_lnk_cb WHERE CBID = " . $CblockInfo['OBJECTID'] . " AND CBVERSION = " . $CblockInfo['VERSION'] . ";";
             $linkedMailings = $this->cacheExecuteGetArray($sql);
             if (count($linkedMailings) > 0) {
                 // Yes, it links to a Mailing
                 $mailingMgr = new MailingMgr();
                 foreach ($linkedMailings as $linkedMailing) {
                     $mailing = $mailingMgr->getMailing($linkedMailing['PID'], $linkedMailing['PVERSION']);
                     if ($mailing) {
                         $mailing->markAsChanged();
                     }
                 }
             } else {
                 // Check if it is related to a Page
                 $sites = sSites()->getList(true, false);
                 for ($i = 0; $i < count($sites); $i++) {
                     $sql = "SELECT PID, PVERSION FROM yg_site_" . (int) $sites[$i]['ID'] . "_lnk_cb WHERE CBID = " . (int) $CblockInfo['OBJECTID'] . " AND CBVERSION = " . (int) $CblockInfo['VERSION'] . ";";
                     $linkedPages = $this->cacheExecuteGetArray($sql);
                     if (count($linkedPages) > 0) {
                         // Yes, it links to a Pages
                         $pageMgr = sPageMgr($sites[$i]['ID']);
                         foreach ($linkedPages as $linkedPage) {
                             $page = $pageMgr->getPage($linkedPage['PID'], $linkedPage['PVERSION']);
                             if ($page) {
                                 $page->markAsChanged();
                             }
                         }
                     }
                 }
             }
         } else {
             // Entrymask is NOT embedded, so mark this Cblock as changed
             $this->markAsChanged();
         }
         return true;
     } else {
         return false;
     }
 }