Beispiel #1
0
function getContent()
{
    $index = getIndex();
    if (!$index) {
        $index = 'home';
    }
    if (!isPage($index)) {
        $index = '404';
    } else {
        if (!isAccess($index)) {
            $index = '403';
        }
    }
    $p = Pages::getPages($index)['link'];
    include "/pages/{$p}";
}
Beispiel #2
0
/** 검색어 추가
 * @class write
 * @param
		$data: 대상 String 데이터
		$mode: 모드
		-num: 대상 게시물
		-cmt_no: 댓글 번호
		-id: 대상 아이디
		-date: 날짜
		-target: 대상 회원번호
		-ip: 대상 IP
 * @return 
 */
function addIndex($data, $param = '')
{
    global $mini;
    $param = param($param);
    iss($param['num']);
    iss($param['cmt_no']);
    iss($param['id']);
    iss($param['date']);
    iss($param['target']);
    iss($param['ip']);
    iss($query);
    $arr = $param['cmt_no'] ? array('ment', 'tag', 'name') : array('ment', 'title', 'tag', 'category', 'name');
    foreach ($arr as $val) {
        $tmp = array();
        if ($val == 'name') {
            $tmp = $data[$val];
        } else {
            $tmp = $val == 'category' || $val == 'tag' ? getStr($data[$val]) : getIndex($data[$val]);
        }
        if (is_array($tmp) && count($tmp) > 0) {
            foreach ($tmp as $val2) {
                $query .= ",('{$val}', '{$param['num']}', '{$param['cmt_no']}', '{$param['id']}', '{$param['ip']}', '{$param['date']}', '{$val2}', '{$param['target']}')";
            }
        } else {
            if (!empty($tmp)) {
                $query .= ",('{$val}', '{$param['num']}', '{$param['cmt_no']}', '{$param['id']}', '{$param['ip']}', '{$param['date']}', '{$tmp}', '{$param['target']}')";
            }
        }
    }
    if (!empty($param['is_conv'])) {
        return array('keys' => '(mode, num, cmt_no, id, ip, date, ment, target_member)', 'values' => substr($query, 1));
    } else {
        sql("INSERT INTO {$mini['name']['search']} (mode, num, cmt_no, id, ip, date, ment, target_member) VALUES " . substr($query, 1));
    }
}
$blueWithRedDisk = array(3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 2);
$redDisk = array(1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1701, 1702);
$blueDisk = array(4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1);
$tdb = array("TDB # 996-145-577", "TDB # 996-145-578", "TDB # 996-145-579", "TDB # 996-145-580", "TDB # 996-145-581", "TDB # 996-145-582");
$datesBlueAndRed = array("27-01-2016", "24-02-2016", "23-03-2016", "20-04-2016", "18-05-2016", "15-06-2016", "13-07-2016", "10-08-2016", "07-09-2016", "05-10-2016", "02-11-2016", "30-11-2016", "28-12-2016", "25-01-2017");
$datesBlueDisk = array("10-02-2016", "09-03-2016", "06-04-2016", "04-05-2016", "01-06-2016", "29-06-2016", "27-07-2016", "24-08-2016", "21-09-2016", "19-10-2016", "16-11-2016", "14-12-2016", "11-01-2017");
$datesTerrainDataBase = array("24-02-2016", "20-04-2016", "15-06-2016", "08-08-2016", "05-10-2016", "30-11-2016");
if ($i = getIndex($todays_date, $datesBlueAndRed) > -1) {
    $message = "Blue disk #" . $blueWithRedDisk[$i] . "and Red dsk cycle" . $redDisk[$i] . "are available for download at:\n\nhttps://inds.epicinds.com/epic/login";
    sendMailToPilots("Blue and Red disk up-date", $message, $pilots);
} else {
    if ($i = getIndex($todays_date, $datesBlueDisk) > -1) {
        $message = "Blue disk #" . $blueDisk[$i] . "is available for download at:\n\nhttps://inds.epicinds.com/epic/login";
        sendMailToPilots("Blue disk up-date", $message, $pilots);
    } else {
        if ($i = getIndex($todays_date, $datesTerrainDataBase) > -1) {
            $message = $tdb[$i] . "is available for download at:\n\nhttps://inds.epicinds.com/epic/login";
            sendMailToPilots("Terrain database up-date", $message, $pilots);
        }
    }
}
function sendMailToPilots($subject, $message, $pilots)
{
    for ($p = 0; $p < count($pilots); $p++) {
        mail($pilots[$p], $subject, $message);
    }
}
function getIndex($todays_date, $dates)
{
    for ($i = 0; $i < count($dates); $i++) {
        if ($todays_date == $dates[$i]) {
Beispiel #4
0
 public function createPng($doImages = true, $doFill = true, $endTime = null)
 {
     $app = Application::getInstance();
     $im = imagecreatetruecolor(2000, 2000);
     // imageantialias($im,true);
     $white = convertHexColor($im, 'ffffff');
     imagefill($im, 0, 0, $white);
     if (!$doFill) {
         imagecolortransparent($im, $white);
     }
     if ($doImages) {
         $imgArray = array();
         $s = $app->db->prepare("select * from Scribble where DoodleBoardId=:i and type='Image' order by timeCreated asc");
         $s->bindParam(':i', $this->id);
         $s->execute();
         while ($obj = $s->fetchObject()) {
             $tmp = new ImageStruct();
             $tmp->source = $obj->metaData;
             $xData = explode(':', $obj->xCoords);
             $yData = explode(':', $obj->yCoords);
             $tmp->x = $xData[0];
             $tmp->y = $yData[0];
             $tmp->w = array_key_exists('1', $xData) ? $xData[1] : -1;
             $tmp->h = array_key_exists('1', $yData) ? $yData[1] : -1;
             $imgArray[$obj->timeCreated] = $tmp;
         }
         $s = $app->db->prepare("select metaData from Scribble where DoodleBoardId=:i and type='RImage' order by timeCreated asc");
         $s->bindParam(':i', $this->id);
         $s->execute();
         while ($obj = $s->fetchObject()) {
             $id = substr(strrchr($obj->metaData, ":"), 1);
             $imgArray[$id] = null;
         }
         $finalImgArray = array();
         foreach ($imgArray as $key => $img) {
             if ($img != null) {
                 array_push($finalImgArray, array($key, $img));
             }
         }
         $s = $app->db->prepare("select metaData from Scribble where DoodleBoardId=:i and type='FrontImage' order by timeCreated asc");
         $s->bindParam(':i', $this->id);
         $s->execute();
         while ($obj = $s->fetchObject()) {
             $id = substr(strrchr($obj->metaData, ":"), 1);
             $index = getIndex($id, $finalImgArray);
             $temp = $finalImgArray[$index];
             $finalImgArray[$index] = null;
             array_push($finalImgArray, $temp);
         }
         foreach ($finalImgArray as $img) {
             $img = $img[1];
             if ($img != null) {
                 $cpImg = null;
                 $fileName = "/var/www/html/sneffel.com" . $img->source;
                 $ext = substr($img->source, strrpos($img->source, '.') + 1);
                 switch ($ext) {
                     case 'gif':
                         //gif
                         $cpImg = imagecreatefromgif($fileName);
                         break;
                     case 'jpeg':
                         //jpeg
                         $cpImg = imagecreatefromjpeg($fileName);
                         break;
                     case 'jpg':
                         //jpeg
                         $cpImg = imagecreatefromjpeg($fileName);
                         break;
                     case 'pgn':
                         //png
                         $cpImg = imagecreatefrompng($fileName);
                         break;
                 }
                 if ($img->w == -1) {
                     $img->w = imagesx($cpImg);
                 }
                 if ($img->h == -1) {
                     $img->h = imagesy($cpImg);
                 }
                 imagecopyresampled($im, $cpImg, $img->x, $img->y, 0, 0, $img->w, $img->h, imagesx($cpImg), imagesy($cpImg));
                 imagedestroy($cpImg);
             }
         }
     }
     if ($endTime) {
         $s = $app->db->prepare("select * from Scribble where DoodleBoardId=:i and (type='Draw' or type='Erase') and serverTimeCreated <= :end order by serverTimeCreated asc");
         $s->bindParam(':end', $endTime);
         $s->bindParam(':i', $this->id);
         $s->execute();
     } else {
         $s = $app->db->prepare("select * from Scribble where DoodleBoardId=:i and (type='Draw' or type='Erase') order by serverTimeCreated asc");
         $s->bindParam(':i', $this->id);
         $s->execute();
     }
     while ($obj = $s->fetchObject()) {
         $xData = explode(':', $obj->xCoords);
         $yData = explode(':', $obj->yCoords);
         $obj->color = substr(dechex($obj->color + hexdec('FF000000')), 2);
         $color = $obj->type == 'Erase' ? $white : convertHexColor($im, $obj->color);
         for ($i = 0; $i < count($xData) - 1; $i++) {
             if ($xData[$i] != -1 && $xData[$i + 1] != -1) {
                 drawLine($im, $xData[$i], $yData[$i], $xData[$i + 1], $yData[$i + 1], $obj->width - 1, $color);
             }
         }
     }
     return $im;
 }
Beispiel #5
0
<?php

if (!defined("ROOT")) {
    echo "You don't have permission to access this page!";
    exit;
}
$loai = getIndex("idcat");
?>
<div class="productList">
	Các sản phẩm của loại có mã: <?php 
echo $loai;
?>
</div>
Beispiel #6
0
function update(&$s, $dbName, $fromVersion, $toVersion = "Latest")
{
    global $noahVersions;
    global $lll;
    $s = "";
    $length = sizeof($noahVersions);
    if ($toVersion == "Latest") {
        $toVersion = $noahVersions[$length - 1];
    }
    if (!in_array($fromVersion, $noahVersions) || !in_array($toVersion, $noahVersions)) {
        iPrint(sprintf($lll["invalid_version"], "{$fromVersion}, {$toVersion}"), "err", $sp);
        $s .= $sp;
        return ok;
    }
    if ($fromVersion == $toVersion) {
        iPrint(sprintf($lll["already_installed"], $toVersion), "ok", $sp);
        $s .= $sp;
        return ok;
    }
    $fromIndex = getIndex($fromVersion);
    $toIndex = getIndex($toVersion);
    if ($toIndex < $fromIndex) {
        iPrint(sprintf($lll["invalid_version"], "{$fromVersion}, {$toVersion}"), "err", $sp);
        $s .= $sp;
        return ok;
    }
    global $updateOutput;
    $updateOutput = "";
    for ($vInd = $fromIndex + 1; $vInd <= $toIndex; $vInd++) {
        $fname = NOAH_BASE . "/updateinfo-{$noahVersions[$vInd]}.php";
        if (file_exists($fname)) {
            $contents = join('', file($fname));
            if (preg_match('{/\\* Files to delete:\\s*(\\S.*)\\s*\\*/}s', $contents, $matches)) {
                $filesToDelete = preg_split('/[\\n\\r]+/', $matches[1]);
                foreach ($filesToDelete as $file) {
                    @unlink(NOAH_BASE . "/{$file}");
                }
            }
            include $fname;
            $s .= $updateOutput;
        } else {
            updateGlobalstatAndFooter($noahVersions[$vInd]);
        }
    }
    // storing the last update time:
    executeQueryForUpdate("UPDATE @globalstat SET lastUpdate=NOW()", __FILE__, __LINE__);
    iPrint($lll["updateSuccessful"], "ok", $sp);
    $s .= $sp;
}
Beispiel #7
0
function getTable($tableXML, &$database, &$tables)
{
    global $classNames;
    global $build_version;
    $name = trim((string) $tableXML->name);
    $klass = trim((string) $tableXML->class);
    $base = value('base', $tableXML) . '/DAO/';
    $pre = str_replace('/', '_', $base);
    $classNames[$name] = $pre . $klass;
    $localizable = false;
    foreach ($tableXML->field as $fieldXML) {
        if ($fieldXML->localizable) {
            $localizable = true;
            break;
        }
    }
    $table = array('name' => $name, 'base' => $base, 'fileName' => $klass . '.php', 'objectName' => $klass, 'labelName' => substr($name, 8), 'className' => $classNames[$name], 'attributes_simple' => trim($database['tableAttributes_simple']), 'attributes_modern' => trim($database['tableAttributes_modern']), 'comment' => value('comment', $tableXML), 'localizable' => $localizable, 'log' => value('log', $tableXML, 'false'));
    $config =& CRM_Core_Config::singleton(false);
    $fields = array();
    foreach ($tableXML->field as $fieldXML) {
        if (value('drop', $fieldXML, 0) > 0 and value('drop', $fieldXML, 0) <= $build_version) {
            continue;
        }
        // check if hrd field and hrd is enabled to include
        if (value('hrd', $fieldXML, 0) == 1 && !$config->civiHRD) {
            continue;
        }
        if (value('add', $fieldXML, 0) <= $build_version) {
            getField($fieldXML, $fields);
        }
    }
    $table['fields'] =& $fields;
    // print_r($table['fields' ]);
    //Anil
    $table['hasEnum'] = false;
    foreach ($table['fields'] as $field) {
        if ($field['crmType'] == 'CRM_Utils_Type::T_ENUM') {
            $table['hasEnum'] = true;
            break;
        }
    }
    if (value('primaryKey', $tableXML)) {
        getPrimaryKey($tableXML->primaryKey, $fields, $table);
    }
    $config =& CRM_Core_Config::singleton(false);
    if (value('index', $tableXML)) {
        $index = array();
        foreach ($tableXML->index as $indexXML) {
            if (value('drop', $indexXML, 0) > 0 and value('drop', $indexXML, 0) <= $build_version) {
                continue;
            }
            // check if hrd field and hrd is enabled to include
            if (value('hrd', $fieldXML, 0) == 1 && !$config->civiHRD) {
                continue;
            }
            getIndex($indexXML, $fields, $index);
        }
        $table['index'] =& $index;
    }
    if (value('foreignKey', $tableXML)) {
        $foreign = array();
        foreach ($tableXML->foreignKey as $foreignXML) {
            // print_r($foreignXML);
            if (value('drop', $foreignXML, 0) > 0 and value('drop', $foreignXML, 0) <= $build_version) {
                continue;
            }
            if (value('add', $foreignXML, 0) <= $build_version) {
                getForeignKey($foreignXML, $fields, $foreign, $name);
            }
        }
        $table['foreignKey'] =& $foreign;
    }
    $tables[$name] =& $table;
    return;
}
    return $indexval;
}
function restart()
{
    shell_exec("sudo ifup wlan0");
}
if (!array_key_exists('interface', get_defined_vars()) || is_null($interface) || $interface == "") {
    $interface = "wlan0";
}
$networks = $wifi->scan($interface);
$ssid = "linksys";
if ($_POST["ssid"]) {
    $passwd = "";
    if (isset($_POST['password'])) {
        $passwd = $_POST["password"];
    }
    $ssid = $_POST["ssid"];
    echo "<!-- " . $ssid . $passwd . " ---!>";
    $networkindex = 0;
    $networkindex = getIndex($ssid);
    echo "<!-- " . $ssid . " index=" . $networkindex . " ---!>";
    if ($networkindex < 0 || $networkindex == "") {
        // create new index & wpa supplicant entrya
        $networkindex = nextIndex();
        // @TODO add logic for encrypted network = true
        newNetworkOpen($ssid, $networkindex);
    } else {
        setNetwork($ssid, $networkindex);
    }
}
include 'config.php';
Beispiel #9
0
<?php

if (!defined("ROOT")) {
    echo "You don't have permission to access this page!";
    exit;
}
$tensach = getIndex("proname");
?>
<div class="productList">
	Danh sách các cuốn sách có tên sách chứa chuỗi: <?php 
echo $tensach;
?>
</div>
Beispiel #10
0
 protected function getPosWin($gamePos)
 {
     global $game;
     $ind = getIndex($gamePos[0]);
     $binNum = $ind * 5 + $gamePos[1];
     $charNum = ($binNum - $binNum % 8) / 8;
     $char = $game[$charNum + 1];
     $rest = 7 - $binNum % 8;
     while ($rest--) {
         $char /= 2;
     }
     return $char % 2;
 }
Beispiel #11
0
{
    $f = file($codes) or die("Can't open codes: {$codes}");
    return $f[$line];
}
function setIndex($index, $value)
{
    $fh = fopen($index, 'w') or die("Can't open index: {$index}");
    fwrite($fh, $value);
    fclose($fh);
}
// if either codes.txt or codes.index doesn't exist, generate new codes.
if (!file_exists($index) || !file_exists($codes)) {
    generate($codes);
    randomize($codes);
}
/* begin main program */
$i = getIndex($index);
$lines = count(file($codes));
if ($i == $lines) {
    // shuffle file and reset the count
    randomize($codes);
    setIndex($index, '0');
    $i = 0;
}
$read = file($codes);
// read all the codes into $read
echo $read[$i];
// output the $i-th line
$i++;
//incrament the counter and save it
setIndex($index, $i);
Beispiel #12
0
    });
    describe("Facets", function () {
        it("should filtered by a set of ids to the intersection", function () {
            $store = getRafflesStore();
            $exns = 'http://example.com/';
            $data = <<<_TTL_
@base <{$exns}> .
<A> a <Book> ; <date> "1500" .
<C> a <Book> ; <date> "1500" .
<B> a <Person> ; <born> "1450" .
_TTL_;
            $store->loadData($data);
            $index = $store->Index;
            $ids = $index->getPredicateObject(rdftype, $exns . 'Book');
            $filtered = $index->filterPredicateObjectIndex($ids);
            $expected = array(rdftype => array($exns . 'Book' => array(0, 1)), $exns . 'date' => array('1500' => array(0, 1)));
            expect($filtered)->to_equal($expected);
        });
    });
    describe("splitURI", function () {
        it("should return an array( namespace, localname)", function () {
            $index = getIndex();
            expect($index->splitURI('http://example.com/foo/bar'))->to_equal(array('http://example.com/foo/', 'bar'));
            expect($index->splitURI('http://example.com/foo/bar/'))->to_equal(array('http://example.com/foo/', 'bar/'));
            expect($index->splitURI('http://example.com/foo#bar'))->to_equal(array('http://example.com/foo#', 'bar'));
            expect($index->splitURI('http://example.com/foo/bar#'))->to_equal(array('http://example.com/foo/', 'bar#'));
            expect($index->splitURI('http://example.com/ns/people/tom'))->to_equal(array('http://example.com/ns/people/', 'tom'));
        });
    });
});
//\pecs\run();
/**
 * Retrieves all links for a certain RecType
 * 
 * @param mixed $system  System reference
 * @param mixed $rectype Rectype reference
 */
