5 * This applies database files from
6 * a) OLD - {MODULE}/DataObjects/XXXX.{dbtype}.sql
8 * b) NEW - {MODULE}/sql/XXX.sql (SHARED or translable)
9 * and {MODULE}/{dbtype}/XXX.sql (SHARED or translable)
14 require_once 'Pman.php';
15 class Pman_Core_UpdateDatabase extends Pman
18 static $cli_desc = "Update SQL - Beta (it will run updateData of all modules)";
20 static $cli_opts = array(
23 'desc' => 'prefix for the password (eg. fred > xxx4fred - prefix is xxx4)',
30 'desc' => 'only run the updateData - do not run import the tables and procedures.',
37 'add-company' => array(
38 'desc' => 'add a company name of the company',
44 'add-company-with-type' => array(
45 'desc' => 'the type of company (default OWNER)',
52 'desc' => 'Initialize the database (pg only supported)',
58 'only-module-sql' => array(
59 'desc' => 'Only run sql import on this modules - eg. Core',
64 'skip-mysql-checks' => array(
65 'desc' => 'Skip mysql checks',
70 'procedures-only' => array(
71 'desc' => 'Only import procedures (not supported by most modules yet) - ignores sql directory',
77 'json-person' => array(
78 'desc' => 'Person JSON file',
86 static function cli_opts()
89 $ret = self::$cli_opts;
90 $ff = HTML_FlexyFramework::get();
92 $mods = $a->modulesList();
93 foreach($mods as $m) {
95 $fd = $ff->rootDir. "/Pman/$m/UpdateDatabase.php";
96 if (!file_exists($fd)) {
102 $cls = new ReflectionClass('Pman_'. $m . '_UpdateDatabase');
104 $ret = array_merge($ret, $cls->getStaticPropertyValue('cli_opts'));
113 var $disabled = array();
118 var $local_base_url = false;
123 $ff = HTML_FlexyFramework::get();
124 if (!empty($ff->cli)) {
129 parent::getAuth(); // load company!
130 $au = $this->getAuthUser();
131 if (!$au || $au->company()->comptype != 'OWNER') {
132 $this->jerr("Not authenticated", array('authFailure' => true));
134 $this->authUser = $au;
138 function get($args, $opts=array())
140 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
142 $this->checkSystem();
144 if (class_exists('PDO_DataObjects_Introspection')) {
145 PDO_DataObject_Introspection::$cache = array();
148 HTML_FlexyFramework::get()->generateDataobjectsCache(true);
150 $ff = HTML_FlexyFramework::get();
152 if(!isset($ff->Pman) || !isset($ff->Pman['local_base_url'])){
153 die("Please setup Pman[local_base_url]\n");
156 $this->local_base_url = $ff->Pman['local_base_url'];
158 if(!empty($ff->Core_Notify)){
159 // require_once 'Pman/Core/NotifySmtpCheck.php';
160 // $x = new Pman_Core_NotifySmtpCheck();
164 $this->disabled = explode(',', $ff->disable);
166 //$this->fixSequencesPgsql();exit;
169 // ask all the modules to verify the opts
171 $this->checkOpts($opts);
174 // do this first, so the innodb change + utf8 fixes column max sizes
176 // this will trigger errors about freetext indexes - we will have to remove them manually.?
177 // otherwise we need to do an sql query to find them, then remove them (not really worth it as it only affects really old code..)
179 $this->runExtensions();
182 if (empty($opts['data-only'])) {
185 if (!empty($opts['only-module-sql'])) {
189 $this->runUpdateModulesData();
191 if (!empty($opts['add-company']) && !in_array('Core', $this->disabled)) {
192 // make sure we have a good cache...?
194 DB_DataObject::factory('core_company')->initCompanies($this, $opts);
197 $this->runExtensions();
199 $this->generateDataobjectsCache();
207 * imports SQL files from all DataObjects directories....
209 * except any matching /migrate/
214 // loop through all the modules, and see if they have a importSQL method?
217 $ff = HTML_Flexyframework::get();
219 $dburl = parse_url($ff->database); // used to be DB_DataObject['database'] - but not portable to PDO
221 //$this->{'import' . $url['scheme']}($url);
223 $dbtype = $dburl['scheme'];
226 $dirmethod = 'import' . $dburl['scheme'] . 'dir';
231 $ar = $this->modulesList();
236 if(in_array($m, $this->disabled)){
237 echo "module $m is disabled \n";
241 echo "Importing SQL from module $m\n";
242 if (!empty($this->opts['only-module-sql']) && $m != $this->opts['only-module-sql']) {
247 // check to see if the class has
251 $file = $this->rootDir. "/Pman/$m/UpdateDatabase.php";
252 if($m != 'Core' && file_exists($file)){
255 $class = "Pman_{$m}_UpdateDatabase";
257 if(method_exists($x, 'importModuleSQL')){
258 echo "Importing SQL from module $m using Module::importModuleSQL\n";
259 $x->opts = $this->opts;
260 $x->rootDir = $this->rootDir;
261 $x->importModuleSQL($dburl);
266 echo "Importing SQL from module $m\n";
269 // if init has been called
271 if (!empty($this->opts['init'])) {
272 $this->{$dirmethod}($dburl, $this->rootDir. "/Pman/$m/{$dbtype}.init");
278 $fd = $this->rootDir. "/Pman/$m/DataObjects";
280 $this->{$dirmethod}($dburl, $fd);
283 // new -- sql directory..
284 // new style will not support migrate ... they have to go into mysql-migrate.... directories..
285 // new style will not support pg.sql etc.. naming - that's what the direcotries are for..
287 $this->{$dirmethod}($dburl, $this->rootDir. "/Pman/$m/sql");
288 $this->{$dirmethod}($dburl, $this->rootDir. "/Pman/$m/{$dbtype}");
292 if (!empty($this->opts['init']) && file_exists($this->rootDir. "/Pman/$m/{$dbtype}.initdata")) {
293 if (class_exists('PDO_DataObjects_Introspection')) {
294 PDO_DataObject_Introspection::$cache = array();
296 HTML_FlexyFramework::get()->generateDataobjectsCache(true);
298 $this->{$dirmethod}($dburl, $this->rootDir. "/Pman/$m/{$dbtype}.initdata");
299 $this->{'fixSequences'. $dbtype}();
312 /** -------------- code to handle importing a whole directory of files into the database ------- **/
315 function importpgsqldir($url, $dir, $disable_triggers = false)
317 $ff = HTML_FlexyFramework::get();
319 require_once 'System.php';
320 $cat = System::which('cat');
321 $psql = System::which('psql');
324 if (!empty($url['pass'])) {
325 putenv("PGPASSWORD=". $url['pass']);
329 ' -h ' . $url['host'] .
330 ' -U' . escapeshellarg($url['user']) .
331 ' ' . basename($url['path']);
334 echo $psql_cmd . "\n" ;
335 echo "scan : $dir\n";
338 $files = array($dir);
343 $files = glob($dir.'/*.sql');
344 uksort($files, 'strcasecmp');
346 //$lsort = create_function('$a,$b','return strlen($a) > strlen($b) ? 1 : -1;');
347 //usort($files, $lsort);
350 foreach($files as $bfn) {
353 if (preg_match('/migrate/i', basename($bfn))) { // skip migration scripts at present..
356 if (preg_match('#\.[a-z]{2}\.sql#i', basename($bfn))
357 && !preg_match('#\.pg\.sql#i', basename($bfn))
358 ) { // skip migration scripts at present..
363 if (!preg_match('/pgsql/', basename($dir) )) {
364 if ( !preg_match('#\.pg\.sql$#', basename($bfn))) {
365 $fn = $this->convertToPG($bfn);
369 // files ending in .pg.sql are native postgres files.. ## depricated
372 $cmd = "$psql_cmd < " . escapeshellarg($fn ? $fn : $bfn) . ' 2>&1' ;
374 echo "$bfn: $cmd ". ($ff->cli ? "\n" : "<BR>\n");
390 * mysql - does not support conversions.
394 function importmysqlidir($dburl, $dir) {
395 return $this->importmysqldir($dburl, $dir);
398 function importmysqldir($dburl, $dir)
401 $this->fixMysqlInnodb(); /// run once
403 echo "Import MYSQL :: $dir\n";
406 require_once 'System.php';
407 $cat = System::which('cat');
408 $mysql = System::which('mysql');
412 $mysql_cmd = $mysql .
413 ' -h ' . $dburl['host'] .
414 ' -u' . escapeshellarg($dburl['user']) .
415 (!empty($dburl['pass']) ? ' -p' . escapeshellarg($dburl['pass']) : '') .
416 ' ' . basename($dburl['path']);
417 //echo $mysql_cmd . "\n" ;
419 $files = glob($dir.'/*.sql');
420 uksort($files, 'strcasecmp');
423 foreach($files as $fn) {
426 if (preg_match('/migrate/i', basename($fn))) { // skip migration scripts at present..
429 // .my.sql but not .pg.sql
430 if (preg_match('#\.[a-z]{2}\.sql#i', basename($fn))
431 && !preg_match('#\.my\.sql#i', basename($fn))
432 ) { // skip migration scripts at present..
435 if (!strlen(trim($fn))) {
439 $cmd = "$mysql_cmd -f < " . escapeshellarg($fn) ." 2>&1" ;
441 echo basename($dir).'/'. basename($fn) . '::' . $cmd. ($this->cli ? "\n" : "<BR>\n");
444 $fp = popen($cmd, "r");
447 // send the current file part to the browser
448 $line = trim(fgets($fp, 1024));
453 if (!preg_match('/^ERROR\s+([0-9]+)/', $line, $matches)) {
454 echo " ---- {$line}\n"; flush();
458 switch($matches[1]) {
459 case 1017: // cause by renaming table -- old one does not exist..
460 case 1050: // create tables triggers this..
461 case 1060: // Duplicate column name
462 case 1061: // Duplicate key name - triggered by add index.. but could hide error. - unlikely though.
463 case 1091: // drop index -- name does not exist.. might hide errors..
465 case 1146: // drop a index on an unknown table.. - happens rarely...
466 case 1054: // Unknown column -- triggered by CHANGE COLUMN - but may hide other errrors..
472 echo " ---- {$line}\n"; flush();
476 // 1051: // Unknown table -- normally drop = add iff exists..
477 echo "File: $fn\n$line\n";
493 * simple regex based convert mysql to pgsql...
495 function convertToPG($src)
497 //echo "Convert $src\n";
499 $fn = $this->tempName('sql');
501 $ret = array( ); // pad it a bit.
502 $extra = array("", "" );
505 foreach(file($src) as $l) {
508 if (!strlen($l) || $l[0] == '#') {
512 if (preg_match('#create\s+table\s+([a-z0-9_]+)#i', $l, $m)) {
515 if (preg_match('#create\s+table\s+\`([a-z0-9_]+)\`#i', $l, $m)) {
516 $tbl = 'shop_' . strtolower($m[1]);
517 $l = preg_replace('#create\s+table\s+\`([a-z0-9_]+)\`#i', "CREATE TABLE {$tbl}", $l);
519 if (preg_match('#\`([a-z0-9_]+)\`#i', $l, $m) && !preg_match('#alter\s+table\s+#i', $l)) {
520 $l = preg_replace('#\`([a-z0-9_]+)\`#i', "{$m[1]}_name", $l);
523 if ($tbl && preg_match('#auto_increment#i', $l, $m)) {
524 $l = preg_replace('#auto_increment#i', "default nextval('{$tbl}_seq')", $l);
525 $extra[] = "create sequence {$tbl}_seq;";
529 if (preg_match('#alter\s+table\s+(\`[a-z0-9_]+\`)#i', $l, $m)){
530 $l = preg_replace('#alter\s+table\s+(\`[a-z0-9_]+\`)#i', "ALTER TABLE {$tbl}", $l);
533 // enum value -- use the text instead..
535 if ($tbl && preg_match('#([\w]+)\s+(enum\([\w|\W]+\))#i', $l, $m)) {
536 $l = preg_replace('#enum\([\w|\W]+\)#i', "TEXT", $l);
538 // ignore the alter enum
539 if ($tbl && preg_match('#alter\s+table\s+([\w|\W]+)\s+enum\([\w|\W]+\)#i', $l, $m)) {
543 // UNIQUE KEY .. ignore
544 if ($tbl && preg_match('#UNIQUE KEY#i', $l, $m)) {
545 $last = array_pop($ret);
546 $ret[] = trim($last, ",");
550 if ($tbl && preg_match('#RENAME\s+TO#i', $l, $m)) {
554 if ($tbl && preg_match('#change\s+column#i', $l, $m)) {
558 // INDEX lookup ..ignore
559 if ($tbl && preg_match('#INDEX lookup+([\w|\W]+)#i', $l, $m)) {
560 $last = array_pop($ret);
561 $ret[] = trim($last, ",");
566 // CREATE INDEX ..ignore
567 if (preg_match('#alter\s+table\s+([a-z0-9_]+)\s+add\s+index\s+#i', $l, $m)) {
568 // $l = "CREATE INDEX {$m[1]}_{$m[2]} ON {$m[1]} {$m[3]}";
573 $l = preg_replace('#int\([0-9]+\)#i', 'INT', $l);
575 $l = preg_replace('# datetime#i', ' TIMESTAMP WITHOUT TIME ZONE', $l);
576 $l = preg_replace('# blob#i', ' TEXT', $l);
577 $l = preg_replace('# longtext#i', ' TEXT', $l);
578 $l = preg_replace('# tinyint#i', ' INT', $l);
584 $ret = array_merge($extra,$ret);
585 // echo implode("\n", $ret); exit;
587 file_put_contents($fn, implode("\n", $ret));
593 function checkOpts($opts)
597 foreach($opts as $o=>$v) {
598 if (!preg_match('/^json-/', $o) || empty($v)) {
601 if (!file_exists($v)) {
602 die("File does not exist : OPTION --{$o} = {$v} \n");
606 $modules = array_reverse($this->modulesList());
608 // move 'project' one to the end...
610 foreach ($modules as $module){
611 $file = $this->rootDir. "/Pman/$module/UpdateDatabase.php";
612 if($module == 'Core' || !file_exists($file)){
616 $class = "Pman_{$module}_UpdateDatabase";
618 if(!method_exists($x, 'checkOpts')){
621 $x->checkOpts($opts);
625 static function jsonImportFromArray($opts)
627 foreach($opts as $o=>$v) {
628 if (!preg_match('/^json-/', $o) || empty($v)) {
631 $type = str_replace('_', '-', substr($o,5));
633 $data= json_decode(file_get_contents($v),true);
634 $pg = HTML_FlexyFramework::get()->page;
635 DB_DataObject::factory($type)->importFromArray($pg ,$data,$opts);
645 function runUpdateModulesData()
647 if (class_exists('PDO_DataObjects_Introspection')) {
648 PDO_DataObject_Introspection::$cache = array();
650 HTML_FlexyFramework::get()->generateDataobjectsCache(true);
652 if(!in_array('Core', $this->disabled)){
653 echo "Running jsonImportFromArray\n";
654 Pman_Core_UpdateDatabase::jsonImportFromArray($this->opts);
657 echo "Running updateData on modules\n";
663 $modules = array_reverse($this->modulesList());
665 // move 'project' one to the end...
667 foreach ($modules as $module){
668 if(in_array($module, $this->disabled)){
671 $file = $this->rootDir. "/Pman/$module/UpdateDatabase.php";
672 if($module == 'Core' || !file_exists($file)){
677 $class = "Pman_{$module}_UpdateDatabase";
679 if(!method_exists($x, 'updateData')){
689 function updateDataEnums()
692 $enum = DB_DataObject::Factory('core_enum');
693 //DB_DAtaObject::debugLevel(1);
698 'name' => 'COMPTYPE',
699 'display_name' => 'Company Types',
700 'is_system_enum' => 1,
704 'display_name' => 'Owner',
705 'seqid' => 999, // last...
706 'is_system_enum' => 1,
713 'name' => 'HtmlEditor.font-family',
714 'display_name' => 'HTML Editor font families',
715 'is_system_enum' => 1,
718 'name' => 'Helvetica,Arial,sans-serif',
719 'display_name' => 'Helvetica',
724 'name' => 'Courier New',
725 'display_name' => 'Courier',
730 'display_name' => 'Tahoma',
734 'name' => 'Times New Roman,serif',
735 'display_name' => 'Times',
740 'display_name' => 'Verdana',
753 function updateDataGroups()
756 $groups = DB_DataObject::factory('core_group');
757 $groups->initGroups();
759 $groups->initDatabase($this,array(
761 'name' => 'bcc-email', // group who are bcc'ed on all requests.
762 'type' => 0, // system
765 'name' => 'system-email-from',
766 'type' => 0, // system
769 'name' => 'core-person-signup-bcc',
770 'type' => 0, // system
778 function updateDataCompanies()
781 // fix comptypes enums..
782 $c = DB_DataObject::Factory('core_company');
784 $c->selectAdd('distinct(comptype) as comptype');
785 $c->whereAdd("comptype != ''");
788 foreach($c->fetchAll('comptype') as $cts) {
792 $ctb[]= array( 'etype'=>'COMPTYPE', 'name' => $cts, 'display_name' => ucfirst(strtolower($cts)));
795 $c = DB_DataObject::Factory('core_enum');
798 //DB_DataObject::debugLevel(1);
800 $c = DB_DataObject::Factory('core_company');
802 UPDATE {$c->tableName()}
804 comptype_id = (SELECT id FROM core_enum where etype='comptype' and name={$c->tableName()}.comptype LIMIT 1)
818 function initEmails($templateDir, $emails)
821 $pg = HTML_FlexyFramework::get()->page;
822 foreach($emails as $name=>$data) {
823 $cm = DB_DataObject::factory('core_email');
824 $update = $cm->get('name', $name);
827 if (empty($cm->bcc_group)) {
828 if (empty($data['bcc_group'])) {
829 $this->jerr("missing bcc_group for template $name");
831 $g = DB_DataObject::Factory('core_group')->lookup('name',$data['bcc_group']);
834 $this->jerr("bcc_group {$data['bcc_group']} does not exist when importing template $name");
838 if (!$g->members('email')) {
839 $this->jerr("bcc_group {$data['bcc_group']} does not have any members");
842 $cm->bcc_group = $g->id;
844 // initEmails will always have the latest location of the test class - in theory the user should not be changign the value of this...
845 //if (empty($cm->test_class)) {
846 if (empty($data['test_class'])) {
847 $this->jerr("missing test_class for template $name");
849 $cm->test_class = $data['test_class'];
851 require_once $cm->test_class . '.php';
853 $clsname = str_replace('/','_', $cm->test_class);
855 $method = new ReflectionMethod($clsname , 'test_'. $name) ;
856 $got_it = $method->isStatic();
857 } catch(Exception $e) {
862 $this->jerr("template {$name} does not have a test method {$clsname}::test_{$name}");
866 echo "email: {$name} - checked\n";
867 continue; /// we do not import the body content of templates that exist...
874 // $basedir = $this->bootLoader->rootDir . $mail_template_dir;
878 'file' => $templateDir. $name .'.html'
881 if (!empty($data['master'])) {
882 $opts['master'] = $templateDir . $master .'.html';
884 require_once 'Pman/Core/Import/Core_email.php';
885 $x = new Pman_Core_Import_Core_email();
886 $x->updateOrCreateEmail('', $opts, $cm);
888 echo "email: {$name} - CREATED\n";
893 function updateData()
896 if (class_exists('PDO_DataObjects_Introspection')) {
897 PDO_DataObject_Introspection::$cache = array();
899 HTML_FlexyFramework::get()->generateDataobjectsCache(true);
900 $this->updateDataEnums();
901 $this->updateDataGroups();
902 $this->updateDataCompanies();
904 $c = DB_DataObject::Factory('I18n');
912 function fixMysqlInnodb()
915 static $done_check = false;
921 if (!empty($this->opts['skip-mysql-checks'])) {
924 // innodb in single files is far more efficient that MYD or one big innodb file.
925 // first check if database is using this format.
926 $db = DB_DataObject::factory('core_enum');
927 $db->query("show variables like 'innodb_file_per_table'");
929 if ($db->Value == 'OFF') {
930 die("Error: set innodb_file_per_table = 1 in my.cnf (or run with --skip-mysql-checks\n\n");
933 $db = DB_DataObject::factory('core_enum');
934 $db->query("select version() as version");
937 if (version_compare($db->version, '5.7', '>=' )) {
939 $db = DB_DataObject::factory('core_enum');
940 $db->query("show variables like 'sql_mode'");
943 $modes = explode(",", $db->Value);
945 // these are 'new' problems with mysql.
947 in_array('NO_ZERO_IN_DATE', $modes) ||
948 in_array('NO_ZERO_DATE', $modes) ||
949 in_array('STRICT_TRANS_TABLES', $modes) ||
950 !in_array('ALLOW_INVALID_DATES', $modes)
952 die("Error: set sql_mode include 'ALLOW_INVALID_DATES', remove 'NO_ZERO_IN_DATE' AND 'STRICT_TRANS_TABLES' AND 'NO_ZERO_DATE' in my.cnf\n\n");
967 /** ------------- schema fixing ... there is an issue with data imported having the wrong sequence names... --- */
969 function fixSequencesMysql()
974 function fixSequencesPgsql()
978 //DB_DataObject::debugLevel(1);
979 $cs = DB_DataObject::factory('core_enum');
983 CASE WHEN strpos(seq_name, '.') > 0 THEN
986 quote_ident(min(schema_name)) ||'.'|| quote_ident(min(seq_name))
989 ||' OWNED BY '|| quote_ident(min(schema_name)) || '.' ||
990 quote_ident(min(table_name)) ||'.'|| quote_ident(min(column_name)) ||';' as cmd
994 n.nspname AS schema_name,
995 c.relname AS table_name,
996 a.attname AS column_name,
997 regexp_replace(regexp_replace(d.adsrc, E'nextval\\\\(+[''\\\"]*', ''),E'[''\\\"]*::.*\$','') AS seq_name
999 JOIN pg_attribute a ON (c.oid=a.attrelid)
1000 JOIN pg_attrdef d ON (a.attrelid=d.adrelid AND a.attnum=d.adnum)
1001 JOIN pg_namespace n ON (c.relnamespace=n.oid)
1002 WHERE has_schema_privilege(n.oid,'USAGE')
1003 AND n.nspname NOT LIKE 'pg!_%' escape '!'
1004 AND has_table_privilege(c.oid,'SELECT')
1005 AND (NOT a.attisdropped)
1006 AND d.adsrc ~ '^nextval'
1010 CASE WHEN strpos(seq_name, '.') > 0 THEN
1011 substring(seq_name, 1,strpos(seq_name,'.')-1)
1016 GROUP BY seq_name HAVING count(*)=1
1019 while ($cs->fetch()) {
1022 foreach($cmds as $cmd) {
1023 $cs = DB_DataObject::factory('core_enum');
1027 $cs = DB_DataObject::factory('core_enum');
1029 SELECT 'SELECT SETVAL(' ||
1030 quote_literal(quote_ident(nspname) || '.' || quote_ident(S.relname)) ||
1031 ', MAX(' || quote_ident(C.attname)|| ')::integer ) FROM ' || nspname || '.' || quote_ident(T.relname)|| ';' as cmd
1037 WHERE S.relkind = 'S'
1039 AND D.refobjid = T.oid
1040 AND D.refobjid = C.attrelid
1041 AND D.refobjsubid = C.attnum
1042 AND NS.oid = T.relnamespace
1046 while ($cs->fetch()) {
1049 foreach($cmds as $cmd) {
1050 $cs = DB_DataObject::factory('core_enum');
1057 var $extensions = array(
1062 function runExtensions()
1065 $ff = HTML_Flexyframework::get();
1067 $dburl = parse_url($ff->database);
1069 $dbtype = $dburl['scheme'];
1071 foreach($this->extensions as $ext) {
1073 $scls = ucfirst($dbtype). $ext;
1074 $cls = __CLASS__ . '_'. $scls;
1075 $fn = implode('/',explode('_', $cls)).'.php';
1076 if (!file_exists(__DIR__.'/UpdateDatabase/'. $scls .'.php')) {
1087 function checkSystem($req = false, $pref = false)
1089 // most of these are from File_Convert...
1091 // these are required - and have simple dependancies.
1092 require_once 'System.php';
1093 $req = $req !== false ? $req : array(
1098 'rsvg-convert', //librsvg2-bin
1105 // these are prefered - but may have complicated depenacies
1106 $pref = $pref !== false ? $pref : array(
1110 'html2text', // not availabe in debian squeeze
1111 'pdftocairo', //poppler-utils - not available in debian squeeze.
1121 foreach($req as $r) {
1122 if (!System::which($r)) {
1128 die("Missing these programs - need installing\n" . implode("\n",$res). "\n");
1130 foreach($pref as $r) {
1131 if (!System::which($r)) {
1137 echo "WARNING: Missing these programs - they may need installing\n". implode("\n",$res);
1144 function generateDataobjectsCache()
1146 $url = "http://localhost{$this->local_base_url}/Core/RefreshDatabaseCache";
1152 function curl($url, $request = array(), $method = 'GET')
1154 if($method == 'GET'){
1155 $request = http_build_query($request);
1156 $url = $url . "?" . $request;
1159 $ch = curl_init($url);
1161 if ($method == 'POST') {
1163 curl_setopt($ch, CURLOPT_POST, 1);
1164 curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
1168 curl_setopt($ch, CURLOPT_HTTPHEADER,
1169 array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($request)));
1173 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1175 curl_setopt($ch, CURLOPT_HEADER, false);
1176 curl_setopt($ch, CURLOPT_VERBOSE, 0);
1177 curl_setopt($ch, CURLOPT_TIMEOUT, 30);
1178 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1180 $response = curl_exec($ch);