function checkDBFilesForChanges()
 {
     global $parm;
     $this->LogStage("Checking spec files for changes");
     $changed = false;
     $checksums = array();
     $specboot = $parm["SPEC_BOOT"] . ".add";
     $checksums[] = array('file' => $specboot, 'md5' => md5_file($parm['DIR_PUB'] . "lib/" . $specboot), 'fullpath' => $parm['DIR_PUB'] . "lib/" . $specboot);
     if (isset($parm['INST'])) {
         $app = str_replace('_' . $parm['INST'], '', $parm['APP']);
     } else {
         $app = $parm['APP'];
     }
     if ($parm["SPEC_LIST"] != "") {
         $speclist = explode(",", $parm["SPEC_LIST"]);
         foreach ($speclist as $spec) {
             if (substr($spec, -5) != '.yaml') {
                 $file = $spec . ".add";
             } else {
                 $file = $spec;
             }
             $checksums[] = array('file' => $file, 'md5' => md5_file($parm["DIR_PUB"] . "application/" . $file), 'fullpath' => $parm["DIR_PUB"] . "application/" . $file);
         }
     }
     $checkqry = "SELECT relname FROM pg_class WHERE relname='instance_spec_checksums'";
     $checkrslts = SQL_AllRows($checkqry);
     if (count($checkrslts) == 0) {
         $this->LogEntry("Instance tracking table doesnt exist yet...ignoring until next build");
         return true;
     }
     foreach ($checksums as $checksum) {
         $query = "SELECT checksum,skey FROM " . ddTable_idResolve('instance_spec_checksums') . " WHERE \n            application=" . SQLFC($app) . " AND spec_name=" . SQLFC($checksum['file']) . (isset($parm['INST']) ? " AND instance=" . SQLFC($parm['INST']) : '');
         $row = SQL_OneRow($query);
         if ($row) {
             $this->LogEntry('Entry for ' . $checksum['file'] . ' file found');
             if ($row['checksum'] != $checksum['md5']) {
                 $this->LogEntry("Spec File Changed: " . $checksum['file']);
                 $changed = true;
                 $checksum_update = array('skey' => $row['skey'], 'checksum' => md5_file($checksum['fullpath']));
                 SQLX_Update('instance_spec_checksums', $checksum_update);
                 $this->LogEntry("Updating Entry");
             }
         } else {
             $this->LogEntry('Entry for ' . $checksum['file'] . ' not found');
             $checksum_entry = array('application' => $app, 'instance' => isset($parm['INST']) ? $parm['INST'] : '', 'spec_name' => $checksum['file'], 'checksum' => md5_file($checksum['fullpath']));
             SQLX_Insert('instance_spec_checksums', $checksum_entry);
             $this->LogEntry("Spec File Changed: " . $checksum['file']);
             $changed = true;
         }
     }
     if ($changed) {
         $this->LogEntry('One or more spec files have changed: Proceeding with full build');
     } else {
         $this->LogEntry('Spec files have not changed: Proceeding with mini build');
     }
     return $changed;
 }
