Example #1
0
function is_token_valid($token = null, $userid = null)
{
    global $mysqli;
    if ($token == null) {
        if (isset($_SESSION["token"])) {
            $token = $_SESSION["token"];
        } else {
            return false;
        }
    }
    if ($userid == null) {
        if (isset($_SESSION["userid"])) {
            $userid = $_SESSION["userid"];
        } else {
            return false;
        }
    }
    connect_mysqli();
    $valid = true;
    switch ($mysqli->query("SELECT `AllowIPChange` FROM `Users` WHERE `ID` = '{$userid}'")->fetch_array()[0]) {
        case 'No':
            $valid = $_SESSION["ip"] == $_SERVER["REMOTE_ADDR"];
            break;
        case 'Minor':
            $valid = substr($_SESSION["ip"], 0, strpos($_SESSION["ip"], '.', strpos($_SESSION["ip"], '.') + 1)) == substr($_SERVER["REMOTE_ADDR"], 0, strpos($_SERVER["REMOTE_ADDR"], '.', strpos($_SERVER["REMOTE_ADDR"], '.') + 1));
            break;
    }
    return $valid && (bool) count_rows("Sessions", "`Token` = '{$token}' AND `User-ID` = {$userid} AND `Valid` = 1", 1);
}
Example #2
0
     $order_db = $order_p['namea'][1];
 }
 /*  параметры для сортировки    */
 //постраничная навигация, параметры
 $perpage = PERPAGE;
 //кол-во товаров на страницу
 if (isset($_GET['page'])) {
     $page = (int) $_GET['page'];
     if ($page < 1) {
         $page = 1;
     }
 } else {
     // пусто в адресной строке нет page
     $page = 1;
 }
 $count_rows = count_rows($category);
 //общее кол-во товаров данной категории
 $pages_count = ceil($count_rows / $perpage);
 //кол-во страниц, частное от деления. ceil  -округляет
 if (!$pages_count) {
     $pages_count = 1;
 }
 //проверяем чтоб общее кол-во страниц не было < 1, еслипользователь введет несуществующую категорию.
 //минимум 1 страница должна быть
 if ($page > $pages_count) {
     $page = $pages_count;
 }
 //если пользователь в адресную строку введет число большее чем реальное кол-во страниц
 $start_position = ($page - 1) * $perpage;
 //начальная позиция вывода товара (для запроса)
 //хлебные крошки, считаем имя родителя
Example #3
0
<?php 
echo $meta;
?>
</head>
<body>

