/**
      Define any javascript needed
      @return A javascript string
    function javascript_content(){
        $js ="";
        return $js;
    
    }
    */
    function body_content()
    {
        global $FANNIE_AUTH_ENABLED;
        include '../config.php';
        ob_start();
        echo showInstallTabs('Authentication');
        ?>

<form action=InstallAuthenticationPage.php method=post>
<h1 class="install">
    <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
</h1>
<?php 
        if (is_writable('../config.php')) {
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
        } else {
            echo "<div class=\"alert alert-danger;\"><b>Error</b>: config.php is not writeable</div>";
        }
        ?>
<hr />
<p class="ichunk" style="margin-top: 1.0em;">
<b>Authentication enabled</b>
<?php 
        echo installSelectField('FANNIE_AUTH_ENABLED', $FANNIE_AUTH_ENABLED, array(1 => 'Yes', 0 => 'No'), false, false);
        ?>
</p><!-- /.ichunk -->
<?php 
        // Default to Authenticate ("Authenticate Everything") or not.
        if ($FANNIE_AUTH_ENABLED) {
            echo "<p class='ichunk'>";
            echo "<b>Authenticate by default </b>";
            echo installSelectField('FANNIE_AUTH_DEFAULT', $FANNIE_AUTH_DEFAULT, array(1 => 'Yes', 0 => 'No'), false, false);
            echo "If 'Yes' all Admin utilities will require Login<br />";
            echo "If 'No' only those utilities coded for it will require Login";
            echo "</p><!-- /.ichunk -->";
        }
        if ($FANNIE_AUTH_ENABLED) {
            if (!function_exists("login")) {
                include $FANNIE_ROOT . 'auth/login.php';
            }
            // if no users exist, offer to create one
            if (getNumUsers() == 0) {
                $success = False;
                if (isset($_REQUEST['newuser']) && isset($_REQUEST['newpass'])) {
                    $FANNIE_AUTH_ENABLED = False;
                    // toggle to bypass user checking
                    $newUser = $_REQUEST['newuser'];
                    $success = createLogin($_REQUEST['newuser'], $_REQUEST['newpass']);
                    if ($success) {
                        echo "<i>User " . $_REQUEST['newuser'] . " created</i><br />";
                        $FANNIE_AUTH_ENABLED = True;
                        // toggle enforce error checking
                        $success = addAuth($_REQUEST['newuser'], 'admin');
                        if ($success) {
                            echo "<i>User " . $_REQUEST['newuser'] . " is an admin</i><br />";
                            echo "You can use these credentials at the <a href='../auth/ui/' target='_aui'>Authentication Interface</a></br />";
                            echo " Other protected pages may require different credentials.<br />";
                            $success = addAuth($_REQUEST['newuser'], 'sysadmin');
                            if ($success) {
                                echo "<i>User " . $_REQUEST['newuser'] . " is a sysadmin</i><br />";
                                echo "You can use these credentials at the Installation and Configuration Interface (these pages)</br />";
                                // populate known privileges table automatically
                                $db = FannieDB::get($FANNIE_OP_DB);
                                ob_start();
                                // don't care about primary key errors
                                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'userKnownPrivs');
                                ob_end_clean();
                                // loaddata() has no return value; success assumed.
                                echo "Table {$FANNIE_OP_DB}.userKnownPrivs has been populated with the standard privilege set.<br />";
                            } else {
                                echo "<b>Error making user {$newUser} a sysadmin</b><br />";
                            }
                        } else {
                            echo "<b>Error making user {$newUser} an admin</b><br />";
                        }
                    } else {
                        echo "<b>Error creating initial user</b><br />";
                    }
                    $FANNIE_AUTH_ENABLED = True;
                    // toggle enforce error checking
                }
                if (!$success) {
                    echo "<br /><i>No users defined. To create an initial admin user,\n                enter a username and password below</i><br />";
                    echo 'Username: <input type="text" name="newuser" /><br />';
                    echo 'Password: <input type="password" name="newpass" /><br />';
                }
            } else {
                echo "<p class='ichunk'>You can manage Login users and groups via the <a href='../auth/ui/' target='_aui'>Authentication Interface</a>";
                echo "</p><!-- /.ichunk -->";
            }
            echo "<p class='ichunk'><a href='../../documentation/Fannie/developer/auth.html' target='_audoc'>How Authentication Works</a>";
            echo "</p><!-- /.ichunk -->";
        }
        ?>