Esempio n. 2
0
    function main()
    {
        # KFD 2/17/09.  If installed with Debian package, will
        #               have username and password of "start".
        #               Must force a new id now.
        #
        if (SessionGet('UID') == 'start') {
            if (gp('user_id') != '') {
                if (gp('user_id') == '') {
                    ErrorAdd("User Id may not be empty");
                }
                if (substr(gp('user_id'), 0, 5) == 'andro') {
                    ErrorAdd("User Id may not begin with 'andro'");
                }
                if (gp('password1') != gp('password2')) {
                    ErrorAdd("Passwords do not match");
                }
                if (strlen(trim(gp('password1'))) == 0) {
                    ErrorAdd("Password may not be empty");
                }
                if (!Errors()) {
                    $row = array('user_id' => gp('user_id'), 'member_password' => gp('password1'));
                    SQLX_Insert('usersroot', $row);
                    if (!Errors()) {
                        scDBConn_Pop();
                        SessionSet('UID', gp('user_id'));
                        SessionSet('PWD', gp('password1'));
                        scDBConn_Push();
                        SQL("DELETE FROM USERSROOT WHERE user_id='start'");
                        # Get rid of the form that replaces login
                        $file = fsDirTop() . 'application/x_login_form.inc.html';
                        $fileto = $file . '.done';
                        @rename($file, $fileto);
                        ?>
                        <h1>New Root User Created</h1>
                        
                        <p>Your new user is created.</p>
                        
                        <p><a href="index.php?st2logout=1">
                           Return to Login Page</a></p>
                        <?php 
                        return;
                    }
                }
            }
            ?>
            <h1>New Install - Must Create User</h1>
            
            <p>You are logged into your Node Manager with the default
               username of "start" and password "start".  We have to change
               this right now so nobody can get into your new system.
            </p>
            
            <p>Please provide a new ROOT (superuser) user id and password
               below.  Andromeda will create the new user, log you in as
               that user, and remove the "start" user.
            </p>
            
            <table>
              <tr><td align="left">User Name
                  <td><input name = 'user_id' /> (may not begin with 'andro')
              <tr><td align="left">Password
                  <td><input type="password" name = 'password1'/>
              <tr><td align="left">Password (verify)
                  <td><input type="password" name = 'password2'/>
            </table>
            <input type="submit" value="Create User Now" />
            <?php 
            return;
        }
        /* FUTURE X6 VERSION OF NODE MANAGER
           ?>
           <h1>Node Manager Upgrade Required</h1>
           
           <p>The new version of the Node Manager uses the "x6" 
              interface to provide a richer experience.  Please click
              the link below to upgrade your Node Manager.  Once the
              upgrade is complete, log out and back in.
           </p>
           
           <p><a href="javascript:Popup('index.php?gp_page=a_builder&gp_out=none&x2=1&txt_application=andro','Build')"
               >Upgrade Node Manager Now</a>.</p>
               
           <p><a href="?st2logout=1">Logout After Upgrade</a>.</p>
           
           <?php
           return;
           */
        # <------- EARLY RETURN.
        # KFD 1/10/08, The old x_welcome screen is not used anymore,
        #              we have the new 'cpanel' now in x6.
        # ===============================================================
        ?>
        <h1>Welcome to the Andromeda Node Manager</h1>
        <?php 
        // Work out if there is a new release available
        //
        $apps = svnVersions();
        $andro = a($apps, 'andro', array('svn_url' => ''));
        if (trim($andro['svn_url']) == '') {
            $htmlVersions = '';
        } else {
            $htmlVersions = @file_get_contents($andro['svn_url']);
        }
        $matches = array();
        preg_match_all('/<li><a href=.*\\>(.*)<\\/a><\\/li>/', $htmlVersions, $matches);
        $versions = ArraySafe($matches, 1, array());
        if (count($versions) > 0) {
            $latest = array_pop($versions);
            $latest = str_replace('/', '', $latest);
            // Get current latest
            $current = $andro['local'];
            if ($latest > $current) {
                ?>
            <br/>
            <div style="border: 5px solid gray; color: blue
            font-weight: bolder; margin: 8px; padding: 0 8px 8px 8px">
            <h2>New Version of Andromeda Available</h2>
            
            <p>Version <?php 
                echo $latest;
                ?>
 is available.   <a href="?gp_page=a_pullsvn"
            >Click Here </a> to go to the Pull Code From Subversion.
            </div>
            <?php 
            }
        }
        $dirs = SQL_AllRows("select * from webpaths where webpath='DEFAULT'");
        ?>
<div style="font-size: 120%; line-height: 120%; padding: 10px">

<h2>For First Time Users</h2>
    This program is the Andromeda <b>Node Manager</b>.  You use this
    program to build your applications.
    <br/>
    <br/>
    Our main documentation is <a target="_blank" href=
    "http://www.andromeda-project.org/">here</a>.
    <br/>
    <br/>

    If you want to start programming a new application right away, 
    <a target="_blank"  href=
    "http://www.andromeda-project.org/creatinganapplication.html"
    >The instructions are here</a>, or you can just 
    <a href="?gp_page=applications&gp_mode=ins">define a new application here.</a>
    <br/>
    <br/>

After you defined an application, click on the "build this application"
link to create all of the directories and the empty database.</p>
<br/>
<br/>

<h2>Your Application Program Files</h2>

After building the application skeleton you can start working on the
   database specification.  If your application code is "test", then put
   the database specification into the file
   <br/>
   <br/>
   <b><?php 
        echo $dirs[0]['dir_pub'];
        ?>
/test/application/test.dd.yaml</b>
<br/>
<br/>

All Andromeda applications start with
a database specification.  These specifications are 
more powerful than anything else out there, 
and you will want learn the Andromeda's 
<a target="_blank" href=
"http://www.andromeda-project.org/databaseprogramming.html"
>Database Programming</a> language.

<br/>
<br/>
Once you are ready to try some custom pages, you are ready to look
at <a target="_blank" href=
"http://www.andromeda-project.org/webprogramming.html"
>Web Programming</a>.
   
    
</div>        
        <?php 
    }
