Esempio n. 1
0
                    		}
                    		.$now_viewing
                    		*/
                } else {
                    $img = 'unlocked';
                    $now_viewing = '';
                    $last_post = 'N/A';
                }
                $HTMLOUT .= '<tr>
		<td align="left" class="' . $class . '">
		<table border="0" cellspacing="0" cellpadding="0">
		<tr>
		<td class="' . $class . '" align="left" width="30"><img src="pic/forums/' . $img . '.gif" alt="' . $img . '" title="Unlocked" /></td>
		<td class="' . $class . '" align="left">
		' . bubble('<span style="font-weight: bold;"><a class="altlink" href="?action=view_forum&amp;forum_id=' . $arr_forums['real_forum_id'] . '">
		' . $forum_name . '</a></span>', '<span style="font-size: x-small;">' . $forum_name . '</span>
		' . $forum_description) . ($CURUSER['class'] >= UC_ADMINISTRATOR ? '<span style="font-size: x-small;"> 
		[<a class="altlink" href="staffpanel.php?tool=forum_manage&amp;action=forum_manage&amp;action2=edit_forum_page&amp;id=' . $forum_id . '">Edit</a>] 
		[<a class="altlink" href="javascript:confirm_delete(\'' . $forum_id . '\');">Delete</a>]</span>' : '') . '<br />
		<span style="font-size: x-small;"> ' . $forum_description . '</span>' . $child_boards . '</td>
		</tr>
		</table>
		</td>
		<td class="' . $class . '" align="center" width="80"><span style="font-size: x-small;">' . $post_count . ' Posts<br />' . $topic_count . ' Topics</span></td>
		<td class="' . $class . '" align="left" width="140"><span style="font-size: x-small;">' . $last_post . '</span></td>
		</tr>';
            }
            //== end of sectioon
            $over_forum_id = $arr_forums['over_forum_id'];
            $child_boards = '';
        }
Esempio n. 2
0
function show_params_cat($r, $h)
{
    $ron = 1;
    $fon = 0;
    $j = 'lang_admin*restrictions_';
    foreach ($r as $k => $v) {
        $hlp = bubble('txtsmall2', 'popmsqt', $j . $k . '_description', $k);
        $t = $h[$k][0] ? $h[$k][0] : $v;
        if (rstr($k)) {
            $n = 1;
            $c = '';
        } else {
            $n = 0;
            $c = 'active';
        }
        $ret[] = offon($n) . ' ' . btn($cx, lj('', 'rstr_params___' . $k . '_' . $n, $t)) . $hlp . br();
    }
    return divc('nbp', colonize($ret, 3, '', '', 550));
}
Esempio n. 3
0
    <td valign="middle" align="left">
    ' . bubble('<b>' . $lang['mega_invite'] . '</b>', $lang['mega_invite_1']) . '</td>
    </tr>
    <tr>
    <td align="left"><input type="text" name="invite_code" size="70" value="' . $invite_code . '" /></td>
    </tr>
    <tr>
    <td align="left"><input type="submit" class="button" value="' . $lang['mega_search_btn'] . '" onmouseover="this.className=\'button_hover\'" onmouseout="this.className=\'button\'" /></td>
    </tr>
    </table>
    </form>
    <form method="post" action="staffpanel.php?tool=mega_search&amp;action=mega_search">
    <table class="table table-bordered">
    <tr>
    <td valign="middle" align="left">
    ' . bubble('<b>' . $lang['mega_names'] . '</b>', $lang['mega_names_1']) . '</td>
    </tr>
    <tr>
    <td align="left"><textarea name="user_names" rows="4" cols="70">' . $user_names . '</textarea></td>
    </tr>
    <tr>
    <td align="left"><input type="submit" class="button" value="' . $lang['mega_search_btn'] . '" onmouseover="this.className=\'button_hover\'" onmouseout="this.className=\'button\'" /></td>
    </tr>
    </table>
    </form>';
//=== if searching for usernames
if (isset($_POST['user_names'])) {
    //=== make the $_POST into a nice array and remove all non alpha numeric stuff 'cept  _ & -
    $searched_users = array(explode(' ', $user_names));
    foreach ($searched_users[0] as $search_users) {
        $search_users = trim($search_users);
Esempio n. 4
0
function get_re($DiscussID = "")
{
    global $xoopsDB, $MyWebs, $TadUpFiles;
    if (empty($DiscussID)) {
        return;
    }
    $sql = "select * from " . $xoopsDB->prefix("tad_web_discuss") . " where ReDiscussID='{$DiscussID}' order by DiscussDate";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
    $re_data = "";
    while ($all = $xoopsDB->fetchArray($result)) {
        //以下會產生這些變數: $DiscussID , $ReDiscussID , $MemID , $DiscussTitle , $DiscussContent , $DiscussDate , $WebID , $LastTime , $DiscussCounter
        foreach ($all as $k => $v) {
            ${$k} = $v;
        }
        if (!empty($uid)) {
            $TadUpFiles->set_col("WebOwner", $WebID, "1");
            $pic = $TadUpFiles->get_pic_file("thumb");
            if (empty($pic)) {
                $pic = "images/nobody.png";
            }
        } else {
            $TadUpFiles->set_col("MemID", $MemID, "1");
            $pic = $TadUpFiles->get_pic_file("thumb");
            $M = get_tad_web_mems($MemID);
            if (empty($pic)) {
                $pic = $M['MemSex'] == '1' ? XOOPS_URL . "/modules/tad_web/images/boy.gif" : XOOPS_URL . "/modules/tad_web/images/girl.gif";
            }
        }
        $fun = isMineDiscuss($MemID) ? "<div style='font-size:12px;'>\n  \t<a href='{$_SERVER['PHP_SELF']}?WebID={$WebID}&op=tad_web_discuss_form&DiscussID={$DiscussID}'>" . _TAD_EDIT . "</a> | <a href=\"javascript:delete_tad_web_discuss_func({$DiscussID});\">" . _TAD_DEL . "</a>\n  \t</div>" : "";
        $DiscussContent = nl2br($DiscussContent);
        $DiscussContent = bubble($DiscussContent);
        $re_data .= "<tr><td style='line-height:180%;'>\n    {$DiscussContent}\n    <img src='{$pic}' alt='{$MemName}" . _MD_TCW_DISCUSS_REPLY . "' style='margin:0px 15px 0px 30px;float:left;' class='img-rounded img-polaroid'>\n    <div style='line-height:1.5em;'>\n      <div>{$MemName}</div><div style='font-size:12px;'>{$DiscussDate}</div>{$fun}\n    </div>\n    <div style='clean:both;'></div>\n    </td></tr>";
    }
    $re = "";
    if (!empty($re_data)) {
        $re = "\n  \t<table>\n  \t{$re_data}\n  \t</table>\n    ";
    }
    return $re;
}
Esempio n. 5
0
<?php

$fh = fopen($argv[1], 'r');
$track = array();
function bubble($numbers)
{
    $sorted = false;
    for ($i = 0; $i < count($numbers) - 1; $i++) {
        if ($numbers[$i] > $numbers[$i + 1]) {
            $sorted = true;
            $temp = $numbers[$i];
            $numbers[$i] = $numbers[$i + 1];
            $numbers[$i + 1] = $temp;
        }
    }
    return array($sorted, $numbers);
}
while (false !== ($line = fgets($fh))) {
    list($numbers, $iterations) = explode('|', trim($line));
    $numbers = explode(' ', trim($numbers));
    $iterations = trim($iterations);
    for ($i = 1; $i <= $iterations; $i++) {
        list($sorted, $numbers) = bubble($numbers);
        if (!$sorted) {
            break;
        }
    }
    echo join(' ', $numbers) . PHP_EOL;
}
Esempio n. 6
0
File: art.php Progetto: philum/cms
function conn_props()
{
    $pad = plugin('keyboard', 'txtarea');
    $r = array('html', 'arts', 'media', 'tools', 'filters', 'del', 'msql', 'codeline', 'backup');
    foreach ($r as $k => $v) {
        $ret .= togbub('navs', $v, $v, '', $v == 'del' ? 1 : '');
    }
    //
    $r = array('ascii', 'pictos', 'icons', 'disk');
    foreach ($r as $k => $v) {
        $ret .= bubble('', 'navs', $v, $v);
    }
    return $ret . togbub('navs', 'uc', 'uc') . $pad . br();
}
Esempio n. 7
0
	Maurэcio Sipmann (sipmann@gmail.com)
Tipo: 
	sorting
Descriчуo: 
	Varre o vetor comparando cada um dos pares de nњmeros
	possэveis e trocando suas posiчѕes no vetor se necessсrio
Complexidade:
	Pior caso: O(nВ)
	Melhor caso: O(nВ)
Dificuldade:
	facil
Referъncias:
	http://en.wikipedia.org/wiki/Bubble_sort
*/
function bubble($valores)
{
    $ordenado = false;
    for ($i = 0; $i < count($valores); $i++) {
        for ($x = 0; $x < count($valores); $x++) {
            if ($valores[$i] < $valores[$x]) {
                $tmp = $valores[$i];
                $valores[$i] = $valores[$x];
                $valores[$x] = $tmp;
            }
        }
    }
    return $valores;
}
// Passando um array com valores a serem ordenados
print_r(bubble(array(5, 2, 1, 9, 3, 6, 8, 7, 4, 10, 20, 13, 17, 11, 12, 18, 14, 16, 19, 15)));
Esempio n. 8
0
<?php

function bubble($str, $strlen)
{
    $string = explode(" ", trim($str));
    //var_dump($string);
    for ($i = 1; $i < $strlen; $i++) {
        for ($j = 0; $j < $strlen - $i; $j++) {
            if ($string[$j] >= $string[$j + 1]) {
                $tmp = $string[$j];
                $string[$j] = $string[$j + 1];
                $string[$j + 1] = $tmp;
            }
        }
    }
    var_dump($string);
}
$handle = fopen("php://stdin", "r");
$strlen = fgets($handle);
$str = fgets($handle);
fclose($handle);
bubble($str, $strlen);
Esempio n. 9
0
#!/usr/bin/env php
<?php 
echo "Content-type: text/html\n\n";
echo "<html><head><title>PHP冒泡排序测试</title></head><body><pre>";
function bubble(array $array)
{
    for ($i = 0, $len = count($array) - 1; $i < $len; ++$i) {
        for ($j = $len; $j > $i; --$j) {
            if ($array[$j] < $array[$j - 1]) {
                $temp = $array[$j];
                $array[$j] = $array[$j - 1];
                $array[$j - 1] = $temp;
            }
        }
    }
    return $array;
}
print_r(bubble(array(23, 45, 67, 3, 56, 82, 24, 23, 5, 77, 19, 33, 51, 99)));
echo "</pre></body></html>";
Esempio n. 10
0
File: admin.php Progetto: philum/cms
function adm_params($curauth, $rep)
{
    $auth = ses('auth');
    $goto = '/?admin=params';
    $qb = ses('qb');
    req('boot,adminx');
    connect();
    //$db
    if ($auth > 6 && $_GET['m_cnfg'] == '=') {
        $mcfg = '&m_cnfg==';
        $f = 'params/_' . $db . '_config.txt';
        if (is_file($f)) {
            $prms = explode('#', read_file($f));
        }
        $arr = msql_read_prep('system', 'admin_config');
        $hl = 'lang_admin*config_';
    } else {
        $prms = $_SESSION['prmb'];
        $prmb = sql('config', 'qdu', 'v', 'name="' . ses('qb') . '"');
        $prms = explode('#', $prmb);
        $prms = prmb_defaults($prms);
        $arr = msql_read_prep('system', 'admin_params');
        $hl = 'lang_admin*params_';
    }
    if ($_GET['params'] == 'save' && $auth >= $curauth) {
        for ($i = 0; $i <= $_POST['valmax']; $i++) {
            $prms[$i] = $_POST['pms' . $i];
            $vaue .= $prms[$i] . '#';
        }
        if ($prms[1] != prmb(1) && !$_GET['m_cnfg']) {
            newmodfrom($prms[1]);
        }
        if ($_GET['m_cnfg'] == '=') {
            write_file($f, $vaue);
            update('qdu', 'struct', $vaue, 'name', $qb);
            master_params('params/_' . $db, $qd, $aqb, $subd);
            alert(lkt('txtyl', $f, $db . '_config'));
        } else {
            $_SESSION['prmb'] = $prms;
            update('qdu', 'config', $vaue, 'name', $qb);
        }
    }
    $sty = '" style="width:200px;';
    //read
    foreach ($arr as $t => $ak) {
        foreach ($ak as $i => $v) {
            if ($i != 22) {
                if ($valmax < $i) {
                    $valmax = $i;
                }
                $attr = array('name' => 'pms' . $i, 'style' => 'width:200px;');
                if ($i == 11 && !$_GET['m_cnfg']) {
                    //$r[$t].=menuder_form_kv(affect_auth($auth),'pms'.$i.$sty,$prms[$i],'kv');
                    $r[$t] .= select($attr, affect_auth($auth), 'kv', $prms[$i]);
                } elseif ($i == 25) {
                    $lc = 'msql/lang/';
                    $dirs = explore($lc, 'dirs', 1);
                    $dirs = str_replace($lc, '', $dirs);
                    //$r[$t].=menuder_form_kv($dirs,'pms'.$i.$sty,$prms[$i],'vv').' ';
                    $r[$t] .= select($attr, $dirs, 'vv', $prms[$i]);
                } elseif ($i == 21) {
                    $r[$t] .= txarea('pms' . $i, $prms[$i], 31, 5) . ' ';
                } else {
                    $r[$t] .= input2('text" size="34', 'pms' . $i, $prms[$i], '') . ' ';
                }
                $r[$t] .= btn('txtblc', $v) . ' ' . btn('txtsmall2', bubble('grey', 'popmsqt', $hl . $i, $i)) . br();
            }
        }
    }
    $r[$t] .= hidden('valmax', '', $valmax) . br();
    $ret = form($goto . $mcfg . '&params=save', make_tabs($r, 'prm') . input2('submit', 'Submit', nms(27), '')) . br();
    if ($auth > 6 && !$mcfg) {
        $ret .= lkc('txtbox', $goto . '&m_cnfg==', 'server') . ' ' . backup_config();
    }
    return $ret;
}
Esempio n. 11
0
    ' . bubble('<b>Invite Code:</b>', 'To search for an invite code, use this box. It will show you who make the code, and who used it!') . '</td>
    </tr>
    <tr>
    <td align="left"><input type="text" name="invite_code" size="70" value="' . $invite_code . '" /></td>
    </tr>
    <tr>
    <td align="left"><input type="submit" class="button" value="Search!" onmouseover="this.className=\'button_hover\'" onmouseout="this.className=\'button\'" /></td>
    </tr>
    </table>
    </form>
    <form method="post" action="staffpanel.php?tool=mega_search&amp;action=mega_search">
    <table width="100%" border="0" cellspacing="5" cellpadding="5" align="center">
    <tr>
    <td valign="middle" align="left">
    ' . bubble('<b>User Names:</b>', 'Use this section to search for multiple usernames. The search is not case sensitive, 
    but you must seperate all usernames with a space! 
    Line breaks are ignored as are any non alpha numeric charecters except - and  _') . '</td>
    </tr>
    <tr>
    <td align="left"><textarea name="user_names" rows="4" cols="70">' . $user_names . '</textarea></td>
    </tr>
    <tr>
    <td align="left"><input type="submit" class="button" value="Search!" onmouseover="this.className=\'button_hover\'" onmouseout="this.className=\'button\'" /></td>
    </tr>
    </table>
    </form>';
//=== if searching for usernames
if (isset($_POST['user_names'])) {
    //=== make the $_POST into a nice array and remove all non alpha numeric stuff 'cept  _ & -
    $searched_users = array(explode(' ', $user_names));
    foreach ($searched_users[0] as $search_users) {
<?php

$init = round(microtime(true) * 1000);
for ($c = 0; $c < 1000000; $c++) {
    bubble();
}
$end = round(microtime(true) * 1000);
echo $end - $init;
function bubble()
{
    $arrayb = [3, 4, 1, 3, 5, 1, 92, 2, 4124, 424, 52, 12];
    $size = sizeof($arrayb);
    // 	for($i = 0; $i < $size; $i ++) {
    // 		for($y = 0; $y < ($size - 1); $y ++) {
    // 			if ($arrayb [$y + 1] < $arrayb [$y]) {
    // 				$t = $arrayb [$y];
    // 				$arrayb [$y] = $arrayb [$y + 1];
    // 				$arrayb [$y + 1] = $t;
    // 			}
    // 		}
    // 	}
    sort($arrayb);
}