コード例 #1
0
 public function authentificate()
 {
     //echo Berta::$options['SITE_ABS_ROOT'];
     session_name(BertaUtils::canonizeString('berta_' . Berta::$options['version'] . '_' . Berta::$options['SITE_ABS_ROOT'], '_', ''));
     session_start();
     $curTime = time();
     //var_dump($_SESSION);
     //echo $curTime - $_SESSION['_berta__user']['last_access'];
     if (isset($_SESSION['_berta__user']) && is_array($_SESSION['_berta__user'])) {
         if ($curTime - $_SESSION['_berta__user']['last_access'] <= $this->authExpiresSeconds) {
             if ($_SESSION['_berta__user']['last_ip'] == $_SERVER['REMOTE_ADDR']) {
                 $_SESSION['_berta__user']['last_access'] = $curTime;
                 $this->user = $_SESSION['_berta__user'];
                 $this->userLoggedIn = true;
                 if (!empty($_REQUEST['_security_reload_user'])) {
                     $this->updateUserSettings($this->user);
                 }
                 return $this->userLoggedIn = true;
             } else {
                 $this->destroy(self::BERTASECURITY_ERROR_SESSION_IP_CONFLICT);
                 // ip conflict
                 return $this->userLoggedIn = false;
             }
         } else {
             $this->destroy(self::BERTASECURITY_ERROR_SESSION_EXPIRED);
             return $this->userLoggedIn = false;
         }
     } elseif (isset($_SESSION['_berta__user']) && !is_array($_SESSION['_berta__user'])) {
         $this->destroy(self::BERTASECURITY_ERROR_SESSION_VARIABLE);
         return $this->userLoggedIn = false;
     } else {
         return $this->userLoggedIn = false;
     }
 }
コード例 #2
0
function smarty_function_entrySlug($params, &$smarty)
{
    global $berta;
    if (!empty($params['entry'])) {
        $section_type = isset($berta->sections[$berta->sectionName]['@attributes']['type']) ? $berta->sections[$berta->sectionName]['@attributes']['type'] : null;
        if ($section_type == 'portfolio' && isset($params['entry']['title']) && $params['entry']['title']) {
            $title = $params['entry']['title'];
        } else {
            $title = 'entry-' . $params['entry']['id'];
        }
        $slug = strtolower(BertaUtils::canonizeString($title, '-', '-'));
        return $slug;
    }
    return '';
}
コード例 #3
0
 public static function getUniqueSectionSlug($oldSlug, $title, $sectionsList)
 {
     $notUnique = true;
     $title = trim($title);
     if (strlen($title) < 1) {
         return '';
     }
     $slug = strtolower(BertaUtils::canonizeString($title, '-', '\\._-', true));
     unset($sectionsList[$oldSlug]);
     $existingSections = array_map('strval', array_keys($sectionsList));
     $slug = $slug ? $slug : '_';
     $i = 1;
     while ($notUnique) {
         if (in_array($slug, $existingSections)) {
             $slug = preg_replace('/(^.*?)+([\\-])+([0-9])+$/', '$1', $slug);
             $slug .= '-' . $i;
             $i++;
         } else {
             $notUnique = false;
         }
     }
     return $slug;
 }