Esempio n. 3
0
    function xajax()
    {
        if (gp('gp_xajax') != '1') {
            return $this->xAjaxColSave();
        }
        // No conditionals here, this is always ajax
        echo "xajax|";
        $tid = gp('gp_table_id');
        $parms['gp_table_id'] = $tid;
        $parms['gp_page'] = 'x_import';
        $parms['gp_xajax'] = '1';
        $parms['gp_map'] = gp('gp_map', '');
        //$a1=aFromgp('gp_');
        //hprint_r($a1);
        //$a2=aFromgp('txt_');
        //hprint_r($a2);
        // Look for a map delete command
        if (gpExists('gp_del')) {
            SQL("Delete from importmaps where importmap=" . SQLFC(gp('gp_del')));
            if (gp('gp_del') == gp('gp_map')) {
                gpSet('gp_map', '');
                $parms['gp_map'] = '';
            }
        }
        // Look for a map insert command. If found and works, automatically
        // select this as the map we want.
        $row = aFromGP('txt_');
        if (count($row) > 0 && gpExists('gp_new')) {
            $dd = DD_TableRef('importmaps');
            $row['table_id'] = gp('gp_table_id');
            SQLX_Insert($dd, $row);
            if (!Errors()) {
                gpSet('gp_map', $row['importmap']);
                $parms['gp_map'] = gp('gp_map');
            }
        }
        // Display a list of maps we may use
        $maps = SQL_AllRows("Select importmap,name_prefix from importmaps\n           where table_id=" . SQLFC($tid), 'importmap');
        //hprint_r($maps);
        ?>

      <h2>Map Selection</h2>
      
      <p>Please choose a map to use.  If no map exists, please create
         a new one.  After a map is chosen you can map individual columns.
      </p>
      
      <table id="x2data1">
        <thead>
          <tr><th>Map Name
              <th>Select
              <th>Delete
        </thead>
        <tbody>
      <?php 
        foreach ($maps as $map) {
            $px = $parms;
            $px['gp_map'] = $map['importmap'];
            $hp1 = http_build_query($px);
            $px['gp_del'] = $map['importmap'];
            $hp2 = http_build_query($px);
            echo $map['importmap'] == $parms['gp_map'] ? '<tr class="hilite">' : '<tr>';
            ?>
         <td><?php 
            echo $map['importmap'];
            ?>
         <td><a href="javascript:andrax('?<?php 
            echo $hp1;
            ?>
')">Select</a>
         <td><a href="javascript:andrax('?<?php 
            echo $hp2;
            ?>
')">Delete</a>
         <?php 
        }
        // Now the row for a new entry
        $px = $parms;
        $px['gp_new'] = 1;
        $hp = "'?" . http_build_query($px);
        $hp .= "&txt_importmap='+ob('txt_importmap').value";
        ?>
         <tr><td><input name="txt_importmap"   id="txt_importmap">
             <td>&nbsp;
             <td><a href="javascript:andrax(<?php 
        echo $hp;
        ?>
)">Create</a>
      </table>
      <?php 
        // If they have not picked a map, we are done.  If we continue
        // we will let them pick individual columns.
        if ($parms['gp_map'] == '') {
            return;
        }
        // Get column listing from dictionary
        $dd = DD_TableRef(gp('gp_table_id'));
        $cols = array_keys($dd['flat']);
        // Get cols available from import
        $fi = SessionGet('importfile');
        $FILE = fopen($fi['uname'], 'r');
        $sline = fsGets($FILE);
        $aline = explode('|', $sline);
        array_unshift($aline, '');
        $aline = array_combine($aline, $aline);
        // make keys and values the same
        fclose($FILE);
        // Get current map
        $mapcols = SQL_AllRows("Select column_id,column_id_src FROM importmapcolumns\n           WHERE importmap=" . SQLFC(gp('gp_map')) . "\n             AND table_id =" . SQLFC(gp('gp_table_id')), 'column_id');
        ?>
      <hr />
      <h2>Individual Column Mappings</h2>
      <table id="x2data1">
        <thead><tr><th>Destination Column</td>
                   <th>Caption</td>
                   <th>Source Column</td>
        </thead>
        <tbody>
      <?php 
        foreach ($cols as $col) {
            $value = ArraySafe($mapcols, $col, array());
            $value = ArraySafe($value, 'column_id_src', '');
            $px = $parms;
            $px['gp_xajax'] = $col;
            $andrax = "?" . http_build_query($px);
            $extra = "onchange=\"andrax('{$andrax}&gp_xval='+this.value)\"";
            $hSelect = hSelectFromAA($aline, 'anycol', $value, $extra);
            if ($dd['flat'][$col]['uino'] != 'Y') {
                ?>
            <tr><td><?php 
                echo $col;
                ?>
                <td><?php 
                echo $dd['flat'][$col]['description'];
                ?>
                <td><?php 
                echo $hSelect;
                ?>
            <?php 
            }
        }
        ?>
        </tbody>
      </table>
      <?php 
        $href = '?gp_page=x_import&gp_table_id=' . $tid . '&gp_fbproc=1' . '&gp_map=' . $parms['gp_map'];
        ?>
      <hr />
      <h2>File Process</h2>
      
      <p>The file <?php 
        echo $fi['name'];
        ?>
 was uploaded, size 
         <?php 
        echo number_format($fi['size']);
        ?>
 bytes.
      </p>
      
      <p><a href="javascript:SetAndPost('gp_nofile',1)">
         Upload A Different File
         </a>
      </p>  
         
      <p><a href="javascript:Popup('<?php 
        echo $href;
        ?>
