Файл: adultscript-2.0.3-pro/files/install/upgrade-1.0rc4-to-1.0.php
Строк: 432
<?php
define('_VALID', true);
define('_INSTALL', true);
require '../libraries/bootstrap.php';
require 'functions.php';
set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', 1);
if (ini_get('date.timezone') == '') {
date_default_timezone_set('Europe/Helsinki');
}
$uri = get_uri();
define('INSTALL_URL', BASE_URL.'/install');
$errors = array();
$finished = false;
$test = VF::factory('test');
$required = $test->get_required_results();
$optional = $test->get_optional_results();
$recommended = $test->get_recommended_results();
if (isset($_POST['submit-upgrade'])) {
$db = VF::factory('database');
// lets make sure UTF8 is supported
$db->query("ALTER DATABASE ".VF::cfg_item('db_name')."
CHARACTER SET utf8
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci
DEFAULT COLLATE utf8_general_ci");
$db->query("SHOW TABLES");
$tables = $db->fetch_rows();
foreach ($tables as $table) {
$name = $table['0'];
$db->query("ALTER TABLE ".$name."
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci");
}
$db->query("CREATE TABLE `#__user_premium_ips` (
`user_id` int(11) unsigned NOT NULL DEFAULT '0',
`ip` int(11) unsigned NOT NULL DEFAULT '0',
KEY `user_id` (`user_id`),
KEY `user_ip` (`user_id`,`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
$db->query("ALTER TABLE `#__video` ADD `featured` enum('0','1') NOT NULL DEFAULT '0';");
$db->query("ALTER TABLE `#__video` ADD `s3` enum('0','1') NOT NULL DEFAULT '0';");
$db->query("ALTER TABLE `#__video_category` DROP KEY `cat_id`;");
$db->query("ALTER TABLE `#__video_category` DROP KEY `video_categ`;");
$db->query("ALTER TABLE `#__video_category` ADD KEY `cat_video` (`cat_id`,`video_id`);");
$db->query("ALTER TABLE `#__video_comments` ADD `nickname` varchar(100) NOT NULL DEFAULT '';");
$db->query("ALTER TABLE `#__photo_comments` ADD `nickname` varchar(100) NOT NULL DEFAULT '';");
$db->query("ALTER TABLE `#__user_comments` ADD `nickname` varchar(100) NOT NULL DEFAULT '';");
$db->query("ALTER TABLE `#__model_comments` ADD `nickname` varchar(100) NOT NULL DEFAULT '';");
$db->query("DROP TABLE IF EXISTS `#__video_embeds`;");
$db->query("CREATE TABLE `#__video_embeds` (
`video_id` int(11) NOT NULL DEFAULT '0',
`url` varchar(255) NOT NULL DEFAULT '',
`view_time` int(11) NOT NULL DEFAULT '0',
KEY `embed` (`video_id`,`view_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
$db->query("ALTER TABLE `#__video_feeds` ADD `format` enum('smart','nats') NOT NULL DEFAULT 'smart';");
$db->query("ALTER TABLE `#__video_history` DROP COLUMN `view_date`;");
$db->query("ALTER TABLE `#__video_history` DROP COLUMN `status`;");
$db->query("ALTER TABLE `#__video_history` DROP KEY `ip`;");
$db->query("ALTER TABLE `#__video_history` ADD `view_time` int(11) NOT NULL default '0'");
$db->query("ALTER TABLE `#__video_history` ADD KEY `view_time` (`view_time`);");
// adding our playslist here...forgot in previous version
$db->query("CREATE TABLE `#__playlist` (
`playlist_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) unsigned NOT NULL DEFAULT '0',
`thumb_id` int(11) unsigned NOT NULL DEFAULT '0',
`name` varchar(255) NOT NULL DEFAULT '',
`type` enum('public','private') NOT NULL DEFAULT 'public',
`add_time` int(11) unsigned NOT NULL DEFAULT '0',
`slug` varchar(100) NOT NULL DEFAULT '',
`total_videos` int(3) unsigned NOT NULL DEFAULT '0',
`duration` float NOT NULL DEFAULT '0',
`total_views` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`playlist_id`),
KEY `user_id` (`user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE `#__playlist_videos` (
`playlist_id` int(11) unsigned NOT NULL DEFAULT '0',
`video_id` int(11) unsigned NOT NULL DEFAULT '0',
`add_time` int(11) unsigned NOT NULL DEFAULT '0',
KEY `playlist_id` (`playlist_id`),
KEY `video_id` (`video_id`),
KEY `add_time` (`add_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
// WTF...no function to add main configuration options yet
// VConfig::add('core', 'sphinx_host', 'localhost');
// VConfig::add('core', 'sphinx_port', 3312);
// lets add our new email here
$body = file_get_contents(dirname(__FILE__).'/emails/video-flag.txt');
$db->query("INSERT INTO #__email
SET name = 'video-flag',
description = 'Video Flag Notification',
subject = 'Video Flagged on [#SITE_NAME#]',
message = '".$db->escape($body)."',
status = '1'");
// add our new upload limit
$db->query("SELECT code FROM #__language");
$rows = $db->fetch_rows();
foreach ($rows as $row) {
$code = $row['code'];
language_add($code, 'frontend', 'video', array(
'upload-limit' => 'You are allow to upload only %d videos per day! Please contact us to increase this limit!',
'no-related' => 'No related videos found!',
'playlist-private' => 'This playlist is private! You need to be friends with %s to watch this playlist!',
'related-meta-desc' => 'Watch videos related to %s, page %s at %s!',
'related-meta-title' => 'Videos related to %s',
'related-title' => 'Videos related to: %s',
'playlist-already' => 'Video already in playlist!',
'playlist-select-success' => 'Your video was successfuly added to your playlist!',
'playlist-create-success' => 'Playlist created and video added!',
'playlist-invalid' => 'Invalid playlist type!',
'playlist-empty' => 'Playlist name field cannot be left blank!',
'playlist-select' => 'Add to Playlist',
'playlist-create' => 'Create Playlist'
), NULL);
language_add($code, 'frontend', 'global', array(
'playlists' => 'Playlists',
'playlist' => 'Playlist',
'day' => 'day',
'days' => 'days',
'nickname' => 'Nickname'
), NULL);
language_add($code, 'frontend', 'feedback', array(
'captcha-invalid' => 'Invalid verification code! Are you human!?',
'captcha-help' => 'Enter the code from the above image!',
'cant-read' => 'Cant read?'
), NULL);
language_add($code, 'frontend', 'photo', array(
'add-success' => 'Photos were added to your album!',
'add-failed' => 'Failed to process at least one image from the uploaded images!'
), NULL);
// this part belongs to the premium stuff, but we cannot disable it
language_add($code, 'frontend', 'mobile', array(
'free-payment' => 'Your account was created! Please proceed with payment!',
'users-meta-desc' => '%s Mobile Profile at %s',
'users-title' => '%s Mobile Profile',
'never' => 'never',
'last-login' => 'Last Login',
'profile-viewed' => 'Profile Viewed',
'people-watched-videos' => 'People have watched %s's videos',
'joined' => 'Joined',
'community-title' => 'Community',
'edit-profile' => 'Edit Profile',
'password-retype' => 'Password Retype',
'password-new' => 'New Password',
'edit-account' => 'Edit Account',
'premium-upgrade' => 'Upgrade to a Premium Account!',
'welcome-dashboard' => 'Welcome %s! You have watched %s videos!',
'account-information' => 'Account Information',
'credit-invalid' => 'You need to add credit to your account!',
'package-invalid' => 'Invalid payment package selected!',
'payment-invalid' => 'Invalid payment method selected!',
'payment-select' => 'Please select one payment method!',
'password-empty' => 'Password cannot be blank!',
'email-used' => 'Email is already used by another user!',
'username-used' => 'Username is already used by another user on this site!',
'username-invalid' => 'Username can contain only letters, numbers, dashes and underscores!',
'username-length' => 'Username can contain maximum %s characters!',
'username-emtpy' => 'Username field cannot be left blank!',
'free-success' => 'Welcome %s! Please login below!',
'payment-success' => 'Payment information stored! Please proceed to our payment processor!',
'register-title' => 'Create Your %s Account',
'login-title' => 'Member Login',
'login-failed' => 'Incorrect username and/or password!',
'account-confirm' => 'You need to verify your email before you can log in!',
'account-approve' => 'Your account is valid, but the site administrator needs to approve it first!',
'account-suspended' => 'Account Suspended!',
'redirect-help' => 'Redirecting to payment processor. If you are not automatically redirected within 5 seconds please click the button below!',
'redirect-payment' => 'Proceed to Payment Processor',
'register-premium' => 'Proceed with payment!',
'register-free' => 'Create your free account!',
'password' => 'Password',
'username' => 'Username',
'join-cc' => 'Join by Credit Card',
'join-sms' => 'Join by SMS',
), NULL);
VF::cache_del($code.'.frontend.video', 'language');
VF::cache_del($code.'.frontend.global', 'language');
VF::cache_del($code.'.frontend.feedback', 'language');
VF::cache_del($code.'.frontend.photo', 'language');
VF::cache_del($code.'.frontend.mobile', 'language');
}
$finished = TRUE;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>Adult Script Pro Installation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="<?php echo INSTALL_URL ?>/css/style.css?v1" type="text/css" media="all" />
<script type="text/javascript">
var base_url = "<?php echo BASE_URL; ?>";
</script>
</head>
<script type="text/javascript" src="<?php echo INSTALL_URL; ?>/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("img[id^='help_']").click(function() {
var id = $(this).attr('id').match(/help_(.*)/)[1];
if ($("p[id='test_" + id + "']").is(':visible')) {
$("p[id='test_" + id + "']").slideUp();
} else {
$("p[id='test_" + id + "']").slideDown();
}
});
});
</script>
<body>
<div id="container">
<?php if (!$finished): ?>
<?php if ($errors): ?>
<div class="errors">
<?php foreach ($errors as $error): ?>
<span><?php echo htmlspecialchars($error),'<br />'; ?></span>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="left width-475">
<h2>Testing Requirements</h2>
<div class="box-content">
<h3>Required Items</h3>
<?php foreach ($required as $id => $values): if (!isset($values['system'])): ?>
<span class="key"><?php if ($values['status'] !== true): echo '<strong>'; endif; ?><?php echo htmlspecialchars($values['message']); ?><?php if ($values['status'] !== true): echo '</strong>'; endif; ?></span>
<span class="value">
<?php if ($values['status'] === true): ?>
<img src="<?php echo INSTALL_URL; ?>/images/accept.png" alt="accept.png" />
<?php else: ?>
<img src="<?php echo INSTALL_URL; ?>/images/help.png" id="help_<?php echo $id; ?>" class="help" alt="help.png" />
<?php if (isset($values['warning']) && $values['warning'] == '1'): ?>
<img src="<?php echo INSTALL_URL; ?>/images/error.png" alt="error.png" />
<?php else: ?>
<img src="<?php echo INSTALL_URL; ?>/images/delete.png" alt="delete.png" />
<?php endif; endif; ?>
</span>
<div class="clear"></div>
<p id="test_<?php echo $id; ?>" style="display: none;"><?php echo htmlspecialchars($values['error']); ?></p>
<?php endif; endforeach; ?>
<h3>Required PHP Settings</h3>
<?php foreach ($recommended as $id => $values): if (!isset($values['system'])): ?>
<span class="key"><?php if ($values['status'] !== true): echo '<strong>'; endif; ?><?php echo htmlspecialchars($values['message']); ?><?php if ($values['status'] !== true): echo '</strong>'; endif; ?></span>
<span class="value">
<?php if ($values['status'] === true): ?>
<img src="<?php echo INSTALL_URL; ?>/images/accept.png" alt="accept.png" />
<?php else: ?>
<img src="<?php echo INSTALL_URL; ?>/images/help.png" id="help_<?php echo $id; ?>" class="help" alt="help.png" />
<?php if ($values['warning'] == '1'): ?>
<img src="<?php echo INSTALL_URL; ?>/images/error.png" alt="error.png" />
<?php else: ?>
<img src="<?php echo INSTALL_URL; ?>/images/delete.png" alt="delete.png" />
<?php endif; endif; ?>
</span>
<div class="clear"></div>
<p id="test_<?php echo $id; ?>" style="display: none;"><?php echo htmlspecialchars($values['error']); ?></p>
<?php endif; endforeach; ?>
<h3>Optional Items</h3>
<?php foreach ($optional as $id => $values): if (!isset($values['system'])): ?>
<span class="key"><?php if ($values['status'] !== true): echo '<strong>'; endif; ?><?php echo htmlspecialchars($values['message']); ?><?php if ($values['status'] !== true): echo '</strong>'; endif; ?></span>
<span class="value">
<?php if ($values['status'] === true): ?>
<img src="<?php echo INSTALL_URL; ?>/images/accept.png" alt="accept.png" />
<?php else: ?>
<img src="<?php echo INSTALL_URL; ?>/images/help.png" id="help_<?php echo $id; ?>" class="help" alt="help.png" />
<img src="<?php echo INSTALL_URL; ?>/images/error.png" alt="error.png" />
<?php endif; ?>
</span>
<div class="clear"></div>
<p id="test_<?php echo $id; ?>" style="display: none;"><?php echo htmlspecialchars($values['error']); ?></p>
<?php endif; endforeach; ?>
<form name="test-form" method="post" action="<?php echo BASE_URL; ?>/install/upgrade-1.0rc2-to-1.0rc3.php?a=test">
<div class="submit">
<input name="submit-test" type="submit" id="submit-test" class="submit" value="Run Tests Again" />
</div>
</form>
</div>
</div>
<div class="right width-475">
<h2>Upgrade Options</h2>
<div class="box-content">
<form id="upgrade-form" method="post" action="<?php echo BASE_URL; ?>/install/upgrade-1.0rc4-to-1.0.php?a=upgrade">
<div class="submit">
<input name="submit-upgrade" type="submit" id="submit-upgrade" class="submit" value="Upgrade >"<?php if ($test->is_error() === true): echo ' disabled="1"'; endif; ?> />
</div>
</form>
</div>
</div>
<div class="clear"></div>
<?php else: ?>
<div class="box">
<h1>Congratulations! Adult Script Pro has been upgraded!</h1>
<br /><i>This upgrade contains important configuration changes. Please login to your site's Administration Panel and update
the below configuration options:<br /><br />
MAIN: Sphinx Host and Sphinx Port (leave empty if you are not using sphinx)<br />
VIDEO: Pseudostreaming, Upload Progress (set to Flash Uploader), Upload Limit, Amazon S3, MP4 Reconvert, Thumb Server, Show Comments<br />
PHOTO: Show Comments<br />
LINK: Cron Check<br />
USER: Guest Limit and Registered Limit (set both to Disabled, in most cases)<br /><br />
<center>WARNING: Your site will not work without these updates!</center>
<br /><br />
Click on the 'Site' button to view your site or 'Administrator' button to configure installed upgrades!
<div class="links">
<a href="<?php echo BASE_URL; ?>">Site</a>
<a href="<?php echo ADMIN_URL; ?>/index.php">Administrator Panel</a>
</div>
<div class="install">
Please completly remove the installation directory (/install). This is a security feature!
</div>
</div>
<?php endif; ?>
</div>
</body>
</html>