Paperyard
ppyrd.base.php
Go to the documentation of this file.
1 <?php
9  class ppyrd
10  {
19  var $db;
20 
24  function __construct($db) {
25  $this->db = $db;
26  $this->output("checking setup");
27 
28  // checks that all relevant directories have been mounted.
29  $warning = array();
30  if (file_exists('/data/scan/paperyardDirectoryNotMounted.txt'))
31  {
32  $warning[]= "scan folder not properly mounted. Please specify /data/scan in docker run command.\n";
33  }
34  if (file_exists('/data/inbox/paperyardDirectoryNotMounted.txt'))
35  {
36  $warning[]= "inbox folder not properly mounted. Please specify /data/inbox in docker run command.\n";
37  }
38  if (file_exists('/data/outbox/paperyardDirectoryNotMounted.txt'))
39  {
40  $warning[]= "outbox folder not properly mounted. Please specify /data/outbox in docker run command.\n";
41  }
42  if (file_exists('/data/sort/paperyardDirectoryNotMounted.txt'))
43  {
44  $warning[]= "sort folder not properly mounted. Please specify /sort/outbox in docker run command.\n";
45  }
46  if (file_exists('/data/database/paperyardDirectoryNotMounted.txt'))
47  {
48  $warning[]= "database folder not properly mounted. Please specify /data/database in docker run command.\n";
49  }
50  $this->warning = $warning;
51  $warningMessage = join($warning, "");
52  if (!empty($warning))
53  echo "docker run not properly set:" . $warningMessage;
54 
55  } // End constructor
56 
58  {
59  if ("cli" == php_sapi_name())
60  {
61  $this->output("Program call from CLI detected.");
62  if ($this->db->getConfigValue('enableCron')==0) {
63  $this->output("please enable cron in config");
64  die();
65  }
66  }else{
67  $this->output("Program call from Webserver detected.");
68  }
69  }
70 
71 
78  function output($string, $debug=0)
79  {
80  //$logProgram = basename(__FILE__, '.php');
81  $logProgram = basename($_SERVER['SCRIPT_NAME']);
82  echo "$logProgram: $string\n";
83 
84  $this->db->exec("INSERT INTO logShell (logProgram, logContent) VALUES ('$logProgram','$string');");
85  }
86 
87  }
88 
89 ?>
__construct($db)
constructor
Definition: ppyrd.base.php:24
checkCliVsWebserver()
Definition: ppyrd.base.php:57
output($string, $debug=0)
outputs string
Definition: ppyrd.base.php:78