')">Process Now</a>
      </p>
      
      <?php 
    }
Esempio n. 4
0
 /**
  * Execute an skey-based update
  *
  */
 function update()
 {
     $row = aFromGP('x4v_');
     $skey = 0;
     $table_id = $this->dd['table_id'];
     # KFD 6/12/08, allow functions to modify or prevent a write
     $tbefore = $table_id . "_writeBefore";
     $tafter = $table_id . "_writeAfter";
     if (function_exists($tbefore)) {
         $message = $tbefore($row);
         if ($message != '') {
             x4Error($message);
             return;
         }
     }
     # KFD 6/28/08, a non-empty date must be valid
     $errors = false;
     foreach ($row as $col => $value) {
         if (!isset($this->dd['flat'][$col])) {
             unset($row[$col]);
             continue;
         }
         $ermsg = "Invalid date format for " . $this->dd['flat'][$col]['description'];
         $ermsg2 = "Invalid date value for " . $this->dd['flat'][$col]['description'];
         if ($this->dd['flat'][$col]['type_id'] == 'date') {
             if (trim($value) == '') {
                 continue;
             }
             if (strpos($value, '/') === false && strpos($value, '-') === false) {
                 x4Error($ermsg);
                 $errors = true;
                 continue;
             }
             if (strpos($value, '/') !== false) {
                 $parsed = explode('/', $value);
                 if (count($parsed) != 3) {
                     $errors = true;
                     x4Error($ermsg);
                     continue;
                 }
                 if (!checkdate($parsed[0], $parsed[1], $parsed[2])) {
                     x4Error($ermsg2);
                     $errors = true;
                     continue;
                 }
             }
             if (strpos($value, '-') !== false) {
                 $parsed = explode('-', $value);
                 if (count($parsed) != 3) {
                     $errors = true;
                     x4Error($ermsg);
                     continue;
                 }
                 if (!checkdate($parsed[1], $parsed[2], $parsed[0])) {
                     x4Error($ermsg2);
                     $errors = true;
                     continue;
                 }
             }
         }
     }
     if ($errors) {
         return;
     }
     if ($row['skey'] == 0 || !isset($row['skey'])) {
         unset($row['skey']);
         $skey = SQLX_Insert($this->dd, $row);
         if (!errors()) {
             $row = SQL_OneRow("Select * FROM {$this->view_id} WHERE skey = {$skey}");
         }
         x4Data('row', $row);
     } else {
         SQLX_Update($this->dd, $row);
         if (!errors()) {
             $skey = $row['skey'];
             $row = SQL_OneRow("Select * FROM {$this->view_id} WHERE skey = {$skey}");
             x4Data('row', $row);
         }
     }
     # KFD 6/12/08, allow functions to modify or prevent a write
     if (Errors()) {
         return;
     }
     if (function_exists($tafter)) {
         $message = $tafter($row);
         if ($message != '') {
             x4Error($message);
             return;
         }
     }
 }
