function aLinks_Extra($mode) { if ($mode != 'upd') { return; } $link = 'http://' . AddSlash($this->row['node_url']) . 'andro'; $hLink = "<a href='{$link}' target='_BLANK'>{$link}</a>"; return array($hLink); }
/** * The user has requested that we download the latest * version of each application from its respective * * */ function mainPull() { # Don't hold up the system Session_write_close(); $rows = svnVersions(); $dir = fsDirTop() . 'pkg-apps/'; x_echoFlush('<pre>'); x_EchoFlush('<h2>Pulling Software Updates From SVN</h2>'); // Loop through the apps. foreach ($rows as $row) { x_EchoFlush(""); x_echoFlush("<b>Application: " . $row['application'] . "</b>"); if ($row['svn_url'] == '') { x_echoFlush(" No SVN repository, skipping."); continue; } # Add a trailing slash to svn_url $row['svn_url'] = AddSlash(trim($row['svn_url'])); # If there is a username and password both, use those $urlDisplay = $row['svn_url']; $url = $row['svn_url']; if ($row['svn_uid'] != '' && $row['svn_pwd'] != '') { list($proto, $urlstub) = explode("//", $url); $uid = $row['svn_uid']; $pwd = $row['svn_pwd']; $url = "{$proto}//{$uid}:{$pwd}@{$urlstub}"; $urlDisplay = "{$proto}//{$uid}:*****@{$urlstub}"; } x_echoFlush(" Complete URL: " . $urlDisplay); # Now pull the list of versions x_echoFlush(" Querying for latest version"); $rawtext = @file_get_contents($url); if ($rawtext) { $matches = array(); preg_match_all('!\\<li\\>\\<a.*\\>(.*)\\</a\\>\\</li\\>!U', $rawtext, $matches); $versions = $matches[1]; foreach ($versions as $key => $version) { if ($version == '..') { unset($versions[$key]); } } if (count($versions) == 0) { x_EchoFlush(" No versions listed, nothing to pull."); continue; } } else { x_EchoFlush("Unable to get a release list from the svn server."); continue; } # Work out what the latest was and report it $latest = array_pop($versions); if (substr($latest, -1) == '/') { $latest = substr($latest, 0, strlen($latest) - 1); } x_echoFlush(" Latest version is: " . $latest); x_EchoFlush(" Local version is: " . $row['local']); # Decide if we need to continue if ($latest == $row['local']) { x_EchoFlush(" Local version is latest, nothing do to."); continue; } # Determine some stub values and pass processing to # the recursive file puller. If no uid & pwd, use subversion x_EchoFlush(" Local version is out of date, pulling latest"); $dirv = $dir . trim($row['application']) . '-VER-' . $latest . '/'; if ($row['svn_uid'] != '' && $row['svn_pwd'] != '') { mkdir($dirv); $this->svnWalk("{$url}/{$latest}/", $dirv); } else { $command = "svn export {$url}{$latest} {$dirv}"; x_echoFlush(" Pulling code now, this make take a minute or three..."); x_EchoFlush($command); `{$command}`; x_echoFlush(" Code pulled, finished with this application."); } x_echoFlush(" Copying files into application directory"); $basedir = str_replace('andro/', '', fsDirTop()); if (isWindows()) { $command = 'xcopy /y /e /c /k /o ' . $dirv . '* ' . $basedir . trim($row['application']) . '/'; } else { $command2 = 'cp -Rf ' . $dirv . '* ' . $basedir . trim($row['application']) . '/'; } echo $command2; `{$command2}`; } x_echoFlush("<hr/>"); x_EchoFlush("<h3>Processing Complete</h3>"); $this->flag_buffer = false; }
function FS_PrepareMake() { $grp = $this->ShellWhoAmI(); global $parm; $app = $GLOBALS["parm"]["APP"]; $dir_pub = $this->FS_ADDSLASH($GLOBALS["parm"]["DIR_PUBLIC"]); $dir_pubx = $dir_pub . $this->FS_ADDSLASH($GLOBALS["parm"]["DIR_PUBLIC_APP"]); // Establish the source $this->LogStage("Building Directories and Copying Files"); if (isset($parm['IVER'])) { $dirl = AddSlash($parm['DIR_LINK_LIB']); $dira = AddSlash($parm['DIR_LINK_APP']); } else { $dirl = $dira = $GLOBALS['dir_andro']; } // Now handle all of the subdirectories, including templates, lib, // clib and so forth. Read them out of the node manager. // // KFD 2/5/08, fix huge bug introduced by this. On a new // install this does not work, must have hardcoded dir if (isset($this->dirsAll)) { $dirs = $this->dirsAll; } else { $dbres = pg_query($GLOBALS["dbconna"], "SELECT * FROM appdirs"); $dirs = pg_fetch_all($dbres); } foreach ($dirs as $row) { $tgt = trim($row['dirname']); $this->LogEntry("Processing subdir: {$tgt}"); if (!file_exists($dir_pubx . $tgt)) { $this->LogEntry(" -> Creating this directory: {$dir_pubx}.{$tgt}"); mkdir($dir_pubx . $tgt); } // KFD 4/13/08, must remove minified JS files during build if ($tgt == 'clib') { $jsfiles = scandir($dir_pubx . $tgt); foreach ($jsfiles as $jsfile) { if ($jsfile == '.') { continue; } if ($jsfile == '..') { continue; } if (substr($jsfile, -3) == '.js') { if (substr($jsfile, 0, 7) == 'js-min-') { $jsfile2 = "{$dir_pubx}{$tgt}/{$jsfile}"; $this->LogENtry("Deleting minified file: " . $jsfile2); unlink($jsfile2); } } if (substr($jsfile, -4) == '.css') { if (substr($jsfile, 0, 8) == 'css-min-') { $jsfile2 = "{$dir_pubx}{$tgt}/{$jsfile}"; $this->LogENtry("Deleting css combo file: " . $jsfile2); unlink($jsfile2); } } } } if ($row['flag_copy'] != 'Y') { $this->LogEntry(" -> Nothing will be copied for this directory."); if ($tgt == 'generated' || $tgt == 'dynamic') { $this->LogEntry(" -> Purging this directory"); //$cmd="rm $dir$tgt/*"; //`$cmd`; } } else { // In this branch we have directories that must be copied. // They may be application or library directories, and this // may be an app or an instance, so there are a few more // switches. And of course, nothing gets copied for the node // manager itself. // if ($app == 'andro') { $this->LogEntry(" -> NODE MANAGER build, no copy."); } else { # KFD 7/14/08, hardcode templates to pull from # library first, then application if ($tgt == 'templates') { $this->LogEntry(" -> Hardcoded handling of templates dir"); $this->LogEntry(" Copy from lib first, then app"); $this->FSCopyTree($dirl, $dir_pubx, $tgt); $this->FSCopyTree($dira, $dir_pubx, $tgt); } else { if ($row['flag_lib'] == 'Y') { $this->LogEntry(" -> Library copy from: {$dirl}"); $this->LogEntry(" -> to: {$dir_pubx}"); $this->FSCopyTree($dirl, $dir_pubx, $tgt); } else { if (!isset($parm['IVER'])) { $this->LogEntry(" -> DEV Instance build, no copy"); } else { $this->LogEntry("Directory {$tgt} will be copied"); $this->LogEntry(" -> Application copy from: {$dira}"); $this->LogEntry(" -> to: {$dir_pubx}"); $this->FSCopyTree($dira, $dir_pubx, $tgt); } } } } } // Cleanup: Make sure hidden if required if ($row['flag_vis'] != 'Y') { $file = $dir_pubx . $tgt . '/.htaccess'; $text = "Deny From All"; $this->FS_PUT_CONTENTS($file, $text); } } $this->LogEntry("Copying /root files into root directory..."); if (isWindows()) { $cmd = "copy \"{$dir_pubx}\\root\\*\" \"{$dir_pubx}\"\\"; $cmd = str_replace('/', '\\', $cmd); $this->LogEntry(" " . $cmd); `{$cmd}`; $cmd = "copy \"{$dir_pubx}/root/htaccess\" \"{$dir_pubx}/.htaccess\""; $cmd = str_replace('/', '\\', $cmd); $this->LogEntry(" " . $cmd); `{$cmd}`; $cmd = "del \"{$dir_pubx}\\htaccess\""; $cmd = str_replace('/', '\\', $cmd); $this->LogEntry(" " . $cmd); `{$cmd}`; } else { $cmd = "cp {$dir_pubx}/root/* {$dir_pubx}/"; `{$cmd}`; $cmd = "cp {$dir_pubx}/root/htaccess {$dir_pubx}/.htaccess"; `{$cmd}`; `rm {$dir_pubx}/htaccess`; } # KFD 1/24/09, copy any skeleton files found if not # an instance if (!isset($parm['IVER'])) { $this->LogEntry(""); $this->LogEntry("This is not an instance, looking for skeleton files"); # Pull all files named "skeleton" out of the andro library $raw = scandir($dirl . 'lib/'); foreach ($raw as $onefile) { if (substr($onefile, 0, 9) != 'skeleton.') { continue; } $filedest = substr($onefile, 9); if ($filedest == 'dd.yaml') { $filedest = $GLOBALS["parm"]["APP"] . ".dd.yaml"; } if (file_exists("{$dir_pubx}/application/{$filedest}")) { $this->LogEntry(" -> File {$filedest} is already in application, no action"); } else { $this->LogEntry(" -> Creating {$filedest} from skeleton file"); $fc = file_get_contents($dirl . "lib/{$onefile}"); file_put_contents("{$dir_pubx}/application/{$filedest}", $fc); } } } return true; }
function hImgFromBytes($table_id, $column_id, $skey, $bytes, $decode = true) { $x = $bytes; //annoying compile error $x = $decode; // First step is to save the image if it is not already // saved in the "dbobj" directory $fname = $table_id . '_' . $column_id . '_' . $skey; $fdir = AddSlash($GLOBALS['AG']['dirs']['root']) . "dbobj/"; //if(!file_exists($fdir.$fname)) { /* if ($decode) { file_put_contents($fdir.$fname,base64_decode($bytes)); } else { file_put_contents($fdir.$fname,$bytes); } */ //} // Now return some hypertext that refers to this image //if (strlen($bytes)>0) { // return '<span><image src="dbobj/'.$fname.'"></span>'; //} //else { return ''; //} }
function mainPR_DirFiles($v, $r2, $root, $dirname, $dirpath) { // Put together three segments of directories to begin looping $dir = AddSlash($root); $dir = AddSlash($dir . $dirname); $dir = AddSlash($dir . $dirpath); $d2 = AddSlash($r2); $d2 = AddSlash($d2 . $dirname); $d2 = AddSlash($d2 . $dirpath); if (!file_exists($d2)) { mkdir($d2); } x_EchoFlush(""); x_EchoFlush("Begin scan of directory: {$dir}"); $DIR = opendir($dir); while (false !== ($file = readdir($DIR))) { // no . or .. if ($file == '.') { continue; } if ($file == '..') { continue; } // Get formatted name of dir + file; $fn = AddSlash($dirpath) . $file; // This is a directory, maybe recurse if (is_dir($dir . $file)) { $this->mainPR_DirFiles($v, $r2, $root, $dirname, $fn); } else { $filecnts = file_get_contents($dir . $file); $row = array('version' => $v, 'application' => $this->app, 'filename' => $fn, 'dirname' => $dirname, 'filecnts' => '', 'filets' => filemtime($dir . $file), 'filemd5' => md5($filecnts), 'filesize' => strlen($filecnts)); x_EchoFlush("Loading file {$fn}, size: " . strlen($filecnts)); //SQLX_Insert($this->tlf,$row); copy($dir . $file, $d2 . $file); } } x_EchoFlush(""); x_EchoFlush("End scan of directory: {$dir}"); }
function main() { $x_app = trim(gp('txt_application')); session_write_close(); ob_start(); echo "<h1>Build in progress</h1>"; echo "<hr>"; echo "<p>The system is now building the application: <b>" . $x_app . "</b>.</p>"; echo "<p>If you are testing and expect to build several times in a row, do not "; echo "close this window, just hit REFRESH and the build will start again.</p>"; echo "<p>All information below this line is from the build log.</p>"; echo "<hr>"; // Get everything we need from the database, use it to build // a "do" program. // $GLOBALS["x_password"] = trim(gp("supassword")); $tsql = 'SELECT * from applications ' . ' WHERE application = ' . SQL_Format('char', $x_app); $row_a = SQL_OneRow($tsql); $tsql = 'SELECT * from webpaths ' . ' WHERE webpath = ' . SQL_Format('char', $row_a['webpath']); $row_n = SQL_OneRow($tsql); $dirws = trim($row_n["dir_pub"]); if (substr($dirws, -1, 1) != "/") { $dirws .= "/"; } $row["webserver_dir_pub"] = $dirws; $string = ' <?php // To run this program from the command line, you must // be logged in as a user that has superuser priveleges, such // as root or postgres. When running from the web app, // the current user\'s priveleges are used. $GLOBALS["parm"] = array( "DBSERVER_URL"=>"localhost" ,"UID"=>"' . SessionGet('UID') . '" ,"DIR_PUBLIC"=>"' . trim($row_n["dir_pub"]) . '" ,"DIR_PUBLIC_APP"=>"' . $x_app . '" ,"LOCALHOST_SUFFIX"=>"' . ArraySafe($row_n, 'dir_local', '') . '" ,"APP"=>"' . $x_app . '" ,"APPDSC"=>"' . trim($row_a["description"]) . '" ,"XDIRS"=>"' . trim($row_a['xdirs']) . '" ,"ROLE_LOGIN"=>"' . ArraySafe($row_a, 'flag_rolelogin', 'Y') . '" ,"FLAG_PWMD5"=>"' . ArraySafe($row_a, 'flag_pwmd5', 'N') . '" ,"TEMPLATE"=>"' . trim($row_a['template']) . '" ,"SPEC_BOOT"=>"' . trim($row_a["appspec_boot"]) . '" ,"SPEC_LIB"=>"' . trim($row_a["appspec_lib"]) . '" ,"SPEC_LIST"=>"' . trim($row_a["appspec"]) . '"); include("androBuild.php"); ?> '; $t = pathinfo(__FILE__); $dircur = AddSlash($t["dirname"]) . "../tmp/"; $file = $dircur . "do" . $x_app . ".php"; $FILE = fopen($file, "w"); fwrite($FILE, $string); fclose($FILE); x_EchoFlush(""); include $file; echo ob_get_clean(); }
function main_pr_execute() { ob_start(); $sApp = SQLFC(gp('gp_app')); $sInst = SQLFC(gp('gp_inst')); $hApp = hSanitize(gp('gp_app')); $hInst = hSanitize(gp('gp_inst')); $rows = SQL_AllRows("SELECT * from instances \n where application={$sApp} AND instance={$sInst}"); if (count($rows) != 1) { ?> <div class="errorbox">Incorrect call to instance processing.</div> <?php return; } $row = $rows[0]; $sVer = SQLFC(gp('gp_ver')); $hVer = hSanitize(gp('gp_ver')); // KFD 2/4/08, If this is a subversion-enabled server, // get version information from there if (OptionGet('DEV_STATION', '') != '') { $aversions = svnVersions(); $mv = '-VER-' . $aversions['andro']['local']; } else { // Get information on latest version of Node Manager and // link to that $mv = SQL_OneValue("mv", "SELECT max(version) as mv \n FROM appversions\n WHERE application='andro'"); } $DIR_LINK_LIB = $GLOBALS['AG']['dirs']['root'] . '/pkg-apps/andro' . $mv; // Source of symlinks for app directories $DIR_LINK_APP = $GLOBALS['AG']['dirs']['root'] . "/pkg-apps/{$hApp}-VER-{$hVer}"; // Get application information for the DO program $tsql = 'SELECT * from applications ' . ' WHERE application = ' . $sApp; $row_a = SQL_OneRow($tsql); $tsql = 'SELECT * from webpaths ' . ' WHERE webpath = ' . SQLFC($row_a['webpath']); $row_n = SQL_OneRow($tsql); $dirws = AddSlash(trim($row_n["dir_pub"])); //if (substr($dirws,-1,1)<>"/") $dirws.="/"; //$row["webserver_dir_pub"] = $dirws; $string = '<?php // To run this program from the command line, you must // be logged in as a user that has superuser priveleges, such // as root or postgres. When running from the web app, // the current user\'s priveleges are used. $GLOBALS["parm"] = array( "DBSERVER_URL"=>"localhost" ,"UID"=>"' . SessionGet('UID') . '" ,"DIR_PUBLIC"=>"' . $dirws . '" ,"DIR_PUBLIC_APP"=>"' . $hApp . '_' . $hInst . '" ,"DIR_LINK_LIB"=>"' . $DIR_LINK_LIB . '" ,"DIR_LINK_APP"=>"' . $DIR_LINK_APP . '" ,"APP"=>"' . $hApp . '_' . $hInst . '" ,"INST"=>"' . $hInst . '" ,"IVER"=>"' . $hVer . '" ,"XDIRS"=>"' . trim($row_a['xdirs']) . '" ,"FLAG_PWMD5"=>"' . ArraySafe($row_a, 'flag_pwmd5', 'N') . '" ,"ROLE_LOGIN"=>"' . ArraySafe($row_a, 'flag_rolelogin', 'Y') . '" ,"TEMPLATE"=>"' . $row['template'] . '" ,"APPDSC"=>"' . trim($row_a["description"]) . '" ,"SPEC_BOOT"=>"' . trim($row_a["appspec_boot"]) . '" ,"SPEC_LIB"=>"' . trim($row_a["appspec_lib"]) . '" ,"SPEC_LIST"=>"' . trim($row_a["appspec"]) . '" ); include("androBuild.php"); ?> '; $t = pathinfo(__FILE__); $dircur = AddSlash($t["dirname"]) . "../tmp/"; //$dircur = $t["dirname"]; if (substr($dircur, -1) != "/") { $dircur .= "/"; } $file = $dircur . "do-{$hApp}-{$hInst}.php"; $FILE = fopen($file, "w"); fwrite($FILE, $string); fclose($FILE); include $file; if (ArraySafe($GLOBALS, 'retval', 0) == 1) { SQL("update instances set version={$sVer}\n WHERE application = {$sApp}\n AND instance = {$sInst}"); } echo ob_get_clean(); }