/** * updates the site status * @param string $state */ function setSiteState($state, $folder = NULL) { if (is_null($folder)) { $folder = SERVERPATH . '/'; } $_configMutex = new zpMutex('cF', NULL, $folder); $_configMutex->lock(); $zp_cfg = @file_get_contents($folder . DATA_FOLDER . '/' . CONFIGFILE); $zp_cfg = updateConfigItem('site_upgrade_state', $state, $zp_cfg); storeConfig($zp_cfg, $folder); $_configMutex->unlock(); }
$r = sqrt($imw * $imh * $percent / ($watermark_width * $watermark_height)); if (!getOption('watermark_allow_upscale')) { $r = min(1, $r); } $nw = round($watermark_width * $r); $nh = round($watermark_height * $r); if ($nw != $watermark_width || $nh != $watermark_height) { $watermark = zp_imageResizeAlpha($watermark, $nw, $nh); } // Position Overlay in Bottom Right $dest_x = max(0, floor(($imw - $nw) * $offset_w)); $dest_y = max(0, floor(($imh - $nh) * $offset_h)); zp_copyCanvas($newim, $watermark, $dest_x, $dest_y, 0, 0, $nw, $nh); zp_imageKill($watermark); } $iMutex->unlock(); if (!zp_imageOutput($newim, $suffix, $cache_path, $quality) && DEBUG_IMAGE) { debugLog('full-image failed to create:' . $image); } } } if (!is_null($cache_path)) { if ($disposal == 'Download' || !OPEN_IMAGE_CACHE) { require_once dirname(__FILE__) . '/lib-MimeTypes.php'; $mimetype = getMimeString($suffix); $fp = fopen($cache_path, 'rb'); // send the right headers header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header("Content-Type: {$mimetype}"); header("Content-Length: " . filesize($image_path)); // dump the picture and stop the script
if (strpos($full_ip, '.') === false) { //ip v6 $separator = ':'; } else { $separator = '.'; } $x = array_slice(explode($separator, $full_ip), 0, $__config['accessThreshold_SENSITIVITY']); $ip = implode($separator, $x); unset($x); if (isset($recentIP[$ip]['lastAccessed']) && $__time - $recentIP[$ip]['lastAccessed'] > $__config['accessThreshold_IP_ACCESS_WINDOW']) { $recentIP[$ip] = array('accessed' => array(), 'locales' => array(), 'blocked' => 0, 'interval' => 0); } $recentIP[$ip]['lastAccessed'] = $__time; if (@$recentIP[$ip]['blocked']) { file_put_contents(SERVERPATH . '/' . DATA_FOLDER . '/recentIP', serialize($recentIP)); $mu->unlock(); exitZP(); } else { $recentIP[$ip]['accessed'][] = array('time' => $__time, 'ip' => $full_ip); $__locale = getUserLocale(); if (isset($recentIP[$ip]['locales'][$__locale])) { $recentIP[$ip]['locales'][$__locale]['ip'][$full_ip] = $__time; } else { $recentIP[$ip]['locales'][$__locale] = array('time' => $__time, 'ip' => array($full_ip => $__time)); } $__previous = $__interval = $__count = 0; array_walk($recentIP[$ip]['locales'], 'accessThreshold::walk', $__time); foreach ($recentIP[$ip]['locales'] as $key => $data) { if (is_null($data)) { unset($recentIP[$ip]['locales'][$key]); }
} } else { // The config file hasn't been created yet. Show the steps. ?> <div class="error"> <?php echo sprintf(gettext('The %1$s file does not exist.'), CONFIGFILE); ?> </div> <?php } if ($blindInstall) { ob_end_clean(); } ?> <?php if ($noxlate > 0 && !isset($_GET['checked'])) { setupLanguageSelector(); } ?> <br class="clearall" /> </div><!-- content --> </div><!-- main --> <?php printSetupFooter(); ?> </body> </html> <?php $setupMutex->unlock();
/** * * This method establishes the current set of database fields. It will add the * fields to the database if they are not already present. Fields from previous * constructor calls that are no longer in the list will be removed from the * database (along with any data associated with them.) * * @param array $newfields */ function constructor($me, $newfields) { $database = array(); foreach (getDBTables() as $table) { $tablecols = db_list_fields($table); foreach ($tablecols as $key => $datum) { $database[$table][$datum['Field']] = $datum; } } $current = $fields = $searchDefault = array(); if (extensionEnabled($me)) { //need to update the database tables. foreach ($newfields as $newfield) { $table = $newfield['table']; $name = $newfield['name']; if (!($existng = isset($database[$table][$name]))) { if (isset($newfield['searchDefault']) && $newfield['searchDefault']) { $searchDefault[] = $name; } } if (is_null($newfield['type'])) { if ($name == 'tags') { setOption('adminTagsTab', 1); } } else { switch (strtolower($newfield['type'])) { default: $dbType = strtoupper($newfield['type']); break; case 'int': $dbType = strtoupper($newfield['type']) . '(' . min(255, $newfield['size']) . ')'; if (isset($newfield['attribute'])) { $dbType .= ' ' . $newfield['attribute']; unset($newfield['attribute']); } break; case 'varchar': $dbType = strtoupper($newfield['type']) . '(' . min(255, $newfield['size']) . ')'; break; } if ($existng) { if (strtoupper($database[$table][$name]['Type']) != $dbType || empty($database[$table][$name]['Comment'])) { $cmd = ' CHANGE `' . $name . '`'; } else { $cmd = NULL; } unset($database[$table][$name]); } else { $cmd = ' ADD COLUMN'; } $sql = 'ALTER TABLE ' . prefix($newfield['table']) . $cmd . ' `' . $name . '` ' . $dbType; if (isset($newfield['attribute'])) { $sql .= ' ' . $newfield['attribute']; } if (isset($newfield['default'])) { $sql .= ' DEFAULT ' . $newfield['default']; } $sql .= " COMMENT 'optional_{$me}'"; if ((!$cmd || setupQuery($sql)) && in_array($newfield['table'], array('albums', 'images', 'news', 'news_categories', 'pages'))) { $fields[] = strtolower($newfield['name']); } $current[$newfield['table']][$newfield['name']] = $dbType; } } setOption(get_class($this) . '_addedFields', serialize($current)); if (!empty($searchDefault)) { $fieldExtenderMutex = new zpMutex('fE'); $fieldExtenderMutex->lock(); $engine = new SearchEngine(); $set_fields = $engine->allowedSearchFields(); $set_fields = array_unique(array_merge($set_fields, $searchDefault)); setOption('search_fields', implode(',', $set_fields)); $fieldExtenderMutex->unlock(); } } else { purgeOption(get_class($this) . '_addedFields'); } foreach ($database as $table => $fields) { //drop fields no longer defined foreach ($fields as $field => $orphaned) { if ($orphaned['Comment'] == "optional_{$me}") { $sql = 'ALTER TABLE ' . prefix($table) . ' DROP `' . $field . '`'; setupQuery($sql); } } } }