| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * @package Dolphin Core |
|---|
| 4 | * @copyright Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ |
|---|
| 5 | * @license CC-BY - http://creativecommons.org/licenses/by/3.0/ |
|---|
| 6 | */ |
|---|
| 7 | defined('BX_DOL') or die('hack attempt'); |
|---|
| 8 | |
|---|
| 9 | /** |
|---|
| 10 | * design box with content only - no borders, no background, no caption |
|---|
| 11 | * @see DesignBoxContent |
|---|
| 12 | */ |
|---|
| 13 | define('BX_DB_CONTENT_ONLY', 0); |
|---|
| 14 | |
|---|
| 15 | /** |
|---|
| 16 | * default design box with content, borders and caption |
|---|
| 17 | * @see DesignBoxContent |
|---|
| 18 | */ |
|---|
| 19 | define('BX_DB_DEF', 1); |
|---|
| 20 | |
|---|
| 21 | /** |
|---|
| 22 | * just empty design box, without anything |
|---|
| 23 | * @see DesignBoxContent |
|---|
| 24 | */ |
|---|
| 25 | define('BX_DB_EMPTY', 2); |
|---|
| 26 | |
|---|
| 27 | /** |
|---|
| 28 | * design box with content, like BX_DB_DEF but without caption |
|---|
| 29 | * @see DesignBoxContent |
|---|
| 30 | */ |
|---|
| 31 | define('BX_DB_NO_CAPTION', 3); |
|---|
| 32 | |
|---|
| 33 | /** |
|---|
| 34 | * design box with content only wrapped with default padding - no borders, no background, no caption |
|---|
| 35 | * it can be used to just wrap content with default padding |
|---|
| 36 | * @see DesignBoxContent |
|---|
| 37 | */ |
|---|
| 38 | define('BX_DB_PADDING_CONTENT_ONLY', 10); |
|---|
| 39 | |
|---|
| 40 | /** |
|---|
| 41 | * default design box with content wrapped with default padding, borders and caption |
|---|
| 42 | * @see DesignBoxContent |
|---|
| 43 | */ |
|---|
| 44 | define('BX_DB_PADDING_DEF', 11); |
|---|
| 45 | |
|---|
| 46 | /** |
|---|
| 47 | * design box with content wrapped with default padding, like BX_DB_DEF but without caption |
|---|
| 48 | * @see DesignBoxContent |
|---|
| 49 | */ |
|---|
| 50 | define('BX_DB_PADDING_NO_CAPTION', 13); |
|---|
| 51 | |
|---|
| 52 | /** |
|---|
| 53 | * Display "design box" HTML code |
|---|
| 54 | * |
|---|
| 55 | * @see BxBaseFunctions::DesignBoxContent |
|---|
| 56 | * |
|---|
| 57 | * @see BX_DB_CONTENT_ONLY |
|---|
| 58 | * @see BX_DB_DEF |
|---|
| 59 | * @see BX_DB_EMPTY |
|---|
| 60 | * @see BX_DB_NO_CAPTION |
|---|
| 61 | * @see BX_DB_PADDING_CONTENT_ONLY |
|---|
| 62 | * @see BX_DB_PADDING_DEF |
|---|
| 63 | * @see BX_DB_PADDING_NO_CAPTION |
|---|
| 64 | */ |
|---|
| 65 | function DesignBoxContent ($sTitle, $sContent, $iTemplateNum = BX_DB_DEF, $mixedMenu = false) { |
|---|
| 66 | bx_import('BxTemplFunctions'); |
|---|
| 67 | return BxTemplFunctions::getInstance()->designBoxContent ($sTitle, $sContent, $iTemplateNum, $mixedMenu); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | /** |
|---|
| 71 | * DEPRECATED |
|---|
| 72 | * Put top code for the page |
|---|
| 73 | **/ |
|---|
| 74 | function PageCode($oTemplate = null) { |
|---|
| 75 | echo "DEPRECATED: function PageCode, use BxDolTemplate::getPageCode instead"; |
|---|
| 76 | if (empty($oTemplate)) |
|---|
| 77 | $oTemplate = BxDolTemplate::getInstance(); |
|---|
| 78 | $oTemplate->getPageCode(); |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | /** |
|---|
| 82 | * Use this function in pages if you want to not cache it. |
|---|
| 83 | **/ |
|---|
| 84 | function send_headers_page_changed() { |
|---|
| 85 | $now = gmdate('D, d M Y H:i:s') . ' GMT'; |
|---|
| 86 | |
|---|
| 87 | header("Expires: $now"); |
|---|
| 88 | header("Last-Modified: $now"); |
|---|
| 89 | header("Cache-Control: no-cache, must-revalidate"); |
|---|
| 90 | header("Pragma: no-cache"); |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | function getFieldValues( $sField, $sUseLKey = 'LKey' ) { |
|---|
| 95 | |
|---|
| 96 | require_once(BX_DIRECTORY_PATH_INC . "prof.inc.php"); |
|---|
| 97 | |
|---|
| 98 | global $aPreValues; |
|---|
| 99 | |
|---|
| 100 | $sValues = db_value( "SELECT `Values` FROM `sys_profile_fields` WHERE `Name` = '$sField'" ); |
|---|
| 101 | |
|---|
| 102 | if( substr( $sValues, 0, 2 ) == '#!' ) { |
|---|
| 103 | //predefined list |
|---|
| 104 | $sKey = substr( $sValues, 2 ); |
|---|
| 105 | |
|---|
| 106 | $aValues = array(); |
|---|
| 107 | |
|---|
| 108 | $aMyPreValues = $aPreValues[$sKey]; |
|---|
| 109 | if( !$aMyPreValues ) |
|---|
| 110 | return $aValues; |
|---|
| 111 | |
|---|
| 112 | foreach( $aMyPreValues as $sVal => $aVal ) { |
|---|
| 113 | $sMyUseLKey = $sUseLKey; |
|---|
| 114 | if( !isset( $aMyPreValues[$sVal][$sUseLKey] ) ) |
|---|
| 115 | $sMyUseLKey = 'LKey'; |
|---|
| 116 | |
|---|
| 117 | $aValues[$sVal] = $aMyPreValues[$sVal][$sMyUseLKey]; |
|---|
| 118 | } |
|---|
| 119 | } else { |
|---|
| 120 | $aValues1 = explode( "\n", $sValues ); |
|---|
| 121 | |
|---|
| 122 | $aValues = array(); |
|---|
| 123 | foreach( $aValues1 as $iKey => $sValue ) |
|---|
| 124 | $aValues[$sValue] = "_$sValue"; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | return $aValues; |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | function get_member_thumbnail( $ID, $float, $bGenProfLink = false, $sForceSex = 'visitor', $aOnline = array()) { |
|---|
| 131 | bx_import('BxTemplFunctions'); |
|---|
| 132 | return BxTemplFunctions::getInstance()->getMemberThumbnail($ID, $float, $bGenProfLink, $sForceSex, true, 'medium', $aOnline); |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | function get_member_icon( $ID, $float = 'none', $bGenProfLink = false ) { |
|---|
| 136 | bx_import('BxTemplFunctions'); |
|---|
| 137 | return BxTemplFunctions::getInstance()->getMemberIcon( $ID, $float, $bGenProfLink ); |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | function MsgBox($sText, $iTimer = 0) { |
|---|
| 141 | bx_import('BxTemplFunctions'); |
|---|
| 142 | return BxTemplFunctions::getInstance()->msgBox($sText, $iTimer); |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | function LoadingBox($sName) { |
|---|
| 146 | bx_import('BxTemplFunctions'); |
|---|
| 147 | return BxTemplFunctions::getInstance()->loadingBox($sName); |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | function PopupBox($sName, $sTitle, $sContent, $isHiddenByDefault = false) { |
|---|
| 151 | bx_import('BxTemplFunctions'); |
|---|
| 152 | return BxTemplFunctions::getInstance()->popupBox($sName, $sTitle, $sContent, $isHiddenByDefault); |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | function getPromoImagesArray() { |
|---|
| 156 | $sPromoPath = BxDolConfig::getInstance()->get('path_dynamic', 'rpr_images_promo'); |
|---|
| 157 | |
|---|
| 158 | $aAllowedExt = array('jpg' => 1, 'png' => 1, 'gif' => 1, 'jpeg' => 1); |
|---|
| 159 | $aFiles = array(); |
|---|
| 160 | $rDir = opendir($sPromoPath); |
|---|
| 161 | if( $rDir ) { |
|---|
| 162 | while(($sFile = readdir($rDir)) !== false) { |
|---|
| 163 | if($sFile == '.' or $sFile == '..' or !is_file($sPromoPath . $sFile)) |
|---|
| 164 | continue; |
|---|
| 165 | $aPathInfo = pathinfo($sFile); |
|---|
| 166 | $sExt = strtolower($aPathInfo['extension']); |
|---|
| 167 | if (isset($aAllowedExt[$sExt])) { |
|---|
| 168 | $aFiles[] = $sFile; |
|---|
| 169 | } |
|---|
| 170 | } |
|---|
| 171 | closedir( $rDir ); |
|---|
| 172 | } |
|---|
| 173 | shuffle( $aFiles ); |
|---|
| 174 | return $aFiles; |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | function getTemplateIcon( $sFileName ) { |
|---|
| 178 | bx_import('BxTemplFunctions'); |
|---|
| 179 | return BxTemplFunctions::getInstance()->getTemplateIcon($sFileName); |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | function getTemplateImage( $sFileName ) { |
|---|
| 183 | bx_import('BxTemplFunctions'); |
|---|
| 184 | return BxTemplFunctions::getInstance()->getTemplateImage($sFileName); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | function getVersionComment() { |
|---|
| 188 | $aVer = explode( '.', BX_DOL_VERSION ); |
|---|
| 189 | |
|---|
| 190 | // version output made for debug possibilities. |
|---|
| 191 | // randomizing made for security issues. do not change it... |
|---|
| 192 | $aVerR[0] = $aVer[0]; |
|---|
| 193 | $aVerR[1] = rand( 0, 100 ); |
|---|
| 194 | $aVerR[2] = $aVer[1]; |
|---|
| 195 | $aVerR[3] = rand( 0, 100 ); |
|---|
| 196 | $aVerR[4] = BX_DOL_BUILD; |
|---|
| 197 | |
|---|
| 198 | //remove leading zeros |
|---|
| 199 | while( $aVerR[4][0] === '0' ) |
|---|
| 200 | $aVerR[4] = substr( $aVerR[4], 1 ); |
|---|
| 201 | |
|---|
| 202 | return '<!-- ' . implode( ' ', $aVerR ) . ' -->'; |
|---|
| 203 | } |
|---|
| 204 | |
|---|
| 205 | // ----------------------------------- site statistick functions --------------------------------------// |
|---|
| 206 | |
|---|
| 207 | function getSiteStatBody($aVal, $sMode = '') { |
|---|
| 208 | $sLink = strlen($aVal['link']) > 0 ? '<a href="'.BX_DOL_URL_ROOT.$aVal['link'].'">{iNum} '._t('_'.$aVal['capt']).'</a>' : '{iNum} '._t('_'.$aVal['capt']) ; |
|---|
| 209 | if ( $sMode != 'admin' ) { |
|---|
| 210 | $sBlockId = ''; |
|---|
| 211 | $iNum = strlen($aVal['query']) > 0 ? db_value($aVal['query']) : 0; |
|---|
| 212 | } else { |
|---|
| 213 | $sBlockId = "id='{$aVal['name']}'"; |
|---|
| 214 | $iNum = strlen($aVal['adm_query']) > 0 ? db_value($aVal['adm_query']) : 0; |
|---|
| 215 | if ( strlen($aVal['adm_link']) > 0 ) { |
|---|
| 216 | if( substr( $aVal['adm_link'], 0, strlen( 'javascript:' ) ) == 'javascript:' ) { |
|---|
| 217 | $sHref = 'javascript:void(0);'; |
|---|
| 218 | $sOnclick = 'onclick="' . $aVal['adm_link'] . '"'; |
|---|
| 219 | } else { |
|---|
| 220 | $sHref = $aVal['adm_link']; |
|---|
| 221 | $sOnclick = ''; |
|---|
| 222 | } |
|---|
| 223 | $sLink = '<a href="'.$sHref.'" '.$sOnclick.'>{iNum} '._t('_'.$aVal['capt']).'</a>'; |
|---|
| 224 | } else { |
|---|
| 225 | $sLink = '{iNum} '._t('_'.$aVal['capt']); |
|---|
| 226 | } |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | $sLink = str_replace('{iNum}', $iNum, $sLink); |
|---|
| 230 | $sCode = |
|---|
| 231 | ' |
|---|
| 232 | <div class="siteStatUnit" '. $sBlockId .'> |
|---|
| 233 | <img src="' . getTemplateIcon($aVal['icon']) . '" alt="" /> |
|---|
| 234 | ' . $sLink . ' |
|---|
| 235 | </div> |
|---|
| 236 | '; |
|---|
| 237 | |
|---|
| 238 | return $sCode; |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | function getSiteStatUser() { |
|---|
| 242 | global $aStat; |
|---|
| 243 | |
|---|
| 244 | $oDb = BxDolDb::getInstance(); |
|---|
| 245 | $oCache = $oDb->getDbCacheObject(); |
|---|
| 246 | $aStat = $oCache->getData($oDb->genDbCacheKey('sys_stat_site')); |
|---|
| 247 | if (null === $aStat) { |
|---|
| 248 | genSiteStatCache(); |
|---|
| 249 | $aStat = $oCache->getData($oDb->genDbCacheKey('sys_stat_site')); |
|---|
| 250 | } |
|---|
| 251 | |
|---|
| 252 | if( !$aStat ) |
|---|
| 253 | $aStat = array(); |
|---|
| 254 | |
|---|
| 255 | $sCode = '<div class="siteStatMain">'; |
|---|
| 256 | |
|---|
| 257 | foreach($aStat as $aVal) |
|---|
| 258 | $sCode .= getSiteStatBody($aVal); |
|---|
| 259 | |
|---|
| 260 | $sCode .= '<div class="clear_both"></div></div>'; |
|---|
| 261 | |
|---|
| 262 | return $sCode; |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | function genSiteStatFile($aVal) { |
|---|
| 266 | |
|---|
| 267 | bx_import('BxTemplMenu'); |
|---|
| 268 | $sLink = BxTemplMenu::getInstance() -> getCurrLink($aVal['link']); |
|---|
| 269 | $sLine = "'{$aVal['name']}'=>array('capt'=>'{$aVal['capt']}', 'query'=>'".addslashes($aVal['query'])."', 'link'=>'$sLink', 'icon'=>'{$aVal['icon']}'),\n"; |
|---|
| 270 | |
|---|
| 271 | return $sLine; |
|---|
| 272 | } |
|---|
| 273 | |
|---|
| 274 | function genAjaxyPopupJS($iTargetID, $sDivID = 'ajaxy_popup_result_div', $sRedirect = '') { |
|---|
| 275 | $iProcessTime = 1000; |
|---|
| 276 | |
|---|
| 277 | if ($sRedirect) |
|---|
| 278 | $sRedirect = "window.location = '$sRedirect';"; |
|---|
| 279 | |
|---|
| 280 | $sJQueryJS = <<<EOF |
|---|
| 281 | <script type="text/javascript"> |
|---|
| 282 | |
|---|
| 283 | setTimeout( function(){ |
|---|
| 284 | $('#{$sDivID}_{$iTargetID}').show({$iProcessTime}) |
|---|
| 285 | setTimeout( function(){ |
|---|
| 286 | $('#{$sDivID}_{$iTargetID}').hide({$iProcessTime}); |
|---|
| 287 | $sRedirect |
|---|
| 288 | }, 3000); |
|---|
| 289 | }, 500); |
|---|
| 290 | |
|---|
| 291 | </script> |
|---|
| 292 | EOF; |
|---|
| 293 | return $sJQueryJS; |
|---|
| 294 | } |
|---|
| 295 | |
|---|
| 296 | function getBlockWidth ($iAllWidth, $iUnitWidth, $iNumElements) { |
|---|
| 297 | $iAllowed = $iNumElements * $iUnitWidth; |
|---|
| 298 | if ($iAllowed > $iAllWidth) { |
|---|
| 299 | $iMax = (int)floor($iAllWidth / $iUnitWidth); |
|---|
| 300 | $iAllowed = $iMax*$iUnitWidth; |
|---|
| 301 | } |
|---|
| 302 | return $iAllowed; |
|---|
| 303 | } |
|---|
| 304 | |
|---|
| 305 | function getMemberLoginFormCode($sID = 'member_login_form', $sParams = '') |
|---|
| 306 | { |
|---|
| 307 | trigger_error ("Replace getMemberLoginFormCode with BxDolService::call('system', 'login_form', array(), 'TemplServiceLogin')", E_USER_ERROR); |
|---|
| 308 | } |
|---|
| 309 | |
|---|
| 310 | bx_import('BxDolAlerts'); |
|---|
| 311 | $oZ = new BxDolAlerts('system', 'design_included', 0); |
|---|
| 312 | $oZ->alert(); |
|---|
| 313 | |
|---|