예제 #1
0
function AJnewRequest()
{
    global $user, $remoteIP;
    $data = processRequestInput();
    #$data['err'] = 1;
    #$data['errmsg'] = 'none';
    if ($data['err']) {
        sendJSON($data);
        return;
    }
    if ($data['start'] == 0) {
        $nowfuture = 'now';
        $startts = unixFloor15();
        if ($data['ending'] == 'duration') {
            $endts = $startts + $data['duration'] * 60;
            $nowArr = getdate();
            if ($nowArr['minutes'] % 15 != 0) {
                $endts += 900;
            }
        }
    } else {
        $nowfuture = 'future';
        $startts = $data['start'];
        if ($data['ending'] == 'duration') {
            $endts = $startts + $data['duration'] * 60;
        }
    }
    if ($data['ending'] == 'indefinite') {
        $endts = datetimeToUnix('2038-01-01 00:00:00');
    } elseif ($data['ending'] == 'endat') {
        $endts = $data['end'];
    }
    $images = getImages();
    # TODO initially, this is a hack where we munge the datastructure
    # finishconfigs
    /*if($data['type'] == 'server') {
    		$tmp = getConfigClusters($data['imageid'], 1);
    		if(count($tmp)) {
    			$subimages = array();
    			foreach($tmp as $cluster) {
    				for($i = 0; $i < $cluster['maxinstance']; $i++)
    					$subimages[] = $cluster['childimageid'];
    			}
    			$images[$data['imageid']]['subimages'] = $subimages;
    			if($images[$data['imageid']]['imagemetaid'] == NULL)
    				$images[$data['imageid']]['imagemetaid'] = 1;
    		}
    		elseif($images[$data['imageid']]['imagemetaid'] != NULL &&
    			count($images[$data['imageid']]['subimages'])) {
    			$images[$data['imageid']]['subimages'] = array();
    		}
    	}*/
    # check for exceeding max overlaps
    $max = getMaxOverlap($user['id']);
    if (checkOverlap($startts, $endts, $max)) {
        print "dojo.byId('deployerr').innerHTML = '";
        print i("The selected time overlaps with another reservation you have.");
        print "<br>";
        if ($max == 0) {
            print i("You cannot have any overlapping reservations.");
        } else {
            printf(i("You can have up to %d overlapping reservations."), $max);
        }
        print "'; dojo.removeClass('deployerr', 'hidden');";
        return;
    }
    $imaging = 0;
    if ($data['type'] == 'imaging') {
        $imaging = 1;
    }
    $availablerc = isAvailable($images, $data['imageid'], $data['revisionids'], $startts, $endts, 1, 0, 0, 0, $imaging, $data['ipaddr'], $data['macaddr']);
    if ($availablerc == -4) {
        $msg = i("The IP address you specified is assigned to another VCL node and cannot be used at this time. Submitting a time in the future may allow you to make the reservation, but if the IP remains assigned to the other node, the reservation will fail at deploy time.");
        $data = array('err' => 1, 'errmsg' => $msg);
        sendJSON($data);
        return;
    } elseif ($availablerc == -3) {
        $msg = i("The IP or MAC address you specified overlaps with another reservation using the same IP or MAC address you specified. Please use a different IP or MAC or select a different time to deploy the server.");
        $data = array('err' => 1, 'errmsg' => $msg);
        sendJSON($data);
        return;
    } elseif ($availablerc == -2) {
        $msg = i("The time you requested overlaps with a maintenance window.");
        $data = array('err' => 1, 'errmsg' => $msg);
        sendJSON($data);
        return;
    } elseif ($availablerc == -1) {
        cleanSemaphore();
        $msg = i("You have requested an environment that is limited in the number of concurrent reservations that can be made. No further reservations for the environment can be made for the time you have selected.");
        $data = array('err' => 1, 'errmsg' => $msg);
        sendJSON($data);
        return;
    } elseif ($availablerc == 0) {
        cleanSemaphore();
        $data = array('err' => 2);
        sendJSON($data);
        return;
    }
    $requestid = addRequest($imaging, $data['revisionids'], 1 - $data['nousercheck']);
    if ($data['type'] == 'server') {
        if ($data['ipaddr'] != '') {
            # save additional network info in variable table
            $allnets = getVariable('fixedIPavailnetworks', array());
            $key = long2ip($data['network']) . "/{$data['netmask']}";
            $allnets[$key] = array('router' => $data['router'], 'dns' => $data['dnsArr']);
            setVariable('fixedIPavailnetworks', $allnets, 'yaml');
        }
        $query = "UPDATE reservation " . "SET remoteIP = '{$remoteIP}' " . "WHERE requestid = {$requestid}";
        doQuery($query);
        $fields = array('requestid', 'serverprofileid');
        $values = array($requestid, $data['profileid']);
        if ($data['name'] == '') {
            $fields[] = 'name';
            $name = $images[$data['imageid']]['prettyname'];
            $values[] = "'{$name}'";
        } else {
            $fields[] = 'name';
            $name = mysql_real_escape_string($data['name']);
            $values[] = "'{$name}'";
        }
        if ($data['ipaddr'] != '') {
            $fields[] = 'fixedIP';
            $values[] = "'{$data['ipaddr']}'";
        }
        if ($data['macaddr'] != '') {
            $fields[] = 'fixedMAC';
            $values[] = "'{$data['macaddr']}'";
        }
        if ($data['admingroupid'] != 0) {
            $fields[] = 'admingroupid';
            $values[] = $data['admingroupid'];
        }
        if ($data['logingroupid'] != 0) {
            $fields[] = 'logingroupid';
            $values[] = $data['logingroupid'];
        }
        if ($data['monitored'] != 0) {
            $fields[] = 'monitored';
            $values[] = 1;
        }
        $allfields = implode(',', $fields);
        $allvalues = implode(',', $values);
        $query = "INSERT INTO serverrequest ({$allfields}) VALUES ({$allvalues})";
        doQuery($query, 101);
        if ($data['ipaddr'] != '') {
            $srqid = dbLastInsertID();
            $var = array('netmask' => $data['netmask'], 'router' => $data['router'], 'dns' => $data['dnsArr']);
            setVariable("fixedIPsr{$srqid}", $var, 'yaml');
        }
        # TODO configs
        //saveRequestConfigs($requestid, $data['imageid'], $data['configs'], $data['configvars']);
    }
    $data = array('err' => 0);
    sendJSON($data);
}
예제 #2
0
    $key_id = $_POST['key_id'];
} else {
    $key_id = "";
}
//this retrieves the form GET info and builds the sql query to input data
$queryString = setVariable('title', $queryString);
$queryString = setVariable('shortdesc', $queryString);
$queryString = setVariable('address', $queryString);
$queryString = setVariable('city', $queryString);
$queryString = setVariable('state', $queryString);
$queryString = setVariable('zip', $queryString);
$queryString = setVariable('phone', $queryString);
$queryString = setVariable('director_fname', $queryString);
$queryString = setVariable('director_lname', $queryString);
$queryString = setVariable('additional_directors', $queryString);
$queryString = setVariable('additional_producers', $queryString);
$queryString = setVariable('synopsis', $queryString);
$queryString = setVariable('title', $queryString);
$queryString = setVariable('applicant_fname', $queryString);
$queryString = setVariable('applicant_lname', $queryString);
//eliminate the comma at the start of the string
$newString = substr($queryString, 1);
//the entire sql query
$query = "update billyx_portal.filmfund set " . $newString . " where key_id='" . $key_id . "'";
$result = mysql_query($query);
if (!$result) {
    die("Database access failed: " . mysql_error());
}
mysql_close($db_server);
//redirect to the next page
header("Location: nwfilmfundapp2.php");
예제 #3
0
    $key_id = $_POST['key_id'];
} else {
    $key_id = "";
}
//this retrieves the form GET info and builds the sql query to input data
$queryString = setVariable('worksamp_1_title', $queryString);
$queryString = setVariable('worksamp_1_trt', $queryString);
$queryString = setVariable('worksamp_1_desc', $queryString);
$queryString = setVariable('worksamp_1_link', $queryString);
$queryString = setVariable('worksamp_1_dvd', $queryString);
$queryString = setVariable('worksamp_2_title', $queryString);
$queryString = setVariable('worksamp_2_trt', $queryString);
$queryString = setVariable('worksamp_2_desc', $queryString);
$queryString = setVariable('worksamp_2_link', $queryString);
$queryString = setVariable('worksamp_2_dvd', $queryString);
$queryString = setVariable('worksamp_3_title', $queryString);
$queryString = setVariable('worksamp_3_trt', $queryString);
$queryString = setVariable('worksamp_3_desc', $queryString);
$queryString = setVariable('worksamp_3_link', $queryString);
$queryString = setVariable('worksamp_3_dvd', $queryString);
//eliminate the comma at the start of the string
$newString = substr($queryString, 1);
//the entire sql query
$query = "update billyx_portal.filmfund set " . $newString . " where key_id='" . $key_id . "'";
$result = mysql_query($query);
if (!$result) {
    die("Database access failed: " . mysql_error());
}
mysql_close($db_server);
//redirect to the next page
header("Location: nwfilmfundapp5.php");
예제 #4
0
require_once 'databaselogin.php';
//very important to have the database connection happen before the use of mysql_real_escape fundtion
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) {
    die("Unable to connecto to MySQL: " . mysql_error());
}
mysql_select_db($db_database) or die("Unable to select database; " . mysql_error());
require_once 'submit_template.php';
$queryString = "";
if (isset($_POST['key_id'])) {
    $key_id = $_POST['key_id'];
} else {
    $key_id = "";
}
//this retrieves the form GET info and builds the sql query to input data
$queryString = setVariable('funding_plan', $queryString);
$queryString = setVariable('budget', $queryString);
$queryString = setVariable('funds_secured', $queryString);
$queryString = setVariable('distribution', $queryString);
//eliminate the comma at the start of the string
$newString = substr($queryString, 1);
//the entire sql query
$query = "update billyx_portal.filmfund set " . $newString . " where key_id='" . $key_id . "'";
$result = mysql_query($query);
if (!$result) {
    die("Database access failed: " . mysql_error());
}
mysql_close($db_server);
//redirect to the next page
header("Location: nwfilmfundapp4.php?key_id={$key_id}");
function handleShutdown()
{
    global $currentPage;
    $error = error_get_last();
    if ($error !== NULL) {
        setVariable("currentPage", $currentPage + 1);
    }
}
예제 #6
0
 function AJupdateAllSettings()
 {
     if (!checkUserHasPerm('Site Configuration (global)')) {
         $arr = array('status' => 'noaccess', 'msg' => i('You do not have access to modify the submitted settings.'));
         sendJSON($arr);
         return;
     }
     switch ($this->type) {
         case 'numeric':
             $newval = processInputVar('newval', ARG_NUMERIC);
             if ($newval < $this->minval || $newval > $this->maxval) {
                 $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("Invalid value submitted"));
                 sendJSON($arr);
                 return;
             }
             break;
         case 'boolean':
             $newval = processInputVar('newval', ARG_NUMERIC);
             if ($newval !== '0' && $newval !== '1') {
                 $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("Invalid value submitted"));
                 sendJSON($arr);
                 return;
             }
             break;
         case 'text':
             # TODO
             $newval = processInputVar('newval', ARG_STRING);
             $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("unsupported type"));
             sendJSON($arr);
             return;
         case 'textarea':
             $newval = processInputVar('newval', ARG_STRING);
             if (!$this->validateValue($newval)) {
                 $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("Invalid value submitted"));
                 if (isset($this->invalidvaluemsg)) {
                     $arr['errmsg'] = $this->invalidvaluemsg;
                 }
                 sendJSON($arr);
                 return;
             }
             break;
         default:
             $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("Invalid value submitted"));
             sendJSON($arr);
             return;
     }
     setVariable($this->key, $newval, 'none');
     $arr = array('status' => 'success', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'msg' => $this->updatemsg);
     sendJSON($arr);
 }