Esempio n. 5
0
 function hMover()
 {
     // Get the parent table, and the "left" side, which is us
     $dd = ContextGet('drilldown', array());
     $tpar = $dd[0]['page'];
     $tleft = $this->table_id;
     // The right side we *assume* is the other parent table
     // of us that is not the drilldown source.  Get it?  It breaks
     // of course if this table has more than one parent
     $tables = array_keys($this->table['fk_parents']);
     unset($tables[$tpar]);
     $tright = array_pop($tables);
     // if > 1 parent, this won't work
     $dd_right = dd_tableref($tright);
     // Get match expression for left-hand side
     $matches = $dd[0]['parent'];
     $pmatch = '';
     foreach ($matches as $key => $value) {
         $ileft = $key;
         $imatch = SQLFC($value);
         $pmatch .= $key . "='" . $value . "'";
     }
     // Do an insert if coming through as ajax
     $sqins = '';
     if (gpExists('moveradd')) {
         if (gp('moveradd') != '0') {
             $row1 = array($dd_right['pks'] => gp('moveradd'));
             $row2 = $dd[0]['parent'];
             $rowi = array_merge($row1, $row2);
             SQLX_Insert($this->table_id, $rowi);
         } else {
             $tab = $this->table_id;
             $cols = $this->table['pks'];
             $colr = $dd_right['pks'];
             $sqins = "insert into {$tab}\n                   ( {$cols} ) \n                  SELECT {$imatch}, {$colr} \n                    FROM {$tright}\n                  WHERE NOT EXISTS (\n                    SELECT * FROM {$tleft}\n                     WHERE {$tleft}.{$key} = {$imatch}\n                       AND {$tleft}.{$colr} = {$tright}.{$colr})";
             SQL($sqins);
         }
     }
     // Do a delete if coming through as ajax
     $sqldel = 'hi';
     if (gpExists('moverdel')) {
         $sqldel = 'moverdel exists';
         if (gp('moverdel') != '0') {
             $sqldel = "delete from " . ddTable_idResolve($this->table_id) . " where skey=" . SQLFN(gp('moverdel'));
             //echo "echo|$sq";
         } else {
             $sqldel = "delete from " . ddTable_idResolve($this->table_id) . " WHERE " . $pmatch;
         }
         SQL($sqldel);
     }
     # Pull the source table, the right-hand side
     # KFD 6/9/08, make left hand side sort by description
     #             if present.
     $vright = ddTable_idResolve($tright);
     $vleft = ddTable_idResolve($tleft);
     $ob = $dd_right['pks'];
     $ljoin = '';
     $lob = '';
     if (isset($dd_right['flat']['description'])) {
         $ob = 'description';
         $ljoin = " JOIN {$vright} r ON {$vleft}." . $dd_right['pks'] . '=r.' . $dd_right['pks'];
         $lob = ' ORDER BY r.description';
     }
     $sq = "SELECT " . $dd_right['pks'] . " as pk\n                 ,description\n             FROM " . ddTable_idResolve($tright) . "\n            WHERE description <> ''\n            ORDER BY {$ob}";
     $rows_right = sql_allrows($sq, 'pk');
     # Left side table.
     $sq = "SELECT {$vleft}." . $dd_right['pks'] . " as pk,{$vleft}.skey\n             FROM " . ddTable_IDResolve($this->table_id) . $ljoin . ' ' . " WHERE {$pmatch} {$lob}";
     $rows_left = sql_allrows($sq, 'pk');
     // Convert the left hand side into options
     $ahl = array();
     foreach ($rows_left as $row) {
         if (isset($rows_right[trim($row['pk'])])) {
             $ahl[] = "<OPTION " . ' VALUE="' . $row['skey'] . '"' . '>' . $rows_right[trim($row['pk'])]['description'] . '</option>';
         }
     }
     // Convert the right hand side into options
     $ahr = array();
     foreach ($rows_right as $row) {
         if (!isset($rows_left[trim($row['pk'])])) {
             $ahr[] = "<OPTION " . ' VALUE="' . $row['pk'] . '"' . '>' . $row['description'] . '</option>';
         }
     }
     ob_start();
     ?>
   <table class="table table-bordered table-striped table-condensed">
     <tr>
     <td>
        <b>Selected Values</b><br/><br/> 
        <select size=20 style="width: 250px"
           onclick="formPostAjax('&gp_xajax=1&moverdel='+this.value)"
           >
        <?php 
     echo implode("\n", $ahl);
     ?>
        </select>
     <td style="padding:10px; vertical-align: top">
        <br/>
        <br/>
        <button onclick="formPostAjax('&gp_xajax=1&moveradd=0')"
              >&lt;&lt; All</button>
        <br/>
        <br/>
        <button onclick="formPostAjax('&gp_xajax=1&moverdel=0')"
              >All &gt;&gt;</button>
     <td>
        <b>Available Values</b><br/><br/> 
        <select size=20 style="width: 250px"
           onclick="formPostAjax('&gp_xajax=1&moveradd='+this.value)"
           >
        <?php 
     echo implode("\n", $ahr);
     ?>
        </select>
   </table>
   <?php 
     $this->h['Content'] = ob_get_clean();
     if (gpexists('gp_xajax')) {
         echo 'mover|' . $this->h['Content'];
         if (errors()) {
             echo "|-|echo|" . asErrors();
         }
         exit;
     } else {
         $this->h['Content'] = '<div id="mover">' . $this->h['Content'] . '</div>';
     }
 }
