Файл: adultscript-2.0.3-pro/files/install/upgrade-1.0beta3-to-1.0beta4.php
Строк: 510
<?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'])) {
require INSTALL_DIR.'/db.php';
$cfg = VF::cfg('core.config');
$db = new VInstall_db($cfg['db_host'], $cfg['db_name'], $cfg['db_username'], $cfg['db_password'], $cfg['db_prefix']);
if ($db->is_error()) {
$errors[] = $db->get_error();
}
if (!$errors) {
$db->load_file(BASE_DIR.'/install/sqls/asp-1.0beta3-to-asp-1.0beta4.sql');
if ($db->is_error()) {
$errors[] = $db->get_error();
}
if (!$errors) {
$cfg_file = require BASE_DIR.'/config.php';
foreach ($cfg_file as $key => $value) {
if (isset($cfg[$key])) {
unset($cfg[$key]);
}
}
// add mobile module
$mcfg = file_get_contents(dirname(__FILE__).'/cfgs/mobile.cfg.php');
$db->query("INSERT INTO #__module
SET name = 'mobile',
description = 'Mobile (Smartphone) Module',
type = 'extension',
version = '1.0.0',
provider = 'adultscriptpro',
config = '".$db->escape($mcfg)."',
config_cache = '".$db->escape($mcfg)."',
status = '1'");
VF::cache_del('modules', 'config');
// add mobile menus
$db->query("INSERT INTO #__menu SET name = 'mobile_main', title = 'Mobile Main Menu'");
$menu_id = (int) $db->get_last_insert_id('#__menu');
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Videos', title = 'Browse Mobile Videos', link = '/recent/', current = 'video', pos = 1, lang = 'Videos'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Categories', title = 'Browse Mobile Categories', link = '/categories/', current = 'categories', pos = 2, lang = 'categories'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Photos', title = 'Browse Mobile Photos', link = '/photos/', current = 'photo', pos = 3, lang = 'photos'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Pornstars', title = 'Browse Mobile Pornstars', link = '/pornstars/', current = 'pornstar', pos = 4, lang = 'pornstars'");
$db->query("INSERT INTO #__menu SET name = 'mobile_footer', title = 'Mobile Footer Menu'");
$menu_id = (int) $db->get_last_insert_id('#__menu');
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Videos', title = 'Browse Mobile Videos', link = '/recent/', current = 'video', pos = 1, lang = 'Videos'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Categories', title = 'Browse Mobile Categories', link = '/categories/', current = 'categories', pos = 2, lang = 'categories'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Photos', title = 'Browse Mobile Photos', link = '/photos/', current = 'photo', pos = 3, lang = 'photos'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Pornstars', title = 'Browse Mobile Pornstars', link = '/pornstars/', current = 'pornstar', pos = 4, lang = 'pornstars'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'DMCA', title = 'DMCA', link = '/dmca/', current = '', pos = 5, lang = 'DMCA'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = '2257', title = '2257', link = '/2257/', current = '', pos = 6, lang = '2257'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Feedback', title = 'Support/Feedback', link = '/feedback/', current = '', pos = 7, lang = 'feedback'");
$db->query("INSERT INTO #__menu_links SET menu_id = ".$menu_id.", name = 'Help', title = 'Help', link = '/help/', current = '', pos = 8, lang = 'help'");
// add mobile static pages
$date = date('Y-m-d h:i:s');
$db->query("INSERT INTO #__static
SET user_id = 1,
name = 'dmca-mobile',
title = 'DMCA',
content = '<p>DMCA Static Content goes here!</p>',
meta_title = 'DMCA Meta Title',
meta_desc = 'DMCA Meta Description',
meta_keys = 'DMCA Meta Keywords',
add_date = '".$date."'");
$db->query("INSERT INTO #__static
SET user_id = 1,
name = 'terms-mobile',
title = 'Terms and Conditions',
content = '<p>Terms and Conditions Static Content goes here!</p>',
meta_title = 'Terms and Conditions Meta Title',
meta_desc = 'Terms and Conditions Meta Description',
meta_keys = 'Terms and Conditions Meta Keywords',
add_date = '".$date."'");
$db->query("INSERT INTO #__static
SET user_id = 1,
name = 'privacy-mobile',
title = 'Privacy Policy',
content = '<p>Privacy Policy Static Content goes here!</p>',
meta_title = 'Privacy Policy Meta Title',
meta_desc = 'Privacy Policy Meta Description',
meta_keys = 'Privacy Policy Meta Keywords',
add_date = '".$date."'");
$db->query("INSERT INTO #__static
SET user_id = 1,
name = '2257-mobile',
title = '2257',
content = '<p>2257 Static Content goes here!</p>',
meta_title = '2257 Meta Title',
meta_desc = '2257 Meta Description',
meta_keys = '2257 Meta Keywords',
add_date = '".$date."'");
$db->query("INSERT INTO #__static
SET user_id = 1,
name = 'help-mobile',
title = 'Help',
content = '<p>Help Static Content goes here!</p>',
meta_title = 'Help Meta Title',
meta_desc = 'Help Meta Description',
meta_keys = 'Help Meta Keywords',
add_date = '".$date."'");
// update our language
$lfile = file_get_contents(dirname(__FILE__).'/langs/mobile.en-US.lang.php');
$db->query("INSERT INTO #__language_files
SET name = 'mobile',
description = 'Mobile Frontend Language File',
code = 'en-US',
type = 'frontend',
file = '".$db->escape($lfile)."'");
// update our language
$lfile = file_get_contents(dirname(__FILE__).'/langs/mobile.en-UK.lang.php');
$db->query("INSERT INTO #__language_files
SET name = 'mobile',
description = 'Mobile Frontend Language File',
code = 'en-UK',
type = 'frontend',
file = '".$db->escape($lfile)."'");
// adding new language fields to en-US
$db->query("SELECT file
FROM #__language_files
WHERE name = 'user'
AND code = 'en-US'
LIMIT 1");
if ($db->affected_rows()) {
$lfile = unserialize($db->fetch_field('file'));
$lfile['confirm-invalid'] = 'Invalid confirmation code and/or username!';
$db->query("UPDATE #__language_files
SET file = '".$db->escape(serialize($lfile))."'
WHERE name = 'user'
AND code = 'en-US'
LIMIT 1");
}
$db->query("SELECT file
FROM #__language_files
WHERE name = 'community'
AND code = 'en-US'
LIMIT 1");
if ($db->affected_rows()) {
$lfile = unserialize($db->fetch_field('file'));
$lfile['interested'] = 'Interests';
$lfile['online'] = 'Online';
$db->query("UPDATE #__language_files
SET file = '".$db->escape(serialize($lfile))."'
WHERE name = 'community'
AND code = 'en-US'
LIMIT 1");
}
$db->query("SELECT file
FROM #__language_files
WHERE name = 'profile'
AND code = 'en-US'
LIMIT 1");
if ($db->affected_rows()) {
$lfile = unserialize($db->fetch_field('file'));
$lfile['comment-delete-success'] = 'Comment deleted!';
$lfile['comment-delete-access'] = 'You are not allowed to delete this comment!';
$lfile['comment-missing'] = 'Invalid comment! Are you sure this comment exists!?';
$lfile['comment-login-delete'] = 'Please login to delete comments!';
$db->query("UPDATE #__language_files
SET file = '".$db->escape(serialize($lfile))."'
WHERE name = 'profile'
AND code = 'en-US'
LIMIT 1");
}
// adding new language fields to en-UK
$db->query("SELECT file
FROM #__language_files
WHERE name = 'user'
AND code = 'en-UK'
LIMIT 1");
if ($db->affected_rows()) {
$lfile = unserialize($db->fetch_field('file'));
$lfile['confirm-invalid'] = 'Invalid confirmation code and/or username!';
$db->query("UPDATE #__language_files
SET file = '".$db->escape(serialize($lfile))."'
WHERE name = 'user'
AND code = 'en-UK'
LIMIT 1");
}
$db->query("SELECT file
FROM #__language_files
WHERE name = 'community'
AND code = 'en-UK'
LIMIT 1");
if ($db->affected_rows()) {
$lfile = unserialize($db->fetch_field('file'));
$lfile['interested'] = 'Interests';
$lfile['online'] = 'Online';
$db->query("UPDATE #__language_files
SET file = '".$db->escape(serialize($lfile))."'
WHERE name = 'community'
AND code = 'en-UK'
LIMIT 1");
}
$db->query("SELECT file
FROM #__language_files
WHERE name = 'profile'
AND code = 'en-UK'
LIMIT 1");
if ($db->affected_rows()) {
$lfile = unserialize($db->fetch_field('file'));
$lfile['comment-delete-success'] = 'Comment deleted!';
$lfile['comment-delete-access'] = 'You are not allowed to delete this comment!';
$lfile['comment-missing'] = 'Invalid comment! Are you sure this comment exists!?';
$lfile['comment-login-delete'] = 'Please login to delete comments!';
$db->query("UPDATE #__language_files
SET file = '".$db->escape(serialize($lfile))."'
WHERE name = 'profile'
AND code = 'en-UK'
LIMIT 1");
}
// convert old thumbs to new system
$db->query("SELECT video_id, thumbs FROM #__video");
$videos = $db->fetch_rows();
foreach ($videos as $video) {
$video_id = (int) $video['video_id'];
$thumbs = (int) $video['thumbs'];
$path = MEDIA_DIR.'/videos/tmb/'.path($video_id);
if (!file_exists($path)) {
mkdir($path, 0777, TRUE);
}
for ($i=1; $i<=$thumbs; $i++) {
$tmb_old = MEDIA_DIR.'/videos/tmb/'.$video_id.'/'.$i.'.jpg';
$tmb_new = $path.'/'.$i.'.jpg';
rename($tmb_old, $tmb_new);
}
VFolder::delete(MEDIA_DIR.'/videos/tmb/'.$video_id);
}
// clear the cache
VF::factory('cache')->clear();
$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.0beta3-to-1.0beta4.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.0beta3-to-1.0beta4.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 a few important configuration changes. It is recommended that you login to the site's
Administration Panel and re-update the configuration for the video module (set the default values on the conversion config page)! You
also need to edit the email templates and make sure the variables are defined correctly, like [#VAR_NAME#]!</i><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>