Exemplo n.º 1
0
 public function getSize($strApiName = "")
 {
     //*** Return the width and height of an image field as an array.
     $arrReturn = array('width' => 0, 'height' => 0);
     $objCms = PCMS_Client::getInstance();
     $strFile = $objCms->getBasePath() . $this->getSrc($strApiName);
     if (is_file($strFile)) {
         $arrTemp = getimagesize($strFile);
         $arrReturn['width'] = $arrTemp[0];
         $arrReturn['height'] = $arrTemp[1];
     }
     return $arrReturn;
 }
Exemplo n.º 2
0
function exportSite()
{
    global $strExportName;
    $objCms = PCMS_Client::getInstance();
    $objCms->setLanguage(ContentLanguage::getDefault());
    //*** Get the list of pages.
    $objElements = $objCms->getElementByTemplate("Pages")->getElements();
    foreach ($objElements as $objElement) {
        exportPage($objElement);
    }
    //*** Return the zip file to the user.
    header("HTTP/1.1 200 OK");
    header("Pragma: public");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private", false);
    header('Content-Type: text; charset=utf-8');
    header("Content-Length: " . (string) filesize($strExportName));
    header('Content-Disposition: attachment; filename="' . $objCms->getAccount()->getUri() . '.txt"');
    readfile($strExportName);
    exit;
}
Exemplo n.º 3
0
 public static function escape($strValue)
 {
     /*
      * Escape a value according to the database rules.
      */
     $DBAConn = PCMS_Client::getConn();
     return $DBAConn->quote($strValue);
     return $strValue;
 }
Exemplo n.º 4
0
<?php

