예제 #1
0
function getScore(array $data, array $props, array $amounts)
{
    if (getCals($data, $amounts) !== 500) {
        return 0;
    }
    $score = 1;
    foreach ($props as $prop) {
        $sub = 0;
        foreach ($data as $name => $ing) {
            $sub += $amounts[$name] * $ing[$prop];
        }
        if ($sub <= 0) {
            return 0;
        }
        $score *= $sub;
    }
    return $score;
}
예제 #2
0
$action = (!empty($_POST['action']) and !$back) ? $_POST['action'] : '';
//selected action
$start = !empty($_POST['start']) ? true : false;
//start action
$defCal = !empty($_POST['defCal']) ? $_POST['defCal'] : '';
//default calendar
$selCal = !empty($_POST['selCal']) ? $_POST['selCal'] : '';
//selected calendar
$ldapSet = array('ldapServer' => array(0, 'LDAP server (0:ldap disabled, 1:ldap enabled)'), 'ldapProto' => array(3, 'LDAP protocol version'), 'ldapEnv' => array('', 'LDAP environment settings'), 'ldapURI' => array('', 'LDAP server URI'), 'ldapPort' => array(636, 'LDAP port number'), 'ldapBindDN' => array('', 'LDAP Bind DN'), 'ldapDN' => array('', 'LDAP Base DN'), 'ldapFilter' => array('', 'LDAP Filter'), 'ldapUID' => array('', 'LDAP Attr. UID'), 'ldapRN' => array('', 'LDAP Attr. real name'), 'ldapRNpattern' => array('', 'LDAP Attr. real name extraction pattern'), 'ldapMail' => array('', 'LDAP Attr. mail'));
// default LDAP settings
$lf = !empty($_POST['lf']) ? $_POST['lf'] : array();
// possibly altered LDAP settings
//start PHP session (needed to be able to unset session variables later)
session_start();
//get installed calendars
$calIDs = getCals();
//get calendar ID/title pairs
//check/set default calendar
if (reset($calIDs)) {
    //calendar(s) present
    if (empty($dbDef) or !isset($calIDs[$dbDef])) {
        $dbDef = key($calIDs);
    }
    //if no default, make first calendar default
} else {
    $dbDef = '';
    //no calendar: no default
}
if (empty($defCal) and !empty($dbDef)) {
    $defCal = $dbDef;
}
예제 #3
0
     $dbHost = $dbUnam = $dbPwrd = $dbName = $adName = $adMail = $adPwMd5 = $adPwrd = $dbPfix = '';
     if (file_exists('./lcconfig.php')) {
         include './lcconfig.php';
         //get database credentials
         $dbLink = mysql_connect($dbHost, $dbUnam, $dbPwrd);
         //connect to db server
         if ($dbLink !== false) {
             $selected = mysql_select_db($dbName, $dbLink);
         }
     }
 }
 //initialize
 $calendars = array(0 => "None.");
 if ($selected) {
     //get installed calendars
     $calendars = getCals($dbPfix);
     //get admin user data
     $result = mysql_query("SELECT user_name, email, password FROM {$dbPfix}_users WHERE user_id = 2");
     if ($result !== false and mysql_num_rows($result) >= 1) {
         $row = mysql_fetch_assoc($result);
         $adName = stripslashes($row['user_name']);
         $adMail = stripslashes($row['email']);
         $adPwMd5 = stripslashes($row['password']);
         if ($adPwMd5) {
             $adPwrd = '********';
         }
         mysql_close($dbLink);
     }
 }
 //display header
 echo $instructions;