name : getdata.func.php
<?

if (!defined('SITE'))
    exit('Access Denied');

function getDBpagecenter() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 1", null);
    $arr = splitformatToarrayData($result[0]['data'], false);
    foreach ($arr as $val) {
        $returndata .= '<img src="timthumb.php?src=' . $val . '&w=1230&h=540" alt="pic-' . $val . '" />';
    }
    return $returndata;
}

function getDBcompany() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 2", null);
    $arr = splitformatToarrayData($result[0]['data']);
    if ($base['cookie']['lang'] == "th") {
        return stripcslashes($arr[1]);
    } else {
        return stripcslashes($arr[2]);
    }
}

function getDBcompanyImages() {
    global $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 2", null);
    $arr = splitformatToarrayData($result[0]['data']);
    return '<div style="text-align:right;"><img src="timthumb.php?src=' . $arr[0] . '&w=807&h=540" alt="pic company" /></div>';
}

function getDBteam() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 4", null);
    $arr = splitformatToarrayData($result[0]['data'], true);
    $count = 0;
    $fixPosition = array('75', '435', '795');
    for ($i = 0; $i < count($arr); $i++) {
        $returndata .= '<div style="position: absolute;left: ' . $fixPosition[$i] . 'px;top:0px;width:360px;height:540px;background-color: #FFF;"><img src="timthumb.php?src=' . $arr[$i] . '&w=360&h=540" alt="team"/></div>';
    }
    return $returndata;
}

function getDBawards($col = 2) {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 5", null);
    $arrlang = explode("--th-en--", $result[0]['data']);
    if ($base['cookie']['lang'] == "th") {
        $arr = splitformatToarrayData($arrlang[0]);
    } else {
        $arr = splitformatToarrayData($arrlang[1]);
    }
    $count = 0;
    for ($i = 0; $i < 15; $i++) {//synchronize with fixaward[admin]
        $left = ($count+=1);
        $right = ($count+=1);
        if ($arr[$left] != "" && $arr[$right] != "") {
            $data .= '<div style="float:left;">' . $arr[$left] . '</div><div style="float:right;">' . $arr[$right] . '</div><hr style="clear:both;"/>';
        }
    }
    $data .= '<br/><br/>';
    for ($i = 0; $i < 5; $i++) {//synchronize with fixaward[admin]
        $left = ($count+=1);
        $right = ($count+=1);
        if ($arr[$left] != "") {
            $data .= '<p>' . $arr[$left] . '</p><hr style="clear:both;"/>';
        }
    }
    return '<div>' . $data . '</div>';
}

function getDBawardsImages() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 5", null);
    $arr = splitformatToarrayData($result[0]['data']);
    return '<div style="text-align:right;"><img src="timthumb.php?src=' . stripcslashes($arr[0]) . '&w=410&h=540" alt="Awards Image"/></div>';
}

function getClient() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 6", null);
    $arr = splitformatToarrayData($result[0]['data'], false);
    foreach ($arr as $val) {
        $returndata .= '<img src="timthumb.php?src=' . $val . '&w=1230&h=540" width="1230" height="540" alt="pic-' . $val . '" />';
    }
    return $returndata;
}

function getLocation() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 7", null);
    $arr = splitformatToarrayData($result[0]['data']);
    if ($base['cookie']['lang'] == "th") {
        return '' . stripcslashes($arr[1]) . '';
    } else {
        return '' . stripcslashes($arr[2]) . '';
    }
}

function getLocationImage() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 7", null);
    $arr = splitformatToarrayData($result[0]['data']);
    return '<img src="timthumb.php?src=' . stripcslashes($arr[0]) . '&w=807&h=540" alt="My location"/>';
}

function getJoinus() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 8", null);
    $arr = splitformatToarrayData($result[0]['data']);
    if ($base['cookie']['lang'] == "th") {
        return '' . stripcslashes($arr[1]) . '';
    } else {
        return '' . stripcslashes($arr[2]) . '';
    }
}

function getJoinusJob() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 8", null);
    $arr = splitformatToarrayData($result[0]['data'], true);
    if (stripcslashes($arr[0]) != "") {
        $data .= '<div class="menu_list" id="firstpane">';
//        return '<img src="timthumb.php?src=' . stripcslashes($arr[0]) . '&w=410&h=540" alt="join us image"/>';
//        $row = nl2br();
        //  $rowArr = split("\r\n", );
        $strArr = explode("\n", stripcslashes($arr[0]));
        $count = 0;
        foreach ($strArr as $value) {
            if (strpos($value, '++++') === 0) {
                if ($count == 1) {
                    $count = 0;
                    $data .='</div>';
                }
                $data .= '<p class="menu_head">' . str_replace("++++", "", $value) . '</p>';
                if ($count == 0) {
                    $count = 1;
                    $data .='<div class="menu_body"><ul class="jobdetail">';
                }
            } else {
                $data .= '<li>' . str_replace("----", "", $value) . '</li>';
            }
        }
        $data .= '</ul></div>'; // ปิด div สุดท้าย ที่ loop ได้เปิดเอาไว้
        $data .= '</div>';
        return $data;
    }
    return "";
}

