Please login or register.

Login with username, password and session length
Advanced search  


You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: sNews Automatic Remote Installer  (Read 16607 times)


  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1717
sNews Automatic Remote Installer
« on: September 27, 2007, 05:36:06 pm »

This is for testing purposes only and should not be used on a live server!


Collects credentials, takes sNews install files from and tries to set up sNews automatically. Ideally, you would just have to upload a single php file where you want sNews installed and everything would be set up automatically.

How to try it out:

1) Save this file

2) Rename it to install.php and copy to your www folder if you're testing locally. (On Linux make that folder 777)

3) Run install.php


  • Guest
Re: sNews Automatic Remote Installer
« Reply #1 on: September 27, 2007, 05:57:40 pm »

Haven't tried this out Luka but it seems like a great idea!

oh and by the way.... any word on that gallery??

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: sNews Automatic Remote Installer
« Reply #2 on: September 27, 2007, 07:00:13 pm »

LUKA impressive, ideia.

I tried in local host, works 100%.

Congratulations for this amazing project, Future is for sNews for sure.

Thank You, you deserve 100 karma.  ;D
Need a Job on Europe. Linkdin - Facebook / Group

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: sNews Automatic Remote Installer
« Reply #3 on: September 27, 2007, 08:01:37 pm »

101! 8)


  • Sr. Member
  • ****
  • Karma: 4
  • Posts: 276
Re: sNews Automatic Remote Installer
« Reply #4 on: September 27, 2007, 08:09:59 pm »

102 ;D


  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Re: sNews Automatic Remote Installer
« Reply #5 on: September 28, 2007, 01:26:21 am »

wow this is neato! :D
my apologies to the sNews crew, but I will be MIA for the forseeable future


  • Guest
Re: sNews Automatic Remote Installer
« Reply #6 on: January 30, 2008, 12:38:57 pm »

Bug on Mac. 
sNews Installer
Installing Database

Connection successfull for user: root
Database was not created!
Articles Table: OK
Categories Table: OK
Comments Table: OK
Settings Table: OK
Installing Files

.htaccess successfully copied
index.php successfully copied
style.css successfully copied
snews.php successfully copied

Database was clearly created but script is saying it wasn't


  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
Re: sNews Automatic Remote Installer
« Reply #7 on: January 30, 2008, 08:04:22 pm »

Bug on Mac. 
Database was clearly created but script is saying it wasn't.

Just gave this a test-run on my localhost (XP) machine. I hadn't tried this before until Jason revived the discussion (thanks Jason).
My result - a near perfect install.  :)
After install was complete, script said the database was installed successfully.
I did not realize that is also created the database as well as install the tables... until I used a dbase name that didn't exist yet.
I also wasn't sure what the site uname and password fields were for and left them empty. It appeared to have created some other U & P string-set in the settings rows 22 & 23... which I didn't know of course... so I added the default hashed strings for "test | test" to get logged in.
Other than that little learning curve... it works 100%.
Do it now... later may not come.
sNews 1.6 MESU | sNews 1.6 MEMU


  • Jr. Member
  • **
  • Karma: 0
  • Posts: 67
Re: sNews Automatic Remote Installer
« Reply #8 on: January 18, 2009, 02:45:18 am »

The link in the original post to the auto install script is no longer valid - does someone have a copy of this they could provide?

This installer looks to be a good idea (not surprising given where the idea came from).


  • Guest
Re: sNews Automatic Remote Installer
« Reply #9 on: January 18, 2009, 05:42:42 am »

May not work if the files it needs is not on Luka's site... it is also not supported at all. 

Code: [Select]


sNews Installer
Installer version: .97
     Collects credentials, takes sNews install files 
     from and tries to set up sNews 
     Future Ideas:
     This installer would work along with an automod
     script for sNews. Users would be able to choose
     which mods they would like installed and have it
     all automatically set up by uploading only
     this single file installer.
     == WARNING =====================================

