function defaultCodeblocks_codebox($current, $object, $number) { if (empty($current) && getOption('defaultCodeblocks_object_' . $object->table)) { $defaultCodeBlocks = new defaultCodeblocks(); $blocks = getSerializedArray($defaultCodeBlocks->getCodeblock()); if (isset($blocks[$number])) { $current = $blocks[$number]; } } return $current; }
/** * Creates an instance of a gallery * * @return Gallery */ function __construct() { // Set our album directory $this->albumdir = ALBUM_FOLDER_SERVERPATH; $data = getOption('gallery_data'); if ($data) { $this->data = getSerializedArray($data); } if (isset($this->data['unprotected_pages'])) { $pages = getSerializedArray($this->data['unprotected_pages']); if (is_array($pages)) { $this->unprotected_pages = $pages; } // protect against a failure } }
static function handleOption($option, $currentValue) { global $_zp_authority; if ($option == 'ldap_group_map_custom') { $groups = $_zp_authority->getAdministrators('groups'); $ldap = getSerializedArray(getOption('ldap_group_map')); if (empty($groups)) { echo gettext('No groups or templates are defined'); } else { ?> <dl> <dt><em><?php echo gettext('ZenPhoto20 group'); ?> </em></dt> <dd><em><?php echo gettext('LDAP group'); ?> </em></dd> <?php foreach ($groups as $group) { if ($group['name'] != 'template') { if (array_key_exists($group['user'], $ldap)) { $ldapgroup = $ldap[$group['user']]; } else { $ldapgroup = $group['user']; } ?> <dt> <?php echo html_encode($group['user']); ?> </dt> <dd> <?php echo '<input type="textbox" name="LDAP_group_for_' . $group['id'] . '" value="' . html_encode($ldapgroup) . '">'; ?> </dd> <?php } } ?> </dl> <?php } } }
function __construct() { global $_zp_authority, $_userAddressFields; $firstTime = false; $tablecols = db_list_fields('administrators'); foreach ($tablecols as $key => $datum) { if ($datum['Field'] == 'custom_data') { $firstTime = true; enableExtension('userAddressFields', true); break; } } parent::constructor('userAddressFields', self::fields()); if ($firstTime) { // migrate the custom data user data $result = query('SELECT * FROM ' . prefix('administrators') . ' WHERE `valid`!=0'); if ($result) { while ($row = db_fetch_assoc($result)) { $custom = getSerializedArray($row['custom_data']); if (!empty($custom)) { $sql = 'UPDATE ' . prefix('administrators') . ' SET '; foreach ($custom as $field => $val) { $sql .= '`' . $field . '`=' . db_quote($val) . ','; } setupQuery($sql); } } db_free_result($result); } setupQuery('ALTER TABLE ' . prefix('administrators') . ' DROP `custom_data`'); } $cloneid = bin2hex(FULLWEBPATH); if (OFFSET_PATH == 2 && isset($_SESSION['admin'][$cloneid])) { $user = unserialize($_SESSION['admin'][$cloneid]); $user2 = $_zp_authority->getAnAdmin(array('`user`=' => $user->getUser(), '`pass`=' => $user->getPass(), '`valid`=' => 1)); if ($user2) { foreach (userAddressFields::fields() as $field) { $user2->set($field['name'], $user->get($field['name'])); } $user2->save(); } } }
static function handleOptionSave($themename, $themealbum) { $x = str_replace(':', '.', getOption('accessThreshold_SENSITIVITY')); $sensitivity = 0; foreach (explode('.', $x) as $v) { if ($v) { $sensitivity++; } else { break; } } if (getOption('accessThreshold_CLEAR')) { $recentIP = array(); setOption('accessThreshold_CLEAR', 0); } else { $recentIP = getSerializedArray(@file_get_contents(SERVERPATH . '/' . DATA_FOLDER . '/recentIP')); } $recentIP['config'] = array('accessThreshold_IP_RETENTION' => getOption('accessThreshold_IP_RETENTION'), 'accessThreshold_THRESHOLD' => getOption('accessThreshold_THRESHOLD'), 'accessThreshold_IP_ACCESS_WINDOW' => getOption('accessThreshold_IP_ACCESS_WINDOW'), 'accessThreshold_LocaleCount' => getOption('accessThreshold_LocaleCount'), 'accessThreshold_SENSITIVITY' => $sensitivity); file_put_contents(SERVERPATH . '/' . DATA_FOLDER . '/recentIP', serialize($recentIP)); }
/** * * 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) { $previous = getSerializedArray(getOption(get_class($this) . '_addedFields')); $current = $fields = array(); if (extensionEnabled($me)) { //need to update the database tables. foreach ($newfields as $newfield) { $current[$newfield['table']][$newfield['name']] = true; unset($previous[$newfield['table']][$newfield['name']]); switch (strtolower($newfield['type'])) { default: $dbType = strtoupper($newfield['type']); break; case 'int': case 'varchar': $dbType = strtoupper($newfield['type']) . '(' . min(255, $newfield['size']) . ')'; break; } $sql = 'ALTER TABLE ' . prefix($newfield['table']) . ' ADD COLUMN `' . $newfield['name'] . '` ' . $dbType; if (query($sql, false) && in_array($newfield['table'], array('albums', 'images', 'news', 'news_categories', 'pages'))) { $fields[] = strtolower($newfield['name']); } } setOption(get_class($this) . '_addedFields', serialize($current)); } else { purgeOption(get_class($this) . '_addedFields'); } $set_fields = array_flip(explode(',', getOption('search_fields'))); foreach ($previous as $table => $orpahed) { //drop fields no longer defined foreach ($orpahed as $field => $v) { unset($set_fields[$field]); $sql = 'ALTER TABLE ' . prefix($table) . ' DROP `' . $field . '`'; query($sql, false); } } $set_fields = array_unique(array_merge($fields, array_flip($set_fields))); setOption('search_fields', implode(',', $set_fields)); }
function __construct() { global $_userAddressFields; $firstTime = extensionEnabled('userAddressFields') && is_null(getOption('userAddressFields_addedFields')); parent::constructor('userAddressFields', self::fields()); if ($firstTime) { // migrate the custom data user data $result = query('SELECT * FROM ' . prefix('administrators') . ' WHERE `valid`!=0'); if ($result) { while ($row = db_fetch_assoc($result)) { $custom = getSerializedArray($row['custom_data']); if (!empty($custom)) { $sql = 'UPDATE ' . prefix('administrators') . ' SET '; foreach ($custom as $field => $val) { $sql .= '`' . $field . '`=' . db_quote($val) . ','; } $sql .= '`custom_data`=NULL WHERE `id`=' . $row['id']; query($sql); } } db_free_result($result); } } }
/** * Gets the content of a codeblock for an image, album or Zenpage newsarticle or page. * * The priority for codeblocks will be (based on context) * 1: articles * 2: pages * 3: images * 4: albums * 5: gallery. * * This means, for instance, if we are in ZP_ZENPAGE_NEWS_ARTICLE context we will use the news article * codeblock even if others are available. * * Note: Echoing this array's content does not execute it. Also no special chars will be escaped. * Use printCodeblock() if you need to execute script code. * * @param int $number The codeblock you want to get * @param mixed $what optonal object for which you want the codeblock * * @return string */ function getCodeblock($number = 1, $object = NULL) { global $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_gallery, $_zp_gallery_page; if (!$number) { setOptionDefault('codeblock_first_tab', 0); } if (!is_object($object)) { if ($_zp_gallery_page == 'index.php') { $object = $_zp_gallery; } if (in_context(ZP_ALBUM)) { $object = $_zp_current_album; } if (in_context(ZP_IMAGE)) { $object = $_zp_current_image; } if (in_context(ZP_ZENPAGE_PAGE)) { if ($_zp_current_zenpage_page->checkAccess()) { $object = $_zp_current_zenpage_page; } } if (in_context(ZP_ZENPAGE_NEWS_ARTICLE)) { if ($_zp_current_zenpage_news->checkAccess()) { $object = $_zp_current_zenpage_news; } } } if (!is_object($object)) { return NULL; } $codeblock = getSerializedArray($object->getcodeblock()); $codeblock = zp_apply_filter('codeblock', @$codeblock[$number], $object, $number); if ($codeblock) { $codeblock = applyMacros($codeblock); } return $codeblock; }
/** * Searches out i.php image links and replaces them with cache links if image is cached * @param string $text * @return string */ static function updateImageProcessorLink($text) { if (is_string($text) && preg_match('/^a:[0-9]+:{/', $text)) { // serialized array $text = getSerializedArray($text); $serial = true; } else { $serial = false; } if (is_array($text)) { foreach ($text as $key => $textelement) { $text[$key] = self::updateImageProcessorLink($textelement); } if ($serial) { $text = serialize($text); } } else { preg_match_all('|<\\s*img.*?\\ssrc\\s*=\\s*"([^"]*)?|', $text, $matches); foreach ($matches[1] as $key => $match) { preg_match('|.*i\\.php\\?(.*)|', $match, $imgproc); if ($imgproc) { $match = preg_split('~\\&[amp;]*~', $imgproc[1]); $set = array(); foreach ($match as $v) { $s = explode('=', $v); $set[$s[0]] = $s[1]; } $args = getImageArgs($set); $imageuri = getImageURI($args, urldecode($set['a']), urldecode($set['i']), NULL); if (strpos($imageuri, 'i.php') === false) { $text = str_replace($matches[1][$key], $imageuri, $text); } } } } return $text; }
/** * Removes duplicate entries in multi dimensional array. * From kenrbnsn at rbnsn dot com http://uk.php.net/manual/en/function.array-unique.php#57202 * @param array $array * @return array */ function getAllTagsFromAlbum_multi_unique($array) { foreach ($array as $k => $na) { $new[$k] = serialize($na); } $uniq = array_unique($new); foreach ($uniq as $k => $ser) { $new1[$k] = getSerializedArray($ser); } return $new1; }
header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/search_statistics/search_analysis.php'); exitZP(); } $zenphoto_tabs['overview']['subtabs'] = array(gettext('Analysis') => ''); printAdminHeader('overview', 'analysis'); echo '</head>'; $sql = 'SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`="search_statistics"'; $data = query($sql); $ip_maxvalue = $criteria_maxvalue = $criteria_maxvalue_f = $terms_maxvalue = 1; $results_f = $results = $terms = $sites = array(); $bargraphmaxsize = 400; $maxiterations = array(); $opChars = array('(', ')', '&', '|', '!', ','); if ($data) { while ($datum = db_fetch_assoc($data)) { $element = getSerializedArray($datum['data']); $ip = $datum['aux']; if (array_key_exists($ip, $sites)) { $sites[$ip]++; if ($ip_maxvalue < $sites[$ip]) { $ip_maxvalue = $sites[$ip]; } } else { $sites[$ip] = 1; } if (is_array($element)) { $maxiterations[$element['iteration']] = 1; $searchset = $element['data']; $type = $element['type']; $success = $element['success']; $instance = implode(' ', $searchset);
static function passwordAllowed($msg, $pwd, $user) { if ($id = $user->getID() > 0) { $store = query_single_row('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`=' . db_quote('user_expiry_usedPasswords') . ' AND `aux`=' . $id); if ($store) { $used = getSerializedArray($store['data']); if (in_array($pwd, $used)) { if (zp_loggedin(ADMIN_RIGHTS)) { // persons with ADMIN_RIGHTS get to override this so they can reset a passwrod for a user unset($used[$pwd]); } else { return gettext('You have used that password recently. Please choose a different password.'); } } if (count($used) > 9) { $used = array_slice($used, 1); } } else { $used = array(); } array_push($used, $pwd); if ($store) { query('UPDATE ' . prefix('plugin_storage') . 'SET `data`=' . db_quote(serialize($used)) . ' WHERE `type`=' . db_quote('user_expiry_usedPasswords') . ' AND `aux`=' . $id); } else { query('INSERT INTO ' . prefix('plugin_storage') . ' (`type`, `aux`, `data`) VALUES (' . db_quote('user_expiry_usedPasswords') . ',' . $id . ',' . db_quote(serialize($used)) . ')'); } } return $msg; }
<?php /* * popup to display IP list for an entry * * @author Stephen Billard (sbillard) * * Copyright 2016 by Stephen L Billard for use in {@link https://github.com/ZenPhoto20/ZenPhoto20 ZenPhoto20} * * @package plugins * @subpackage admin */ require_once dirname(dirname(dirname(__FILE__))) . '/admin-globals.php'; $ip = sanitize($_GET['selected_ip']); $recentIP = getSerializedArray(@file_get_contents(SERVERPATH . '/' . DATA_FOLDER . '/recentIP')); $localeList = $ipList = array(); if (isset($recentIP[$ip])) { foreach ($recentIP[$ip]['accessed'] as $instance) { $ipList[] = $instance['ip']; } $ipList = array_unique($ipList); foreach ($recentIP[$ip]['locales'] as $instance => $data) { foreach ($data['ip'] as $ipl => $time) { $localeList[$ipl][$instance] = $time; } } } ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
<h1><?php echo gettext("edit comment"); ?> </h1> <?php zp_apply_filter('admin_note', 'comments', 'edit'); ?> <div id="container"> <div class="box" style="padding: 10px"> <?php $id = sanitize_numeric($_GET['id']); $commentarr = query_single_row("SELECT * FROM " . prefix('comments') . " WHERE id = {$id} LIMIT 1"); if ($commentarr) { extract($commentarr); $commentarr = array_merge($commentarr, getSerializedArray($commentarr['custom_data'])); ?> <form class="dirtylistening" onReset="setClean('form_editcomment');" id="form_editcomment" action="?action=savecomment" method="post" autocomplete="off"> <?php XSRFToken('savecomment'); ?> <input type="hidden" name="id" value="<?php echo $id; ?> " /> <span class="buttons"> <p class="buttons"> <a href="javascript:if(confirm('<?php echo gettext('Are you sure you want to delete this comment?'); ?> ')) { window.location='?action=deletecomment&id=<?php
setOption('pluginEnabler_currentset', serialize(array_keys(getEnabledPlugins()))); $report = gettext('Current enabled plugins remembered'); } if (isset($_GET['pluginsEnable'])) { $paths = getPluginFiles('*.php'); $pluginlist = array_keys($paths); switch ($setting = sanitize_numeric($_GET['pluginsEnable'])) { case 0: $report = gettext('Plugins disabled'); break; case 1: $report = gettext('Zenphoto plugins enabled'); break; case 2: $report = gettext('Remembered plugins enabled'); $savedlist = getSerializedArray(getOption('pluginEnabler_currentset')); break; case 3: $report = gettext('All plugins enabled'); break; } foreach ($pluginlist as $extension) { if ($extension != 'pluginEnabler') { $opt = 'zp_plugin_' . $extension; switch ($setting) { case 1: if (strpos($paths[$extension], ZENFOLDER) !== false && $extension != 'show_not_logged-in') { $enable = true; break; } case 0:
/** * Updates the path to the cache folder * @param mixed $text * @param string $target * @param string $update * @return mixed */ function updateCacheName($text, $target, $update) { if (is_string($text) && preg_match('/^a:[0-9]+:{/', $text)) { // serialized array $text = getSerializedArray($text); $serial = true; } else { $serial = false; } if (is_array($text)) { foreach ($text as $key => $textelement) { $text[$key] = updateCacheName($textelement, $target, $update); } if ($serial) { $text = serialize($text); } } else { $text = str_replace($target, $update, $text); } return $text; }
function listDBUses($pattern) { $lookfor = array('images', 'albums', 'news', 'pages'); $found = array(); foreach ($lookfor as $table) { echo '<br /><strong>' . sprintf(gettext('%s table'), $table) . '</strong>'; $output = false; $sql = 'SELECT * FROM ' . prefix($table) . ' WHERE `codeblock` <> "" and `codeblock` IS NOT NULL and `codeblock`!="a:0:{}"'; $result = query($sql); while ($row = db_fetch_assoc($result)) { $codeblocks = getSerializedArray($row['codeblock']); foreach ($codeblocks as $key => $codeblock) { switch ($table) { case 'news': case 'pages': $what = $row['titlelink'] . '::' . $key; break; case 'images': $album = getItemByID('albums', $row['albumid']); $what = $album->name . ':' . $row['filename'] . '::' . $key; break; case 'albums': $what = $row['folder'] . '::' . $key; break; } if (formatList($what, $codeblock, $pattern)) { $output = true; } } } if ($output) { echo '</ul>'; } else { ?> <p class="messagebox"><?php echo gettext('No calls on deprecated functions were found.'); ?> </p> <?php } } return $output; }
function getChallengePhraseInfo() { $info = $this->get('challenge_phrase'); if ($info) { return getSerializedArray($info); } else { return array('challenge' => '', 'response' => ''); } }
/** * Checks the suspension list for the ip * @return boolean */ static function suspended() { if ($block = getOption('ipBlocker_forbidden')) { $block = getSerializedArray($block); if (array_key_exists($ip = getUserIP(), $block)) { if ($block[$ip] < time() - getOption('ipBlocker_timeout') * 60) { // cooloff period passed unset($block[$ip]); if (count($block) > 0) { setOption('ipBlocker_forbidden', serialize($block)); } else { setOption('ipBlocker_forbidden', NULL); } } else { return true; } } } return false; }
/** * Prints the mail contact form, handles checks and the mail sending. It uses Zenphoto's check for valid e-mail address and website URL and also supports CAPTCHA. * The contact form itself is a separate file and is located within the /contact_form/form.php so that it can be style as needed. * * @param string $subject_override set to override the subject. */ function printContactForm($subject_override = '') { global $_zp_UTF8, $_zp_captcha, $_processing_post, $_zp_current_admin_obj; $error = array(); if (isset($_POST['sendmail'])) { $mailcontent = array(); $mailcontent['title'] = getField('title'); $mailcontent['name'] = getField('name'); $mailcontent['honeypot'] = getField('username'); $mailcontent['company'] = getField('company'); $mailcontent['street'] = getField('street'); $mailcontent['city'] = getField('city'); $mailcontent['state'] = getField('state'); $mailcontent['postal'] = getField('postal'); $mailcontent['country'] = getField('country'); $mailcontent['email'] = getField('email'); $mailcontent['website'] = getField('website'); $mailcontent['phone'] = getField('phone'); $mailcontent['subject'] = getField('subject'); $mailcontent['message'] = getField('message', 1); // if you want other required fields or less add/modify their checks here if (getOption('contactform_title') == "required" && empty($mailcontent['title'])) { $error[1] = gettext("a title"); } if (getOption('contactform_name') == "required" && empty($mailcontent['name'])) { $error[2] = gettext("a name"); } if (getOption('contactform_company') == "required" && empty($mailcontent['company'])) { $error[3] = gettext("a company"); } if (getOption('contactform_street') == "required" && empty($mailcontent['street'])) { $error[4] = gettext("a street"); } if (getOption('contactform_city') == "required" && empty($mailcontent['city'])) { $error[5] = gettext("a city"); } if (getOption('contactform_state') == "required" && empty($mailcontent['state'])) { $error[5] = gettext("a state"); } if (getOption('contactform_postal') == "required" && empty($mailcontent['postal'])) { $error[5] = gettext("a postal code"); } if (getOption('contactform_country') == "required" && empty($mailcontent['country'])) { $error[6] = gettext("a country"); } if (getOption('contactform_email') == "required" && (empty($mailcontent['email']) || !is_valid_email_zp($mailcontent['email']))) { $error[7] = gettext("a valid email address"); } if (getOption('contactform_website') == "required" && empty($mailcontent['website'])) { $error[8] = gettext('a website'); } else { if (!empty($mailcontent['website'])) { if (substr($mailcontent['website'], 0, 7) != "http: //") { $mailcontent['website'] = "http://" . $mailcontent['website']; } } } if (getOption("contactform_phone") == "required" && empty($mailcontent['phone'])) { $error[9] = gettext("a phone number"); } if (empty($mailcontent['subject'])) { $error[10] = gettext("a subject"); } if (empty($mailcontent['message'])) { $error[11] = gettext("a message"); } // CAPTCHA start if (getOption("contactform_captcha")) { $code_ok = trim(sanitize(isset($_POST['code_h']) ? $_POST['code_h'] : NULL)); $code = trim(sanitize(isset($_POST['code']) ? $_POST['code'] : NULL)); if (!$_zp_captcha->checkCaptcha($code, $code_ok)) { $error[5] = gettext("the correct CAPTCHA verification code"); } // no ticket } // CAPTCHA end // If required fields are empty or not valide print note if (count($error) != 0) { ?> <div class="errorbox"> <h2> <?php $err = $error; switch (count($err)) { case 1: printf(gettext('Please enter %s. Thanks.'), array_shift($err)); break; case 2: printf(gettext('Please enter %1$s and %2$s. Thanks.'), array_shift($err), array_shift($err)); break; default: $list = '<ul class="errorlist">'; foreach ($err as $item) { $list .= '<li>' . $item . '</li>'; } $list .= '</ul>'; printf(gettext('Please enter: %sThanks.'), $list); break; } ?> </h2> </div> <?php } else { $mailaddress = $mailcontent['email']; $name = $mailcontent['name']; $subject = $mailcontent['subject'] . " (" . getBareGalleryTitle() . ")"; $message = ''; if (!empty($mailcontent['title'])) { $message .= $mailcontent['title'] . "\n"; } if (!empty($mailcontent['name'])) { $message .= $mailcontent['name'] . "\n"; } if (!empty($mailcontent['email'])) { $message .= $mailcontent['email'] . "\n"; } if (!empty($mailcontent['company'])) { $message .= $mailcontent['company'] . "\n"; } if (!empty($mailcontent['street'])) { $message .= $mailcontent['street'] . "\n"; } if (!empty($mailcontent['city'])) { $message .= $mailcontent['city'] . "\n"; } if (!empty($mailcontent['state'])) { $message .= $mailcontent['state'] . "\n"; } if (!empty($mailcontent['postal'])) { $message .= $mailcontent['postal'] . "\n"; } if (!empty($mailcontent['country'])) { $message .= $mailcontent['country'] . "\n"; } if (!empty($mailcontent['phone'])) { $message .= $mailcontent['phone'] . "\n"; } if (!empty($mailcontent['website'])) { $message .= $mailcontent['website'] . "\n"; } $message .= "\n\n" . $mailcontent['message']; $message .= "\n\n"; if (getOption('contactform_confirm')) { echo get_language_string(getOption("contactform_confirmtext")); if (getOption('contactform_sendcopy')) { echo get_language_string(getOption("contactform_sendcopy_text")); } ?> <div> <?php $_processing_post = true; include getPlugin('contact_form/form.php', true); ?> <form id="confirm" action="<?php echo html_encode(getRequestURI()); ?> " method="post" accept-charset="UTF-8" style="float: left"> <input type="hidden" id="confirm" name="confirm" value="confirm" /> <input type="hidden" id="name" name="name" value="<?php echo html_encode($name); ?> " /> <input type="hidden" id="subject" name="subject" value="<?php echo html_encode($subject); ?> " /> <input type="hidden" id="message" name="message" value="<?php echo html_encode($message); ?> " /> <input type="hidden" id="mailaddress" name="mailaddress" value="<?php echo html_encode($mailaddress); ?> " /> <input type="text" id="username" name="username" value="<?php echo html_encode($mailcontent['honeypot']); ?> " style="display: none" /> <input type="submit" value="<?php echo gettext("Confirm"); ?> " /> </form> <form id="discard" action="<?php echo html_encode(getRequestURI()); ?> " method="post" accept-charset="UTF-8"> <input type="hidden" id="discard" name="discard" value="discard" /> <input type="submit" value="<?php echo gettext("Discard"); ?> " /> </form> </div> <?php return; } else { // simulate confirmation action $_POST['confirm'] = true; $_POST['subject'] = $subject; $_POST['message'] = $message; $_POST['mailaddress'] = $mailaddress; $_POST['name'] = $name; } } } if (isset($_POST['confirm'])) { $subject = sanitize($_POST['subject']); $message = sanitize($_POST['message'], 1); $mailaddress = sanitize($_POST['mailaddress']); $honeypot = sanitize($_POST['username']); $name = sanitize($_POST['name']); $mailinglist = explode(';', getOption("contactform_mailaddress")); if (getOption('contactform_sendcopy')) { $sendcopy = array($name => $mailaddress); } else { $sendcopy = NULL; } // If honeypot was triggered, silently don't send the message $err_msg = false; if (empty($honeypot)) { $err_msg = zp_mail($subject, $message, $mailinglist, $sendcopy, NULL, array($name => $mailaddress)); } if ($err_msg) { $msgs = explode('.', $err_msg); unset($msgs[0]); // the "mail send failed" text unset($msgs[count($msgs)]); // a trailing empty one ?> <div class="errorbox"> <strong><?php echo ngettext('Error sending mail:', 'Errors sending mail:', count($msgs)); ?> </strong> <ul class="errorlist"> <?php foreach ($msgs as $line) { echo '<li>' . trim($line) . '</li>'; } ?> </ul> </div> <?php } else { echo get_language_string(getOption("contactform_thankstext")); } echo '<p><a href="?again">' . get_language_string(getOption('contactform_newmessagelink')) . '</a></p>'; } else { if (count($error) <= 0) { if (zp_loggedin()) { $mailcontent = array('title' => '', 'name' => $_zp_current_admin_obj->getName(), 'company' => '', 'street' => '', 'city' => '', 'state' => '', 'country' => '', 'postal' => '', 'email' => $_zp_current_admin_obj->getEmail(), 'website' => '', 'phone' => '', 'subject' => $subject_override, 'message' => '', 'honeypot' => ''); if (extensionEnabled('comment_form')) { $address = getSerializedArray($_zp_current_admin_obj->getCustomData()); foreach ($address as $key => $field) { $mailcontent[$key] = $field; } } } else { $mailcontent = array('title' => '', 'name' => '', 'company' => '', 'street' => '', 'city' => '', 'st ate' => '', 'country' => '', 'email' => '', 'postal' => '', 'website' => '', 'phone' => '', 'subject' => $subject_override, 'message' => '', 'honeypot' => ''); } } echo get_language_string(getOption("contactform_introtext")); if (getOption('contactform_sendcopy')) { echo get_language_string(getOption("contactform_sendcopy_text")); } $_processing_post = false; include getPlugin('contact_form/form.php', true); } }
/** * * Check to see if the setup script needs to be run */ function checkInstall() { preg_match('|([^-]*)|', ZENPHOTO_VERSION, $version); if ($i = getOption('zenphoto_install')) { $install = getSerializedArray($i); } else { $install = array('ZENPHOTO' => '0.0.0[0000]'); } preg_match('|([^-]*).*\\[(.*)\\]|', $install['ZENPHOTO'], $matches); if (isset($matches[1]) && isset($matches[2]) && $matches[1] != $version[1] || $matches[2] != ZENPHOTO_RELEASE || (time() & 7) == 0 && OFFSET_PATH != 2 && $i != serialize(installSignature())) { require_once dirname(__FILE__) . '/reconfigure.php'; reconfigureAction(0); } }
$tab = 'edit'; $album = newAlbum($folder); if (!$album->isMyItem(ALBUM_RIGHTS)) { if (!zp_apply_filter('admin_managed_albums_access', false, $return)) { header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php'); exitZP(); } } } else { $object = '<em>' . gettext('Gallery') . '</em>'; $zenphoto_tabs['overview']['subtabs'] = array(gettext('Cache images') => PLUGIN_FOLDER . '/cacheManager/cacheImages.php?page = overview&tab=images', gettext('Cache stored images') => PLUGIN_FOLDER . '/cacheManager/cacheDBImages.php?page=overview&tab=DB&XSRFToken=' . getXSRFToken('cacheDBImages')); } $custom = array(); $result = query('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type` = "cacheManager" ORDER BY `aux`'); while ($row = db_fetch_assoc($result)) { $row = getSerializedArray($row['data']); $custom[] = $row; } $custom = sortMultiArray($custom, array('theme', 'thumb', 'image_size', 'image_width', 'image_height')); if (isset($_GET['select'])) { XSRFdefender('cacheImages'); $enabled = @$_POST['enable']; } else { $enabled = false; } printAdminHeader('overview', 'images'); echo "\n</head>"; echo "\n<body>"; printLogoAndLinks(); echo "\n" . '<div id = "main">'; printTabs();
echo '<strong>*</strong>'; } ?> </label> <input type="text" id="admin_email" name="admin_email" value="<?php echo html_encode($admin_e); ?> " size="<?php echo TEXT_INPUT_SIZE; ?> " /> </p> <?php } if (extensionEnabled('userAddressFields')) { $address = getSerializedArray(zp_getCookie('reister_user_form_addresses')); if (empty($address)) { $address = array('street' => '', 'city' => '', 'state' => '', 'country' => '', 'postal' => '', 'website' => ''); } $show = $required = getOption('register_user_address_info'); if ($required == 'required') { $required = '<strong>*</strong>'; } else { $required = false; } if ($show) { ?> <p> <label for="comment_form_street"> <?php printf(gettext('Street%s'), $required);
/** * * custom option handler * @param string $option * @param mixed $currentValue */ function handleOption($option, $currentValue) { global $_zp_gallery; $currenttheme = $_zp_gallery->getCurrentTheme(); $custom = array(); $result = query('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`="cacheManager" ORDER BY `aux`'); $key = 0; while ($row = db_fetch_assoc($result)) { $theme = $row['aux']; $data = getSerializedArray($row['data']); $custom[$theme][] = $data; } ksort($custom, SORT_LOCALE_STRING); $custom[''] = array(array()); $c = 0; ?> <script type="text/javascript"> //<!-- <![CDATA[ function showTheme(theme) { html = $('#' + theme + '_arrow').html(); if (html.match(/down/)) { html = html.replace(/_down/, '_up'); html = html.replace(/title="<?php echo gettext('Show'); ?> /, 'title="<?php echo gettext('Hide'); ?> "'); $('#' + theme + '_list').show(); } else { html = html.replace(/_up/, '_down'); html = html.replace(/title="<?php echo gettext('Hide'); ?> /, 'title="<?php echo gettext('Show'); ?> "'); $('#' + theme + '_list').hide(); } $('#' + theme + '_arrow').html(html); } //]]> --> </script> <?php foreach ($custom as $theme => $themedata) { $themedata = sortMultiArray($themedata, array('thumb', 'image_size', 'image_width', 'image_height')); ?> <span class="icons" id="<?php echo $theme; ?> _arrow"> <?php if ($theme) { $inputclass = 'hidden'; echo '<em>' . $theme . '</em> (' . count($themedata), ')'; } else { $inputclass = 'textbox'; echo '<br />' . gettext('add'); } ?> <a href="javascript:showTheme('<?php echo $theme; ?> ');" title="<?php echo gettext('Show'); ?> "> <img class="icon-position-top4" src="<?php echo WEBPATH . '/' . ZENFOLDER . '/images/arrow_down.png'; ?> " alt="" /> </a> </span> <br /> <div id="<?php echo $theme; ?> _list" style="display:none"> <br /> <?php foreach ($themedata as $cache) { $key++; if ($c % 2) { $class = 'boxb'; } else { $class = 'box'; } ?> <div> <?php $c++; if (isset($cache['enable']) && $cache['enable']) { $allow = ' checked="checked"'; } else { $allow = ''; } ?> <div class="<?php echo $class; ?> "> <input type="<?php echo $inputclass; ?> " size="25" name="cacheManager_theme_<?php echo $key; ?> " value="<?php echo $theme; ?> " /> <?php if ($theme) { ?> <span class="displayinlineright"><?php echo gettext('Delete'); ?> <input type="checkbox" name="cacheManager_delete_<?php echo $key; ?> " value="1" /></span> <input type="hidden" name="cacheManager_valid_<?php echo $key; ?> " value="1" /> <?php } ?> <br /> <?php foreach (array('image_size' => gettext('Size'), 'image_width' => gettext('Width'), 'image_height' => gettext('Height'), 'crop_width' => gettext('Crop width'), 'crop_height' => gettext('Crop height'), 'crop_x' => gettext('Crop X axis'), 'crop_y' => gettext('Crop Y axis')) as $what => $display) { if (isset($cache[$what])) { $v = $cache[$what]; } else { $v = ''; } ?> <span class="nowrap"><?php echo $display; ?> <input type="textbox" size="2" name="cacheManager_<?php echo $what; ?> _<?php echo $key; ?> " value="<?php echo $v; ?> " /></span> <?php } if (isset($cache['wmk'])) { $wmk = $cache['wmk']; } else { $wmk = ''; } ?> <span class="nowrap"><?php echo gettext('Watermark'); ?> <input type="textbox" size="20" name="cacheManager_wmk_<?php echo $key; ?> " value="<?php echo $wmk; ?> " /></span> <br /> <span class="nowrap"><?php echo gettext('MaxSpace'); ?> <input type="checkbox" name="cacheManager_maxspace_<?php echo $key; ?> " value="1"<?php if (isset($cache['maxspace']) && $cache['maxspace']) { echo ' checked="checked"'; } ?> /></span> <span class="nowrap"><?php echo gettext('Thumbnail'); ?> <input type="checkbox" name="cacheManager_thumb_<?php echo $key; ?> " value="1"<?php if (isset($cache['thumb']) && $cache['thumb']) { echo ' checked="checked"'; } ?> /></span> <span class="nowrap"><?php echo gettext('Grayscale'); ?> <input type="checkbox" name="cacheManager_gray_<?php echo $key; ?> " value="gray"<?php if (isset($cache['gray']) && $cache['gray']) { echo ' checked="checked"'; } ?> /></span> </div> <br /> </div> <?php } ?> </div><!-- <?php echo $theme; ?> _list --> <?php } }
/** * Prints a form for posting comments * * @param bool $showcomments defaults to true for showing list of comments * @param string $addcommenttext alternate text for "Add a comment:" * @param bool $addheader set true to display comment count header * @param string $comment_commententry_mod use to add styles, classes to the comment form div * @param bool $desc_order default false, set to true to change the comment order to descending ( = newest to oldest) */ function printCommentForm($showcomments = true, $addcommenttext = NULL, $addheader = true, $comment_commententry_mod = '', $desc_order = false) { global $_zp_gallery_page, $_zp_current_admin_obj, $_zp_current_comment, $_zp_captcha, $_zp_authority, $_zp_HTML_cache, $_zp_current_image, $_zp_current_album, $_zp_current_page, $_zp_current_article; if (getOption('email_new_comments')) { $email_list = $_zp_authority->getAdminEmail(); if (empty($email_list)) { setOption('email_new_comments', 0); } } if (is_null($addcommenttext)) { $addcommenttext = '<h3>' . gettext('Add a comment:') . '</h3>'; } switch ($_zp_gallery_page) { case 'album.php': if (!getOption('comment_form_albums')) { return; } $obj = $_zp_current_album; break; case 'image.php': if (!getOption('comment_form_images')) { return; } $obj = $_zp_current_image; break; case 'pages.php': if (!getOption('comment_form_pages')) { return; } $obj = $_zp_current_page; break; case 'news.php': if (!getOption('comment_form_articles') || !is_NewsArticle()) { return; } $obj = $_zp_current_article; break; default: return; break; } $comments_open = $obj->getCommentsAllowed(); ?> <!-- printCommentForm --> <div id="commentcontent"> <?php $num = getCommentCount(); if ($showcomments) { if ($num == 0) { if ($addheader) { echo '<h3 class="empty">' . gettext('No Comments') . '</h3>'; } $display = ''; } else { if ($addheader) { echo '<h3>' . sprintf(ngettext('%u Comment', '%u Comments', $num), $num) . '</h3>'; } if (getOption('comment_form_toggle')) { ?> <div id="comment_toggle"><!-- place holder for toggle button --></div> <script type="text/javascript"> // <!-- <![CDATA[ function toggleComments(hide) { if (hide) { $('div.comment').hide(); $('.Pagination').hide(); $('#comment_toggle').html('<button class="button buttons" onclick="toggleComments(false);"><?php echo gettext('show comments'); ?> </button>'); } else { $('div.comment').show(); $('.Pagination').show(); $('#comment_toggle').html('<button class="button buttons" onclick="toggleComments(true);"><?php echo gettext('hide comments'); ?> </button>'); } } $(document).ready(function () { toggleComments(window.location.hash.search(/#zp_comment_id_/)); }); // ]]> --> </script> <?php $display = ' style="display:none"'; } else { $display = ''; } } $hideoriginalcomments = ''; if (getOption('comment_form_pagination') && COMMENTS_PER_PAGE < $num) { $hideoriginalcomments = ' style="display:none"'; // hide original comment display to be replaced by jQuery pagination } if (getOption('comment_form_pagination') && COMMENTS_PER_PAGE < $num) { ?> <div class="Pagination"></div><!-- this is the jquery pagination nav placeholder --> <div id="Commentresult"></div> <?php } ?> <div id="comments"<?php echo $hideoriginalcomments; ?> > <?php while (next_comment($desc_order)) { if (!getOption('comment_form_showURL')) { $_zp_current_comment['website'] = ''; } ?> <div class="comment" <?php echo $display; ?> > <div class="commentinfo"> <h4 id="zp_comment_id_<?php echo $_zp_current_comment['id']; ?> "><?php printCommentAuthorLink(); ?> : <?php echo gettext('on'); ?> <?php echo getCommentDateTime(); printEditCommentLink(gettext('Edit'), ', ', ''); ?> </h4> </div><!-- class "commentinfo" --> <div class="commenttext"><?php echo html_encodeTagged(getCommentBody(), false); ?> </div><!-- class "commenttext" --> </div><!-- class "comment" --> <?php } ?> </div><!-- id "comments" --> <?php } if (getOption('comment_form_pagination') && COMMENTS_PER_PAGE < $num) { ?> <div class="Pagination"></div><!-- this is the jquery pagination nav placeholder --> <?php } ?> <!-- Comment Box --> <?php if ($comments_open) { if (MEMBERS_ONLY_COMMENTS && !zp_loggedin(POST_COMMENT_RIGHTS)) { echo gettext('Only registered users may post comments.'); } else { $disabled = array('name' => '', 'website' => '', 'anon' => '', 'private' => '', 'comment' => '', 'street' => '', 'city' => '', 'state' => '', 'country' => '', 'postal' => ''); $stored = array_merge(array('email' => '', 'custom' => ''), $disabled, getCommentStored()); $custom = getSerializedArray($stored['custom']); foreach ($custom as $key => $value) { if (!empty($value)) { $stored[$key] = $value; } } foreach ($stored as $key => $value) { $disabled[$key] = false; } if (zp_loggedin()) { if (extensionEnabled('userAddressFields')) { $address = userAddressFields::getCustomData($_zp_current_admin_obj); foreach ($address as $key => $value) { if (!empty($value)) { $disabled[$key] = true; $stored[$key] = $value; } } } $name = $_zp_current_admin_obj->getName(); if (!empty($name)) { $stored['name'] = $name; $disabled['name'] = ' disabled="disabled"'; } else { $user = $_zp_current_admin_obj->getUser(); if (!empty($user)) { $stored['name'] = $user; $disabled['name'] = ' disabled="disabled"'; } } $email = $_zp_current_admin_obj->getEmail(); if (!empty($email)) { $stored['email'] = $email; $disabled['email'] = ' disabled="disabled"'; } if (!empty($address['website'])) { $stored['website'] = $address['website']; $disabled['website'] = ' disabled="disabled"'; } } $data = zp_apply_filter('comment_form_data', array('data' => $stored, 'disabled' => $disabled)); $disabled = $data['disabled']; $stored = $data['data']; foreach ($data as $check) { foreach ($check as $v) { if ($v) { $_zp_HTML_cache->disable(); // shouldn't cache partially filled in pages break 2; } } } if (!empty($addcommenttext)) { echo $addcommenttext; } ?> <div id="commententry" <?php echo $comment_commententry_mod; ?> > <?php $theme = getCurrentTheme(); $form = getPlugin('comment_form/comment_form.php', $theme); require $form; ?> </div><!-- id="commententry" --> <?php } } else { ?> <div id="commententry"> <h3><?php echo gettext('Closed for comments.'); ?> </h3> </div><!-- id="commententry" --> <?php } ?> </div><!-- id="commentcontent" --> <?php if (getOption('comment_form_rss') && getOption('RSS_comments')) { ?> <br clear="all" /> <?php if (class_exists('RSS')) { switch ($_zp_gallery_page) { case "image.php": printRSSLink("Comments-image", "", gettext("Subscribe to comments"), ""); break; case "album.php": printRSSLink("Comments-album", "", gettext("Subscribe to comments"), ""); break; case "news.php": printRSSLink("Comments-news", "", gettext("Subscribe to comments"), ""); break; case "pages.php": printRSSLink("Comments-page", "", gettext("Subscribe to comments"), ""); break; } } } ?> <!-- end printCommentForm --> <?php }
/** * Returns the sring for the current language from a serialized set of language strings * Defaults to the string for the current locale, the en_US string, or the first string which ever is present * * @param string $dbstring either a serialized languag string array or a single string * @param string $locale optional locale of the translation desired * @return string */ function get_language_string($dbstring, $locale = NULL) { $strings = getSerializedArray($dbstring); if (count($strings) > 1) { if (!empty($locale) && isset($strings[$locale])) { return $strings[$locale]; } if (isset($strings[$locale = getOption('locale')])) { return $strings[$locale]; } if (isset($strings['en_US'])) { return $strings['en_US']; } } return array_shift($strings); }
} if (getOption('comment_web_required') == 1) { setOption('comment_web_required', 'required'); } setOptionDefault('fullsizeimage_watermark', getOption('fullimage_watermark')); $data = getOption('gallery_data'); if ($data) { $data = getSerializedArray($data); if (isset($data['Gallery_description'])) { $data['Gallery_description'] = getSerializedArray($data['Gallery_description']); } if (isset($data['gallery_title'])) { $data['gallery_title'] = getSerializedArray($data['gallery_title']); } if (isset($data['unprotected_pages'])) { $data['unprotected_pages'] = getSerializedArray($data['unprotected_pages']); } } else { $data = array(); } if (!isset($data['gallery_sortdirection'])) { $data['gallery_sortdirection'] = (int) getOption('gallery_sortdirection'); } if (!isset($data['gallery_sorttype'])) { $data['gallery_sorttype'] = getOption('gallery_sorttype'); if (empty($data['gallery_sorttype'])) { $data['gallery_sorttype'] = 'ID'; } } if (!isset($data['gallery_title'])) { $data['gallery_title'] = getOption('gallery_title');
/** * * prints codeblock edit boxes * @param object $obj * @param int $id */ function printCodeblockEdit($obj, $id) { $codeblock = getSerializedArray($obj->getCodeblock()); $keys = array_keys($codeblock); array_push($keys, 1); $codeblockCount = max($keys) + 1; if (array_key_exists(0, $codeblock) && !empty($codeblock)) { $start = 0; } else { $start = (int) getOption('codeblock_first_tab'); } ?> <div id="cbd-<?php echo $id; ?> " class="tabs"> <ul id="<?php echo 'cbu' . '-' . $id; ?> " class="tabNavigation"> <?php for ($i = $start; $i < $codeblockCount; $i++) { ?> <li><a class="<?php if ($i == 1) { echo 'first '; } ?> cbt-<?php echo $id; ?> " id="<?php echo 'cbt' . $i . '-' . $id; ?> " onclick="cbclick(<?php echo $i . ',' . $id; ?> );" title="<?php printf(gettext('codeblock %u'), $i); ?> "> <?php echo $i; ?> </a></li> <?php } if (zp_loggedin(CODEBLOCK_RIGHTS)) { $disabled = ''; ?> <li><a id="<?php echo 'cbp' . '-' . $id; ?> " onclick="cbadd(<?php echo $id; ?> ,<?php echo 1 - $start; ?> );" title="<?php echo gettext('add codeblock'); ?> "> + </a></li> <?php } else { $disabled = ' disabled="disabled"'; } ?> </ul> <?php for ($i = $start; $i < $codeblockCount; $i++) { ?> <div class="cbx-<?php echo $id; ?> " id="cb<?php echo $i . '-' . $id; ?> "<?php if ($i != 1) { echo ' style="display:none"'; } ?> > <?php if (!$i) { ?> <span class="notebox"><?php echo gettext('Codeblock 0 is deprecated.'); ?> </span> <?php } ?> <textarea name="codeblock<?php echo $i; ?> -<?php echo $id; ?> " class="codeblock" id="codeblock<?php echo $i; ?> -<?php echo $id; ?> " rows="40" cols="60"<?php echo $disabled; ?> ><?php echo html_encode(@$codeblock[$i]); ?> </textarea> </div> <?php } ?> </div> <?php }
/** * Returns the last vote rating from an IP or false if * no vote on record * * @param string $ip * @param array $usedips * @param float $ratingAverage * @return float */ static function getRatingByIP($ip, $usedips, $ratingAverage) { global $_rating_current_IPlist; $rating = 0; if (empty($_rating_current_IPlist)) { if (!empty($usedips)) { $_rating_current_IPlist = getSerializedArray($usedips); if (array_key_exists($ip, $_rating_current_IPlist)) { return $_rating_current_IPlist[$ip]; } } } return false; }
/** * Returns a of a slice of the images for this album. They will * also be sorted according to the sort type of this album, or by filename if none * has been set. * * @param string $page Which page of images should be returned. If zero, all images are returned. * @param int $firstPageCount count of images that go on the album/image transition page * @param string $sorttype optional sort type * @param string $sortdirection optional sort direction * @param bool $care set to false if the order of the images does not matter * @param bool $mine set true/false to override ownership * * @return array */ function getImages($page = 0, $firstPageCount = 0, $sorttype = null, $sortdirection = null, $care = true, $mine = NULL) { if ($mine || is_null($this->images) || $care && $sorttype . $sortdirection !== $this->lastimagesort) { $this->images = NULL; $images = array(); $result = query('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `type`="favorites" AND `aux`=' . db_quote($this->getInstance()) . ' AND `data` LIKE "%s:4:\\"type\\";s:6:\\"images\\";%"'); if ($result) { while ($row = db_fetch_assoc($result)) { $id = $row['id']; $data = getSerializedArray($row['data']); $imageObj = newImage(NULL, array('folder' => dirname($data['id']), 'filename' => basename($data['id'])), true); if ($imageObj->exists) { $images[] = array_merge(array('folder' => dirname($data['id']), 'filename' => basename($data['id'])), $imageObj->getData()); } else { query("DELETE FROM " . prefix('plugin_storage') . ' WHERE `id`=' . $row['id']); } } db_free_result($result); if (is_null($sorttype)) { $sorttype = $this->getSortType(); } $sortkey = str_replace('` ', ' ', $this->getImageSortKey($sorttype)); if ($sortkey == 'sort_order' || $sortkey == 'RAND()') { // manual sort is always ascending $order = false; } else { if (!is_null($sortdirection)) { $order = strtoupper($sortdirection) == 'DESC'; } else { $order = $this->getSortDirection('image'); } } $images = sortByKey($images, $sortkey, $order); $this->images = array(); foreach ($images as $data) { $this->images[] = array('folder' => $data['folder'], 'filename' => $data['filename']); } $this->lastimagesort = $sorttype . $sortdirection; } } return parent::getImages($page, $firstPageCount); }