/**************************************************************************
* PunchCMS Language include v0.2.5
* Handles language selection.
**************************************************************************/
$strLanguageAbbr = Request::get("lang");
$strRewrite = Request::get('rewrite');
$blnChanged = FALSE;
$objCms = PCMS_Client::getInstance();
if (!empty($strRewrite)) {
    $strRewrite = rtrim($strRewrite, " \\/");
    $arrUrl = explode("/", $strRewrite);
    $intKey = array_search("language", $arrUrl);
    if ($intKey !== FALSE && $intKey < count($arrUrl) - 1) {
        //*** Google friendly language URL.
        $strLanguageAbbr = $arrUrl[$intKey + 1];
        if (isset($_COOKIE["userlanguage_abbr"]) && $strLanguageAbbr == $_COOKIE["userlanguage_abbr"]) {
            $strLanguageAbbr = "";
        }
    }
}
if (!empty($strLanguageAbbr)) {
    //*** A language change has been submitted.
    $objLanguage = ContentLanguage::selectByAbbr($strLanguageAbbr);
    if (is_object($objLanguage) && $objLanguage->getActive()) {
        //*** Write to session.
        $_SESSION["userlanguage"] = array();
        $_SESSION["userlanguage"]["id"] = $objLanguage->getId();
        $_SESSION["userlanguage"]["abbr"] = $objLanguage->getAbbr();
        $_SESSION["userlanguage"]["name"] = $objLanguage->getName();
Exemplo n.º 5
0
 public function buildForm($blnHandle = TRUE, $blnClientSide = TRUE)
 {
     $objCms = PCMS_Client::getInstance();
     $strReturn = "";
     $this->__maxLengthAlert = $this->__formElement->getField("AlertMaxLength")->getHtmlValue();
     $this->__minLengthAlert = $this->__formElement->getField("AlertMinLength")->getHtmlValue();
     $this->__requiredAlert = $this->__formElement->getField("AlertRequired")->getHtmlValue();
     $this->__validForm->setRequiredStyle($this->__formElement->getField("RequiredIndicator")->getHtmlValue());
     $this->__validForm->setMainAlert($this->__formElement->getField("AlertMain")->getHtmlValue());
     //*** Form starts here.
     $objPages = $this->__formElement->getElementsByTemplate(array("Page", "Paragraph"));
     foreach ($objPages as $objPage) {
         if (get_class($objPage) == "VF_Hidden") {
             continue;
         }
         $objParent = $this->renderPage($this->__validForm, $objPage);
         $objFieldsets = $objPage->getElementsByTemplate(array("Fieldset", "Paragraph"));
         foreach ($objFieldsets as $objFieldset) {
             switch ($objFieldset->getTemplateName()) {
                 case "Paragraph":
                     $this->renderParagraph($this->__validForm, $objFieldset);
                     break;
                 case "Fieldset":
                     $this->renderFieldset($this->__validForm, $objFieldset);
                     $objFields = $objFieldset->getElementsByTemplate(array("Field", "Area", "ListField", "MultiField"));
                     foreach ($objFields as $objField) {
                         switch ($objField->getTemplateName()) {
                             case "Field":
                                 $this->renderField($this->__validForm, $objField);
                                 break;
                             case "ListField":
                                 $this->renderListField($this->__validForm, $objField);
                                 break;
                             case "Area":
                                 $this->renderArea($this->__validForm, $objField);
                                 break;
                             case "MultiField":
                                 $this->renderMultiField($this->__validForm, $objField);
                                 break;
                         }
                     }
             }
         }
     }
     //*** Add conditions
     foreach ($objPages as $objPage) {
         if (get_class($objPage) == "VF_Hidden") {
             continue;
         }
         $objFieldsets = $objPage->getElementsByTemplate(array("Fieldset", "Paragraph"));
         foreach ($objFieldsets as $objFieldset) {
             $this->addConditions($objFieldset);
             $objFields = $objFieldset->getElementsByTemplate(array("Field", "Area", "ListField", "MultiField"));
             foreach ($objFields as $objField) {
                 $this->addConditions($objField);
             }
         }
     }
     $this->__validForm->setSubmitLabel($this->__formElement->getField("SendLabel")->getHtmlValue());
     if ($blnHandle) {
         if ($this->__validForm->isSubmitted() && $this->__validForm->isValid()) {
             $strReturn = $this->__formElement->getField("ThanksBody")->getHtmlValue();
         } else {
             $strReturn = $this->__validForm->toHtml($blnClientSide);
         }
     }
     return $strReturn;
 }
Exemplo n.º 6
0
 private static function filter_useMedia($objField, &$text, $blnDirect = FALSE)
 {
     $objCms = PCMS_Client::getInstance();
     switch ($objField->typeid) {
         case FIELD_TYPE_LARGETEXT:
             //*** Replace "href='?mid=" with "href='/download.php?mid=" or "href='/download/media/id" if useAliases is on.
             $strPattern = "/(\\?mid=)([0-9]+)/ie";
             $arrMatches = array();
             if (preg_match_all($strPattern, $text, $arrMatches) > 0) {
                 for ($intCount = 0; $intCount < count($arrMatches[0]); $intCount++) {
                     $strMatch = $arrMatches[0][$intCount];
                     if ($blnDirect) {
                         $objMediaItem = $objCms->getMediaById($arrMatches[2][$intCount]);
                         if (is_object($objMediaItem)) {
                             $strLink = $objCms->getFilePath() . $objMediaItem->getData()->getLocalName();
                             $text = str_ireplace("href=\"{$strMatch}", "href=\"" . $strLink, $text);
                         }
                     } else {
                         $strLink = $objCms->usesAliases() ? "/download/media/" : "/download.php?mid=";
                         $text = str_ireplace("href=\"{$strMatch}", "href=\"" . $strLink . $arrMatches[2][$intCount], $text);
                     }
                 }
             }
             break;
     }
 }
Exemplo n.º 7
0
function exportSite()
{
    global $strBaseFolder, $strZipFolder, $strZipName, $objZip;
    $objCms = PCMS_Client::getInstance();
    $objCms->setLanguage(ContentLanguage::getDefault());
    //*** Get a collection of Languages.
    $objLanguages = $objCms->getLanguages();
    foreach ($objLanguages as $objLanguage) {
        //*** Export the entry page.
        exportIndexPage($objLanguage);
        //*** Get the list of pages.
        $objElements = $objCms->getPageElements($objLanguage->getId());
        foreach ($objElements as $objElement) {
            exportPage($objElement, $objLanguage);
        }
    }
    //*** Export auxilary fodlers.
    $arrFileFilter = array("js", "css", "jpg", "gif", "png", "ico", "txt", "html");
    copyr($strBaseFolder . "css", "css", $arrFileFilter);
    copyr($strBaseFolder . "includes", "includes", $arrFileFilter);
    copyr($strBaseFolder . "images", "images", $arrFileFilter);
    copyr($strBaseFolder . "files", "files", $arrFileFilter);
    copyr($strBaseFolder . "libraries", "libraries", $arrFileFilter);
    copyr($strBaseFolder . "favicon.ico", "favicon.ico");
    copyr($strBaseFolder . "robots.txt", "robots.txt");
    //*** Close zip file.
    $objZip->save();
    //*** Return the zip file to the user.
    header("HTTP/1.1 200 OK");
    header("Pragma: public");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private", false);
    header('Content-Type: application/octetstream; charset=utf-8');
    header("Content-Length: " . (string) filesize($strZipName));
    header('Content-Disposition: attachment; filename="' . $objCms->getAccount()->getUri() . '.zip"');
    header("Content-Transfer-Encoding: binary\n");
    readfile($strZipName);
    exit;
}
Exemplo n.º 8
0
 public function buildForm($blnSend = true, $blnClientSide = true)
 {
     $objCms = PCMS_Client::getInstance();
     $strReturn = "";
     $this->__maxLengthAlert = $this->__formElement->getField("AlertMaxLength")->getHtmlValue();
     $this->__minLengthAlert = $this->__formElement->getField("AlertMinLength")->getHtmlValue();
     $this->__requiredAlert = $this->__formElement->getField("AlertRequired")->getHtmlValue();
     $this->__validForm->setRequiredStyle($this->__formElement->getField("RequiredIndicator")->getHtmlValue());
     $this->__validForm->setMainAlert($this->__formElement->getField("AlertMain")->getHtmlValue());
     //*** Form starts here.
     $objFieldsets = $this->__formElement->getElementsByTemplate(array("Fieldset", "Paragraph"));
     foreach ($objFieldsets as $objFieldset) {
         switch ($objFieldset->getTemplateName()) {
             case "Paragraph":
                 $this->renderParagraph($this->__validForm, $objFieldset);
                 break;
             case "Fieldset":
                 $this->renderFieldset($this->__validForm, $objFieldset);
                 $objFields = $objFieldset->getElementsByTemplate(array("Field", "Area", "ListField", "MultiField"));
                 foreach ($objFields as $objField) {
                     switch ($objField->getTemplateName()) {
                         case "Field":
                             $this->renderField($this->__validForm, $objField);
                             break;
                         case "ListField":
                             $this->renderListField($this->__validForm, $objField);
                             break;
                         case "Area":
                             $this->renderArea($this->__validForm, $objField);
                             break;
                         case "MultiField":
                             $this->renderMultiField($this->__validForm, $objField);
                             break;
                     }
                 }
         }
     }
     //*** Add conditions
     foreach ($objFieldsets as $objFieldset) {
         $this->addConditions($objFieldset);
         $objFields = $objFieldset->getElementsByTemplate(array("Field", "Area", "ListField", "MultiField"));
         foreach ($objFields as $objField) {
             $this->addConditions($objField);
         }
     }
     $this->__validForm->setSubmitLabel($this->__formElement->getField("SendLabel")->getHtmlValue());
     if ($this->__validForm->isSubmitted() && $this->__validForm->isValid()) {
         if ($blnSend) {
             $objRecipientEmails = $this->__formElement->getElementsByTemplate("RecipientEmail");
             foreach ($objRecipientEmails as $objRecipientEmail) {
                 $strHtmlBody = "<html><head><title></title></head><body>";
                 $strHtmlBody .= sprintf($objRecipientEmail->getField("Body")->getHtmlValue(), $this->__validForm->valuesAsHtml(true));
                 $strHtmlBody .= "</body></html>";
                 $varEmailId = $objRecipientEmail->getField("SenderEmail")->getValue();
                 $objEmailElement = $objCms->getElementById($varEmailId);
                 $strFrom = "webserver";
                 if (is_object($objEmailElement)) {
                     $varEmailId = $objEmailElement->getElement()->getApiName();
                     if (empty($varEmailId)) {
                         $varEmailId = $objEmailElement->getId();
                     }
                     $strFrom = $this->__validForm->getValidField("formfield_" . strtolower($varEmailId))->getValue();
                 }
                 $strErrors = $this->sendMail($objRecipientEmail->getField("Subject")->getHtmlValue(), $strHtmlBody, $strFrom, explode(",", $objRecipientEmail->getField("RecipientEmail")->getHtmlValue()));
                 if (!empty($strErrors)) {
                     throw new Exception($strErrors, E_ERROR);
                 }
             }
             $objSenderEmails = $this->__formElement->getElementsByTemplate("SenderEmail");
             foreach ($objSenderEmails as $objSenderEmail) {
                 $strHtmlBody = "<html><head><title></title></head><body>";
                 $strHtmlBody .= sprintf($objSenderEmail->getField("Body")->getHtmlValue(), $this->__validForm->valuesAsHtml(true));
                 $strHtmlBody .= "</body></html>";
                 $varEmailId = $objSenderEmail->getField("RecipientEmail")->getValue();
                 $objEmailElement = $objCms->getElementById($varEmailId);
                 if (is_object($objEmailElement)) {
                     $varEmailId = $objEmailElement->getElement()->getApiName();
                     if (empty($varEmailId)) {
                         $varEmailId = $objEmailElement->getId();
                     }
                 }
                 $strErrors = $this->sendMail($objSenderEmail->getField("Subject")->getHtmlValue(), $strHtmlBody, $objSenderEmail->getField("SenderEmail")->getHtmlValue(), array($this->__validForm->getValidField("formfield_" . strtolower($varEmailId))->getValue()));
                 if (!empty($strErrors)) {
                     throw new Exception($strErrors, E_ERROR);
                 }
             }
             $strReturn = $this->__formElement->getField("ThanksBody")->getHtmlValue();
         } else {
             $strReturn = $this->__formElement->getField("ThanksBody")->getHtmlValue();
         }
     } else {
         $strReturn = $this->__validForm->toHtml($blnClientSide);
     }
     return $strReturn;
 }