Esempio n. 6
0
function scDBInsert($table_id, $row, $rewrite_skey = true)
{
    $table = DD_TableRef($table_id);
    return SQLX_Insert($table, $row, $rewrite_skey);
}
Esempio n. 7
0
*/
include 'androInstallBuild.php';
/*
* Insert new webpaths record
*/
$dir_pub = realpath(dirname(__FILE__) . '/../..');
if (strpos(ArraySafe($_ENV, 'OS', ''), 'indows') !== false) {
    $dir_pub = str_replace("\\", "\\\\", $dir_pub);
}
$row = array('webpath' => 'DEFAULT', 'dir_pub' => $dir_pub, 'description' => 'Default Web Path');
SQLX_Insert('webpaths', $row);
/*
* Insert new applications record
*/
$row = array('application' => 'andro', 'description' => "Andromeda Node Manager", 'appspec' => 'andro.dd.yaml', 'node' => 'LOCAL', 'webpath' => 'DEFAULT', 'flag_svn' => 'Y', 'svn_url' => 'http://andro.svn.sourceforge.net/svnroot/andro/releases/');
SQLX_Insert('applications', $row);
/*
* End - Close connection
*/
disconnect();
//==================================================================
//	FUNCTIONS
//==================================================================
/**
* Connect to the postgresql database server with the default installed username
*/
function connect()
{
    $cnx = " dbname=andro" . " user=start" . " password=start";
    $GLOBALS["dbconn"] = pg_connect($cnx, PGSQL_CONNECT_FORCE_NEW);
}
Esempio n. 8
0
function X_EMAIL_SEND($em)
{
    $retval = false;
    //scDBConn_Push('admin');
    if (SQLX_TrxLevel() > 0) {
        ErrorAdd("ERROR: Cannot send an email within a transaction");
    } else {
        if (configGet('email_fromaddr')) {
            $from_addr = configGet('email_fromaddr');
            $from_name = configGet('email_fromname');
        } else {
            $from_addr = trim(OPTION_GET("EMAILFROM_ADDR"));
            $from_name = trim(OPTION_GET("EMAILFROM_NAME"));
        }
        $smtp_server = trim(OPTION_GET('SMTP_SERVER', 'localhost'));
        if ($from_addr == "") {
            ErrorAdd("The system's return email address, defined in system variable " . "EMAILFROM_ADDR, must be set to a valid email address.  " . HTMLE_A_STD("System Variables", "variables", ""));
        } else {
            if ($from_name != "") {
                $from_name = '"' . $from_name . '"';
            }
            $from = "From: " . $from_name . " <" . $from_addr . ">";
            include_once 'Mail.php';
            $recipients = $em["email_to"];
            $headers['From'] = $from_name . "<" . $from_addr . ">";
            $headers['To'] = $em["email_to"];
            $headers['Subject'] = $em["email_subject"];
            $headers['Date'] = date("D, j M Y H:i:s O", time());
            foreach ($em['headers'] as $hname => $hval) {
                $headers[$hname] = $hval;
            }
            $body = $em["email_message"];
            $params['sendmail_path'] = '/usr/lib/sendmail';
            $params['host'] = $smtp_server;
            // Create the mail object using the Mail::factory method
            $mail_object = Mail::factory('smtp', $params);
            $mail_object->send($recipients, $headers, $body);
            if (!$mail_object) {
                ErrorAdd("Email was not accepted by server");
            } else {
                $table_ref = DD_TableRef('adm_emails');
                SQLX_Insert($table_ref, $em, false);
                $retval = false;
            }
        }
    }
    //scDBConn_Pop();
    return $retval;
}
Esempio n. 9
0
 function mainPRocess($v, $dirs)
 {
     // First create the version
     $table_dd = DD_TableRef('appversions');
     $row = array('version' => $v, 'date' => time(), 'application' => $this->app);
     SQLX_Insert($table_dd, $row);
     if (Errors()) {
         echo hErrors();
         return;
     }
     // We'll need this for every file we load
     $this->tlf = DD_TableRef('appfiles');
     // Create the application save directory
     $app = $this->app;
     $r2 = $GLOBALS['AG']['dirs']['root'];
     if (!file_exists($r2 . 'pkg-apps')) {
         mkdir($r2 . 'pkg-apps');
     }
     if (!file_exists($r2 . "pkg-apps/{$app}-{$v}")) {
         mkdir($r2 . "pkg-apps/{$app}-{$v}");
     }
     $r2 = $r2 . "pkg-apps/{$app}-{$v}";
     foreach ($dirs as $dir) {
         if (!file_exists($this->root . $dir['dirname'])) {
             mkdir($this->root . $dir['dirname']);
         }
         $this->mainPR_DirFiles($v, $r2, $this->root, $dir['dirname'], '');
     }
     $dpa = $GLOBALS['AG']['dirs']['root'] . 'pkg-apps/';
     chdir($GLOBALS['AG']['dirs']['root'] . 'pkg-apps/');
     $command = "tar czvf {$app}-{$v}.tgz {$app}-{$v}";
     x_EchoFlush("");
     x_EchoFlush("Tarballing with this command: {$command}");
     `{$command}`;
     x_EchoFlush("");
     // Now create the install version.
     if ($this->app == 'andro') {
         x_EchoFlush("Renaming install.done.php to install.php");
         rename("{$dpa}{$app}-{$v}/application/install.done.php", "{$dpa}{$app}-{$v}/application/install.php");
         x_EchoFlush("Renaming directory to andro, copying index.php");
         rename("{$dpa}{$app}-{$v}", $dpa . "andro");
         copy($dpa . "andro/root/index.php", $dpa . "andro/index.php");
         copy($dpa . "andro/root/htaccess", $dpa . "andro/.htaccess");
         // KFD 8/2/07, Sourceforge bug #1755244, for the node manager
         //             these are created by build but we need them for
         //             the build, so make them here.
         mkdir($dpa . "andro/tmp");
         mkdir($dpa . "andro/generated");
         // KFD 8/2/07, Sourceforge bug #1755244, END
         $command = "tar czvf {$app}-{$v}-install.tgz andro index.php .htaccess";
         x_EchoFlush("");
         x_EchoFlush("Tarballing install version with this command: {$command}");
         `{$command}`;
         x_EchoFlush("Renaming directory back to {$app}-{$v}");
         unlink($dpa . "andro/index.php");
         unlink($dpa . "andro/.htaccess");
         rename($dpa . "andro", "{$dpa}{$app}-{$v}");
         x_EchoFlush("Process is complete!");
     }
 }
