function plugin_footerDemoModeNotice($html) { global $TABLE_PREFIX; // only show in demo mode if (!inDemoMode()) { return $html; } // get minutes remaining $secondsRemaining = $_SESSION['demoCreatedTimeAsFloat'] + MAX_DEMO_TIME - time(); $minutesRemaining = intval($secondsRemaining / 60); // $html .= "<br/><br/><div style='font-size: 12px; color: #C00'><b>Demo Mode: Some features are disabled. Demo will reset in {$minutesRemaining} minutes.</b></div>"; return $html; }
function _init_startSession() { // Remove 0-byte session files on shutdown - added in v2.52 // PHP _always_ creates session files, even when the sessions are empty. This means 10 hits from a search engine spider creates // ... ten 0-byte session files that won't be removed until after session.gc_maxlifetime is reached. This can create tens of thousands // ... of unneeded files. This function removes zero-byte session files on shutdown by calling session destroy. For session in active // ... use, unsetting all $_SESSION values will cause the session file to be removed, but the same file will be recreated on next page-view. // PHP Docs Reference: "A file for each session (regardless of if any data is associated with that session) will be created. This is due to // ... the fact that a session is opened (a file is created) but no data is even written to that file. Note that this behavior is a // ... side-effect of the limitations of working with the file system... from: http://php.net/manual/en/session.installation.php function _remove_empty_session_file() { if (isset($_SESSION) && empty($_SESSION) && session_id()) { @session_destroy(); } } // removes session file register_shutdown_function('_remove_empty_session_file'); // remove session file on shutdown // note: run this here so even if we're not creating a session, session's created by other PHP code won't leave 0 byte files either. // check if we need to start a session $startSession = false; if (inCLI()) { $startSession = false; } elseif (inDemoMode()) { $startSession = true; } elseif (defined('IS_CMS_ADMIN')) { $startSession = true; } elseif (defined('START_SESSION')) { $startSession = true; } // if starting a session is explicitly requested if (!$startSession) { return; } startSessionIfRequired(); }
function disableInDemoMode($message = '', $interface = '', $showHeaderAndFooter = true) { if (!inDemoMode()) { return; } // display message //clearAlertsAndNotices(); // so previous alerts won't display if ($message == '') { alert(t('This feature is disabled in demo mode.')); } else { if ($message == 'settings') { alert(t('Changing settings is disabled in demo mode.')); } else { if ($message == 'plugins') { alert(t('Plugins are disabled in demo mode.')); } else { die("Unknown section name '" . htmlencode($section) . "'!"); } } } // display interface if (!$interface) { showInterface('home.php', $showHeaderAndFooter); } else { if ($interface == 'ajax') { die(t('This feature is disabled in demo mode.')); } else { showInterface($interface, $showHeaderAndFooter); } } // exit; }
: <?php echo inDemoMode() ? 'demo' : htmlencode($SETTINGS['mysql']['hostname']); ?> - <?php echo t('Database'); ?> : <?php echo inDemoMode() ? 'demo' : htmlencode($SETTINGS['mysql']['database']); ?> - <?php echo t('Username'); ?> : <?php echo inDemoMode() ? 'demo' : htmlencode($SETTINGS['mysql']['username']); ?> - <?php echo t('Table Prefix'); ?> : <?php echo htmlencode($TABLE_PREFIX); ?> <br/> <li><?php printf(t('To change %1$s settings edit %2$s'), 'MySQL', '/data/' . SETTINGS_FILENAME); ?> </td>
function eraseRecordsUploads($recordNumsAsCSV) { global $tableName; // if (inDemoMode()) { return; } // create query $where = "tableName = '" . mysql_escape($tableName) . "' AND "; $where .= " recordNum IN (" . mysql_escape($recordNumsAsCSV) . ")"; removeUploads($where); }
function _showUpload($fieldSchema, $record) { global $preSaveTempId, $SETTINGS, $menu; $prefixText = @$fieldSchema['fieldPrefix']; $description = @$fieldSchema['description']; if ($prefixText) { $prefixText .= "<br/>"; } // create uploadList url $uploadList = "?" . "menu=" . urlencode($menu) . "&action=uploadList" . "&fieldName=" . urlencode($fieldSchema['name']) . "&num=" . urlencode(@$_REQUEST['num']) . "&preSaveTempId=" . urlencode($preSaveTempId); // create uploadLink url $uploadLink = "?menu=" . urlencode($menu) . "&action=uploadForm" . "&fieldName=" . urlencode($fieldSchema['name']) . "&num=" . urlencode(@$_REQUEST['num']) . "&preSaveTempId=" . urlencode($preSaveTempId) . "&TB_iframe=true&height=350&width=700&modal=true"; // error checking $errors = ''; list($uploadDir, $uploadUrl) = getUploadDirAndUrl($fieldSchema); if (!file_exists($uploadDir)) { mkdir_recursive($uploadDir, 0755); } // create upload dir (if not possible, dir not exists error will show below) if (!file_exists($uploadDir)) { $errors .= "Upload directory '" . htmlencode($uploadDir) . "' doesn't exist!.<br/>\n"; } elseif (!is_writable($uploadDir)) { $errors .= "Upload directory '" . htmlencode($uploadDir) . "' isn't writable!.<br/>\n"; } // display errors if ($errors) { print <<<__HTML__ <tr> <td valign="top"><br/>{$fieldSchema['label']}<br/></td> <td><div id='alert'><span>{$errors}</span></div></td> </tr> __HTML__; return; } // display field ?> <tr> <td style="vertical-align: top"><?php echo $fieldSchema['label']; ?> </td> <td> <?php echo $prefixText; ?> <iframe id="<?php echo $fieldSchema['name']; ?> _iframe" src="<?php echo $uploadList; ?> " height="100" width="100%" frameborder="0" class="uploadIframe"></iframe><br/> <?php $displayDefaultLink = applyFilters('edit_show_upload_link', true, $fieldSchema, $record); ?> <?php if ($displayDefaultLink) { ?> <div style="position: relative; height: 24px;"> <div style="position: absolute; top: 6px; width: 100%; text-align: center;"> <?php if (inDemoMode()) { ?> <a href="javascript:alert('<?php echo jsEncode(t('This feature is disabled in demo mode.')); ?> ')"><b><?php echo t('Add or Upload File(s)'); ?> </b></a> <?php } else { ?> <a href="<?php echo $uploadLink; ?> " class="thickbox"><b><?php echo t('Add or Upload File(s)'); ?> </b></a> <?php } ?> </div> <div style="position: absolute; z-index: 1; width: 100%; text-align: center;"> <div id="<?php echo $fieldSchema['name']; ?> _uploadButton"></div> </div> </div> <?php $useFlashUploader = !@$SETTINGS['advanced']['disableFlashUploader']; ?> <?php if ($useFlashUploader && !inDemoMode()) { ?> <?php $fileExtCSV = implode(',', preg_split("/\\s*\\,\\s*/", strtolower($fieldSchema['allowedExtensions']))); ?> <div id="<?php echo $fieldSchema['name']; ?> _uploadTips" style="display: none; text-align: center; font-size: xx-small; margin-top: 2px;"> <?php $isMac = preg_match('/macintosh|mac os x/i', @$_SERVER['HTTP_USER_AGENT']); $key = $isMac ? '<Command>' : '<Ctrl>'; if (@$fieldSchema['maxUploads'] != 1) { echo htmlencode(t("Tip: hold {$key} to select multiple files")); } ?> <br/> <?php echo $description; ?> </div> <div class="uploadifyQueue" id="<?php echo $fieldSchema['name']; ?> _uploadQueue"></div> <script type="text/javascript">// <![CDATA[ $(document).ready(function() { $('#<?php echo $fieldSchema['name']; ?> _uploadButton').uploadify(generateUploadifyOptions({ 'script' : <?php echo json_encode(basename(@$_SERVER['SCRIPT_NAME'])); ?> , 'modifyAfterSave' : <?php echo count(getUploadInfoFields($fieldSchema['name'])); ?> , 'menu' : <?php echo json_encode($menu); ?> , 'fieldName' : <?php echo json_encode($fieldSchema['name']); ?> , 'num' : <?php echo json_encode(@$_REQUEST['num'] ? $_REQUEST['num'] : ''); ?> , 'preSaveTempId' : <?php echo json_encode($preSaveTempId); ?> , 'buttonText' : <?php echo json_encode(t('Upload File(s)')); ?> , 'fileExtCSV' : <?php echo json_encode($fileExtCSV); ?> , 'maxUploadSizeKB' : <?php echo json_encode($fieldSchema['checkMaxUploadSize'] ? $fieldSchema['maxUploadSizeKB'] : 0); ?> , 'loginDataEncoded' : <?php echo json_encode(@$_COOKIE[loginCookie_name(true)]); ?> , 'queueID' : <?php echo json_encode($fieldSchema['name'] . "_uploadQueue"); ?> })); }); // ]]></script> <?php } ?> <?php } ?> </td> </tr> <?php }