コード例 #1
0
ファイル: process.php プロジェクト: CPE16/web_swe
function update_temp_member($id, $pdo)
{
    // ตรวจสอบว่า เป็น สมาชิกคนที่ 2 หรือ 3 โดย เชคว่า แถวแรก มีค่าเป็น 0 หรือ ไม่ ถ้าเป้น0คือ เป็นมาชิกคนที่ 2 ถ้าไม่ก็คนที่ 3
    if (check_position("2", $pdo)) {
        $sql = "UPDATE temp SET id =:id WHERE No = 2 ";
        $q = $pdo->prepare($sql);
        $q->execute(array(':id' => $id));
    } else {
        $sql = "UPDATE temp SET id =:id WHERE No = 3 ";
        $q = $pdo->prepare($sql);
        $q->execute(array(':id' => $id));
    }
}
コード例 #2
0
ファイル: Search.php プロジェクト: CPE16/web_swe
					<div class="alert alert-danger alert-dismissable" align="center">   
   					<strong>ขออภัย </strong> 
   					<a class="alert-link">สมาชิกเต็มแล้ว หากต้องการเพิ่ม โปรดติดต่อ อาจารย์ประจำวิชา</a> 
				</div>
<!-- 				</div>
			</div> -->
		<?php 
    die;
}
$sth = $pdo->prepare("SELECT * FROM students WHERE Student_ID = :id");
$sth->bindParam(':id', $id, PDO::PARAM_STR);
$sth->execute();
$found = 0;
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
    $found++;
    if (check_position("2", $pdo)) {
        $No = "2";
    } else {
        $No = "3";
    }
    ?>
  			
					<!-- <div class="card" align="center"> -->
						<!-- <hr> -->
						<div class="row" style="padding-bottom: 15px;">
							<br>
							  <div class="col-lg-1" align="center">
							  	<label>ลำดับที่</label>
                				<div> <?php 
    echo $No;
    ?>