function getJoinusImage() {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM ext_fixdata WHERE id = 8", null);
    $arr = splitformatToarrayData($result[0]['data'], true);
    if (stripcslashes($arr[0]) != "") {
        return '<img src="timthumb.php?src=' . stripcslashes($arr[0]) . '&w=410&h=540" alt="join us image"/>';
    }
    return "";
}

function getProjectDetail($coverDetail) {
    global $base;
    if ($base['cookie']['lang'] == "th") {
//        if (str_replace("||", "", getlang($coverDetail, 0)) == "") {
//            return '' . nl2br(getlang($coverDetail, 1)) . '';
//        }
        return '' . nl2br(getlang($coverDetail, 0)) . '';
    } else {
//        if (str_replace("||", "", getlang($coverDetail, 1)) == "") {
//            return '' . nl2br(getlang($coverDetail, 0)) . '';
//        }
        return '' . nl2br(getlang($coverDetail, 1)) . '';
    }
}

function getGalleryDetail($coverDetail) {
    global $base;
    if ($base['cookie']['lang'] == "th") {
        return '' . nl2br(getlang($coverDetail, 0)) . '';
    } else {
        return '' . nl2br(getlang($coverDetail, 1)) . '';
    }
}

function getProjectName($text) {
    global $base;
    if ($base['cookie']['lang'] == "th") {
        return '' . getlang($text, 0) . '';
    } else {
        return '' . getlang($text, 1) . '';
    }
}

function getlang($str, $index) {
    $arr = explode("{lang}", $str);
    return $arr[$index];
}

function splitformatToarrayData($str, $getDataNull = true) {
    $arr = explode("||", $str);
    if (!$getDataNull) {
        foreach ($arr as $val) {
            if (trim($val) != "") {
                $dataOnly[] = $val;
            }
        }
    } else {
        foreach ($arr as $val) {
            $dataOnly[] = $val;
        }
    }
    return $dataOnly;
}

function arrayToSplitFormat($arr) {
    if (count($arr) != 0) {
        return implode("||", $arr);
    } else {
        return "";
    }
}

////////////////////////////////////////// menu /////////////////////////////

function getMenuInterior($id) {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM catagories_menu WHERE `group` = 1 ORDER BY `sort` ASC", null);
    $data .= '<ul>';
    foreach ($result as $row) {
        $data .= '<li><a ' . ($id == $row['id'] ? ' class="current"' : '') . 'href="index.php?mod=viewinteriorproject&catag=' . $row['id'] . '&cname=Interior&sname=' . $row['name'] . '">' . $row['name'] . '</a></li>';
    }
    $data .= '</ul>';
    return $data;
}

function getMenuArcthecture($id) {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM catagories_menu WHERE `group` = 2 ORDER BY `sort` ASC", null);
    $data .= '<ul>';
    foreach ($result as $row) {
        $data .= '<li><a ' . ($id == $row['id'] ? ' class="current"' : '') . 'href="index.php?mod=viewarchitectureproject&catag=' . $row['id'] . '&cname=Architecture&sname=' . $row['name'] . '">' . $row['name'] . '</a></li>';
    }
    $data .= '</ul>';
    return $data;
}

function getMenuGraphic($id) {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM catagories_menu WHERE `group` = 3 ORDER BY `sort` ASC", null);
    $data .= '<ul>';
    foreach ($result as $row) {
        $data .= '<li><a ' . ($id == $row['id'] ? ' class="current"' : '') . 'href="index.php?mod=viewgraphicproject&catag=' . $row['id'] . '&cname=Graphic&sname=' . $row['name'] . '">' . $row['name'] . '</a></li>';
    }
    $data .= '</ul>';
    return $data;
}

//function getMenuPress() {
//    global $base, $conn;
//    $result = $conn->nativeQuerySelect("SELECT * FROM catagories_menu WHERE `group` = 4 ORDER BY `sort` ASC", null);
//    $data .= '<ul>';
//    foreach ($result as $row) {
//        $data .= '<li><a href="index.php?mod=viewinteriorproject&catag=' . $row['id'] . '&cname=Press&sname=' . $row['name'] . '">' . $row['name'] . '</a></li>';
//    }
//    $data .= '</ul>';
//    return $data;
//}

function getProjectList($id) {
    global $base, $conn;
    $result = $conn->nativeQuerySelect("SELECT * FROM `ext_interior_gallery` WHERE slide_catag = ? AND status = 1 ORDER BY slide_order DESC", array($id));
    return $result;
}

function sortByOption($a, $b) {
//    echo $a[6], '--', $b[6];
//    echo '<br/>';
    $name = strcmp($a[0], $b[0]);
    if ($name === 0) {
        $name = strcmp($a[6], $b[6]);
//        return ($a[6] - $b[6]) * -1;
    }
    return $name * -1;
}

?>

© 2024 UnknownSec