installer changes, pe sync
This commit is contained in:
parent
7294a3aab1
commit
35e29e10e6
15 changed files with 345 additions and 77 deletions
|
@ -170,8 +170,9 @@ function dfrn_notify_post(&$a) {
|
|||
);
|
||||
|
||||
$url = $a->get_baseurl();
|
||||
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||
|
||||
proc_close(proc_open("php include/notifier.php $url comment-import $posted_id > remote-notify.log &",
|
||||
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$url\" \"comment-import\" \"$posted_id\" &",
|
||||
array(),$foo));
|
||||
|
||||
if(($importer['notify-flags'] & NOTIFY_COMMENT) && (! $importer['self'])) {
|
||||
|
|
|
@ -34,7 +34,7 @@ function dfrn_poll_init(&$a) {
|
|||
if((int) $xml->status == 1) {
|
||||
$_SESSION['authenticated'] = 1;
|
||||
$_SESSION['visitor_id'] = $r[0]['id'];
|
||||
$_SESSION['sysmsg'] .= "Hi {$r[0]['name']}" . EOL;
|
||||
notice( t('Hi ') . $r[0]['name'] . EOL);
|
||||
// Visitors get 1 day session.
|
||||
$session_id = session_id();
|
||||
$expire = time() + 86400;
|
||||
|
|
153
mod/install.php
Normal file
153
mod/install.php
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
|
||||
|
||||
function install_post(&$a) {
|
||||
|
||||
global $db;
|
||||
|
||||
$dbhost = notags(trim($_POST['dbhost']));
|
||||
$dbuser = notags(trim($_POST['dbuser']));
|
||||
$dbpass = notags(trim($_POST['dbpass']));
|
||||
$dbdata = notags(trim($_POST['dbdata']));
|
||||
$timezone = notags(trim($_POST['timezone']));
|
||||
$phpath = notags(trim($_POST['phpath']));
|
||||
|
||||
require_once("dba.php");
|
||||
|
||||
$db = new dba($dbhost, $dbuser, $dbpass, $dbdata, $true);
|
||||
|
||||
if(! $db->getdb()) {
|
||||
notice( t('Could not connect to database.') . EOL);
|
||||
return;
|
||||
}
|
||||
else
|
||||
notice( t('Connected to database.') . EOL);
|
||||
|
||||
$tpl = file_get_contents('view/htconfig.tpl');
|
||||
$txt = replace_macros($tpl,array(
|
||||
'$dbhost' => $dbhost,
|
||||
'$dbuser' => $dbuser,
|
||||
'$dbpass' => $dbpass,
|
||||
'$dbdata' => $dbdata,
|
||||
'$timezone' => $timezone,
|
||||
'$phpath' => $phpath
|
||||
));
|
||||
$result = file_put_contents('.htconfig.php', $txt);
|
||||
if(! $result) {
|
||||
$a->data = $txt;
|
||||
}
|
||||
|
||||
$errors = load_database($db);
|
||||
if(! $errors) {
|
||||
// Our sessions normally are stored in the database. But as we have only managed
|
||||
// to get it bootstrapped milliseconds ago, we have to apply a bit of trickery so
|
||||
// that you'll see the following important notice (which is stored in the session).
|
||||
|
||||
session_write_close();
|
||||
require_once('session.php');
|
||||
session_start();
|
||||
$_SESSION['sysmsg'] = '';
|
||||
|
||||
notice( t('Database import succeeded.') . EOL
|
||||
. t('IMPORTANT: You will need to (manually) setup a scheduled task for the poller.') . EOL
|
||||
. t('Please see the file INSTALL.') . EOL );
|
||||
goaway($a->get_baseurl());
|
||||
}
|
||||
else {
|
||||
$db = null; // start fresh
|
||||
notice( t('Database import failed.') . EOL
|
||||
. t('You may need to import the file "database.sql" manually using phpmyadmin or mysql.') . EOL
|
||||
. t('Please see the file INSTALL.') . EOL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function install_content(&$a) {
|
||||
|
||||
notice( t('Welcome to the Mistpark Social Network.') . EOL);
|
||||
|
||||
$o .= check_htconfig();
|
||||
if(strlen($o))
|
||||
return $o;
|
||||
|
||||
if(strlen($a->data)) {
|
||||
$o .= manual_config($a);
|
||||
return;
|
||||
}
|
||||
|
||||
$o .= check_php($phpath);
|
||||
|
||||
require_once('datetime.php');
|
||||
|
||||
$tpl = file_get_contents('view/install_db.tpl');
|
||||
$o .= replace_macros($tpl, array(
|
||||
'$tzselect' => ((x($_POST,'timezone')) ? select_timezone($_POST['timezone']) : select_timezone()),
|
||||
'$submit' => t('Submit'),
|
||||
'$dbhost' => ((x($_POST,'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost'),
|
||||
'$dbuser' => notags(trim($_POST['dbuser'])),
|
||||
'$dbpass' => notags(trim($_POST['dbpass'])),
|
||||
'$dbdata' => notags(trim($_POST['dbdata'])),
|
||||
'$phpath' => $phpath
|
||||
));
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function check_php(&$phpath) {
|
||||
$phpath = trim(shell_exec('which php'));
|
||||
if(! strlen($phpath)) {
|
||||
$o .= <<< EOT
|
||||
Could not find a command line version of PHP in the web server PATH. This is required. Please adjust the configuration file .htconfig.php accordingly.
|
||||
|
||||
EOT;
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
|
||||
function check_htconfig() {
|
||||
|
||||
if(((file_exists('.htconfig.php')) && (! is_writable('.htconfig.php')))
|
||||
|| (! is_writable('.'))) {
|
||||
|
||||
$o .= <<< EOT
|
||||
|
||||
The web installer needs to be able to create a file called ".htconfig.php" in the top folder of
|
||||
your web server. It is unable to do so. This is most often a permission setting, as the web server
|
||||
may not be able to write files in your folder (even if you can).
|
||||
|
||||
Please check with your site documentation or support people to see if this situation can be corrected.
|
||||
If not, you may be required to perform a manual installation. Please see the file "INSTALL" for instructions.
|
||||
|
||||
EOT;
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
function manual_config(&$a) {
|
||||
$o .= <<< EOT
|
||||
The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.
|
||||
|
||||
<textarea rows="24" cols="80" >{$a->data}</textarea>
|
||||
EOT;
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
function load_database($db) {
|
||||
|
||||
$str = file_get_contents('database.sql');
|
||||
$arr = explode(';',$str);
|
||||
$errors = 0;
|
||||
foreach($arr as $a) {
|
||||
if(strlen(trim($a))) {
|
||||
$r = @$db->q(trim($a));
|
||||
if(! $r) {
|
||||
notice( t('Errors encountered creating database tables.') . $a . EOL);
|
||||
$errors ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $errors;
|
||||
}
|
|
@ -239,8 +239,9 @@ function item_post(&$a) {
|
|||
}
|
||||
}
|
||||
$url = $a->get_baseurl();
|
||||
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||
|
||||
proc_close(proc_open("php include/notifier.php \"$url\" \"$notify_type\" \"$post_id\" > notify.log &",
|
||||
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$url\" \"$notify_type\" \"$post_id\" &",
|
||||
array(),$foo));
|
||||
|
||||
goaway($a->get_baseurl() . "/" . $_POST['return'] );
|
||||
|
@ -308,10 +309,11 @@ function item_content(&$a) {
|
|||
|
||||
$url = $a->get_baseurl();
|
||||
$drop_id = intval($item['id']);
|
||||
|
||||
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||
|
||||
// send the notification upstream/downstream as the case may be
|
||||
|
||||
proc_close(proc_open("php include/notifier.php \"$url\" \"drop\" \"$drop_id\" > notify.log &",
|
||||
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$url\" \"drop\" \"$drop_id\" &",
|
||||
array(),$foo));
|
||||
|
||||
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
|
||||
|
|
|
@ -68,9 +68,10 @@ function message_post(&$a) {
|
|||
$post_id = $r[0]['id'];
|
||||
|
||||
$url = $a->get_baseurl();
|
||||
|
||||
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||
|
||||
if($post_id) {
|
||||
proc_close(proc_open("php include/notifier.php \"$url\" \"mail\" \"$post_id\" > mail.log &",
|
||||
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$url\" \"mail\" \"$post_id\" &",
|
||||
array(),$foo));
|
||||
notice( t('Message sent.') . EOL );
|
||||
}
|
||||
|
@ -135,7 +136,9 @@ function message_content(&$a) {
|
|||
if(($a->argc > 2) && ($a->argv[1] == 'redeliver') && intval($a->argv[2])) {
|
||||
$url = $a->get_baseurl();
|
||||
$post_id = intval($a->argv[2]);
|
||||
proc_close(proc_open("php include/notifier.php \"$url\" \"mail\" \"$post_id\" > mail.log &",
|
||||
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||
|
||||
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$url\" \"mail\" \"$post_id\" &",
|
||||
array(),$foo));
|
||||
goaway($a->get_baseurl() . '/message' );
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
function notifications_post(&$a) {
|
||||
|
||||
if((! x($_SESSION,'authenticated')) || (! (x($_SESSION,'uid')))) {
|
||||
if(! local_user()) {
|
||||
goaway($a->get_baseurl());
|
||||
}
|
||||
|
||||
$request_id = (($a->argc > 1) ? $a->argv[0] : 0);
|
||||
$request_id = (($a->argc > 1) ? $a->argv[1] : 0);
|
||||
|
||||
if($request_id == "all")
|
||||
return;
|
||||
|
@ -24,17 +24,17 @@ function notifications_post(&$a) {
|
|||
$intro_id = $r[0]['id'];
|
||||
}
|
||||
else {
|
||||
$_SESSION['sysmsg'] .= "Invalid request identifier." . EOL;
|
||||
notice( t('Invalid request identifier.') . EOL);
|
||||
return;
|
||||
}
|
||||
if($_POST['submit'] == 'Discard') {
|
||||
if($_POST['submit'] == t('Discard'() {
|
||||
$r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", intval($intro_id));
|
||||
$r = q("DELETE `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($request_id),
|
||||
intval($_SESSION['uid']));
|
||||
return;
|
||||
}
|
||||
if($_POST['submit'] == 'Ignore') {
|
||||
if($_POST['submit'] == t('Ignore')) {
|
||||
$r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d LIMIT 1",
|
||||
intval($intro_id));
|
||||
return;
|
||||
|
@ -48,12 +48,13 @@ function notifications_post(&$a) {
|
|||
|
||||
function notifications_content(&$a) {
|
||||
|
||||
$o = '';
|
||||
|
||||
if((! x($_SESSION,'authenticated')) || (! (x($_SESSION,'uid')))) {
|
||||
if(! local_user()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
goaway($a->get_baseurl());
|
||||
}
|
||||
|
||||
$o = '';
|
||||
|
||||
if(($a->argc > 1) && ($a->argv[1] == 'all'))
|
||||
$sql_extra = '';
|
||||
else
|
||||
|
@ -63,7 +64,7 @@ function notifications_content(&$a) {
|
|||
$tpl = file_get_contents('view/intros-top.tpl');
|
||||
$o .= replace_macros($tpl,array(
|
||||
'$hide_url' => ((strlen($sql_extra)) ? 'notifications/all' : 'notifications' ),
|
||||
'$hide_text' => ((strlen($sql_extra)) ? 'Show Ignored Requests' : 'Hide Ignored Requests')
|
||||
'$hide_text' => ((strlen($sql_extra)) ? t('Show Ignored Requests') : t('Hide Ignored Requests'))
|
||||
));
|
||||
|
||||
$r = q("SELECT `intro`.`id` AS `intro-id`, `intro`.*, `contact`.*
|
||||
|
@ -85,14 +86,14 @@ function notifications_content(&$a) {
|
|||
'$contact-id' => $rr['contact-id'],
|
||||
'$photo' => ((x($rr,'photo')) ? $rr['photo'] : "images/default-profile.jpg"),
|
||||
'$fullname' => $rr['name'],
|
||||
'$knowyou' => (($rr['knowyou']) ? 'yes' : 'no'),
|
||||
'$knowyou' => (($rr['knowyou']) ? t('yes') : t('no')),
|
||||
'$url' => $rr['url'],
|
||||
'$note' => $rr['note']
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
$_SESSION['sysmsg'] .= "No notifications." . EOL;
|
||||
notice( t('No notifications.') . EOL);
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -124,11 +124,12 @@ function photos_post(&$a) {
|
|||
|
||||
$url = $a->get_baseurl();
|
||||
$drop_id = intval($rr['id']);
|
||||
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||
|
||||
// send the notification upstream/downstream as the case may be
|
||||
|
||||
if($rr['visible'])
|
||||
proc_close(proc_open("php include/notifier.php \"$url\" \"drop\" \"$drop_id\" & ",
|
||||
proc_close(proc_open("\"php_path\" \"include/notifier.php\" \"$url\" \"drop\" \"$drop_id\" & ",
|
||||
array(),$foo));
|
||||
|
||||
}
|
||||
|
@ -160,11 +161,12 @@ function photos_post(&$a) {
|
|||
|
||||
$url = $a->get_baseurl();
|
||||
$drop_id = intval($i[0]['id']);
|
||||
|
||||
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||
|
||||
// send the notification upstream/downstream as the case may be
|
||||
|
||||
if($i[0]['visible'])
|
||||
proc_close(proc_open("php include/notifier.php \"$url\" \"drop\" \"$drop_id\" & ",
|
||||
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"$url\" \"drop\" \"$drop_id\" & ",
|
||||
array(),$foo));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue