Пример #1
0
    public function view()
    {
        global $user;
        $cfg = new config();
        $main = new main();
        if (empty($_GET['detail'])) {
            if (isset($_GET['type'])) {
                $type = intval($_GET['type']);
            } else {
                $type = 0;
            }
            if (isset($_GET['sort'])) {
                $sort = intval($_GET['sort']);
            } else {
                $sort = 1;
            }
            if ($type > 0 && $type < 3) {
                $href = "index.php?a=list&type=" . $type;
            } else {
                $href = "index.php?a=list";
            }
            $sortto = 'desc';
            if (isset($_GET['sortto']) && ($_GET['sortto'] == "desc" || $_GET['sortto'] == "asc")) {
                if (isset($_GET['last']) && $_GET['last'] == $sort) {
                    $_GET['sortto'] == "desc" ? $sortto = 'asc' : ($sortto = 'desc');
                }
            }
            $mass = array(1 => array("30px", "#"), 2 => array("513px", "Заголовок"), 3 => array("120px", "Отправитель"), 4 => array("100px", "Прогресс"), 5 => array("100px", "Статус"), 6 => array("100px", "Приоритет"));
            $text = '
			<table height="100%" border="0" cellpadding="0" cellspacing="0" align="left">
			 <tr>';
            for ($i = 1; $i < count($mass) + 1; $i++) {
                if ($i == 4 && $cfg->get("progressbar") || $i != 4) {
                    $text .= '<td style="width:' . $mass[$i][0] . ';background-color:#666;" onClick="window.location.href=\'' . $href . '&sort=' . $i . '&sortto=' . $sortto . '&last=' . $sort . '\';" onMouseover="this.style.cursor=\'pointer\';this.style.backgroundColor=\'#777\';" onMouseout="this.style.cursor=\'default\';this.style.backgroundColor=\'#666\';"><div class="pad"><b>' . $mass[$i][1] . '</b></div></td>';
                    if ($i != count($mass)) {
                        $text .= '<td width="1px" style="background-color: #000;"></td>';
                    }
                }
            }
            $text .= '
			 </tr>
			</table>';
            $this->blocknot($text);
            $text = '<table width="100%" height="19px" border="0" cellpadding="0" cellspacing="0" align="left">';
            $psort = '';
            if (isset($_GET['sort']) && intval($_GET['sort']) > 0 && $_GET['sort'] > "0" && $_GET['sort'] < "6") {
                if ($_GET['sortto'] == "desc") {
                    $psort = 'desc_' . $sort;
                } else {
                    if ($_GET['sortto'] == "asc") {
                        $psort = 'asc_' . $sort;
                    }
                }
            }
            if ($type == 1) {
                $result = $main->LoadList("new", $psort);
            } else {
                if ($type == 2) {
                    $result = $main->LoadList("my", $psort);
                } else {
                    $result = $main->LoadList("all", $psort);
                }
            }
            $m = 0;
            $js = "";
            $sql = new sql();
            while ($row = $sql->fetch($result)) {
                if ($m > 0) {
                    $text .= '
					<tr style="height:1px;background-color: #000;">
					 <td></td><td></td><td></td>
					 <td></td><td></td><td></td>
					 <td></td><td></td><td></td>';
                    if ($cfg->get("progressbar")) {
                        $text .= '
					 <td></td><td></td>';
                    }
                    $text .= '
					</tr>';
                }
                $all = $main->SelectMessage($row['id']);
                $opt = $main->SelectOptions($row['id']);
                $title = $all['title'];
                $pcn = $main->GetPercent($all);
                $pix = str_replace("%", "", $pcn);
                $stream = 'stream' . $row['id'];
                $width = $cfg->get("anim") == true ? 0 : $pix;
                $img = '<div id="stream' . $m . '" style="height:19px;width:' . $width . 'px;background-color:#006400;"></div>';
                $text .= '
				<tr style="background-color: #666;" onClick="if(tr_select)window.location.href=\'index.php?a=admin&edit=' . $row['id'] . '\';else window.location.href=\'index.php?a=list&detail=' . $row['id'] . '\';" onMouseover="this.style.cursor=\'pointer\';this.style.backgroundColor=\'#888\';" onMouseout="this.style.cursor=\'default\';this.style.backgroundColor=\'#666\';">
				 <td width="' . $mass[1][0] . '" class="view"><div class="pad">' . $row['id'] . '</div></td>
				 <td width="1px" style="background-color: #000;"></td>
				 <td width="' . $mass[2][0] . '" class="view"><div class="pad">' . $title . '</div></td>
				 <td width="1px" style="background-color: #000;"></td>
				 <td width="' . $mass[3][0] . '" class="view"><div class="pad">' . $main->GetNameByGUID(intval($row['sender'])) . '</div></td>
				 <td width="1px" style="background-color: #000;"></td>';
                if ($cfg->get("progressbar")) {
                    $text .= '
				 <td width="' . $mass[4][0] . '" class="view" style="padding:0;margin:0;">' . $img . '</td>
				 <td width="1px" style="background-color: #000;"></td>';
                }
                $text .= '
				 <td width="' . $mass[5][0] . '" class="view"><div class="pad">' . $main->GetStatus($all) . '</div></td>
				 <td width="1px" style="background-color: #000;"></td>
				 <td width="' . $mass[6][0] . '" class="view"><div class="pad">' . $main->GetPriority($all) . '</div></td>
				</tr>';
                if ($cfg->get("anim") && $pix > "0") {
                    $js .= 'streamimg(' . $m . ',' . $pix . ');';
                }
                $m++;
            }
            $text .= '</table>';
            $text .= '<script>' . $js . '</script>';
            if ($m > 1) {
                $this->blocknot($text);
            } else {
                if ($m > 0) {
                    $this->blocknot($text, '', '', 'ultramini');
                }
            }
        } else {
            if (intval($_GET['detail']) > 0) {
                $int = addslashes(intval($_GET['detail']));
                if ($main->isValidSection($int)) {
                    $this->detail($int);
                } else {
                    echo '<META HTTP-EQUIV="REFRESH" CONTENT="0; URL=index.php?a=list">';
                    exit;
                }
            } else {
                if (strlen($_GET['detail']) > 1) {
                    $this->inject(addslashes($_GET['detail']));
                } else {
                    echo '<META HTTP-EQUIV="REFRESH" CONTENT="0; URL=index.php?a=list">';
                    exit;
                }
            }
        }
    }