<hr />
<b>Allow shadow logins</b>
<?php 
        echo installSelectField('FANNIE_AUTH_SHADOW', $FANNIE_AUTH_SHADOW, array(1 => 'Yes', 0 => 'No'), false, false);
        if (!file_exists("../auth/shadowread/shadowread")) {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: shadowread utility does not exist</div>";
            echo "<div class=\"well\">";
            echo "shadowread lets Fannie authenticate users agaist /etc/shadow. To create it:";
            echo "<pre>\ncd " . realpath('../auth/shadowread') . "\nmake\n    </pre>";
            echo "</div>";
        } else {
            $perms = fileperms("../auth/shadowread/shadowread");
            if ($perms == 0104755) {
                echo "<div class=\"alert alert-success\">shadowread utility has proper permissions</div>";
            } else {
                echo "<div class=\"alert alert-danger\"><b>Warning</b>: shadowread utility has incorrect permissions</div>";
                echo "<div class=\"well\">";
                echo "shadowread needs setuid permission. To fix it: ";
                echo "<pre>\ncd " . realpath('../auth/shadowread') . "\nsudo make install\n        </pre>";
                echo "</div>";
            }
        }
        ?>
<hr />
<b>Allow LDAP logins</b>
<?php 
        echo installSelectField('FANNIE_AUTH_LDAP', $FANNIE_AUTH_LDAP, array(1 => 'Yes', 0 => 'No'), false, false);
        if (!function_exists("ldap_connect")) {
            echo "<div class=\"alert alert-danger\"><b>Warning</b>: PHP install does not have LDAP support enabled</div>";
        } else {
            echo "<div class=\"alert alert-success\">PHP has LDAP support enabled</div>";
        }
        ?>
<br />
<label>LDAP Server Host</label>
<?php 
        echo installTextField('FANNIE_LDAP_SERVER', $FANNIE_LDAP_SERVER, '127.0.0.1');
        ?>
<label>LDAP Port</label>
<?php 
        echo installTextField('FANNIE_LDAP_PORT', $FANNIE_LDAP_PORT, '389');
        ?>
<label>LDAP Domain (DN)</label>
<?php 
        echo installTextField('FANNIE_LDAP_DN', $FANNIE_LDAP_DN, 'ou=People,dc=example,dc=org');
        ?>
<label>LDAP Username Field</label>
<?php 
        echo installTextField('FANNIE_LDAP_SEARCH_FIELD', $FANNIE_LDAP_SEARCH_FIELD, 'uid');
        ?>
<label>LDAP User ID# Field</label>
<?php 
        echo installTextField('FANNIE_LDAP_UID_FIELD', $FANNIE_LDAP_UID_FIELD, 'uidnumber');
        ?>
<label>LDAP Real Name Field</label>
<?php 
        echo installTextField('FANNIE_LDAP_RN_FIELD', $FANNIE_LDAP_RN_FIELD, 'cn');
        ?>
<hr />
<p>
    <button type=submit class="btn btn-default">Save Configuration</button>
</p>
</form>

<?php 
        return ob_get_clean();
        // body_content
    }