function getLinks($system, $rectypes)
{
    $links = array();
    // Go through all rectypes
    for ($i = 0; $i < sizeof($rectypes); $i++) {
        // Find relations
        $relations = getRelations($system, $rectypes[$i]);
        // Find all targets for each relation
        foreach ($relations as $relation) {
            //get counts by target
            $targets = getTargets($system, $rectypes[$i], $relation);
            // Construct a link for each target
            foreach ($targets as $target) {
                $link = new stdClass();
                /* example                    
                relation:Object
                    count:0
                    id:16
                    ids:"10"
                    name:"Person(s) concerned"
                    type:"resource"
                source:1
                target:9
                targetcount:0                    
                */
                // Records
                $link->source = $i;
                $link->target = getIndex($rectypes, $target);
                $link->relation = $relation;
                // Counts
                $link->targetcount = $target->count;
                $link->relation->count = $target->count;
                //print_r($link);
                array_push($links, $link);
            }
        }
    }
    return $links;
}
Beispiel #14
0
 if ($radioGroup1 == 'aggregate') {
     $_SESSION['metasearch'] = $aggregatedList;
     header('Location: ' . $_SERVER['HTTP_REFERER']);
     //$_SESSION['googleresults'] = $googleresults;
     //header ( 'Location: ' . $_SERVER['HTTP_REFERER'] );
 } else {
     if ($radioGroup1 == 'non-aggregate') {
         //$_SESSION['metasearch'] = $bingresults . '<br/>' . $entireWebresults . '<br/>' . $blekkoresults;
         $_SESSION['metasearch'] = $nonAggregatedList;
         header('Location: ' . $_SERVER['HTTP_REFERER']);
         //$_SESSION['googleresults'] = $googleresults;
         //header ( 'Location: ' . $_SERVER['HTTP_REFERER'] );
     } else {
         if ($radioGroup1 == 'cluster') {
             // Create index, tfidf, etc for unique results list
             $resultsIndex = getIndex($nonAggregated);
             $resultsTfidf = getTfidf($resultsIndex, $nonAggregatedTotalSet);
             // Normalise input data for centroids
             $normalisedTfidf = normaliseTfidf($resultsTfidf);
             /*	
             			 	// test
             foreach ( $normalisedTfidf as $docID => $value )
             {
             	foreach ( $value as $term => $tfidfValue )
             	{
             		$normal .= "docId: " . $docID . " , term: " . $term . " , tf-idf: " . $tfidfValue . "<br />";
             	}
             }
             */
             // Calculate centroids, map docs to them
             $numClusters = 5;
Beispiel #15
0
<?php

if (!defined("ROOT")) {
    echo "You don't have permission to access this page!";
    exit;
}
$idpress = getIndex("idpress");
?>
<div class="productList">
	Các sản phẩm của nhà xuất bản có mã: <?php 
echo $idpress;
?>
</div>
Beispiel #16
0
/** 검색 처리
 * @class list
 * @param
		-name: 리스팅 변수배열 이름
		-is_simple: key table 사용 여부
		-where_and: 기본 and 검색조건
		-where: 기본 검색조건
		-other: 뒤에 들어갈 절
		-quickName: quick 검색 변수명
		-sName: 검색 변수명
		-andName: and 검색 변수명
  */
function setSearch($param = '')
{
    global $mini;
    $param = param($param);
    /*
    	리스팅 변수배열 멤버변수
    	table
    	keyTable
    	list
    	start
    	div
    	nowDiv
    	key
    	is_total
    	fieldName
    	where
    	order
    	order_desc
    
    	검색 조건에 따라 total 이 들어가야 한다
    */
    def($param['name'], 'default');
    def($mini['list'][$param['name']], '');
    def($_REQUEST['target'], '');
    def($_REQUEST['id'], '');
    def($param['quickName'], 'quick');
    def($param['sName'], 's');
    def($param['andName'], 'and');
    def($_REQUEST[$param['sName']], '');
    $where = $where_and = $both = '';
    $is_all = 0;
    $sep = !empty($_REQUEST[$param['andName']]) ? "and" : "or ";
    $data =& $mini['list'][$param['name']];
    def($data['key'], 0);
    def($data['is_total'], 0);
    $s = array();
    if (!empty($param['other'])) {
        $data['other_query_after'] = $param['other'];
    }
    //// 기본 검색조건 적용
    if (!empty($param['where_and'])) {
        $where_and .= " and {$param['where_and']}";
    }
    if (!empty($param['where'])) {
        $where .= " {$sep} {$param['where']}";
    }
    //// 모드 없는 검색 설정
    if (!empty($_REQUEST[$param['quickName']]) && empty($param['is_simple'])) {
        $s = array('title' => $_REQUEST[$param['quickName']], 'ment' => $_REQUEST[$param['quickName']], 'name' => $_REQUEST[$param['quickName']], 'tag' => $_REQUEST[$param['quickName']]);
    } else {
        if (!empty($_REQUEST['category']) && empty($_REQUEST[$param['sName']])) {
            $s = array('category!' => $_REQUEST['category']);
        }
    }
    //// 일반
    if (!empty($_REQUEST[$param['sName']])) {
        $s = array_merge($s, $_REQUEST[$param['sName']]);
    }
    //// 검색 루프 시작
    if (!empty($s) && is_array($s)) {
        // 키 테이블만 사용할 수 있는 조건인지 확인(PHP5 에서는 array_diff_key로 한번에 해결, 4.0.4에서 array_diff가 깨질 수 있음!)
        $tmp_keys = "[" . implode("][", array_keys($s)) . "]";
        $tmp_keys = str_replace(array('!', '^', '$', '@', '+', '-', '*', '~'), '', $tmp_keys);
        $is_key = array_diff(getStr($tmp_keys), array('category', 'tag', 'title', 'ment', 'target_member', 'name')) || !empty($param['is_simple']) ? 0 : 1;
        foreach ($s as $key => $val) {
            // 조건 뽑기
            preg_match("/(\\+|\\-|\\@|\\^|\\!|\$|\\~)\$/i", $key, $mat);
            $is_special = preg_match("/^\\@/i", $key);
            $key = str_replace(array('@', '^', '!', '$', '+', '-', '*', '~'), '', trim($key));
            $option = $mat[1];
            // 검색어 언어셋 변경
            $val = convChar($val);
            $val = str_replace("\\'", "&#39;", $val);
            $val = str_replace("\\\\'", "'", $val);
            $val = str_replace("\\\"", "\"", $val);
            // 검색어 쪼개기
            //					if (empty($param['is_simple']) && (!empty($_REQUEST[$param['quickName']]) || (!empty($_REQUEST[$param['sName']]) && count($_REQUEST[$param['sName']]) == 1))) {
            //						$val_arr = array();
            //						$val_arr = getIndex($val, 'search');
            //						$count_val_arr = count($val_arr);
            //					}
            $val_arr = array();
            if ($key != 'ip' && $key != 'date' && $key != 'target_member' && $key != 'name') {
                $val_arr = getIndex($val, 'search');
            } else {
                $val_arr = array($val);
            }
            $count_val_arr = count($val_arr);
            // 특수검색(@모드)
            if ($is_special) {
                switch ($key) {
                    // 모든 게시판에서 검색
                    case 'all':
                        $is_all = 1;
                        break;
                        /*
                        					case 'date':
                        						break;
                        					case 'private':
                        						break;
                        */
                    /*
                    					case 'date':
                    						break;
                    					case 'private':
                    						break;
                    */
                    default:
                        __error("정의되지 않은 특별검색 입니다");
                }
            }
            // 검색테이블 사용
            if ($is_key) {
                $data['key'] = 1;
                $tmp_q = empty($_REQUEST['is_cmt']) ? " and cmt_no=0" : "";
                if ($key == 'target_member' && preg_match("/[^0-9]/", $val)) {
                    continue;
                }
                $tmp_sep = $option == '~' ? " and" : " or ";
                $where_name = $option == '~' ? "where_and" : "where";
                if ($option == '!') {
                    foreach ($val_arr as $key2 => $val2) {
                        ${$where_name} .= $key == 'target_member' ? "{$tmp_sep} (target_member={$val2}{$tmp_q})" : "{$tmp_sep} (mode='{$key}'{$tmp_q} and ment='{$val2}')";
                    }
                    // 총 게시물 수를 저장한 검색조건이라면 전체 검색을 할 수 있게 is_total 변수를 지정한다
                    if ($key == 'category' && count($s) == 1) {
                        $data['is_total'] = 1;
                        $data['key'] = 1;
                        $data['is_only_category'] = 1;
                        //								if (!isset($mini['board']['total'][$key][$val]))
                        //									__error("존재하지 않는 {$key} 입니다.");
                        if (isset($mini['board']['total'][$key][$val])) {
                            $data['total'] = $mini['board']['total'][$key][$val];
                        } else {
                            $data['total'] = 0;
                        }
                    }
                } else {
                    foreach ($val_arr as $key2 => $val2) {
                        ${$where_name} .= $key == 'target_member' ? "{$tmp_sep} (target_member={$val2}{$tmp_q})" : "{$tmp_sep} (mode='{$key}'{$tmp_q} and ment LIKE '{$val2}%')";
                    }
                }
            } else {
                $tmp_sep = $option == '~' ? "and" : $sep;
                $where_name = $sep == 'and' ? "where_and" : "where";
                // +- 가 동시에 적용될 경우 두개는 and로 묶기(date between)
                if ($option == '-' || $option == '+') {
                    if (isset($s["{$key}-"]) && isset($s["{$key}+"])) {
                        ${$where_name} .= "{$tmp_sep} ({$key} <= '{$s[$key . '-']}' and {$key} >= '{$s[$key . '+']}')";
                        $both .= "[{$key}]";
                    }
                }
                // :keyword: 검색 적용(high, low)
                if (preg_match("/:[a-z]+:\$/i", $val)) {
                    $mat = array();
                    preg_match("/:([a-z]+):\$/i", $val, $mat);
                    $val = preg_replace("/:[a-z]+:/i", "", $val);
                    switch ($mat[1]) {
                        case 'high':
                            if ($val !== '') {
                                ${$where_name} .= " {$tmp_sep} {$key} >= '{$val}'";
                            }
                            break;
                        case 'low':
                            if ($val !== '') {
                                ${$where_name} .= " {$tmp_sep} {$key} <= '{$val}'";
                            }
                            break;
                    }
                } else {
                    if (is_array($val_arr)) {
                        foreach ($val_arr as $key2 => $val2) {
                            switch ($option) {
                                case '!':
                                    ${$where_name} .= " {$tmp_sep} {$key}='{$val2}'";
                                    break;
                                case '^':
                                    if ($val2 !== '') {
                                        ${$where_name} .= " {$tmp_sep} {$key} LIKE '{$val2}%'";
                                    }
                                    break;
                                case '$':
                                    if ($val2 !== '') {
                                        ${$where_name} .= " {$tmp_sep} {$key} LIKE '%{$val2}'";
                                    }
                                    break;
                                case '*':
                                    if ($val2 !== '') {
                                        ${$where_name} .= " {$tmp_sep} {$key} LIKE '%[{$val2}]%'";
                                    }
                                    break;
                                case '+':
                                    if ($val2 !== '' && !inStr($key, $both)) {
                                        ${$where_name} .= " {$tmp_sep} {$key} >= '{$val2}'";
                                    }
                                    break;
                                case '-':
                                    if ($val2 !== '' && !inStr($key, $both)) {
                                        ${$where_name} .= " {$tmp_sep} {$key} <= '{$val2}'";
                                    }
                                    break;
                                default:
                                    if ($val2 !== '') {
                                        ${$where_name} .= " {$tmp_sep} {$key} LIKE '%{$val2}%'";
                                    }
                            }
                        }
                    }
                }
            }
        }
    }
    //// 검색 조건이 있을 떄
    if ($where || $where_and) {
        // and와 합침
        if ($where && $where_and) {
            $where = " and (" . substr($where, 4) . "){$where_and}";
        } else {
            if (!$where && $where_and) {
                $where = $where_and;
            }
        }
        if (!empty($is_key)) {
            // 다중 게시판 검색 시(총 게시물 수가 없어야 가능)
            if (!empty($_REQUEST['target']) && !$data['is_total']) {
                $tmp = array();
                $tmp = explode(",", trim($_REQUEST['target']));
                $tmp_where = '';
                foreach ($tmp as $key => $val) {
                    $val = trim($val);
                    if ($val && !preg_match("/[^0-9]/", $val)) {
                        $tmp_where .= " or id={$val}";
                    }
                }
                if ($tmp_where) {
                    $where = " and (" . substr($tmp_where, 3) . ") and (" . substr($where, 4) . ")";
                }
            } else {
                if ($_REQUEST['id'] && (!$is_all || $data['is_total'])) {
                    $where = " and id='{$mini['board']['no']}' and (" . substr($where, 4) . ")";
                }
            }
        }
        $data['where'] = "WHERE " . substr($where, 4);
        if (!empty($is_key) && !empty($_REQUEST[$param['andName']]) && !empty($count_val_arr)) {
            $data['where'] .= " GROUP BY num HAVING count(num) >= {$count_val_arr}";
            $data['is_group'] = 1;
        }
    } else {
        $data['is_total'] = 1;
    }
}
Beispiel #17
0
if (!isset($languageSettings[$coreLanguage])) {
    $languageSettings[$coreLanguage] = array('name' => $coreLanguage, 'locale' => 'en_US', 'long_date_format' => '%F %j, %Y', 'short_date_format' => '%m/%d/%Y', 'time_format' => '%H:%i');
    \CB\Config::setEnvVar('language_settings', $languageSettings);
}
// index for default core language
\CB\Config::setEnvVar('language_index', getIndex(\CB\Config::get('language')));
/* define user_language constant /**/
$user_language = $coreLanguage;
if (!empty($_COOKIE['L']) && strlen($_COOKIE['L']) == 2) {
    $user_language = strtolower($_COOKIE['L']);
}
if (!empty($_GET['l']) && strlen($_GET['l']) == 2) {
    $user_language = strtolower($_GET['l']);
}
/*  If we do not have a tanslation file for users language, we use main core language.
    If there is no translation file for main language set then we use english by default */
if (isset($_SESSION['user']['language']) && isset($languageSettings[$_SESSION['user']['language']])) {
    $user_language = $_SESSION['user']['language'];
} elseif (empty($_SESSION['user']['language']) || !isset($languageSettings[$_SESSION['user']['language']])) {
    $user_language = $coreLanguage;
}
$lidx = getIndex($user_language);
if ($lidx < 1) {
    $user_language = $coreLanguage;
    $lidx = getIndex($user_language);
}
\CB\Config::setEnvVar('user_language', $user_language);
// index for default user language
\CB\Config::setEnvVar('user_language_index', $lidx);
\CB\Config::setEnvVar('rtl', !empty($languageSettings[$user_language]['rtl']));
/* end of define user_language constant /**/
Beispiel #18
0
function getTfidf($term)
{
    $index = getIndex();
    $docCount = count($index['docCount']);
    $entry = $index['dictionary'][$term];
    foreach ($entry['postings'] as $docID => $postings) {
        echo "Document {$docID} and term {$term} give TFIDF: " . $postings['tf'] * log($docCount / $entry['df'], 2);
        echo "\n";
    }
}