Esempio n. 10
0
 function MD5_ForgotPage3()
 {
     $UID = gp('uid');
     $md5 = gp('md5');
     $pw1 = gp('pw1');
     $pw2 = gp('pw2');
     fwLogEntry('1025', 'PW Change Attempt', $UID);
     if ($pw1 != $pw2) {
         ErrorAdd("Password values did not match");
     }
     if (strlen($pw1) < 6) {
         ErrorAdd("Password must be at least 5 characters");
     }
     if (!preg_match("/[0-9]/", $pw1)) {
         ErrorAdd("Password must contain at least one numeric digit");
     }
     if (!preg_match("/[a-z]/", $pw1)) {
         ErrorAdd("Password must contain at least one lower case character");
     }
     if (!preg_match("/[A-Z]/", $pw1)) {
         ErrorAdd("Password must contain at least one upper case character");
     }
     if (strpos(strtolower($pw1), strtolower($UID)) !== false) {
         ErrorAdd("You cannot use your user_id in your password!");
     }
     if (Errors()) {
         echo hErrors();
         gpSet('gpp', '2');
         ErrorsClear();
         return;
     }
     $row = array('user_id' => $UID, 'md5' => $md5, 'member_password' => $pw1);
     SQLX_Insert('users_pwverifies', $row);
     if (Errors()) {
         echo hErrors();
         gpSet('gpp', '2');
         ErrorsClear();
         return;
     } else {
         fwLogEntry('1026', 'PW Change Success', $UID);
         ?>
      <p>Your password has been set, you can now 
         <a href="?gp_page=x_login">Login</a>.
      
      <?php 
     }
 }