示例#2
0
    /**
      Define any javascript needed
      @return A javascript string
    function javascript_content(){
    
    }
    */
    function body_content()
    {
        //Should this really be done with global?
        //global $FANNIE_URL, $FANNIE_EQUITY_DEPARTMENTS;
        include '../../config.php';
        ob_start();
        echo showInstallTabs("Sample Data", '../');
        ?>

<form action=InstallSampleDataPage.php method=post>
<h1 class="install">
    <?php 
        if (!$this->themed) {
            echo "<h1 class='install'>{$this->header}</h1>";
        }
        ?>
</h1>
<?php 
        if (is_writable('../../config.php')) {
            echo "<div class=\"alert alert-success\"><i>config.php</i> is writeable</div>";
        } else {
            echo "<div class=\"alert alert-danger\"><b>Error</b>: config.php is not writeable</div>";
        }
        ?>
<hr />
<div class="well"><em>
<?php 
        /* First, if this is a request to load a file, do that.
        */
        $db = new SQLManager($FANNIE_SERVER, $FANNIE_SERVER_DBMS, $FANNIE_OP_DB, $FANNIE_SERVER_USER, $FANNIE_SERVER_PW);
        if (isset($_REQUEST['employees'])) {
            echo "Loading employees";
            $db->query("TRUNCATE TABLE employees");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'employees');
        } elseif (isset($_REQUEST['custdata'])) {
            echo "Loading custdata";
            $backup1 = $db->query('TRUNCATE TABLE custdataBackup');
            $backup2 = $db->query('INSERT INTO custdataBackup SELECT * FROM custdata');
            if ($backup1 === false || $backup2 === false) {
                echo _(' - failed to backup current data. Sample data not loaded.');
            } else {
                $db->query("TRUNCATE TABLE custdata");
                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'custdata');
            }
        } elseif (isset($_REQUEST['memtype'])) {
            echo "Loading memtype";
            $db->query("TRUNCATE TABLE memtype");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'memtype');
        } elseif (isset($_REQUEST['products'])) {
            echo "Loading products";
            $backup1 = $db->query('TRUNCATE TABLE productBackup');
            $backup2 = $db->query('INSERT INTO productBackup SELECT * FROM products');
            if ($backup1 === false || $backup2 === false) {
                echo _(' - failed to backup current data. Sample data not loaded.');
            } else {
                $db->query("TRUNCATE TABLE products");
                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'products');
            }
        } elseif (isset($_REQUEST['prod-flags'])) {
            echo "Loading product flags";
            $db->query("TRUNCATE TABLE prodFlags");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'prodFlags');
        } elseif (isset($_REQUEST['batchType'])) {
            echo "Loading batchn types";
            $db->query("TRUNCATE TABLE batchType");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'batchType');
        } elseif (isset($_REQUEST['depts'])) {
            echo "Loading departments";
            $db->query("TRUNCATE TABLE departments");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'departments');
            /* subdepts sample data is of questionable use
               echo "<br />Loading subdepts";
               $db->query("TRUNCATE TABLE subdepts");
               \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db,'subdepts');
               */
        } elseif (isset($_REQUEST['superdepts'])) {
            echo "Loading super departments";
            $db->query("TRUNCATE TABLE superdepts");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'superdepts');
            $db->query("TRUNCATE TABLE superDeptNames");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'superDeptNames');
        } elseif (isset($_REQUEST['tenders'])) {
            echo "Loading tenders";
            $db->query("TRUNCATE TABLE tenders");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'tenders');
        } elseif (isset($_REQUEST['authentication'])) {
            echo "Loading authentication info";
            $db->query("TRUNCATE TABLE userKnownPrivs");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'userKnownPrivs');
        } elseif (isset($_REQUEST['origin'])) {
            echo "Loading country info";
            $db->query("TRUNCATE TABLE originCountry");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'originCountry');
            echo "<br />Loading state/province info";
            $db->query("TRUNCATE TABLE originStateProv");
            \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'originStateProv');
        } else {
            if (isset($_REQUEST['authGroups'])) {
                echo "Loading authentication groups";
                $db->query("TRUNCATE TABLE userGroups");
                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'userGroups');
                $db->query("TRUNCATE TABLE userGroupPrivs");
                \COREPOS\Fannie\API\data\DataLoad::loadSampleData($db, 'userGroupPrivs');
                // give "Administrators" group all permissions
                $db->query("INSERT userGroupPrivs SELECT \n            1, auth_class, 'all', 'all'\n            FROM userKnownPrivs");
            }
        }
        ?>
</em></div>

<?php 
        /* Display a list of data that can be loaded.
        */
        ?>
<p class="ichunk">
Some sample data is available to get a test lane
up and running quickly and to try Fannie functions.
<h3>Keep in mind this data overwrites whatever is currently in the table.</h3>
<br />These utilities populate the server tables.
Then use the <a href="../../sync/SyncIndexPage.php"
target="_sync"><u>Synchronize</u></a>
utilities to populate the lane tables.
</p>
<hr />
<h4 class="install"><?php 
        echo _('Cashiers');
        ?>