コード例 #4
0
ファイル: update.php プロジェクト: JanisAnspaks/berta
							$decoded['value'] = '';
							$format = $settings->getDefinitionParam($propPath[0], $propPath[1], 'format');
							if($propPath[0] == 'siteTexts' && !$format) $format = 'image';
							if($format == 'image') {
								$oldF = $settings->get($propPath[0], $propPath[1]);
								@unlink($options['MEDIA_ROOT'] . $oldF);
								BertaEditor::images_deleteDerivatives($options['MEDIA_ROOT'], $oldF);
							}
						}
						
						if($decoded['value'] === '') 
							$decoded['value'] = $settings->getDefinitionParam($propPath[0], $propPath[1], 'allow_blank') ? 
												'' : $settings->getDefinitionParam($propPath[0], $propPath[1], 'default');
						
						if($settings->getDefinitionParam($propPath[0], $propPath[1], 'validator')) {
							BertaUtils::validate($decoded['value'], $returnError, $settings->getDefinitionParam($propPath[0], $propPath[1], 'validator'));
						}
						
						$settings->update($propPath[0], $propPath[1], $decoded['value']);
						$returnUpdate = $decoded['value'];
					} else {
						$returnError = "the setting is not properly defined in the configuration!\n";
						if($tName) $returnError .= 'check the configuration file for the tempalte "' . $tName . '".';
					}
				}
			} 
			elseif(!empty($decoded['property'])) {
				//echo $decoded['value'];
				//var_dump($settings->settings);
				
				$settings->update('siteTexts', $decoded['property'], /*'<![CDATA[' .*/ ($decoded['value']) /*. ']]>'*/);
コード例 #5
0
ファイル: update.php プロジェクト: DhariniJeeva/berta
                    //var_dump($settings->settings);
                    $settings->update('siteTexts', $decoded['property'], $decoded['value']);
                    $returnUpdate = $decoded['value'];
                    $allowFormatModifier = true;
                }
                //var_dump($settings->settings);
                if (!$settings->save()) {
                    $returnError = "the setting could not be saved!\ncheck permissions for \"{$settings->fileName}\".";
                }
            }
        }
        // format modifier
        if ($allowFormatModifier) {
            if (!empty($decoded['format_modifier'])) {
                $berta->template->loadSmartyPlugin('modifier', $decoded['format_modifier']);
                $modName = 'smarty_modifier_' . $decoded['format_modifier'];
                if (function_exists($modName)) {
                    $returnUpdate = @call_user_func($modName, $returnUpdate);
                }
            }
        }
    }
    // add "last updated" time
    $berta->settings->update('berta', 'lastUpdated', gmdate('D, d M Y H:i:s', time()) . ' GMT');
    $berta->settings->save();
    //log event after update
    BertaUtils::logEvent('after update');
    echo Zend_Json::encode($returnValues ? $returnValues : array('update' => $returnUpdate, 'updateText' => $returnUpdate, 'real' => $returnReal, 'eval_script' => $returnEvalScript, 'error_message' => $returnError, 'params' => $returnParams));
} else {
    echo Zend_Json::encode(array('update' => false, 'real' => false, 'eval_script' => false, 'error_message' => 'NO DATA!'));
}
コード例 #6
0
    public static function getTopPanelHTML($selectedSection = 'site')
    {
        $tickerClass = !empty($_COOKIE['_berta_newsticker_hidden']) ? 'xHidden' : '';
        $tickerColorClass = empty($_COOKIE['_berta_newsticker_hilight']) ? 'xNewsTickerRed' : 'xNewsTickerGrey';
        $newsTickerContent = false;
        //	$_SESSION['_berta_newsticker'] = false;				// for testing...
        //$_SESSION['_berta_newsticker_numtries'] = 0;		// for testing...
        if (!empty(self::$options['newsticker_update_uri'])) {
            if (!empty($_SESSION['_berta_newsticker'])) {
                $newsTickerContent = $_SESSION['_berta_newsticker'];
            } elseif ((empty($_SESSION['_berta_newsticker_numtries']) || $_SESSION['_berta_newsticker_numtries'] < 5) && ini_get('allow_url_fopen')) {
                $remoteResult = false;
                reset(self::$options['newsticker_update_uri']);
                while ((!$remoteResult || empty($remoteResult['content'])) && (list(, $remoteURL) = each(self::$options['newsticker_update_uri']))) {
                    $remoteResult = BertaUtils::getRemoteFile($remoteURL, 5);
                }
                //var_dump($remoteResult ); //$options['newsticker_update_uri_alt']);
                if ($remoteResult && isset($remoteResult['content'])) {
                    $newsTickerContent = $_SESSION['_berta_newsticker'] = $remoteResult['content'];
                    setcookie('_berta_newsticker', $remoteResult['content']);
                }
                $_SESSION['_berta_newsticker_numtries'] = !empty($_SESSION['_berta_newsticker_numtries']) ? ++$_SESSION['_berta_newsticker_numtries'] : 1;
            }
        }
        if (!$newsTickerContent) {
            $tickerClass = 'xHidden';
        }
        $m0 = I18n::_('close this');
        $m1 = I18n::_('my site');
        $m2 = I18n::_('sections');
        $m3 = I18n::_('settings');
        $m4 = I18n::_('template design');
        $m5 = I18n::_('profile');
        $m6 = I18n::_('sign out');
        $m1Class = $selectedSection == 'site' ? ' class="selected"' : '';
        $m2Class = $selectedSection == 'sections' ? ' class="selected"' : '';
        $m3Class = $selectedSection == 'settings' ? ' class="selected"' : '';
        $m4Class = $selectedSection == 'template' ? ' class="selected"' : '';
        $m5Class = $selectedSection == 'profile' ? ' selected' : '';
        $str = <<<DOC
\t\t\t<div id="xTopPanelContainer" class="xPanel">
\t\t\t\t<div id="xTopPanel">
\t\t\t\t\t
\t\t\t\t\t<div id="xNewsTickerContainer" class="{$tickerClass}">
\t\t\t\t\t\t<div class="news-ticker-background {$tickerColorClass}"></div>
\t\t\t\t\t\t<div class="news-ticker-content">{$newsTickerContent}</div>
\t\t\t\t\t\t<a href="#" class="close">{$m0}</a>
\t\t\t\t\t\t<br class="clear" />
\t\t\t\t\t</div>
\t\t\t\t\t<ul id="xEditorMenu">
\t\t\t\t\t\t<li id="xEditorMenuBg"></li>
\t\t\t\t\t\t<li{$m1Class}><a href=".">{$m1}</a></li><li>|</li>
\t\t\t\t\t\t<li{$m2Class}><a href="sections.php">{$m2}</a></li><li>|</li>
\t\t\t\t\t\t<li{$m3Class}><a href="settings.php">{$m3}</a></li><li>|</li>
\t\t\t\t\t\t<li{$m4Class}><a href="settings.php?mode=template">{$m4}</a></li>
\t\t\t\t\t\t<li class="last{$m5Class}"><a href="profile.php">{$m5}</a> | <a href="logout.php">{$m6}</a></li>
\t\t\t\t\t</ul>
\t\t\t\t</div>
\t\t\t</div>
DOC;
        return $str;
    }