예제 #7
0
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) {
    die("Unable to connecto to MySQL: " . mysql_error());
}
mysql_select_db($db_database) or die("Unable to select database; " . mysql_error());
require_once 'submit_template.php';
$queryString = "";
if (isset($_POST['key_id'])) {
    $key_id = $_POST['key_id'];
} else {
    $key_id = "";
}
//this retrieves the form GET info and builds the sql query to input data
$queryString = setVariable('prod_desc', $queryString);
$queryString = setVariable('timeline', $queryString);
$queryString = setVariable('artist_statement', $queryString);
$queryString = setVariable('bio_1', $queryString);
$queryString = setVariable('bio_2', $queryString);
$queryString = setVariable('bio_3', $queryString);
$queryString = setVariable('bio_4', $queryString);
//eliminate the comma at the start of the string
$newString = substr($queryString, 1);
//the entire sql query
$query = "update billyx_portal.filmfund set " . $newString . " where key_id='" . $key_id . "'";
$result = mysql_query($query);
if (!$result) {
    die("Database access failed: " . mysql_error());
}
mysql_close($db_server);
//redirect to the next page
header("Location: nwfilmfundapp3.php");
예제 #8
0
setVariable($channel, "AUDIOHOOK_INHERIT(MixMonitor)", "yes");
setVariable($bridgePeer, "AUDIOHOOK_INHERIT(MixMonitor)", "yes");
$astman->mixmonitor($masterChannel, "{$mixMonDir}{$year}/{$month}/{$day}/{$callFileName}.{$mixMonFormat}", "ai(LOCAL_MIXMON_ID)", $mixMonPost, rand());
$mixmonid = getVariable($channel, "LOCAL_MIXMON_ID");
setVariable($channel, "__MIXMON_ID", $mixmonid);
$channame = getVariable($channel, "CHANNEL(name)");
setVariable($channel, "__RECORD_ID", $channame);
//Set the monitor format and file name for the cdr entry
ot_debug("Setting CDR info");
$monFmt = $mixMonFormat != "" ? $mixMonFormat : "wav";
setVariable($channel, "MON_FMT", $monFmt);
setVariable($bridgePeer, "CDR(recordingfile)", "{$callFileName}.{$monFmt}");
setVariable($channel, "CDR(recordingfile)", "{$callFileName}.{$monFmt}");
setVariable($bridgePeer, "CALLFILENAME", "{$callFileName}");
setVariable($channel, "CALLFILENAME", "{$callFileName}");
setVariable($channel, "ONETOUCH_REC_SCRIPT_STATUS", "RECORDING_STARTED");
//Get variable function
function getVariable($channel, $varName)
{
    global $astman;
    $results = $astman->GetVar($channel, $varName, rand());
    if ($results["Response"] != "Success") {
        return '';
    }
    return $results["Value"];
}
function ot_debug($string)
{
    global $ot_debug;
    if ($ot_debug) {
        dbug($string);
<?php

require_once 'databaselogin.php';
//very important to have the database connection happen before the use of mysql_real_escape fundtion
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) {
    die("Unable to connecto to MySQL: " . mysql_error());
}
mysql_select_db($db_database) or die("Unable to select database; " . mysql_error());
require_once 'submit_template.php';
$queryString = "";
if (isset($_POST['key_id'])) {
    $key_id = $_POST['key_id'];
} else {
    $key_id = "";
}
//this retrieves the form GET info and builds the sql query to input data
$queryString = setVariable('funding_plan', $queryString);
$queryString = setVariable('budget', $queryString);
//eliminate the comma at the start of the string
$newString = substr($queryString, 1);
//the entire sql query
$query = "update billyx_portal.fiscal set " . $newString . " where key_id='" . $key_id . "'";
$result = mysql_query($query);
if (!$result) {
    die("Database access failed: " . mysql_error());
}
mysql_close($db_server);
//redirect to the next page
header("Location: fiscalsponsorshipapp4.php?key_id={$key_id}");
예제 #10
0
function AJsaveServerProfile()
{
    global $user;
    $data = processProfileInput();
    if (array_key_exists('error', $data)) {
        sendJSON($data);
        return;
    }
    $name = mysql_real_escape_string($data['name']);
    $desc = mysql_real_escape_string($data['desc']);
    $fixedIP = mysql_real_escape_string($data['fixedIP']);
    $fixedMAC = mysql_real_escape_string($data['fixedMAC']);
    $ret = array();
    if ($data['profileid'] == 70000) {
        $query = "INSERT INTO serverprofile " . "(name, " . "description, " . "imageid, " . "ownerid, " . "fixedIP, " . "fixedMAC, " . "admingroupid, " . "logingroupid, " . "monitored) " . "VALUES " . "('{$name}', " . "'{$desc}', " . "{$data['imageid']}, " . "{$user['id']}, " . "'{$fixedIP}', " . "'{$fixedMAC}', " . "{$data['admingroupid']}, " . "{$data['logingroupid']}, " . "{$data['monitored']})";
        doQuery($query, 101);
        $id = dbLastInsertID();
        $query = "INSERT INTO resource " . "(resourcetypeid, " . "subid) " . "VALUES " . "(17, " . "{$id})";
        doQuery($query, 101);
        $ret['success'] = 1;
        $ret['name'] = $data['name'];
        $ret['id'] = $id;
        $ret['newprofile'] = 1;
        if ($fixedIP != '') {
            $vdata = array('netmask' => $data['netmask'], 'router' => $data['router'], 'dns' => $data['dnsArr']);
            setVariable("fixedIPsp{$id}", $vdata, 'yaml');
        }
    } else {
        $query = "UPDATE serverprofile SET " . "name = '{$name}', " . "description = '{$desc}', " . "imageid = {$data['imageid']}, " . "fixedIP = '{$fixedIP}', " . "fixedMAC = '{$fixedMAC}', " . "admingroupid = {$data['admingroupid']}, " . "logingroupid = {$data['logingroupid']}, " . "monitored = {$data['monitored']} " . "WHERE id = {$data['profileid']}";
        doQuery($query, 101);
        $ret['success'] = 1;
        $ret['name'] = $data['name'];
        $ret['id'] = $data['profileid'];
        $ret['newprofile'] = 0;
    }
    if ($data['fixedIP'] != '') {
        $vdata = array('netmask' => $data['netmask'], 'router' => $data['router'], 'dns' => $data['dnsArr']);
        setVariable("fixedIPsp{$ret['id']}", $vdata, 'yaml');
        $ret['netmask'] = $data['netmask'];
        $ret['router'] = $data['router'];
        $ret['dns'] = $data['dns'];
        $allnets = getVariable('fixedIPavailnetworks', array());
        $network = ip2long($data['fixedIP']) & ip2long($data['netmask']);
        $key = long2ip($network) . "/{$data['netmask']}";
        $allnets[$key] = array('router' => $data['router'], 'dns' => $data['dnsArr']);
        setVariable('fixedIPavailnetworks', $allnets, 'yaml');
    }
    $ret['access'] = 'admin';
    $ret['desc'] = preg_replace("/\n/", "<br>", $data['desc']);
    $_SESSION['usersessiondata'] = array();
    $_SESSION['userresources'] = array();
    sendJSON($ret);
}
예제 #11
0
 function addResource($data)
 {
     global $user;
     $ownerid = getUserlistID($data['owner']);
     $esc = array('sysadminemail' => mysql_real_escape_string($data['sysadminemail']), 'sharedmailbox' => mysql_real_escape_string($data['sharedmailbox']));
     $keys = array('IPaddress', 'hostname', 'ownerid', 'stateid', 'checkininterval', 'installpath', '`keys`', 'sshport', 'sysadminEmailAddress', 'sharedMailBox', 'availablenetworks', 'NOT_STANDALONE', 'imagelibenable', 'publicIPconfiguration', 'imagelibgroupid', 'imagelibuser', 'imagelibkey', 'publicSubnetMask', 'publicDefaultGateway', 'publicDNSserver');
     $values = array("'{$data['ipaddress']}'", "'{$data['name']}'", $ownerid, $data['stateid'], $data['checkininterval'], "'{$data['installpath']}'", "'{$data['keys']}'", $data['sshport'], "'{$esc['sysadminemail']}'", "'{$esc['sharedmailbox']}'", "'{$data['availablenetworks']}'", "'{$data['federatedauth']}'", $data['imagelibenable'], "'{$data['publicIPconfig']}'");
     if ($data['imagelibenable'] == 1) {
         $values[] = $data['imagelibgroupid'];
         $values[] = "'{$data['imagelibuser']}'";
         $values[] = "'{$data['imagelibkey']}'";
     } else {
         $values[] = 'NULL';
         $values[] = 'NULL';
         $values[] = 'NULL';
     }
     if ($data['publicIPconfig'] == 'static') {
         $values[] = "'{$data['publicnetmask']}'";
         $values[] = "'{$data['publicgateway']}'";
         $values[] = "'{$data['publicdnsserver']}'";
     } else {
         $values[] = 'NULL';
         $values[] = 'NULL';
         $values[] = 'NULL';
     }
     $query = "INSERT INTO managementnode (" . implode(', ', $keys) . ") VALUES (" . implode(', ', $values) . ")";
     doQuery($query);
     $rscid = dbLastInsertID();
     // add entry in resource table
     $query = "INSERT INTO resource " . "(resourcetypeid, " . "subid) " . "VALUES (16, " . "{$rscid})";
     doQuery($query);
     $resourceid = dbLastInsertID();
     # NAT host
     if ($data['nathostenabled']) {
         $query = "INSERT INTO nathost " . "(resourceid, " . "publicIPaddress, " . "internalIPaddress) " . "VALUES " . "({$resourceid}, " . "'{$data['natpublicIPaddress']}', " . "'{$data['natinternalIPaddress']}')";
         doQuery($query);
     }
     # time server
     $globalval = getVariable('timesource|global');
     if ($data['timeservers'] != $globalval) {
         setVariable("timesource|{$data['name']}", $data['timeservers'], 'none');
     }
     return $rscid;
 }
예제 #12
0
// name of zip (gzip) file
$backupdate = date("Ymd");
// backup to gzip fuinction
$backupdir = $strPath;
$files = "*";
$backupto = $strPath;
$fileprefix = "";
$tararg = "-cf";
createForlder($strPath);
// only get properties that have been updated in the past 10 days
$today = strtotime($date_mysql);
$ten_days = 5 * 24 * 60 * 60;
$date_comparison = date('Y-m-d H:i:s', $today - $ten_days);
$imagesql = "SELECT max(photos) AS photos FROM (SELECT\n\n\tcount(DISTINCT(photos.med_file)) AS photos\n\nFROM deal\n\nLEFT JOIN property ON deal.dea_prop = property.pro_id\nLEFT JOIN area ON property.pro_area = area.are_id\nLEFT JOIN branch ON deal.dea_branch = branch.bra_id\n\nLEFT JOIN ptype AS T ON deal.dea_ptype = T.pty_id\nLEFT JOIN ptype AS ST ON deal.dea_psubtype = ST.pty_id\n\nLEFT JOIN media AS photos ON deal.dea_id = photos.med_row AND photos.med_table = 'deal' AND photos.med_type = 'Photograph'\nLEFT JOIN media AS floorplans ON deal.dea_id = floorplans.med_row AND floorplans.med_table = 'deal' AND floorplans.med_type = 'Floorplan'\nLEFT JOIN media AS epc ON deal.dea_id = epc.med_row AND epc.med_table = 'deal' AND epc.med_type = 'EPC'\n\nLEFT JOIN link_instruction_to_feature ON dealId = deal.dea_id\nLEFT JOIN feature ON featureId = feature.fea_id\n\nWHERE\n(deal.dea_status = 'Available' OR deal.dea_status = 'Under Offer' OR deal.dea_status = 'Under Offer with Other')\nAND (deal.noPortalFeed <> 1 AND deal.underTheRadar <> 1)\nGROUP BY dea_id) AS t1";
//SET the value of group_concat_max_len
setVariable(99999);
$qimage = $db->query($imagesql);
if (DB::isError($qimage)) {
    die("error: " . $qimage->getMessage());
}
while ($rowimage = $qimage->fetchRow()) {
    $max_images = $rowimage["photos"];
}
if ($max_images > 59) {
    $max_images = 59;
}
$floorplansql = "SELECT max(floorplans) AS floorplans FROM (SELECT\n\n\tcount(DISTINCT(floorplans.med_file)) AS floorplans\n\nFROM deal\n\nLEFT JOIN property ON deal.dea_prop = property.pro_id\nLEFT JOIN area ON property.pro_area = area.are_id\nLEFT JOIN branch ON deal.dea_branch = branch.bra_id\n\nLEFT JOIN ptype AS T ON deal.dea_ptype = T.pty_id\nLEFT JOIN ptype AS ST ON deal.dea_psubtype = ST.pty_id\n\nLEFT JOIN media AS photos ON deal.dea_id = photos.med_row AND photos.med_table = 'deal' AND photos.med_type = 'Photograph'\nLEFT JOIN media AS floorplans ON deal.dea_id = floorplans.med_row AND floorplans.med_table = 'deal' AND floorplans.med_type = 'Floorplan'\nLEFT JOIN media AS epc ON deal.dea_id = epc.med_row AND epc.med_table = 'deal' AND epc.med_type = 'EPC'\n\nLEFT JOIN link_instruction_to_feature ON dealId = deal.dea_id\nLEFT JOIN feature ON featureId = feature.fea_id\n\nWHERE\n(deal.dea_status = 'Available' OR deal.dea_status = 'Under Offer' OR deal.dea_status = 'Under Offer with Other')\nAND (deal.noPortalFeed <> 1 AND deal.underTheRadar <> 1)\nGROUP BY dea_id) AS t1";
$qfloorplan = $db->query($floorplansql);
if (DB::isError($qfloorplan)) {
    die("error: " . $qfloorplan->getMessage());
}