$insertsqlarr = $sqlarr;
        inserttable('attachmenttypes', $insertsqlarr);
        showmessage('attachmenttype_add_success', $newurl);
    } else {
        //UPDATE
        $setsqlarr = $sqlarr;
        updatetable('attachmenttypes', $setsqlarr, array('id' => $_POST['id']));
        showmessage('attachmenttype_update_success', $newurl);
    }
}
//GET METHOD
$addclass = $viewclass = '';
if (empty($_GET['op'])) {
    //LIST VIEW
    $wheresqlarr = array();
    $wheresqlstr = getwheresql($wheresqlarr);
    $query = $_SGLOBAL['db']->query('SELECT COUNT(*) FROM ' . tname('attachmenttypes') . ' WHERE ' . $wheresqlstr);
    $listcount = $_SGLOBAL['db']->result($query, 0);
    $multipage = '';
    if ($listcount) {
        $plussql = 'LIMIT ' . $start . ',' . $perpage;
        $listarr = selecttable('attachmenttypes', array(), $wheresqlarr, $plussql);
        $multipage = multi($listcount, $perpage, $page, $theurl);
    }
    $viewclass = ' class="active"';
} elseif ($_GET['op'] == 'edit') {
    //ONE VIEW FOR UPDATE
    $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('attachmenttypes') . ' WHERE id=\'' . $_GET['id'] . '\'');
    if ($thevalue = $_SGLOBAL['db']->fetch_array($query)) {
        $thevalue['maxsize'] = $thevalue['maxsize'] / 1024;
    }
Example #2
0
function getmodelsearchsql($chararr, $intarr, $likearr, $betweenarr)
{
    $resultstr = '';
    $resultarr = array();
    if (!empty($intarr)) {
        $resultarr[] = getwheresql($intarr);
    }
    if (!empty($betweenarr)) {
        foreach ($betweenarr as $tmpkey => $tmpvalue) {
            if (is_array($tmpvalue)) {
                $value = array();
                $tmpvalue[0] = trim($tmpvalue[0]);
                $tmpvalue[1] = trim($tmpvalue[1]);
                if (strlen($tmpvalue[0]) > 0) {
                    $value[] = $tmpkey . ' >= \'' . $tmpvalue[0] . '\'';
                }
                if (strlen($tmpvalue[1]) > 0) {
                    $value[] = $tmpkey . ' <= \'' . $tmpvalue[1] . '\'';
                }
                if (!empty($value)) {
                    $resultarr[] = implode(' AND ', $value);
                }
            }
        }
    }
    if (!empty($chararr)) {
        $resultarr[] = getwheresql($chararr);
    }
    if (!empty($likearr)) {
        foreach ($likearr as $tmpkey => $tmpvalue) {
            if (is_array($tmpvalue)) {
                foreach ($tmpvalue as $value) {
                    $value = trim($value);
                    if (strlen($value) > 0) {
                        $resultarr[] = $tmpkey . ' like \'%' . $value . '%\'';
                    }
                }
            } else {
                $resultarr[] = $tmpkey . ' like \'%' . $tmpvalue . '%\'';
            }
        }
    }
    $resultstr = implode(' AND ', $resultarr);
    if (empty($resultstr)) {
        $resultstr = '1';
    }
    return $resultstr;
}
Example #3
0
function getmodelsearchsql($chararr, $intarr, $likearr, $betweenarr)
{
    $resultstr = '';
    $resultarr = array();
    if (!empty($intarr)) {
        $resultarr[] = getwheresql($intarr);
    }
    if (!empty($betweenarr)) {
        foreach ($betweenarr as $tmpkey => $tmpvalue) {
            if (is_array($tmpvalue)) {
                $value = array();
                $tmpvalue[0] = trim($tmpvalue[0]);
                $tmpvalue[1] = trim($tmpvalue[1]);
                if (strlen($tmpvalue[0]) > 0) {
                    $value[] = $tmpkey . ' >= \'' . $tmpvalue[0] . '\'';
                }
                if (strlen($tmpvalue[1]) > 0) {
                    $value[] = $tmpkey . ' <= \'' . $tmpvalue[1] . '\'';
                }
                if (!empty($value)) {
                    $resultarr[] = implode(' AND ', $value);
                }
            }
        }
    }
    if (!empty($chararr)) {
        $resultarr[] = getwheresql($chararr);
    }
    if (!empty($likearr)) {
        foreach ($likearr as $tmpkey => $tmpvalue) {
            if (strpos($tmpkey, '@') !== FALSE) {
                $keyarr = explode('@', $tmpkey);
                $tmpvalue = trim($tmpvalue);
                $tmpvaluearr = preg_split("/[\\s]+/", $tmpvalue, -1, PREG_SPLIT_NO_EMPTY);
                foreach ($tmpvaluearr as $valuearr) {
                    $orstring = '';
                    $orpre = '';
                    $valuearr = trim($valuearr);
                    if (strlen($valuearr) > 0) {
                        foreach ($keyarr as $keyval) {
                            $orstring .= $orpre . $keyval . ' like \'%' . $valuearr . '%\'';
                            $orpre = ' OR ';
                        }
                        $resultarr[] = ' (' . $orstring . ') ';
                    }
                }
            } else {
                if (is_array($tmpvalue)) {
                    foreach ($tmpvalue as $value) {
                        $value = trim($value);
                        if (strlen($value) > 0) {
                            $resultarr[] = $tmpkey . ' like \'%' . $value . '%\'';
                        }
                    }
                } else {
                    $resultarr[] = $tmpkey . ' like \'%' . $tmpvalue . '%\'';
                }
            }
        }
    }
    $resultstr = implode(' AND ', $resultarr);
    if (empty($resultstr)) {
        $resultstr = '1';
    }
    return $resultstr;
}
Example #4
0
function updatetable($tablename, $setsqlarr, $wheresqlarr)
{
    global $_SGLOBAL;
    $setsql = $comma = '';
    foreach ($setsqlarr as $set_key => $set_value) {
        $setsql .= $comma . $set_key . '=\'' . $set_value . '\'';
        $comma = ', ';
    }
    $_SGLOBAL['db']->query('UPDATE ' . tname($tablename) . ' SET ' . $setsql . ' WHERE ' . getwheresql($wheresqlarr));
}