Merge pull request #1274 from annando/issue-1218
Issue 1218: generate $argv and $argc from $_SERVER if it wasn't defined
This commit is contained in:
commit
418ac91c31
8
boot.php
8
boot.php
|
@ -435,7 +435,7 @@ if(! class_exists('App')) {
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
|
|
||||||
global $default_timezone, $argv, $argc;
|
global $default_timezone;
|
||||||
|
|
||||||
$hostname = "";
|
$hostname = "";
|
||||||
|
|
||||||
|
@ -504,9 +504,9 @@ if(! class_exists('App')) {
|
||||||
if ($hostname != "")
|
if ($hostname != "")
|
||||||
$this->hostname = $hostname;
|
$this->hostname = $hostname;
|
||||||
|
|
||||||
if (is_array($argv) && $argc>1 && substr(end($argv), 0, 4)=="http" ) {
|
if (is_array($_SERVER["argv"]) && $_SERVER["argc"]>1 && substr(end($_SERVER["argv"]), 0, 4)=="http" ) {
|
||||||
$this->set_baseurl(array_pop($argv) );
|
$this->set_baseurl(array_pop($_SERVER["argv"]) );
|
||||||
$argc --;
|
$_SERVER["argc"] --;
|
||||||
}
|
}
|
||||||
|
|
||||||
#set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
|
#set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
|
||||||
|
|
|
@ -66,6 +66,6 @@ function cronhooks_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
cronhooks_run($argv,$argc);
|
cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1346,6 +1346,6 @@ function dbstructure_run(&$argv, &$argc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
dbstructure_run($argv,$argc);
|
dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ function dbupdate_run(&$argv, &$argc) {
|
||||||
if(is_null($a)){
|
if(is_null($a)){
|
||||||
$a = new App;
|
$a = new App;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_null($db)) {
|
if(is_null($db)) {
|
||||||
@include(".htconfig.php");
|
@include(".htconfig.php");
|
||||||
require_once("include/dba.php");
|
require_once("include/dba.php");
|
||||||
|
@ -23,7 +23,6 @@ function dbupdate_run(&$argv, &$argc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
dbupdate_run($argv,$argc);
|
dbupdate_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -565,6 +565,6 @@ function delivery_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
delivery_run($argv,$argc);
|
delivery_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,6 @@ function directory_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
directory_run($argv,$argc);
|
directory_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,6 @@ function dsprphotoq_run($argv, $argc){
|
||||||
|
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
dsprphotoq_run($argv,$argc);
|
dsprphotoq_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,6 @@ function expire_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
expire_run($argv,$argc);
|
expire_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,6 @@ function gprobe_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
gprobe_run($argv,$argc);
|
gprobe_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,16 @@ require_once('include/html2plain.php');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file was at one time responsible for doing all deliveries, but this caused
|
* This file was at one time responsible for doing all deliveries, but this caused
|
||||||
* big problems on shared hosting systems, where the process might get killed by the
|
* big problems on shared hosting systems, where the process might get killed by the
|
||||||
* hosting provider and nothing would get delivered.
|
* hosting provider and nothing would get delivered.
|
||||||
* It now only delivers one message under certain cases, and invokes a queued
|
* It now only delivers one message under certain cases, and invokes a queued
|
||||||
* delivery mechanism (include/deliver.php) to deliver individual contacts at
|
* delivery mechanism (include/deliver.php) to deliver individual contacts at
|
||||||
* controlled intervals.
|
* controlled intervals.
|
||||||
* This has a much better chance of surviving random processes getting killed
|
* This has a much better chance of surviving random processes getting killed
|
||||||
* by the hosting provider.
|
* by the hosting provider.
|
||||||
* A lot of this code is duplicated in include/deliver.php until we have time to go back
|
* A lot of this code is duplicated in include/deliver.php until we have time to go back
|
||||||
* and re-structure the delivery procedure based on the obstacles that have been thrown at
|
* and re-structure the delivery procedure based on the obstacles that have been thrown at
|
||||||
* us by hosting providers.
|
* us by hosting providers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -50,7 +50,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
if(is_null($a)){
|
if(is_null($a)){
|
||||||
$a = new App;
|
$a = new App;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_null($db)) {
|
if(is_null($db)) {
|
||||||
@include(".htconfig.php");
|
@include(".htconfig.php");
|
||||||
require_once("include/dba.php");
|
require_once("include/dba.php");
|
||||||
|
@ -946,7 +946,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if((! $mail) && (! $fsuggest) && (! $followup)) {
|
if((! $mail) && (! $fsuggest) && (! $followup)) {
|
||||||
logger('notifier: delivery agent: ' . $rr['name'] . ' ' . $rr['id']);
|
logger('notifier: delivery agent: ' . $rr['name'] . ' ' . $rr['id']);
|
||||||
proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']);
|
proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']);
|
||||||
if($interval)
|
if($interval)
|
||||||
@time_sleep_until(microtime(true) + (float) $interval);
|
@time_sleep_until(microtime(true) + (float) $interval);
|
||||||
|
@ -966,7 +966,7 @@ function notifier_run(&$argv, &$argc){
|
||||||
if ($h === '[internal]') {
|
if ($h === '[internal]') {
|
||||||
// Set push flag for PuSH subscribers to this topic,
|
// Set push flag for PuSH subscribers to this topic,
|
||||||
// they will be notified in queue.php
|
// they will be notified in queue.php
|
||||||
q("UPDATE `push_subscriber` SET `push` = 1 " .
|
q("UPDATE `push_subscriber` SET `push` = 1 " .
|
||||||
"WHERE `nickname` = '%s'", dbesc($owner['nickname']));
|
"WHERE `nickname` = '%s'", dbesc($owner['nickname']));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -1001,6 +1001,6 @@ function notifier_run(&$argv, &$argc){
|
||||||
|
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
notifier_run($argv,$argc);
|
notifier_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -586,8 +586,8 @@ function onepoll_run(&$argv, &$argc){
|
||||||
|
|
||||||
// load current friends if possible.
|
// load current friends if possible.
|
||||||
|
|
||||||
if($contact['poco']) {
|
if($contact['poco']) {
|
||||||
$r = q("SELECT count(*) as total from glink
|
$r = q("SELECT count(*) as total from glink
|
||||||
where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
|
where `cid` = %d and updated > UTC_TIMESTAMP() - INTERVAL 1 DAY",
|
||||||
intval($contact['id'])
|
intval($contact['id'])
|
||||||
);
|
);
|
||||||
|
@ -602,6 +602,6 @@ function onepoll_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
onepoll_run($argv,$argc);
|
onepoll_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,6 +301,6 @@ function poller_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
poller_run($argv,$argc);
|
poller_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,6 +265,6 @@ function queue_run(&$argv, &$argc){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
queue_run($argv,$argc);
|
queue_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
12
testargs.php
12
testargs.php
|
@ -8,14 +8,14 @@
|
||||||
* During installation we need to check if register_argc_argv is
|
* During installation we need to check if register_argc_argv is
|
||||||
* enabled for the command line PHP processor, because otherwise
|
* enabled for the command line PHP processor, because otherwise
|
||||||
* deliveries will fail. So we will do a shell exec of php and
|
* deliveries will fail. So we will do a shell exec of php and
|
||||||
* execute this file with a command line argument, and see if it
|
* execute this file with a command line argument, and see if it
|
||||||
* echoes the argument back to us. Otherwise notify the person
|
* echoes the argument back to us. Otherwise notify the person
|
||||||
* that their installation doesn't meet the system requirements.
|
* that their installation doesn't meet the system requirements.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if(($argc > 1) && isset($argv[1]))
|
if(($_SERVER["argc"] > 1) && isset($_SERVER["argv"][1]))
|
||||||
echo $argv[1];
|
echo $_SERVER["argv"][1];
|
||||||
else
|
else
|
||||||
echo '';
|
echo '';
|
||||||
|
|
|
@ -8,7 +8,7 @@ function po2php_run(&$argv, &$argc) {
|
||||||
print "Usage: ".$argv[0]." <file.po>\n\n";
|
print "Usage: ".$argv[0]." <file.po>\n\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pofile = $argv[1];
|
$pofile = $argv[1];
|
||||||
$outfile = dirname($pofile)."/strings.php";
|
$outfile = dirname($pofile)."/strings.php";
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@ function po2php_run(&$argv, &$argc) {
|
||||||
print "Unable to find '$pofile'\n";
|
print "Unable to find '$pofile'\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "Out to '$outfile'\n";
|
print "Out to '$outfile'\n";
|
||||||
|
|
||||||
$out="<?php\n\n";
|
$out="<?php\n\n";
|
||||||
|
|
||||||
$infile = file($pofile);
|
$infile = file($pofile);
|
||||||
$k="";
|
$k="";
|
||||||
$v="";
|
$v="";
|
||||||
|
@ -53,14 +53,14 @@ function po2php_run(&$argv, &$argc) {
|
||||||
$out .= ' return '.$cond.';'."\n";
|
$out .= ' return '.$cond.';'."\n";
|
||||||
$out .= '}}'."\n";
|
$out .= '}}'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($k!="" && substr($l,0,7)=="msgstr "){
|
if ($k!="" && substr($l,0,7)=="msgstr "){
|
||||||
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
|
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
|
||||||
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
|
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
|
||||||
|
|
||||||
$v = substr($l,8,$len-10);
|
$v = substr($l,8,$len-10);
|
||||||
$v = preg_replace_callback($escape_s_exp,'escape_s',$v);
|
$v = preg_replace_callback($escape_s_exp,'escape_s',$v);
|
||||||
$inv = True;
|
$inv = True;
|
||||||
|
@ -69,28 +69,28 @@ function po2php_run(&$argv, &$argc) {
|
||||||
if ($k!="" && substr($l,0,7)=="msgstr["){
|
if ($k!="" && substr($l,0,7)=="msgstr["){
|
||||||
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
|
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
|
||||||
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
|
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
|
||||||
|
|
||||||
if (!$arr) {
|
if (!$arr) {
|
||||||
$arr=True;
|
$arr=True;
|
||||||
$out .= "array(\n";
|
$out .= "array(\n";
|
||||||
}
|
}
|
||||||
$match=Array();
|
$match=Array();
|
||||||
preg_match("|\[([0-9]*)\] (.*)|", $l, $match);
|
preg_match("|\[([0-9]*)\] (.*)|", $l, $match);
|
||||||
$out .= "\t".
|
$out .= "\t".
|
||||||
preg_replace_callback($escape_s_exp,'escape_s',$match[1])
|
preg_replace_callback($escape_s_exp,'escape_s',$match[1])
|
||||||
." => "
|
." => "
|
||||||
.preg_replace_callback($escape_s_exp,'escape_s',$match[2]) .",\n";
|
.preg_replace_callback($escape_s_exp,'escape_s',$match[2]) .",\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr($l,0,6)=="msgid_") { $ink = False; $out .= '$a->strings["'.$k.'"] = '; };
|
if (substr($l,0,6)=="msgid_") { $ink = False; $out .= '$a->strings["'.$k.'"] = '; };
|
||||||
|
|
||||||
|
|
||||||
if ($ink) {
|
if ($ink) {
|
||||||
$k .= trim($l,"\"\r\n");
|
$k .= trim($l,"\"\r\n");
|
||||||
$k = preg_replace_callback($escape_s_exp,'escape_s',$k);
|
$k = preg_replace_callback($escape_s_exp,'escape_s',$k);
|
||||||
//$out .= '$a->strings['.$k.'] = ';
|
//$out .= '$a->strings['.$k.'] = ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr($l,0,6)=="msgid "){
|
if (substr($l,0,6)=="msgid "){
|
||||||
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
|
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
|
||||||
if ($k!="") $out .= $arr?");\n":";\n";
|
if ($k!="") $out .= $arr?");\n":";\n";
|
||||||
|
@ -101,28 +101,28 @@ function po2php_run(&$argv, &$argc) {
|
||||||
} else {
|
} else {
|
||||||
$k = "";
|
$k = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$k = preg_replace_callback($escape_s_exp,'escape_s',$k);
|
$k = preg_replace_callback($escape_s_exp,'escape_s',$k);
|
||||||
$ink = True;
|
$ink = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($inv && substr($l,0,6)!="msgstr") {
|
if ($inv && substr($l,0,6)!="msgstr") {
|
||||||
$v .= trim($l,"\"\r\n");
|
$v .= trim($l,"\"\r\n");
|
||||||
$v = preg_replace_callback($escape_s_exp,'escape_s',$v);
|
$v = preg_replace_callback($escape_s_exp,'escape_s',$v);
|
||||||
//$out .= '$a->strings['.$k.'] = ';
|
//$out .= '$a->strings['.$k.'] = ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
|
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
|
||||||
if ($k!="") $out .= $arr?");\n":";\n";
|
if ($k!="") $out .= $arr?");\n":";\n";
|
||||||
|
|
||||||
$out = str_replace(DQ_ESCAPE, '\"', $out);
|
$out = str_replace(DQ_ESCAPE, '\"', $out);
|
||||||
file_put_contents($outfile, $out);
|
file_put_contents($outfile, $out);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_search(__file__,get_included_files())===0){
|
if (array_search(__file__,get_included_files())===0){
|
||||||
po2php_run($argv,$argc);
|
po2php_run($_SERVER["argv"],$_SERVER["argc"]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user