コード例 #7
0
         }
     }
     BertaEditor::saveSections($sectionsList);
 } else {
     if ($decoded['action'] == 'ORDER_SECTIONS') {
         // apply the new order
         $oldSectionsList = BertaEditor::getSections();
         $newSectionsList = array();
         foreach ($decoded['value'] as $s) {
             $newSectionsList[$s] = $oldSectionsList[$s];
         }
         BertaEditor::saveSections($newSectionsList);
     } else {
         if ($decoded['action'] == 'CREATE_NEW_SECTION') {
             $sTitle = 'untitled' . uniqid();
             $sName = strtolower(BertaUtils::canonizeString($sTitle, '-', '-'));
             //echo " {$decoded['value']} $sName ";
             $emptyXML = '<?xml version="1.0" encoding="utf-8"?><blog></blog>';
             $fName = $options['XML_ROOT'] . str_replace('%', $sName, $options['blog.%.xml']);
             if (file_exists($fName)) {
                 $returnError = 'section cannot be created! another section with the same (or too similar name) exists.';
             } else {
                 if (!@file_put_contents($fName, $emptyXML)) {
                     $returnError = 'section cannot be created! the storage file cannot be created. check permissions and be sure the name of the section is not TOO fancy.';
                 } else {
                     @chmod($fName, 0666);
                     $possibleTypes = 'default|Default';
                     $typeParams = array();
                     if (!empty($berta->template->sectionTypes)) {
                         $possibleTypes = array();
                         foreach ($berta->template->sectionTypes as $sT => $sTParams) {
コード例 #8
0
     }
     $sTitle = 'untitled' . uniqid();
     $sName = strtolower(BertaUtils::canonizeString($sTitle, '-', '-'));
     $dir = $options['XML_SITES_ROOT'] . $sName;
     @mkdir($dir, 0777);
     @chmod($dir, 0777);
     //clone contents
     $cloneFromSite = $decoded['site'];
     if ($cloneFromSite >= 0) {
         if ($cloneFromSite === 0) {
             //root site
             $src = $options['XML_MAIN_ROOT'];
         } else {
             $src = $options['XML_SITES_ROOT'] . $cloneFromSite;
         }
         BertaUtils::copyFolder($src, $dir);
     }
     //end clone contents
     $returnUpdate = '';
     $returnUpdate .= '<div class="csHandle"><span class="handle"></span></div>';
     $returnUpdate .= '<div class="csTitle"><span class="' . $xEditSelectorSimple . ' xProperty-title xNoHTMLEntities xSite-' . $sName . '">' . BertaEditor::getXEmpty('title') . '</span></div>';
     $returnUpdate .= '<div class="csName">' . $options['SITE_HOST_ADDRESS'] . $options['SITE_ABS_ROOT'] . '<span class="' . $xEditSelectorSimple . ' xProperty-name xNoHTMLEntities xSite-' . $sName . '">' . $sName . '</span></div>';
     $returnUpdate .= '<div class="csPub"><span class="' . $xEditSelectorYesNo . ' xProperty-published xSite-' . $sName . '">0</span></div>';
     $returnUpdate .= '<div class="csClone"><a href="#" class="xSiteClone">clone</a></div>';
     $returnUpdate .= '<div class="csDelete"><a href="#" class="xSiteDelete">delete</a></div>';
     $returnReal = $sName;
     $sitesList = BertaEditor::getSites();
     $sitesList[$sName] = array('@attributes' => array('published' => 0), 'name' => $sName, 'title' => array('value' => ''));
     BertaEditor::saveSites($sitesList);
 } else {
     if ($decoded['action'] == 'DELETE_SITE') {
コード例 #9
0
ファイル: upload.php プロジェクト: DhariniJeeva/berta
         $fName = rand(1, 100) . $fName;
     }
     // only derivatives start with "_"
 } elseif ($posterFor) {
     // if this image is uploaded as a poster frame, then its name should be the same as the name of the video
     $fName = substr($posterFor, 0, strrpos($posterFor, '.')) . '.' . strtolower(substr(strrchr($_FILES['Filedata']['name'], '.'), 1));
     if (file_exists($fileFolder . $fName)) {
         if (@unlink($fileFolder . $fName)) {
             BertaEditor::images_deleteDerivatives($fileFolder, $fName);
         } else {
             $result['result'] = 'failed';
             $result['error'] = 'Cannot delete the current poster frame file!';
         }
     }
 } else {
     $fName = $fRealName = strtolower(BertaUtils::canonizeString($_FILES['Filedata']['name'], '_', '\\.-'));
     //str_replace(' ', '', str_replace($badChars, '_', strtolower($_FILES['Filedata']['name'])));
     if (substr($fName, 0, 1) == '_') {
         $fName = rand(1, 100) . $fName;
     }
     // only derivatives start with "_"
     $ext = strtolower(substr(strrchr($fName, '.'), 1));
 }
 if (empty($result['error'])) {
     // be sure that we won't overwrite anything
     while (file_exists($fileFolder . $fName)) {
         $fName = substr($fName, 0, strlen($fName) - strlen($ext) - 1) . rand(1, 9) . '.' . $ext;
     }
     // UPLOAD!
     if (!move_uploaded_file($file, $fileFolder . $fName)) {
         $result['result'] = 'error';
コード例 #10
0
 public static function createThumbnail($imagePath, $thumbPath, $thumbWidth, $thumbHeight)
 {
     if (file_exists($imagePath)) {
         $imageInfo = getimagesize($imagePath);
         $canMakeThumb = function_exists('imagejpeg') && ($imageInfo[2] == IMAGETYPE_GIF && function_exists('imagecreatefromgif') || $imageInfo[2] == IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg') || $imageInfo[2] == IMAGETYPE_PNG && function_exists('imagecreatefrompng'));
         if ($canMakeThumb) {
             if ($thumbWidth && !$thumbHeight) {
                 $thumbHeight = $thumbWidth / $imageInfo[0] * $imageInfo[1];
             } elseif (!$thumbWidth && $thumbHeight) {
                 $thumbWidth = $thumbHeight / $imageInfo[1] * $imageInfo[0];
             }
             $imageThumb = BertaUtils::smart_resize_image($imagePath, $thumbWidth, $thumbHeight, false, 'return', false);
             if ($imageThumb) {
                 switch ($imageInfo[2]) {
                     case IMAGETYPE_GIF:
                         imagegif($imageThumb, $thumbPath);
                         break;
                     case IMAGETYPE_JPEG:
                         imagejpeg($imageThumb, $thumbPath, 90);
                         break;
                     case IMAGETYPE_PNG:
                         imagepng($imageThumb, $thumbPath);
                         break;
                     default:
                         return false;
                 }
                 if (file_exists($thumbPath)) {
                     chmod($thumbPath, 0666);
                 }
                 return true;
             }
         }
     }
     return false;
 }
コード例 #11
0
 public static function createThumbnail($imagePath, $thumbPath, $thumbWidth, $thumbHeight)
 {
     if (is_file($imagePath)) {
         $imageInfo = getimagesize($imagePath);
         $canMakeThumb = function_exists('imagejpeg') && ($imageInfo[2] == IMAGETYPE_GIF && function_exists('imagecreatefromgif') || $imageInfo[2] == IMAGETYPE_JPEG && function_exists('imagecreatefromjpeg') || $imageInfo[2] == IMAGETYPE_PNG && function_exists('imagecreatefrompng'));
         if ($canMakeThumb) {
             if ($thumbWidth && !$thumbHeight) {
                 $thumbHeight = $thumbWidth / $imageInfo[0] * $imageInfo[1];
             } elseif (!$thumbWidth && $thumbHeight) {
                 $thumbWidth = $thumbHeight / $imageInfo[1] * $imageInfo[0];
             }
             $imageThumb = BertaUtils::smart_resize_image($imagePath, $thumbWidth, $thumbHeight, false, 'return', false);
             if ($imageThumb) {
                 switch ($imageInfo[2]) {
                     case IMAGETYPE_GIF:
                         //solution for animated gif
                         if (0 && self::$options['HOSTING_PROFILE'] && $imageInfo[2] == IMAGETYPE_GIF) {
                             $file_path = realpath($imagePath);
                             $file_info = pathinfo($file_path);
                             $thumb_info = pathinfo($thumbPath);
                             $thumbPath = $file_info['dirname'] . '/' . $thumb_info['basename'];
                             $command = "/usr/bin/convert {$file_path} -coalesce -bordercolor LightSteelBlue -border 0 -resize {$thumbWidth}x{$thumbHeight} -layers Optimize {$thumbPath}";
                             exec($command);
                         } elseif (extension_loaded('imagick') && $imageInfo[2] == IMAGETYPE_GIF) {
                             $animation = new Imagick($imagePath);
                             $animation = $animation->coalesceImages();
                             foreach ($animation as $frame) {
                                 $frame->thumbnailImage($thumbWidth, $thumbHeight);
                                 $frame->setImagePage($thumbWidth, $thumbHeight, 0, 0);
                             }
                             $animation = $animation->deconstructImages();
                             $animation->writeImages($thumbPath, true);
                         } else {
                             imagegif($imageThumb, $thumbPath);
                         }
                         break;
                     case IMAGETYPE_JPEG:
                         imagejpeg($imageThumb, $thumbPath, 97);
                         break;
                     case IMAGETYPE_PNG:
                         imagepng($imageThumb, $thumbPath);
                         break;
                     default:
                         return false;
                 }
                 if (file_exists($thumbPath)) {
                     @chmod($thumbPath, 0666);
                 }
                 return true;
             }
         }
     }
     return false;
 }
コード例 #12
0
 public function login($name, $pass, $realName, $realPass)
 {
     if ($name && $pass) {
         if ($name == $realName && $pass == $realPass) {
             $this->destroy();
             session_start();
             $this->updateUserSettings(array('name' => $realName));
             //log login event
             BertaUtils::logEvent('login');
             return $this->userLoggedIn = true;
         } else {
             $this->errLogin = self::BERTASECURITY_ERROR_LOGIN_INCORRECT;
             // wrong creditentials
             return false;
         }
     } else {
         $this->errLogin = self::BERTASECURITY_ERROR_LOGIN_VARIABLE;
         // no identification supplied
         return false;
     }
 }
コード例 #13
0
    public static function getTopPanelHTML($selectedSection = 'site')
    {
        global $shopEnabled;
        $site = !empty($_REQUEST['site']) ? $_REQUEST['site'] : false;
        $newsTickerContent = false;
        if (!empty(self::$options['remote_update_uri'])) {
            if (!empty($_SESSION['_berta_newsticker'])) {
                $newsTickerContent = $_SESSION['_berta_newsticker'];
            } elseif ((empty($_SESSION['_berta_newsticker_numtries']) || $_SESSION['_berta_newsticker_numtries'] < 5) && ini_get('allow_url_fopen')) {
                $remoteResult = false;
                reset(self::$options['remote_update_uri']);
                while ((!$remoteResult || empty($remoteResult['content'])) && (list(, $remoteURL) = each(self::$options['remote_update_uri']))) {
                    $remoteResult = BertaUtils::getRemoteFile($remoteURL, 'newsticker', 5);
                }
                //var_dump($remoteResult ); //$options['newsticker_update_uri_alt']);
                if ($remoteResult && isset($remoteResult['content'])) {
                    $newsTickerContent = $_SESSION['_berta_newsticker'] = $remoteResult['content'];
                    setcookie('_berta_newsticker', $remoteResult['content']);
                } else {
                    $newsTickerContent = $_SESSION['_berta_newsticker'] = I18n::_('To enable Berta\'s news ticker, your computer needs to be connected to the internet!');
                    setcookie('_berta_newsticker', $newsTickerContent);
                }
                $_SESSION['_berta_newsticker_numtries'] = !empty($_SESSION['_berta_newsticker_numtries']) ? ++$_SESSION['_berta_newsticker_numtries'] : 1;
            }
        }
        $m1 = I18n::_('my site');
        $m2 = I18n::_('sections');
        $m3 = I18n::_('settings');
        $m4 = I18n::_('design');
        $m5 = I18n::_('account');
        $m6 = I18n::_('log out');
        if ($shopEnabled) {
            $m7 = I18n::_('shop');
            $m7Class = $selectedSection == 'shop' ? ' class="selected"' : '';
            $shopItem = '<li' . $m7Class . ' id="xSections"><a href="shopsettings.php' . ($site ? '?site=' . $site : '') . '">' . $m7 . '</a></li><li>|</li>';
        } else {
            $shopItem = '';
        }
        $m8 = I18n::_('multisite');
        $m9 = I18n::_('seo');
        $m10 = I18n::_('upgrade');
        $m1Class = $selectedSection == 'site' ? ' class="selected"' : '';
        $m2Class = $selectedSection == 'sections' ? ' class="selected"' : '';
        $m3Class = $selectedSection == 'settings' ? ' class="selected"' : '';
        $m4Class = $selectedSection == 'template' ? ' class="selected"' : '';
        $m5Class = $selectedSection == 'profile' ? ' class="selected"' : '';
        $m1_link = $site ? '.?site=' . $site : '.';
        $m2_link = 'sections.php' . ($site ? '?site=' . $site : '');
        $m3_link = 'settings.php' . ($site ? '?site=' . $site : '');
        $m4_link = 'settings.php?mode=template' . ($site ? '&amp;site=' . $site : '');
        $m5_link = self::$options['HOSTING_PROFILE'] ? self::$options['HOSTING_PROFILE'] : 'profile.php';
        $m5_target = self::$options['HOSTING_PROFILE'] ? '_blank' : '_self';
        $m9_link = 'seo.php' . ($site ? '?site=' . $site : '');
        $m8Class = $selectedSection == 'multisite' ? ' class="selected"' : '';
        $m9Class = $selectedSection == 'seo' ? ' class="selected"' : '';
        if (self::$options['HOSTING_PROFILE'] && !self::$options['HOSTING_PLAN']) {
            //trial user
            $upgradeItem = '<li id="xUpgrade"><a href="' . self::$options['HOSTING_PROFILE'] . '" target="_blank">' . $m10 . '</a></li><li>|</li>';
        } else {
            $upgradeItem = '';
        }
        if (!self::$options['MULTISITE_DISABLED']) {
            $multisiteItem = '<li' . $m8Class . ' id="xMultisite"><a href="multisite.php">' . $m8 . '</a></li><li>|</li>';
        } else {
            $multisiteItem = '';
        }
        $helpdeskItem = self::$options['HOSTING_PROFILE'] ? '<li id="xHelpDesk"><a href="http://support.berta.me" target="_blank">helpdesk</a></li><li>|</li>' : '';
        $str_start = <<<DOC
\t\t\t<div id="xTopPanelContainer" class="xPanel">
\t\t\t\t<div id="xTopPanelSlideIn"><span title="show menu">▼</span></div>
\t\t\t\t<div id="xTopPanel">
\t\t\t\t\t<ul id="xEditorMenu">
\t\t\t\t\t\t<li id="xTopPanelSlideOut"><span title="hide menu">▲</span></li>
\t\t\t\t\t\t<li{$m1Class} id="xMySite"><a href="{$m1_link}">{$m1}</a></li><li>|</li>
\t\t\t\t\t\t<li{$m2Class} id="xSections"><a href="{$m2_link}">{$m2}</a></li><li>|</li>
\t\t\t\t\t\t<li{$m4Class} id="xTemplateDesign"><a href="{$m4_link}">{$m4}</a></li><li>|</li>
                        <li{$m3Class} id="xSettings"><a href="{$m3_link}">{$m3}</a></li><li>|</li>
                        {$multisiteItem}
                        {$shopItem}
\t\t\t\t\t\t<li{$m9Class} id="xSeo"><a href="{$m9_link}">{$m9}</a></li><li>|</li>
\t\t\t\t\t\t{$helpdeskItem}
                        <li{$m5Class}><a href="{$m5_link}" target="{$m5_target}">{$m5}</a></li><li>|</li>
                        {$upgradeItem}
\t\t\t\t\t\t<li><a href="logout.php">{$m6}</a></li>
\t\t\t\t\t</ul>
DOC;
        $str_ticker = '';
        if ($newsTickerContent) {
            $str_ticker = <<<DOC
\t\t\t\t<div id="xNewsTickerContainer">
\t\t\t\t\t<div class="news-ticker-content">{$newsTickerContent}</div>
\t\t\t\t\t<a href="#" class="close">X</a>
\t\t\t\t\t<br class="clear" />
\t\t\t\t</div>
DOC;
        }
        $str_end = <<<DOC
\t\t\t\t</div>
\t\t\t</div>
DOC;
        $str = $str_start . (empty($_COOKIE['_berta_newsticker_hidden']) ? $str_ticker : '') . $str_end;
        return $str;
    }
コード例 #14
0
 public static function entryForTemplate($p, $additionalValues = false)
 {
     $e = array();
     // preset variables..
     $e['__raw'] = $p;
     $e['id'] = $p['id']['value'];
     $e['uniqid'] = $p['uniqid']['value'];
     $e['date'] = !empty($p['date']) && !empty($p['date']['value']) ? $p['date']['value'] : '';
     $e['mediafolder'] = $p['mediafolder']['value'];
     $e['marked'] = !empty($p['marked']['value']) ? '1' : '0';
     if ($additionalValues) {
         foreach ($additionalValues as $key => $value) {
             if (!isset($e[$key])) {
                 // don't overwrite
                 $e[$key] = $value;
             }
         }
     }
     // entry content..
     if (!empty($p['content'])) {
         foreach ($p['content'] as $key => $value) {
             if (!isset($e[$key])) {
                 // don't overwrite
                 $e[$key] = !empty($value['value']) ? $value['value'] : '';
             }
         }
     }
     // tags..
     $tagsList = array();
     if (!empty($p['tags']['tag'])) {
         Array_XML::makeListIfNotList($p['tags']['tag']);
         foreach ($p['tags']['tag'] as $tName => $t) {
             if (!empty($t['value'])) {
                 $tagsList[strtolower(BertaUtils::canonizeString($t['value']))] = $t['value'];
             }
         }
     }
     $e['tags'] = $tagsList;
     return $e;
 }
コード例 #15
0
 public static function logEvent($action = '')
 {
     $options = self::$options;
     if ($options['HOSTING_PROFILE']) {
         $db = BertaUtils::db();
         $db->exec("\n\t\t\t\tCREATE TABLE IF NOT EXISTS `log` (\n\t\t\t\t  `id` INTEGER PRIMARY KEY,\n\t\t\t\t  `created_at` datetime NOT NULL,\n\t\t\t\t  `action` varchar(20) NOT NULL,\n\t\t\t\t  `get` text NOT NULL,\n\t\t\t\t  `post` text NOT NULL\n\t\t\t\t)\n\t\t\t");
         $q = $db->prepare("INSERT INTO log VALUES (NULL, :created_at, :action, :get, :post)") or die(print_r($db->errorInfo(), true));
         $q->execute(array(':created_at' => date("Y-m-d H:i:s"), ':action' => $action, ':get' => serialize($_GET), ':post' => serialize($_POST)));
         //send stats to server
         if ($action == 'before update' || $action == 'login') {
             $data = array('session_id' => session_id(), 'host' => $_SERVER['HTTP_HOST'], 'action' => $action);
             $url = "http://hosting.berta.me/stats";
             $ch = curl_init();
             $timeout = 30;
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
             curl_exec($ch);
             curl_close($ch);
         }
     }
 }
コード例 #16
0
     unset($cloneSection['positionXY']);
     $sectionsList[$sName] = $cloneSection;
     $cloneContent = BertaContent::loadBlog($decoded['cloneSection']);
     if ($cloneContent) {
         $cloneSectionName = isset($cloneContent['@attributes']['section']) ? $cloneContent['@attributes']['section'] : $sName;
         $cloneContent['@attributes']['section'] = $sName;
         if (isset($cloneContent['entry'])) {
             foreach ($cloneContent['entry'] as $k => $entry) {
                 $cloneContent['entry'][$k]['uniqid'] = uniqid();
                 $cloneContent['entry'][$k]['date'] = date('d.m.Y H:i:s');
                 $cloneContent['entry'][$k]['updated'] = date('d.m.Y H:i:s');
                 if (isset($entry['mediafolder'])) {
                     $cloneMediafolder = $entry['mediafolder']['value'];
                     $cloneContent['entry'][$k]['mediafolder'] = str_replace($cloneSectionName, $sName, $cloneMediafolder);
                     //clone media folder
                     BertaUtils::copyFolder(realpath($options['MEDIA_ROOT']) . '/' . $cloneMediafolder, realpath($options['MEDIA_ROOT']) . '/' . $cloneContent['entry'][$k]['mediafolder']);
                 }
             }
         }
         BertaEditor::saveBlog($sName, $cloneContent);
     }
 }
 $possibleTypes = 'default|Default';
 $typeParams = array();
 if (!empty($berta->template->sectionTypes)) {
     $possibleTypes = array();
     foreach ($berta->template->sectionTypes as $sT => $sTParams) {
         $possibleTypes[] = "{$sT}|{$sTParams['title']}";
         if (!empty($sTParams['params'])) {
             $typeParams[$sT] = $sTParams['params'];
         }
コード例 #17
0
<?

if($decoded['section']) {

	// create media folder name
	$mediafolder = '';
	$mFAddNum = false;
	if($decoded['mediafolder']) $mediafolder = BertaUtils::canonizeString($decoded['mediafolder'], '_');
	if(!$decoded['mediafolder'] || $mediafolder == str_repeat('_', strlen($decoded['mediafolder']))) {
		$mediafolder = $decoded['section'];
		$mFAddNum = true;
	}
	$MFTestNum = 1;
	do {
		$mFTest = $mediafolder . ($mFAddNum ? $MFTestNum : ($MFTestNum > 1 ? ($MFTestNum - 1) : ''));
		$MFTestNum++;
	} while(file_exists($options['MEDIA_ROOT'] . $mFTest));
	$mediafolder = $mFTest;

	$defaultGalleryType = $berta->template->settings->get('entryLayout', 'defaultGalleryType');
	if(!$defaultGalleryType) $defaultGalleryType = 'slideshow';
	
	$FullScreen=$berta->settings->get('entryLayout', 'galleryFullScreenDefault');
	
	// try to create media folder
	//echo realpath($options['MEDIA_ROOT']) . '/' . $mFTest;
	if(@mkdir(realpath($options['MEDIA_ROOT']) . '/' . $mFTest, 0777)) {
		@chmod(realpath($options['MEDIA_ROOT']) . '/' . $mFTest, 0777);
		//echo realpath($options['MEDIA_ROOT']) . $mFTest;
	
		// update xml... 
コード例 #18
0
 public static function validate(&$value, &$errorMsg, $validator)
 {
     switch ($validator) {
         case "GoogleAnalytics":
             if (preg_match("/(\\w{2}-\\d+-\\d{1,3})/", $value, $regs)) {
                 $value = $regs[1];
             }
             break;
         case 'email':
             $value = BertaUtils::validateEmailAddress($value) ? $value : '';
             if (!$value) {
                 $errorMsg = true;
             }
             break;
     }
 }