</h4>
    This table contains login information for cashiers. The two
    included logins are '56' and '7000'.<br />
    <?php 
        echo $this->loadButton('employees', 'employees', _('Load sample cashiers'));
        ?>
<hr />
<h4 class="install">Customer Data</h4>
    Customer data is the membership information. Sample data includes
    a bunch of members and default non-member 11.<br />
    <?php 
        echo $this->loadButton('custdata', 'custdata', _('Load sample customers'));
        ?>
    <br />
    <br />
    Customers are classified into different membership types.<br />
    <?php 
        echo $this->loadButton('memtype', 'memtype', _('Load sample member types'));
        ?>
<hr />
    <h4 class="install">Products</h4>
    Stuff to sell. There's a lot of sample data. I think this might
    be the Wedge's or at least a snapshot of it.<br />
    <?php 
        echo $this->loadButton('products', 'products', _('Load sample products'));
        ?>
<hr />
    <h4 class="install">Product Flags</h4>
    Product Flags are a flexible method for identifying custom attributes of items.
    CORE includes a default set of some more common flags.<br />
    <?php 
        echo $this->loadButton('prodFlags', 'prod-flags', _('Load sample product flags'));
        ?>
<hr />
    <h4 class="install">Batch Types</h4>
    Batches are used for temporary promotional pricing as well as scheduling changes
    in regular retail price. Batches may be organized by type. Sample data includes
    a couple common options.
    <?php 
        echo $this->loadButton('batchType', 'batchType', _('Load sample batch types'));
        ?>
<hr />
    <h4 class="install">Departments</h4>
    Products get categorized into departments .
    You can also ring amounts directly to a department. Not needed,
    strictly speaking, for a basic lane (Ring up items, total, 
    accept tender, provide change).<br />
    <?php 
        echo $this->loadButton('departments', 'depts', _('Load sample departments'));
        ?>
<hr />
    <h4 class="install">Super-Department Names <span style="font-weight:400;">and</span> Super-Department Links</h4>
    Super Departments are tags for grouping Departments.
    A Department can have more than one, that is, belong to more than one Super-Department.
    This rudimentary set agrees with the Products sample data.
    Super-Departments can also be used to group the domains of Buyers.
    Use them with e.g. the <a href="../../fannie/item/productList.php">Product List report/tool</a>
    They are also used for grouping shelftags for printing and for grouping data in reports.
    <?php 
        echo $this->loadButton('superdepts', 'superdepts', _('Load sample super departments'));
        ?>
<hr />
<h4 class="install">Tenders</h4>
    Load all the default tenders into the tenders table.<br />
    <?php 
        echo $this->loadButton('tenders', 'tenders', _('Load sample tenders'));
        ?>
<hr />
    <h4 class="install">Authentication</h4>
    Load information about currently defined authorization classes<br />
    <?php 
        echo $this->loadButton('userKnownPrivs', 'authentication', _('Load auth classes'));
        ?>
<br /><br />
    Load default groups<br />
    <?php 
        echo $this->loadButton('userGroups', 'authGroups', _('Load auth groups'));
        ?>
<hr />
    <h4 class="install">Countries, States, and Provinces</h4>
    Load default place-of-origin information<br />
    <?php 
        echo $this->loadButton('originCountry', 'origin', _('Load origin info'));
        ?>
<hr />

</form>

<?php 
        return ob_get_clean();
        // body_content
    }
示例#3
0
 public function testSampleData()
 {
     $op_db = FannieConfig::config('OP_DB');
     $con = FannieDB::get($op_db);
     $samples = array('batchType', 'custdata', 'departments', 'employees', 'memtype', 'originCountry', 'originStateProv', 'products', 'superdepts', 'superDeptNames', 'tenders');
     foreach ($samples as $sample) {
         $con->query('TRUNCATE TABLE ' . $con->identifierEscape($sample));
         ob_start();
         $loaded = \COREPOS\Fannie\API\data\DataLoad::loadSampleData($con, $sample);
         $output = ob_get_clean();
         $this->assertEquals(true, $loaded, 'Error loading ' . $sample . ' (' . $output . ')');
     }
 }