<?php 
if ($errors = input_errors()) {
    echo $errors;
} else {
    $rows_per_page = 100;
    $url = htmlentities($_SERVER['REQUEST_URI']);
    $sqlresult = build_runselect_sql($_GET);
    $sql = $sqlresult['sql'];
    $binds = $sqlresult['binds'];
    $total_rows = count_rows($conn, $sql, $binds);
    $sum_events = fetch_sum_events($sqlresult);
    if ($total_rows == 0) {
        echo "<h3>No results found.</h3>";
    } else {
        $total_pages = total_pages($total_rows, $rows_per_page);
        // Set the page number
        if (isset($_GET['page'])) {
            $page = $_GET['page'];
        }
        if (!isset($_GET['page']) || !preg_match('/^[0-9]+$/', $_GET['page']) || $_GET['page'] < 1) {
            $page = 1;
        } else {
            if ($_GET['page'] > $total_pages) {
                $page = $total_pages;
            }
Example #4
0
*******************************************************************************/
require_once "includes/common.php";
?>

<head>
<link rel = stylesheet href = includes/widgets/style.css>
	<title>Viewing slave.</title>
</head>

<body class = "noBgImage">

<?php 
$slave = $HTTP_GET_VARS['slave'];
$result = db_query("SELECT * FROM tycoonism_slaves WHERE name = '" . $slave . "' LIMIT 1");
if (count_rows($result) == 0) {
    message(TYPE_ERROR, 'Cannot get slave info.');
}
while ($row = mysql_fetch_array($result)) {
    if ($userdata['gold'] < $row['gold']) {
        die("This slave costs " . $row['gold'] . " gold, and you only have " . $userdata['gold'] . " gold. Come back another day. </body>");
    }
    switch ($submit) {
        case 'buy slave':
            echo "<strong>Slave: </strong>" . $row['name'] . "<hr>";
            $result = db_query("UPDATE tycoonism_slaves SET `owner` = '" . $_SESSION['username'] . "' WHERE `id` = '" . $row['id'] . "'");
            $result = db_query("UPDATE tycoonism_users SET `gold` = (`gold` - " . $row['gold'] . ") WHERE `username` = '" . $_SESSION['username'] . "' LIMIT 1");
            die("Thanks for buying " . $row['name'] . ".");
            break;
        case 'sell slave':
            echo "<strong>Slave: </strong>" . $row['name'] . "<hr>";
Example #5
0
switch ($advisor) {
    case 'slaves':
        $result = $db->query("SELECT * FROM slaves WHERE user = '******'username'] . "'");
        if ($result->numRows() == 0) {
            echo "You dont have any slaves, prehaps you should invest in some?";
        } else {
            echo "You have <strong>" . $result->numRows() . "</strong> slaves. Keep your number of slaves up.";
        }
        break;
    case 'business':
        $result = $db->query("SELECT * FROM inventory WHERE owner = '" . $_SESSION['username'] . "' AND type = 'BUSINESS'");
        if ($result->numRows() <= 0) {
            echo "You've no businesses! Go to the shop, and buy some to start making money!";
            echo "<br /><br /><strong>Overall</strong>: Bad";
        } else {
            echo "You have </strong>" . count_rows($result) . "</strong> businsesses, nice going.";
            echo "<br /><br /><strong>Overall</strong>: Good";
        }
        break;
    case 'financial':
        if (\libAllure\Session::getUser()->getData('gold') <= 0) {
            echo "We are in debt! Try raising some more cash.";
            echo "<br /><br /><strong>Overall</strong>: Bad";
        } else {
            echo "We are not in debt, but make more money!";
            echo "<br /><br /><strong>Overall</strong>: Good";
        }
        break;
    case 'rankings':
        $turns = get_turns($_SESSION['username']);
        $rank = intval($turns['total_turns'] * $user->getData('gold') / 10000);
Example #6
0
     }
     if (is_adminer_ajax()) {
         exit;
     }
     echo "</table>\n";
 }
 if (($rows || $page) && !is_adminer_ajax()) {
     $exact_count = true;
     if ($_GET["page"] != "last") {
         if (!+$limit) {
             $found_rows = count($rows);
         } elseif ($jush != "sql" || !$is_group) {
             $found_rows = $is_group ? false : found_rows($table_status, $where);
             if ($found_rows < max(10000.0, 2 * ($page + 1) * $limit)) {
                 // slow with big tables
                 $found_rows = reset(slow_query(count_rows($TABLE, $where, $is_group, $group)));
             } else {
                 $exact_count = false;
             }
         }
     }
     if (+$limit && ($found_rows === false || $found_rows > $limit || $page)) {
         echo "<p class='pages'>";
         // display first, previous 4, next 4 and last page
         $max_page = $found_rows === false ? $page + (count($rows) >= $limit ? 2 : 1) : floor(($found_rows - 1) / $limit);
         if ($jush != "simpledb") {
             echo '<a href="' . h(remove_from_uri("page")) . "\" onclick=\"pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "'), event); return false;\">" . lang('Page') . "</a>:";
             echo adminer_pagination(0, $page) . ($page > 5 ? " ..." : "");
             for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
                 echo adminer_pagination($i, $page);
             }
Example #7
0
function cheakrow()
{
    session_start();
    $user = $_SESSION['user_id'];
    $query = "SELECT * FROM cart WHERE userid = '{$user}'";
    $row = count_rows($query);
    $result = db_result($query);
    $data = array();
    while ($rows = mysqli_fetch_object($result)) {
        $data[] = $rows;
    }
    if (!empty($row)) {
        return '(' . $row . ')';
    } else {
        return '(empty)';
    }
    return $data;
}
Example #8
0
            echo "<h3><a href='?page=shop&category=" . $cat['cat_id'] . "'>" . $cat['name'] . "</a></h3>";
            echo "<a href='?page=shop&category=" . $cat['cat_id'] . "'><img src='images/default/" . $cat['img'] . "' width='200' height='150'  alt='" . $cat['name'] . "'/></a>";
            echo "</div>";
        }
        echo "<div class='cleaner'></div>";
    }
} else {
    if (isset($_GET['pages'])) {
        $pages = (int) $_GET['pages'];
        if ($pages < 1) {
            $pages = 1;
        }
    } else {
        $pages = 1;
    }
    $count_rows = count_rows($cat_id);
    // общее кол-во товаров
    $pages_count = ceil($count_rows / $perpage);
    // кол-во страниц
    if (!$pages_count) {
        $pages_count = 1;
    }
    // минимум 1 страница
    if ($pages > $pages_count) {
        $pages = $pages_count;
    }
    // если запрошенная страница больше максимума
    $start_pos = ($pages - 1) * $perpage;
    $query = mysql_query("SELECT * FROM goods WHERE cat_id=" . $cat_id . " AND visible='1' UNION (SELECT * FROM goods WHERE cat_id IN (SELECT cat_id FROM category WHERE podcat_id=" . $cat_id . ") AND visible='1') LIMIT " . $start_pos . ", " . $perpage . "", $db);
    $query2 = mysql_query("SELECT * FROM category WHERE cat_id=" . $cat_id . "", $db);
    $cat2 = mysql_fetch_array($query2);
Example #9
0
  You should have received a copy of the GNU General Public License
  along with pFrog; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*******************************************************************************/
require_once "includes/common.php";
$title = "slaves";
require_once "includes/widgets/header.php";
$sql = "SELECT * FROM slaves WHERE `user` = '" . \libAllure\Session::getUser()->getUsername() . "'";
$result = $db->query($sql);
$slaves = $result->numRows();
startBox("Slaves", BOX_GREEN);
echo "You currently have <strong>" . $slaves . "</strong> slaves.";
echo "<ul>";
while ($row = $result->fetchRow()) {
    popup("<li>" . $row['name'] . "</li>", "view_slave.php?slave=" . $row['name']);
}
echo "</ul>";
stopBox(BOX_GREEN);
$sql = 'SELECT * FROM slaves WHERE user = ""';
$result = $db->query($sql);
if ($result->numRows() == 0) {
    startBox("Slave Shop", BOX_RED);
    echo "There are are not any slaves for sale.";
} else {
    startBox("Slave Shop", BOX_GREEN);
    echo "There are <strong>" . count_rows($result) . "</strong> slaves for sale. <a href = shop.php?mode=slaves>buy some</a>.";
}
stopBox(BOX_NULL);
require_once "includes/widgets/footer.php";
Example #10
0
function show_historic_time()
{
    global $livedb, $page, $sort, $filter, $sys, $view, $datestart, $dateend, $Config, $TLDBlockList;
    global $datestart, $dateend;
    $rows = 0;
    $row_class = '';
    $action = '';
    $blockreason = '';
    $rows = count_rows('SELECT COUNT(*) FROM historic' . add_filterstr() . add_datestr());
    if (($page - 1) * ROWSPERPAGE > $rows) {
        $page = 1;
    }
    $query = 'SELECT * FROM historic' . add_filterstr() . add_datestr() . ' ORDER BY log_time ' . $sort . ' LIMIT ' . ROWSPERPAGE . ' OFFSET ' . ($page - 1) * ROWSPERPAGE;
    if (!($result = $livedb->query($query))) {
        die('There was an error running the query' . $livedb->error);
    }
    if ($result->num_rows == 0) {
        //Leave if nothing found
        $result->free();
        echo "Nothing found for the selected dates";
        return false;
    }
    echo '<div class="sys-group">' . PHP_EOL;
    pagination($rows, htmlspecialchars('view=' . $view . '&sort=' . strtolower($sort) . '&filter=' . $filter . '&sys=' . $sys . '&datestart=' . $datestart . '&dateend=' . $dateend));
    draw_viewbuttons();
    echo '<table id="query-time-table">' . PHP_EOL;
    echo '<tr><th>Time<a href="?' . htmlspecialchars('page=' . $page . '&view=' . $view . '&sort=desc&filter=' . $filter . '&sys=' . $sys . '&datestart=' . $datestart . '&dateend=' . $dateend) . '">&#x25BE;</a><a href="?' . htmlspecialchars('page=' . $page . '&view=' . $view . '&sort=asc&filter=' . $filter . '&sys=' . $sys . '&datestart=' . $datestart . '&dateend=' . $dateend) . '">&#x25B4;</a></th><th>System</th><th>Site</th><th>Action</th></tr>' . PHP_EOL;
    while ($row = $result->fetch_assoc()) {
        //Read each row of results
        $action = '<a target="_blank" href="' . $Config['SearchUrl'] . $row['dns_request'] . '"><img class="icon" src="./images/search_icon.png" alt="G" title="Search"></a>&nbsp;<a target="_blank" href="' . $Config['WhoIsUrl'] . $row['dns_request'] . '"><img class="icon" src="./images/whois_icon.png" alt="W" title="Whois"></a>&nbsp;';
        if ($row['dns_result'] == 'A') {
            $row_class = '';
            $action .= '<span class="pointer"><img src="./images/report_icon.png" alt="Rep" title="Report Site" onclick="ReportSite(\'' . $row['dns_request'] . '\', false)"></span>';
        } elseif ($row['dns_result'] == 'B') {
            $row_class = ' class="blocked"';
            $action .= '<span class="pointer"><img src="./images/report_icon.png" alt="Rep" title="Report Site" onclick="ReportSite(\'' . $row['dns_request'] . '\', true)"></span>';
        } elseif ($row['dns_result'] == 'L') {
            $row_class = ' class="local"';
            $action = '&nbsp;';
        }
        echo '<tr' . $row_class . '><td>' . $row['log_time'] . '</td><td>' . $row['sys'] . '</td><td>' . $row['dns_request'] . $blockreason . '</td><td>' . $action . '</td></tr>' . PHP_EOL;
        $blockreason = '';
    }
    echo '</table>' . PHP_EOL;
    echo '</div>' . PHP_EOL;
    $result->free();
    return true;
}
Example #11
0
<?php

function count_rows($pix)
{
    $rows = 0;
    foreach ($pix as $r) {
        $rows++;
    }
    return $rows;
}
function count_objects($pix)
{
    $objects = 0;
    foreach ($pix as $r) {
        foreach ($r as $o) {
            $objects++;
        }
    }
    return $objects;
}
$im = new Imagick('magick:rose');
$it1 = new ImagickPixelIterator($im);
$it2 = ImagickPixelIterator::getPixelIterator($im);
echo (count_rows($it1) == count_rows($it2) ? "match" : "no") . PHP_EOL;
echo (count_objects($it1) == count_objects($it2) ? "match" : "no") . PHP_EOL;
$it1->newPixelIterator(new Imagick('magick:rose'));
echo 'done' . PHP_EOL;
                            if ($value3['type'] != 'comment') {
                                $textarea = true;
                                $modx_input = '<span id="' . $dd_id . '_field"><textarea class="inputbox right-tools" id="' . $dd_id . '_data" name="modx[' . $file_id . '][' . $edit_id . '][' . $dl_id . '][data]" rows="' . count_rows($value3['data'], 85) . '">' . gen_value($value3['data']) . '</textarea></span>';
                                if ($value3['type'] == 'find') {
                                    $modx_img = '<img id="' . $dd_id . '_info" class="action-image" src="' . $imageset_path . '/modx_info.png" alt="Find explain" title="Find tags in the MODX file should be in the order that the find targets appear in the file. In other words, a processor of the MODX file should never need to go backwards in the file to locate all of the finds. When there are multiple finds within a single edit tag, the processor should handle all finds before any actions." />';
                                } else {
                                    if ($value3['type'] == 'remove') {
                                        $modx_img = '<img id="' . $dd_id . '_info" class="action-image" src="' . $imageset_path . '/modx_info.png" alt="Find and delete explain" title="Remove tags should either be alone in the edit tag or preceded by one find to be sure to delete the right code." />';
                                    } else {
                                        $modx_img = '<img id="' . $dd_id . '_info" class="action-image" src="' . $imageset_path . '/modx_info.png" alt="Action explain" title="The string to add before the find, add after the find, replace the find with, or the operation string." />';
                                    }
                                }
                            } else {
                                $textarea = true;
                                // The comments needs a lang select
                                $modx_input = '<span id="' . $dd_id . '_field"><textarea class="inputbox right-tools" id="' . $dd_id . '_data" name="modx[' . $file_id . '][' . $edit_id . '][' . $dl_id . '][data]" rows="' . count_rows($value3['data'], 70) . '">' . gen_value($value3['data']) . '</textarea>';
                                $modx_select = '<br style="clear:both" /><span id="' . $dd_id . '_lang"><select name="modx[' . $file_id . '][' . $edit_id . '][' . $dl_id . '][lang]">' . lang_select($value3['lang']) . '</select></span></span>';
                                $modx_img = '<img id="' . $dd_id . '_info" class="action-image" src="' . $imageset_path . '/modx_info.png" alt="Comment explain" title="Comment pertaining to this edit" />';
                            }
                        }
                        $template->assign_block_vars('file_row.edit.action', array('DL_ID' => $dl_id, 'DT_ID' => $dt_id, 'DD_ID' => $dd_id, 'S_TEXTAREA' => $textarea, 'MODX_INPUT' => $modx_input, 'MODX_IMG' => $modx_img, 'MODX_SELECT' => $modx_select, 'TYPE' => $value3['type']));
                    }
                }
            }
        }
    }
}
if (($dload || $preview) && empty($error)) {
    include $phpbb_root_path . 'includes/modx_creator_phpbb/create_modx.' . $phpEx;
}
$template->assign_vars(array('GITHUB' => $u_github, 'INSTALL_LEVEL' => isset($install_level) ? $install_level : '', 'INSTALL_TIME' => isset($install_time) ? $install_time : '', 'LANG_SELECT' => lang_select(), 'LICENSE' => !empty($license) ? $license : 'http://opensource.org/licenses/gpl-license.php GNU General Public License v2', 'MOD_VERSION' => isset($version) ? $version : '', 'PHP_INSTALLER' => !empty($php_installer) ? $php_installer : '', 'PHPBB_LATEST' => PHPBB_LATEST, 'S_ERROR_TITLE' => isset($error['title']) ? true : false, 'S_ERROR_DESC' => isset($error['desc']) ? true : false, 'S_ERROR_VERSION' => isset($error['version']) ? true : false, 'S_ERROR_TARGET' => isset($error['target']) ? true : false, 'S_ERROR_INSTALL_LEVEL' => isset($error['install_level']) ? true : false, 'S_ERROR_INSTALL_TIME' => isset($error['install_time']) ? true : false, 'S_ERROR_AUTHOR' => isset($error['author']) ? true : false, 'S_ERROR_GITHUB' => isset($error['github']) ? true : false, 'S_ERRORS' => ($dload || $preview) && !empty($error) ? true : false, 'S_IS_COPY' => $s_is_copy, 'S_IS_DELETE' => $s_is_delete, 'S_IN_MODX_CREATOR' => true, 'S_SUBMIT' => $submit ? true : false, 'S_WARNING_TARGET' => isset($warning['target']) ? true : false, 'S_WARNINGS' => ($dload || $preview) && !empty($warning) ? true : false, 'TARGET_VERSION' => isset($target) ? $target : '', 'U_MODX_FILE' => $phpbb_root_path . 'modx_files/modx_file.' . $phpEx));