Esempio n. 11
0
 function checkboxSave()
 {
     $row = aFromGP('cbval_');
     x6Data('row', $row);
     $table_id = gp('x6page');
     if (gp('checked') == 'true') {
         SQLX_Insert($table_id, $row);
     } else {
         SQLX_Delete($table_id, $row);
     }
 }
Esempio n. 12
0
function index_hidden_ajaxsql()
{
    switch (gp('gp_ajaxsql')) {
        case 'update':
            $row = aFromgp('txt_');
            foreach ($row as $key => $value) {
                if ($value == 'b:true') {
                    $row[$key] = 'Y';
                }
                if ($value == 'b:false') {
                    $row[$key] = 'N';
                }
            }
            $table_id = gp('gp_table');
            SQLX_Update($table_id, $row);
            break;
        case 'insert':
            $row = aFromgp('txt_');
            $table_id = gp('gp_table');
            // XDB
            SQLX_Insert($table_id, $row);
            break;
    }
    if (Errors()) {
        echo 'echo|' . hErrors();
    }
}
Esempio n. 13
0
 function PullCodeApp($row)
 {
     $app = trim($row['application']);
     $sApp = SQLFC($app);
     $ver = $row['version'];
     $sVer = SQLFC($ver);
     x_echoFlush("");
     x_EchoFlush("*** Application: " . $row['application']);
     x_EchoFlush("  Authoritative Node is: " . $row['node']);
     x_EchoFlush("  Current Local Version: " . $ver);
     // Get version from remote node
     $remote = $this->CURL($row['node_url'], "select max(version) as version\n             FROM appversions\n            WHERE application={$sApp}");
     if (count($remote) == 0) {
         x_EchoFlush("The remote server says it's got nothing for us!");
     } else {
         $vremote = $remote[0]['version'];
         x_EchoFlush("  Remote server has version: {$vremote}");
         if ($vremote == $ver) {
             x_EchoFlush("Local version is up-to-date, nothing to do here.");
         } elseif ($vremote < $ver) {
             x_EchoFlush("Local version is more recent.");
             x_EchoFlush("  --> this should not normally happen, perhaps");
             x_EchoFlush("      somebody published code on this machine?");
         } else {
             x_EchoFlush("Local version out of date, pulling latest");
             $this->VersionPull($app, $vremote, $row);
             $table_dd = DD_TableRef('appversions');
             $row = array('application' => $app, 'version' => $vremote);
             SQLX_Insert($table_dd, $row);
             echo hERrors();
         }
     }
 }