コード例 #3
0
function message_save($id = false)
{
    global $_CLASS;
    if ($id) {
        $result = $_CLASS['core_db']->query('SELECT block_position FROM ' . BLOCKS_TABLE . ' WHERE block_id = ' . $id);
        $block = $_CLASS['core_db']->fetch_row_assoc($result);
        $_CLASS['core_db']->free_result($result);
        if (!$block) {
            redirect(generate_link('messages', array('admin' => true)));
        }
        check_position($block['block_position']);
        // need to validate data with the db type
        messages_get_data($data, $error);
        if ($error) {
            return message_edit($id, $data, $error);
        }
        $sql = 'UPDATE ' . BLOCKS_TABLE . ' SET ' . $_CLASS['core_db']->sql_build_array('UPDATE', $data) . '  WHERE block_id = ' . $id;
        $_CLASS['core_db']->query($sql);
    } else {
        messages_get_data($data, $error);
        if ($error) {
            return message_edit(false, $data, $error);
        }
        $result = $_CLASS['core_db']->query('SELECT MAX(block_order) as block_order FROM ' . BLOCKS_TABLE . ' WHERE block_position = ' . $data['block_position']);
        list($max_order) = $_CLASS['core_db']->fetch_row_num($result);
        $_CLASS['core_db']->free_result($result);
        $data['block_order'] = (int) $max_order + 1;
        $_CLASS['core_db']->query('INSERT INTO ' . BLOCKS_TABLE . ' ' . $_CLASS['core_db']->sql_build_array('INSERT', $data));
    }
    $_CLASS['core_cache']->destroy('blocks');
    $_CLASS['core_display']->meta_refresh('3', generate_link('messages', array('admin' => true)));
    trigger_error(sprintf($_CLASS['core_user']->lang['SAVED'], generate_link('messages', array('admin' => true))));
}
コード例 #4
0
ファイル: index.php プロジェクト: nguyenquynh1993/multi-p2p
    //Put this line's contents into the nodeinfo array
    for ($i = 0; $i < sizeof($line_array); $i++) {
        $node_info["{$current_position}:{$i}"] = $line_array[$i];
    }
    //Get next position of \n, indicating we have another line to read
    $next_pos = strpos($contents, "\n");
    $current_position++;
}
//Check each user input to make sure the condition is satisfied
$node_info = check_position($node_info, $current_position, 1, trim($_GET['build']), $_GET['build_op']);
$node_info = check_position($node_info, $current_position, 4, trim($_GET['port']), $_GET['port_op']);
$node_info = check_position($node_info, $current_position, 5, trim($_GET['uptime']), $_GET['uptime_op']);
$node_info = check_position($node_info, $current_position, 6, trim($_GET['storage']), $_GET['storage_op']);
$node_info = check_position($node_info, $current_position, 7, trim($_GET['x_coord']), $_GET['x_coord_op']);
$node_info = check_position($node_info, $current_position, 8, trim($_GET['y_coord']), $_GET['y_coord_op']);
$node_info = check_position($node_info, $current_position, 9, trim($_GET['estimate']), $_GET['estimate_op']);
$num_matching = 0;
echo "<p />Matching nodes:<br />";
for ($i = 1; $i < $current_position; $i++) {
    if ($node_info["{$i}:0"] == true) {
        $one = "{$i}:1";
        $two = "{$i}:2";
        $three = "{$i}:3";
        $four = "{$i}:4";
        $five = "{$i}:5";
        $six = "{$i}:6";
        $seven = "{$i}:7";
        $eight = "{$i}:8";
        $nine = "{$i}:9";
        $num_matching++;
        echo "{$num_matching} - {$node_info[$two]} {$node_info[$three]}:{$node_info[$four]}<br />";
コード例 #5
0
</td>
	</tr>

	<tr>
	<th>Username</th><td colspan="2"><?php 
echo $rows->username;
?>
</td>
	</tr>

	<tr>
	<th>User Status</th><td colspan="2"><?php 
echo check_status($rows->user_status);
?>
</td>
	</tr>
		
	<tr>
	<th>User Position</th><td width="197"><?php 
echo check_position($rows->user_position);
?>
</td>
	</tr>
		
	</tbody>
	</table>
	</div><!-- /.box-body -->
  </div><!-- /.box -->
  </div><!-- /.col -->
  </div><!-- /.row -->
	
コード例 #6
0
function block_save($id = false)
{
    global $_CLASS;
    if ($id) {
        $result = $_CLASS['core_db']->query('SELECT block_order, block_position, block_type FROM ' . BLOCKS_TABLE . ' WHERE block_id = ' . $id);
        $block = $_CLASS['core_db']->fetch_row_assoc($result);
        $_CLASS['core_db']->free_result($result);
        if (!$block) {
            return;
        }
        check_position($block['block_position']);
        // need to validate data with the db type
        block_get_data($data, $error, $block['block_type']);
        if ($error) {
            return block_add($id, $data, $error);
        }
        //update old position order if new position is not the same
        if ($block['block_position'] != $data['block_position']) {
            // Make an error msg, just incase this fails for some reason
            blocks_change_position($data['block_position'], $id);
        }
        $sql = 'UPDATE ' . BLOCKS_TABLE . ' SET ' . $_CLASS['core_db']->sql_build_array('UPDATE', $data) . '  WHERE block_id = ' . $id;
    } else {
        block_get_data($data, $error, get_variable('type', 'REQUEST', BLOCKTYPE_FILE));
        if ($error) {
            return block_add(false, $data, $error);
        }
        $result = $_CLASS['core_db']->query('SELECT MAX(block_order) as block_order FROM ' . BLOCKS_TABLE . ' WHERE block_position = ' . $data['block_position']);
        list($max_order) = $_CLASS['core_db']->fetch_row_num($result);
        $_CLASS['core_db']->free_result($result);
        $data['block_order'] = (int) $max_order + 1;
        $sql = 'INSERT INTO ' . BLOCKS_TABLE . ' ' . $_CLASS['core_db']->sql_build_array('INSERT', $data);
    }
    $_CLASS['core_db']->query($sql);
    $_CLASS['core_cache']->destroy('blocks');
    $_CLASS['core_display']->meta_refresh('3', generate_link('blocks', array('admin' => true)));
    trigger_error(sprintf($_CLASS['core_user']->lang['SAVED'], generate_link('blocks', array('admin' => true))));
}
コード例 #7
0
ファイル: funcs.php プロジェクト: sdgdsffdsfff/html-sensor
function format_message($messages, $conf_positions)
{
    $new_message = [];
    foreach ($messages as &$item) {
        $item['消息形式'] = check_msgform($item['消息形式']);
        $item['显示时长'] = intval($item['显示时长']);
        $item['固定显示'] = check_sticky($item['固定显示']);
        $item['消息类型'] = check_msgmod($item['消息类型']);
        $item['弹窗警示'] = check_before_open($item['弹窗警示']);
        $item['显示位置'] = check_position($item['显示位置'], $conf_positions);
        $new_message[] = $item;
    }
    return $new_message;
}
コード例 #8
0
function block_delete($id, $return_link = false)
{
    global $_CLASS;
    $result = $_CLASS['core_db']->query('SELECT block_order, block_type, block_position FROM ' . BLOCKS_TABLE . ' WHERE block_id=' . $id);
    $block = $_CLASS['core_db']->fetch_row_assoc($result);
    $_CLASS['core_db']->free_result($result);
    if (!$block || $block['block_type'] == BLOCKTYPE_SYSTEM) {
        trigger_error($block ? 'BLOCK_NOT_DELETABLE' : 'BLOCK_NOT_FOUND');
    }
    check_position($block['block_position']);
    if (display_confirmation()) {
        $_CLASS['core_db']->query('DELETE from ' . BLOCKS_TABLE . ' where block_id = ' . $id);
        $result = $_CLASS['core_db']->query('UPDATE ' . BLOCKS_TABLE . ' SET block_order = block_order-1 WHERE block_position=' . $block['block_position'] . ' AND block_order > ' . $block['block_order']);
        $_CLASS['core_cache']->destroy('blocks');
        if ($return_link) {
            trigger_error('Block deleted<br/><a href="' . $return_link . '">Click here to return</a>');
        }
    }
    if ($return_link) {
        redirect($return_link);
    }
}
コード例 #9
0
function block_content_cache($id, &$message)
{
    global $_CLASS;
    $result = $_CLASS['core_db']->query('SELECT block_content, block_position, block_title, block_type FROM ' . CORE_BLOCKS_TABLE . ' WHERE block_id = ' . $id);
    $block = $_CLASS['core_db']->fetch_row_assoc($result);
    $_CLASS['core_db']->free_result($result);
    if (!$block) {
        trigger_error('BLOCK_NOT_FOUND');
    }
    if ($block['block_type'] != BLOCKTYPE_FEED) {
        trigger_error('BLOCK_NO_CACHE');
    }
    $message = $_CLASS['core_user']->get_lang('CACHE_REMOVED_FOR') . ' RSS Block<br/><i>' . $block['block_title'] . '<i>';
    if ($block['block_content'] !== '') {
        check_position($block['block_position']);
        $result = $_CLASS['core_db']->query('UPDATE ' . CORE_BLOCKS_TABLE . " SET block_content = '' WHERE block_id = {$id}");
        $_CLASS['core_cache']->destroy('blocks');
    }
}
コード例 #10
0
function block_order($id, $option)
{
    global $_CLASS;
    if (!in_array($option, array('down', 'up', 'bottom', 'top'))) {
        return;
    }
    $result = $_CLASS['core_db']->query('SELECT block_position, block_order FROM ' . CORE_BLOCKS_TABLE . ' WHERE block_id= ' . $id);
    $block = $_CLASS['core_db']->fetch_row_assoc($result);
    $_CLASS['core_db']->free_result($result);
    if (!$block) {
        trigger_error('BLOCK_NOT_FOUND');
    }
    check_position($block['block_position']);
    settype($block['block_order'], 'integer');
    switch ($option) {
        case 'down':
            $result = $_CLASS['core_db']->query('SELECT MAX(block_order) as block_order FROM ' . CORE_BLOCKS_TABLE . ' WHERE block_position=' . $block['block_position']);
            list($max_order) = $_CLASS['core_db']->fetch_row_num($result);
            $_CLASS['core_db']->free_result($result);
            if ($block['block_order'] < $max_order) {
                $result = $_CLASS['core_db']->query('UPDATE ' . CORE_BLOCKS_TABLE . ' SET block_order = block_order-1 WHERE block_position = ' . $block['block_position'] . ' AND block_order=' . ($block['block_order'] + 1));
                $result = $_CLASS['core_db']->query('UPDATE ' . CORE_BLOCKS_TABLE . ' SET block_order = ' . ($block['block_order'] + 1) . ' WHERE block_id =' . $id);
                $_CLASS['core_cache']->destroy('blocks');
            }
            break;
        case 'bottom':
            $result = $_CLASS['core_db']->query('SELECT MAX(block_order) as block_order FROM ' . CORE_BLOCKS_TABLE . ' WHERE block_position=' . $block['block_position']);
            list($max_order) = $_CLASS['core_db']->fetch_row_num($result);
            $_CLASS['core_db']->free_result($result);
            if ($block['block_order'] < $max_order) {
                $result = $_CLASS['core_db']->query('UPDATE ' . CORE_BLOCKS_TABLE . ' SET block_order = block_order-1 WHERE block_position=' . $block['block_position'] . ' AND block_order > ' . $block['block_order']);
                $result = $_CLASS['core_db']->query('UPDATE ' . CORE_BLOCKS_TABLE . ' SET block_order = ' . $max_order . ' WHERE block_id = ' . $id);
                $_CLASS['core_cache']->destroy('blocks');
            }
            break;
        case 'up':
            if ($block['block_order'] && $block['block_order'] != 1) {
                $result = $_CLASS['core_db']->query('UPDATE ' . CORE_BLOCKS_TABLE . ' SET block_order = block_order+1 WHERE block_position=' . $block['block_position'] . ' AND block_order = ' . ($block['block_order'] - 1));
                $result = $_CLASS['core_db']->query('UPDATE ' . CORE_BLOCKS_TABLE . ' SET block_order=' . ($block['block_order'] - 1) . ' WHERE block_id =' . $id);
                $_CLASS['core_cache']->destroy('blocks');
            }
            break;
        case 'top':
            if ($block['block_order'] != 1) {
                $result = $_CLASS['core_db']->query('UPDATE ' . CORE_BLOCKS_TABLE . ' SET block_order = block_order+1 WHERE block_position=' . $block['block_position'] . ' AND block_order < ' . $block['block_order']);
                $result = $_CLASS['core_db']->query('UPDATE ' . CORE_BLOCKS_TABLE . ' SET block_order = 1 WHERE block_id = ' . $id);
                $_CLASS['core_cache']->destroy('blocks');
            }
            break;
    }
}