Cheetah
design.inc.php
Go to the documentation of this file.
1 <?php
2 
8 require_once('header.inc.php');
9 require_once(CH_DIRECTORY_PATH_INC . 'admin.inc.php');
10 require_once(CH_DIRECTORY_PATH_INC . 'protected.inc.php');
11 require_once(CH_DIRECTORY_PATH_INC . 'db.inc.php');
12 require_once(CH_DIRECTORY_PATH_INC . 'languages.inc.php');
13 require_once(CH_DIRECTORY_PATH_INC . 'prof.inc.php');
14 require_once(CH_DIRECTORY_PATH_INC . 'banners.inc.php');
15 require_once(CH_DIRECTORY_PATH_INC . 'membership_levels.inc.php');
16 require_once(CH_DIRECTORY_PATH_INC . 'params.inc.php');
17 require_once(CH_DIRECTORY_PATH_CLASSES . 'ChRSS.php');
18 
19 require_once(CH_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/scripts/ChTemplMenu.php");
20 require_once(CH_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/scripts/ChTemplFunctions.php");
21 
23 
24 $_page['js'] = 1;
25 
32 function spacer($width, $height)
33 {
34  return '<img src="' . CH_WSB_URL_ROOT . 'templates/base/images/spacer.gif" width="' . $width . '" height="' . $height . '" alt="" />';
35 }
36 
44 function DesignProgressPos($text, $width, $max_pos, $curr_pos, $progress_num = '1')
45 {
46  $percent = ($max_pos) ? $curr_pos * 100 / $max_pos : $percent = 0;
47  return DesignProgress($text, $width, $percent, $progress_num);
48 }
49 
56 function DesignProgress($text, $width, $percent, $progress_num, $id = '')
57 {
58  $ret = "";
59  $ret .= '<div class="rate_block" style="width:' . $width . 'px;">';
60  $ret .= '<div class="rate_text"' . ($id ? " id=\"{$id}_text\"" : '') . '>';
61  $ret .= $text;
62  $ret .= '</div>';
63  $ret .= '<div class="rate_scale"' . ($id ? " id=\"{$id}_scale\"" : '') . '>';
64  $ret .= '<div class="rate_bar" ' . ($id ? "id=\"{$id}_bar\"" : '') . ' style="width:' . round($percent) . '%;"></div>';
65  $ret .= '</div>';
66  $ret .= '</div>';
67 
68  return $ret;
69 }
70 
78 function DesignBoxContent($title, $content, $db_num = 0, $caption_item = '', $bottom_item = '')
79 {
80  return $GLOBALS['oSysTemplate']->parseHtmlByName('designbox_' . (int)$db_num . '.html', array(
81  'title' => $title,
82  'caption_item' => $caption_item,
83  'designbox_content' => $content,
84  'bottom_item' => $bottom_item
85  ));
86 }
87 
91 function PageCode($oTemplate = null)
92 {
93  chPageCode($oTemplate);
94 }
95 
100 {
101  $now = gmdate('D, d M Y H:i:s') . ' GMT';
102 
103  header("Expires: $now");
104  header("Last-Modified: $now");
105  header("Cache-Control: no-cache, must-revalidate");
106  header("Pragma: no-cache");
107 }
108 
114 function SelectOptions($sField, $sDefault = '', $sUseLKey = 'LKey')
115 {
116  $aValues = getFieldValues($sField, $sUseLKey);
117 
118  $sRet = '';
119  foreach ($aValues as $sKey => $sValue) {
120  $sStr = _t($sValue);
121  $sSelected = ($sKey == $sDefault) ? 'selected="selected"' : '';
122  $sRet .= "<option value=\"$sKey\" $sSelected>$sStr</option>\n";
123  }
124 
125  return $sRet;
126 }
127 
128 function getFieldValues($sField, $sUseLKey = 'LKey')
129 {
130  global $aPreValues;
131 
132  $sValues = db_value("SELECT `Values` FROM `sys_profile_fields` WHERE `Name` = '$sField'");
133 
134  if (substr($sValues, 0, 2) == '#!') {
135  //predefined list
136  $sKey = substr($sValues, 2);
137 
138  $aValues = array();
139 
140  $aMyPreValues = $aPreValues[$sKey];
141  if (!$aMyPreValues) {
142  return $aValues;
143  }
144 
145  foreach ($aMyPreValues as $sVal => $aVal) {
146  $sMyUseLKey = $sUseLKey;
147  if (!isset($aMyPreValues[$sVal][$sUseLKey])) {
148  $sMyUseLKey = 'LKey';
149  }
150 
151  $aValues[$sVal] = $aMyPreValues[$sVal][$sMyUseLKey];
152  }
153  } else {
154  $aValues1 = explode("\n", $sValues);
155 
156  $aValues = array();
157  foreach ($aValues1 as $iKey => $sValue) {
158  $aValues[$sValue] = "_$sValue";
159  }
160  }
161 
162  return $aValues;
163 }
164 
165 function get_member_thumbnail($ID, $float, $bGenProfLink = false, $sForceSex = 'visitor', $aOnline = array())
166 {
167  return $GLOBALS['oFunctions']->getMemberThumbnail($ID, $float, $bGenProfLink, $sForceSex, true, 'medium', $aOnline);
168 }
169 
170 function get_member_icon($ID, $float = 'none', $bGenProfLink = false)
171 {
172  return $GLOBALS['oFunctions']->getMemberIcon($ID, $float, $bGenProfLink);
173 }
174 
175 function MsgBox($sText, $iTimer = 0)
176 {
177  return $GLOBALS['oFunctions'] -> msgBox($sText, $iTimer);
178 }
179 
180 function AdvMsgBox($sText, $aOptions = array())
181 {
182  return $GLOBALS['oFunctions'] -> advMsgBox($sText, $aOptions);
183 }
184 
186 {
187  return $GLOBALS['oFunctions'] -> loadingBox($sName);
188 }
189 function PopupBox($sName, $sTitle, $sContent, $aActions = array())
190 {
191  return $GLOBALS['oFunctions'] -> popupBox($sName, $sTitle, $sContent, $aActions);
192 }
193 function getTemplateIcon($sFileName)
194 {
195  return $GLOBALS['oFunctions']->getTemplateIcon($sFileName);
196 }
197 
198 function getTemplateImage($sFileName)
199 {
200  return $GLOBALS['oFunctions']->getTemplateImage($sFileName);
201 }
202 
204 {
205  global $site;
206  $aVer = explode('.', $site['ver']);
207 
208  // version output made for debug possibilities.
209  // randomizing made for security issues. do not change it...
210  $aVerR[0] = $aVer[0];
211  $aVerR[1] = rand(0, 100);
212  $aVerR[2] = $aVer[1];
213  $aVerR[3] = rand(0, 100);
214  $aVerR[4] = $site['build'];
215 
216  //remove leading zeros
217  while ($aVerR[4][0] === '0') {
218  $aVerR[4] = substr($aVerR[4], 1);
219  }
220 
221  return '<!-- ' . implode(' ', $aVerR) . ' -->';
222 }
223 
224 // ----------------------------------- site statistick functions --------------------------------------//
225 
226 function getSiteStatUser()
227 {
228  global $aStat;
229  $aStat = getSiteStatArray();
230 
231  $sCode = '<div class="siteStatMain">';
232 
233  foreach ($aStat as $aVal) {
234  $sCode .= $GLOBALS['oFunctions']->getSiteStatBody($aVal);
235  }
236 
237  $sCode .= '<div class="clear_both"></div></div>';
238 
239  return $sCode;
240 }
241 
242 function genAjaxyPopupJS($iTargetID, $sDivID = 'ajaxy_popup_result_div', $sRedirect = '')
243 {
244  $iProcessTime = 1000;
245 
246  if ($sRedirect) {
247  $sRedirect = "window.location = '$sRedirect';";
248  }
249 
250  $sJQueryJS = <<<EOF
251 <script type="text/javascript">
252 
253 setTimeout( function(){
254  $('#{$sDivID}_{$iTargetID}').show({$iProcessTime})
255  setTimeout( function(){
256  $('#{$sDivID}_{$iTargetID}').hide({$iProcessTime});
257  $sRedirect
258  }, 3000);
259 }, 500);
260 
261 </script>
262 EOF;
263  return $sJQueryJS;
264 }
265 
266 function getBlockWidth($iAllWidth, $iUnitWidth, $iNumElements)
267 {
268  $iAllowed = $iNumElements * $iUnitWidth;
269  if ($iAllowed > $iAllWidth) {
270  $iMax = (int)floor($iAllWidth / $iUnitWidth);
271  $iAllowed = $iMax*$iUnitWidth;
272  }
273  return $iAllowed;
274 }
275 
276 function getMemberJoinFormCode($sParams = '')
277 {
278  if (getParam('reg_by_inv_only') == 'on' && getID($_COOKIE['idFriend']) == 0) {
279  return MsgBox(_t('_registration by invitation only'));
280  }
281 
282  $sCodeBefore = '';
283  $sCodeAfter = '';
284 
285  ch_import("ChWsbJoinProcessor");
286  $oJoin = new ChWsbJoinProcessor();
287  $sCode = $oJoin->process();
288 
289  ch_import('ChWsbAlerts');
290  $oAlert = new ChWsbAlerts('profile', 'show_join_form', 0, 0, array('oJoin' => $oJoin, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCodeBefore, 'sCustomHtmlAfter' => &$sCodeAfter, 'sCode' => &$sCode));
291  $oAlert->alert();
292 
293  $sAuthCode = getMemberAuthCode('_sys_auth_join_with');
294 
295  $sAction = 'join';
296  return $GLOBALS['oSysTemplate']->parseHtmlByName('login_join_form.html', array(
297  'action' => $sAction,
298  'ch_if:show_auth' => array(
299  'condition' => !empty($sAuthCode),
300  'content' => array(
301  'auth' => $sAuthCode
302  )
303  ),
304  'custom_code_before' => $sCodeBefore,
305  'form' => $sCode,
306  'custom_code_after' => $sCodeAfter,
307  'ch_if:show_text' => array(
308  'condition' => false,
309  'content' => array(
310  'action' => $sAction,
311  'text' => _t('_join_form_note', CH_WSB_URL_ROOT)
312  )
313  )
314  ));
315 }
316 
317 function getMemberLoginFormCode($sID = 'member_login_form', $sParams = '')
318 {
319  $aForm = array(
320  'form_attrs' => array(
321  'id' => $sID,
322  'action' => CH_WSB_URL_ROOT . 'member.php',
323  'method' => 'post',
324  'onsubmit' => "validateLoginForm(this); return false;",
325  ),
326  'inputs' => array(
327  'nickname' => array(
328  'type' => 'text',
329  'name' => 'ID',
330  'caption' => _t('_NickName'),
331  ),
332  'password' => array(
333  'type' => 'password',
334  'name' => 'Password',
335  'caption' => _t('_Password'),
336  ),
337  'rememberme' => array(
338  'type' => 'hidden',
339  'name' => 'rememberMe',
340  'value' => 'on',
341  ),
342  'relocate' => array(
343  'type' => 'hidden',
344  'name' => 'relocate',
345  'value'=> isset($_REQUEST['relocate']) ? $_REQUEST['relocate'] : CH_WSB_URL_ROOT . 'member.php',
346  ),
347  'LogIn' => array(
348  'type' => 'submit',
349  'name' => 'LogIn',
350  'caption' => '',
351  'value' => _t('_Login'),
352  ),
353  'forgot' => array(
354  'type' => 'custom',
355  'colspan' => '2',
356  'tr_attrs' => array(
357  'class' => 'ch-form-element-forgot'
358  ),
359  'content' => '<a href="' . CH_WSB_URL_ROOT . 'forgot.php">' . _t('_forgot_your_password') . '?</a>',
360  )
361  ),
362  );
363 
365 
366 
367  ch_import('ChWsbAlerts');
368  $sCustomHtmlBefore = '';
369  $sCustomHtmlAfter = '';
370  $oAlert = new ChWsbAlerts('profile', 'show_login_form', 0, 0, array('oForm' => $oForm, 'sParams' => &$sParams, 'sCustomHtmlBefore' => &$sCustomHtmlBefore, 'sCustomHtmlAfter' => &$sCustomHtmlAfter));
371  $oAlert->alert();
372 
373  $sAuthCode = getMemberAuthCode('_sys_auth_login_with');
374 
375  $sAction = 'login';
376  return $GLOBALS['oSysTemplate']->parseHtmlByName('login_join_form.html', array(
377  'action' => $sAction,
378  'ch_if:show_auth' => array(
379  'condition' => !empty($sAuthCode) && false === strpos($sParams, 'disable_external_auth'),
380  'content' => array(
381  'auth' => $sAuthCode
382  )
383  ),
384  'custom_code_before' => $sCustomHtmlBefore,
385  'form' => $oForm->getCode(),
386  'custom_code_after' => $sCustomHtmlAfter,
387  'ch_if:show_text' => array(
388  'condition' => strpos($sParams, 'no_join_text') === false,
389  'content' => array(
390  'action' => $sAction,
391  'text' => _t('_login_form_description2join', CH_WSB_URL_ROOT)
392  )
393  )
394  ));
395 }
396 
397 function getMemberAuthCode($sTitleKey = '')
398 {
399  $aAuthTypes = $GLOBALS['MySQL']-> fromCache('sys_objects_auths', 'getAll', 'SELECT * FROM `sys_objects_auths`');
400  if (empty($aAuthTypes) || !is_array($aAuthTypes)) {
401  return '';
402  }
403 
404  $aTmplButtons = array();
405  foreach ($aAuthTypes as $iKey => $aItems) {
406  $sTitle = _t($aItems['Title']);
407 
408  $aTmplButtons[] = array(
409  'href' => !empty($aItems['Link']) ? CH_WSB_URL_ROOT . $aItems['Link'] : 'javascript:void(0)',
410  'ch_if:show_onclick' => array(
411  'condition' => !empty($aItems['OnClick']),
412  'content' => array(
413  'onclick' => 'javascript:' . $aItems['OnClick']
414  )
415  ),
416  'ch_if:show_icon' => array(
417  'condition' => !empty($aItems['Icon']),
418  'content' => array(
419  'icon' => $aItems['Icon']
420  )
421  ),
422  'title' => !empty($sTitleKey) ? _t($sTitleKey, $sTitle) : $sTitle
423  );
424  }
425 
426  return $GLOBALS['oSysTemplate']->parseHtmlByName('login_join_auth.html', array(
427  'ch_repeat:buttons' => $aTmplButtons
428  ));
429 }
430 
431 ch_import('ChWsbAlerts');
432 $oZ = new ChWsbAlerts('system', 'design_included', 0);
433 $oZ->alert();
header
</code > Be careful enabling this directive if you have a redirector script that does not use the< code > Location</code > HTTP header
Definition: URI.MungeResources.txt:10
ChTemplFormView
Definition: ChTemplFormView.php:11
DesignProgressPos
DesignProgressPos($text, $width, $max_pos, $curr_pos, $progress_num='1')
Definition: design.inc.php:44
LoadingBox
LoadingBox($sName)
Definition: design.inc.php:185
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
getMemberAuthCode
getMemberAuthCode($sTitleKey='')
Definition: design.inc.php:397
get_member_icon
get_member_icon($ID, $float='none', $bGenProfLink=false)
Definition: design.inc.php:170
$sCode
$sCode
Definition: explanation.php:19
SelectOptions
SelectOptions($sField, $sDefault='', $sUseLKey='LKey')
Definition: design.inc.php:114
getFieldValues
getFieldValues($sField, $sUseLKey='LKey')
Definition: design.inc.php:128
$ret
$ret
Definition: index.php:39
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$oAlert
$oAlert
Definition: embed.php:15
php
send_headers_page_changed
send_headers_page_changed()
Definition: design.inc.php:99
$oZ
$oZ
Definition: design.inc.php:432
show
a choreographic work or entertainment in dumb show
Definition: license.txt:19
AdvMsgBox
AdvMsgBox($sText, $aOptions=array())
Definition: design.inc.php:180
getSiteStatUser
getSiteStatUser()
Definition: design.inc.php:226
$oForm
$oForm
Definition: host_tools.php:42
ChWsbAlerts
Definition: ChWsbAlerts.php:39
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
getVersionComment
getVersionComment()
Definition: design.inc.php:203
DesignProgress
DesignProgress($text, $width, $percent, $progress_num, $id='')
Definition: design.inc.php:56
get_member_thumbnail
get_member_thumbnail($ID, $float, $bGenProfLink=false, $sForceSex='visitor', $aOnline=array())
Definition: design.inc.php:165
$sTitle
$sTitle
Definition: actions.inc.php:13
getTemplateIcon
getTemplateIcon($sFileName)
Definition: design.inc.php:193
ChWsbJoinProcessor
Definition: ChWsbJoinProcessor.php:17
$_page
$_page['js']
Definition: design.inc.php:24
$site
$site['ver']
Definition: version.inc.php:8
$sJQueryJS
$sJQueryJS
Definition: list_pop.php:32
$_REQUEST
$_REQUEST['action']
Definition: cmd.php:11
type
if(!defined("USER_STATUS_TYPE")) define("USER_STATUS_TYPE" type
Definition: constants.inc.php:13
getMemberJoinFormCode
getMemberJoinFormCode($sParams='')
Definition: design.inc.php:276
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
PageCode
PageCode($oTemplate=null)
Definition: design.inc.php:91
getBlockWidth
getBlockWidth($iAllWidth, $iUnitWidth, $iNumElements)
Definition: design.inc.php:266
getSiteStatArray
getSiteStatArray()
Definition: utils.inc.php:1184
getTemplateImage
getTemplateImage($sFileName)
Definition: design.inc.php:198
getMemberLoginFormCode
getMemberLoginFormCode($sID='member_login_form', $sParams='')
Definition: design.inc.php:317
genAjaxyPopupJS
genAjaxyPopupJS($iTargetID, $sDivID='ajaxy_popup_result_div', $sRedirect='')
Definition: design.inc.php:242
PopupBox
PopupBox($sName, $sTitle, $sContent, $aActions=array())
Definition: design.inc.php:189
db_value
db_value($query, $bindings=[], $error_checking=true, $index=0)
Definition: db.inc.php:98
getID
getID( $str, $with_email=1)
Definition: admin.inc.php:139
$aForm
$aForm
Definition: forgot.php:43
$ID
$ID
Definition: click.php:11
$sAction
$sAction
Definition: categories.php:274
DesignBoxContent
DesignBoxContent($title, $content, $db_num=0, $caption_item='', $bottom_item='')
Definition: design.inc.php:78
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
spacer
spacer($width, $height)
Definition: design.inc.php:32
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$db_color_index
$db_color_index
Definition: design.inc.php:22
$sName
$sName
Definition: ChWsbAdminTools.php:853
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10