This file should only serve as an example how
sNews could be installed remotely and easily.
You should not attempt to use this installer
on a live server because you might loose files
or database data.





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<meta name="Robots" content="nofollow" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<title>sNews Installer</title>
<style type="text/css">
body { font: .9em Arial; margin: 4% 5%; }
h1, h2 { color: #F74600; }
label { display: block; }
input.field { padding: 3px; font: 1.3em Arial; }
input.submit { padding: 3px; font: 1.3em Arial; }
fieldset { float: left; width: 260px; margin: 0 20px 0 0; border: 1px solid #ccc; padding: 15px; }
.red { font-weight: bold; color: #F74600; }
.green { font-weight: bold; color: #13BD00; }
.link { color: #F74600; text-decoration: underline; cursor: pointer; }
<script type="text/javascript">
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") {
http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
http = new XMLHttpRequest();

function go() {
var dbhost = document.install_form.dbhost.value;
var dbuname = document.install_form.dbuname.value;
var dbpass = document.install_form.dbpass.value;"GET", "install.php?action=check_connection&dbhost="+dbhost+"&dbuname="+dbuname+"&dbpass="+dbpass, true);
http.onreadystatechange=function() {
if(http.readyState == 4) {
document.getElementById('connection').innerHTML = http.responseText;


<div class="wrap">
<h1>sNews Installer</h1>

<div class="box">

if ($_POST['install']) {

echo '<h3>Installing Database</h3>';


$dbhost $_POST['dbhost'];
$dbname $_POST['dbname'];
$dbuname $_POST['dbuname'];
$dbpass $_POST['dbpass'];
$prefix $_POST['prefix'];

$url clean($_POST['url']);
$uname md5(clean($_POST['uname']));
$password md5(clean($_POST['password']));
$passwordr md5(clean($_POST['passwordr']));

/* check if the passwords exist and are the same */
if (!$password || $password <> $passwordr) {
} else {

/* test connection to mysql */
$connection mysql_connect($dbhost$dbuname$dbpass);
  if ( !$connection  ) {

} else {

echo 'Connection successfull for user: <strong>'.$dbuname.'</strong><br />';
if ($dbname) {
$query  "CREATE DATABASE ".$dbname;
$result mysql_query($query);
} else {
if (!$result) { 
echo 'Database was not created!<br />'
} else {
echo 'database created ok<br />'

mysql_select_db($dbname) or die('Cannot select database'); 
$articles_query "CREATE TABLE ".$dbprefix."articles (
id int(11) primary key auto_increment,
title varchar(100) default NULL,
seftitle varchar(100) default NULL,
   `text` longtext,
   `date` datetime default NULL,
   category int(8) NOT NULL default '0',
   position int(6) default NULL,
   displaytitle char(3) NOT NULL default 'YES',
   displayinfo char(3) NOT NULL default 'YES',
   commentable varchar(5) NOT NULL default '',
   published int(3) NOT NULL default '1',
   description_meta varchar(255) default NULL,
   keywords_meta varchar(255) default NULL

$categories_query "CREATE TABLE ".$dbprefix."categories (
   id int(8) primary key auto_increment,
  name varchar(100) NOT NULL,
  seftitle varchar(100) NOT NULL,
  description varchar(255) NOT NULL,
  published varchar(4) NOT NULL default 'YES',
  catorder smallint(6) NOT NULL default '0'

$comments_query "CREATE TABLE ".$dbprefix."comments (
  id int(11) primary key auto_increment,
  articleid int(11) default '0',
  name varchar(50),
  url varchar(100) NOT NULL,
  comment text,
  time datetime NOT NULL default '0000-00-00 00:00:00',
  approved varchar(5) NOT NULL default 'True'

$settings_query "CREATE TABLE ".$dbprefix."settings (
  id int(8) primary key auto_increment,
  name varchar(20) NOT NULL,
  `value` varchar(60) NOT NULL

$articles_result mysql_query($articles_query);
echo 'Articles Table: ';
if (!$articles_result) { echo 'NOT OK'; } else { echo '<span class="ok">OK</span>'; }

$categories_result mysql_query($categories_query);
echo '<br />Categories Table: ';
if (!$categories_result) { echo 'NOT OK'; } else { echo '<span class="ok">OK</span>'; }

$comments_result mysql_query($comments_query);
echo '<br />Comments Table: ';
if (!$comments_result) { echo 'NOT OK'; } else { echo '<span class="ok">OK</span>'; }

$settings_result mysql_query($settings_query);
echo '<br />Settings Table: ';
if (!$settings_result) { echo 'NOT OK'; } else { echo '<span class="ok">OK</span>'; }

mysql_query("INSERT INTO ".$dbprefix."settings VALUES(1, 'website_title', 'sNews 1.6')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(2, 'home_sef', 'home')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(3, 'website_description', 'sNews CMS')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(4, 'website_keywords', 'new, site, snews')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(5, 'website_email', '')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(6, 'contact_subject', 'Contact Form')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(7, 'language', 'EN')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(8, 'charset', 'UTF-8')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(9, 'date_format', 'd.m.Y. H:i')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(10, 'article_limit', '3')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(11, 'rss_limit', '5')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(12, 'display_page', '')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(13, 'display_new_on_home', '')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(14, 'display_pagination', '')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(15, 'num_categories', 'on')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(16, 'approve_comments', '')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(17, 'comments_order', 'ASC')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(18, 'comment_limit', '30')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(19, 'word_filter_enable', '')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(20, 'word_filter_file', '')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(21, 'word_filter_change', '')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(22, 'username', '$uname')");
mysql_query("INSERT INTO ".$dbprefix."settings VALUES(23, 'password', '$password')");


echo '<h3>Installing Files</h3>';

// copy .htaccess
if (!copy('''.htaccess')) {
echo "failed to copy $file...\n";
} else {
echo '.htaccess successfully copied<br />';

// copy index.php
if (!copy('''index.php')) {
echo "failed to copy $file...\n";
} else {
echo 'index.php successfully copied<br />';

// copy style.css
if (!copy('''style.css')) {
echo "failed to copy $file...\n";
} else {
echo 'style.css successfully copied<br />';

// copy snews.txt from the server
if (!copy('''snews.php')) {
echo "failed to copy $file...\n";
} else {
echo 'snews.php successfully copied<br />';

// open snews.php and replace variables
$file 'snews.php';
$fileopen fopen($file,"r+");
$string fread($fileopen,filesize($file));
$fileopen2 fopen($file,"w+");

$string str_replace('$db[\'website\'] = \'http://localhost/snews/\';','$db[\'website\'] = \''.$url.'\';',$string);
$string str_replace('$db[\'dbhost\'] = \'localhost\';','$db[\'dbhost\'] = \''.$dbhost.'\';',$string);
$string str_replace('$db[\'dbname\'] = \'snews\';','$db[\'dbname\'] = \''.$dbname.'\';',$string);
$string str_replace('$db[\'dbuname\'] = \'username\';','$db[\'dbuname\'] = \''.$dbuname.'\';',$string);
$string str_replace('$db[\'dbpass\'] = \'password\';','$db[\'dbpass\'] = \''.$dbpass.'\';',$string);
$string str_replace('$db[\'prefix\'] = \'\';','$db[\'prefix\'] = \''.$prefix.'\';',$string);


echo '<h3>Done!</h3>';
echo '<p><a href=".">View your site</a></p>';


} else if (!$error) {





function form($error) {

$dbhost clean($_POST['dbhost']);
$dbname clean($_POST['dbname']);
$dbuname clean($_POST['dbuname']);
$dbpass clean($_POST['dbpass']);
$prefix clean($_POST['prefix']);

$url clean($_POST['url']);
$uname clean($_POST['uname']);
$password clean($_POST['password']);
$passwordr clean($_POST['passwordr']);

if (!$url) { $url url(); }

if ($error == 'connection_error') { $connclass "red"; } else { $connclass "black"; }
if ($error == 'dbname_error') { $dbnameclass "red"; } else { $dbnameclass "black"; }
if ($error == 'pass_error') { $passclass "red"; } else { $passclass "black"; }


<form method="post" name="install_form" action="install.php">
<legend>Database Settings</legend>
<p><label for="dbh" class="<?php echo $connclass?>">Host:</label>
<input onChange="go();" type="text" name="dbhost" id="dbh" class="field" value="<?php if ($error) { echo $dbhost; } else { echo  'localhost'; } ?>" /></p>
<p><label for="dbu" class="<?php echo $connclass?>">Database username:</label>
<input onChange="go();" type="text" name="dbuname" id="dbu" class="field" value="<?php echo $dbuname?>" /></p>
<p><label for="dbp" class="<?php echo $connclass?>">Database password:</label>
<input onChange="go();" type="text" name="dbpass" id="dbp" class="field" value="<?php echo $dbpass?>" /></p>
<p><label for="dbn" class="<?php echo $connclass?>">Database name: (non-numeric)</label>
<input type="text" name="dbname" id="dbn" class="field" value="<?php echo $dbname?>" /></p>
<p><label for="dbpr" class="<?php echo $connclass?>">Database prefix:</label>
<input type="text" name="prefix" id="dbpr" class="field" value="<?php echo $prefix?>" /></p>
<p id="connection">Connection check</p>


<legend>Site Settings</legend>
<p><label for="u">Site URL:</label>
<input type="text" name="url" id="u" value="<?php echo $url?>" class="field" /></p>
<p><label for="un" class="<?php echo $passclass?>">Site username:</label>
<input type="text" name="uname" id="un" class="field"  value="<?php echo $uname?>"/></p>
<p><label for="pw" class="<?php echo $passclass?>">Site password:</label>
<input type="password" name="password" id="pw" class="field" value="<?php echo $password?>" /></p>
<p><label for="pwr" class="<?php echo $passclass?>">Password repeat:</label>
<input type="password" name="passwordr" id="pwr" class="field" value="<?php echo $passwordr?>" /></p>
<input type="submit" value="Install" name="install" class="submit" />



url() {
$url 'http';
if ($_SERVER["HTTPS"] == "on") { $url .= "s"; }
$url .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
} else {
$url str_replace('install.php','',$url);
return $url;

clean($variable) {
//do some cleaning
return $variable;

doajax() {
if ($_GET['action'] == 'check_connection') { 
$dbhost $_GET['dbhost'];
$dbuname $_GET['dbuname'];
$dbpass $_GET['dbpass'];
$connection mysql_connect($dbhost$dbuname$dbpass);
if ( !$connection  ) {
echo '<span class="red">Not connected</span>';

} else {
echo '<span class="green">Connected</span>';



  • Jr. Member
  • **
  • Karma: 0
  • Posts: 67
Re: sNews Automatic Remote Installer
« Reply #10 on: January 18, 2009, 07:31:06 am »

Thanks for posting the code.

May not work if the files it needs is not on Luka's site... it is also not supported at all.