Пример #1
0
function indexforum()
{
    global $user;
    if (!$user['guest']) {
        $read = "AND r.user_id = '" . $user['id'] . "'";
    } else {
        $read = '';
    }
    $sql = call('sql_query', "SELECT b.id, b.board_name, b.topics_count, b.posts_count, b.visible, b.last_msg, p.id, p.post_time, p.author_id, p.name_author, p.topic_id, t.replies, b.board_description, r.user_id, r.board_id, p.subject, b.cat FROM forum_boards AS b LEFT OUTER JOIN forum_posts AS p ON p.id = b.last_msg LEFT OUTER JOIN forum_topics AS t ON b.id=t.board_id AND p.topic_id = t.topic_id LEFT OUTER JOIN board_read AS r ON r.board_id = b.id " . $read . " GROUP BY b.id ORDER BY item_order ASC");
    $fetch = array();
    $cats = call('sql_query', "SELECT * FROM forum_categories ORDER BY item_order ASC", 'cache');
    foreach ($cats as $cat) {
        $fetch[$cat['id']] = array('cat_id' => $cat['id'], 'cat_name' => $cat['cat_name'], 'boards' => array());
    }
    while ($row = call('sql_fetch_array', $sql)) {
        if (call('visiblecheck', $user['membergroup_id'], $row[4])) {
            $fetch[$row[16]]['boards'][$row[0]] = array('board_id' => $row[0], 'board_name' => $row[1], 'topics_count' => $row[2], 'post_count' => $row[3], 'visible' => $row[4], 'last_msg' => $row[5], 'post_id' => $row[6], 'post_time' => $row[7], 'author_id' => $row[8], 'name_author' => $row[9], 'topic_id' => $row[10], 'replies' => $row[11], 'board_description' => $row[12], 'read_user_id' => $row[13], 'read_board_id' => $row[14], 'subject' => $row[15], 'subject_shorten' => substr($row[15], 0, 25) . '...');
        }
    }
    foreach ($cats as $cat) {
        //see if there are any boards in a category
        if (!count($fetch[$cat['id']]['boards'])) {
            //looks like there arent any so lets remove the category from display
            unset($fetch[$cat['id']]);
        }
    }
    return $fetch;
}
Пример #2
0
 public function validate()
 {
     try {
         if (!$this->validate) {
             return true;
         } else {
             if (is_array($this->validate)) {
                 foreach ($this->validate as $validator => $options) {
                     if (!is_null($options)) {
                         if (is_numeric($validator)) {
                             $result = call('v::' . $options, $this->value());
                         } else {
                             $result = call('v::' . $validator, array($this->value(), $options));
                         }
                         if (!$result) {
                             return false;
                         }
                     }
                 }
                 return true;
             } else {
                 return call('v::' . $this->validate, $this->value());
             }
         }
     } catch (Exception $e) {
         return true;
     }
 }
Пример #3
0
function viewtopic($topicid)
{
    global $settings, $user, $error_die;
    if (isset($topicid) && is_numeric($topicid)) {
        if (!$user['guest']) {
            if ($user['posts_topic'] != '0' && $user['posts_topic'] != '') {
                $settings['posts_topic'] = $user['posts_topic'];
            }
        }
        # how many rows to show per page
        $rowsPerPage = $settings['posts_topic'];
        # by default we show first page
        $pageNum = 1;
        # if $_GET['page'] defined, use it as page number
        if (isset($_GET['page']) && is_numeric($_GET['page'])) {
            $pageNum = $_GET['page'];
        }
        # counting the offset
        $offset = ($pageNum - 1) * $rowsPerPage;
        $sql = call('sql_query', "SELECT u.avatar, u.posts, u.membergroup, u.signature, u.icq, u.aim, u.msn, u.yim, t.board_id, t.thread_title, t.thread_author, t.topic_ip, t.date_created, t.locked, p.id, p.post_time, p.author_id, p.name_author, p.subject, p.message, p.ip, p.disable_smiley, p.modified_time, p.modified_name, p.modified_nameid FROM forum_posts AS p LEFT OUTER JOIN forum_topics AS t ON p.topic_id=t.topic_id LEFT OUTER JOIN users AS u ON p.author_id=u.id WHERE t.topic_id = '{$topicid}' ORDER BY p.id ASC LIMIT {$offset}, {$rowsPerPage}");
        if (call('sql_num_rows', $sql) != 0) {
            $fetch = array();
            while ($row = call('sql_fetch_array', $sql)) {
                $fetch[] = array('avatar' => $row[0], 'posts' => $row[1], 'membergroup' => $row[2], 'signature' => $row[3], 'icq' => $row[4], 'aim' => $row[5], 'msn' => $row[6], 'yim' => $row[7], 'board_id' => $row[8], 'thread_title' => $row[9], 'thread_author' => $row[10], 'topic_ip' => $row[11], 'date_created' => $row[12], 'locked' => $row[13], 'post_id' => $row[14], 'post_time' => $row[15], 'author_id' => $row[16], 'name_author' => $row[17], 'subject' => $row[18], 'message' => $row[19], 'ip' => $row[20], 'disable_smiley' => $row[21], 'modified_time' => $row[22], 'modified_author' => !empty($row[24]) && call('userprofilelink', $row[24]) != false ? call('userprofilelink', $row[24]) : $row[23]);
            }
            # update the number of views in a topic
            $query = call('sql_query', "UPDATE forum_topics SET views = views+1 WHERE topic_id ='{$topicid}'");
            return $fetch;
        } else {
            $error_die[] = 'Error this topic does not exist';
            return false;
        }
    }
}
Пример #4
0
function news()
{
    global $user;
    // how many rows to show per page
    $rowsPerPage = 5;
    // by default we show first page
    $pageNum = 1;
    // if $_GET['page'] defined, use it as page number
    if (isset($_GET['page']) && is_numeric($_GET['page'])) {
        $pageNum = $_GET['page'];
    }
    // counting the offset
    $offset = ($pageNum - 1) * $rowsPerPage;
    $sql = call('sql_query', "SELECT n.id, n.subject, n.content, n.cat, n.created_by, n.visibility, nc.name, nc.image, n.views, n.time_created, n.extended, COUNT(c.type_id) FROM news n LEFT OUTER JOIN news_categories nc ON n.cat=nc.id LEFT OUTER JOIN comments c ON n.id = c.type_id AND c.comment_type = 'news' WHERE (n.start_time='0' OR n.start_time<=" . time() . " " . (DB_TYPE == 'sqlite' ? "OR n.start_time=''" : "") . ") AND (n.end_time='0' OR n.end_time>=" . time() . " " . (DB_TYPE == 'sqlite' ? "OR n.end_time=''" : "") . ") GROUP BY n.id ORDER BY n.time_created DESC LIMIT {$offset}, {$rowsPerPage}");
    if (call('sql_num_rows', $sql) == 0) {
        return false;
    }
    $fetch = array();
    while ($row = call('sql_fetch_array', $sql)) {
        if (call('visiblecheck', $user['membergroup_id'], $row[5])) {
            $fetch[] = array('news_id' => $row[0], 'subject' => $row[1], 'content' => $row[2], 'cat_id' => $row[3], 'created_by' => $row[4], 'visibility' => $row[5], 'cat_name' => $row[6], 'cat_image' => $row[7], 'views' => $row[8], 'time_created' => $row[9], 'extended' => $row[10], 'comments' => $row[11]);
        }
    }
    return $fetch;
}
Пример #5
0
function addemoticon($code, $image, $text)
{
    global $user, $error, $error_die;
    if (!$user['admin_panel']) {
        $error_die[] = 'You do not have permission to do this';
        //No one should be able to actually use this function except an admin, its there just to be safe ;)
        return false;
    }
    if (empty($code)) {
        $error[] = 'You must specify the code';
        return false;
    }
    if (empty($image)) {
        $error[] = 'You must specify an image';
        return false;
    }
    if (empty($text)) {
        $error[] = 'You must specify text';
        return false;
    }
    $code = str_replace(array("\"", "'"), '', $code);
    if (!errors()) {
        $query = call('sql_query', "INSERT INTO emoticons (code, image, alt) VALUES ('{$code}', '{$image}', '{$text}')");
        if ($query) {
            return true;
        }
    }
}
Пример #6
0
 protected function move()
 {
     $source = $this->source();
     if (is_null($source['name']) or is_null($source['tmp_name'])) {
         throw new Error('The file has not been found', static::ERROR_MISSING_FILE);
     }
     if ($source['error'] !== 0) {
         throw new Error('The upload failed', static::ERROR_FAILED_UPLOAD);
     }
     if (file_exists($this->to()) and $this->options['overwrite'] === false) {
         throw new Error('The file exists and cannot be overwritten', static::ERROR_UNALLOWED_OVERWRITE);
     }
     if ($source['size'] > $this->options['maxSize']) {
         throw new Error('The file is too big', static::ERROR_FILE_TOO_BIG);
     }
     if (is_callable($this->options['accept'])) {
         $accepted = call($this->options['accept'], new Media($source['tmp_name']));
         if ($accepted === false) {
             throw new Error('The file is not accepted by the server', static::ERROR_UNACCEPTED);
         }
     }
     if (!@move_uploaded_file($source['tmp_name'], $this->to())) {
         throw new Error('The file could not be moved', static::ERROR_MOVE_FAILED);
     }
 }
Пример #7
0
function editemoticon($code, $image, $text, $id)
{
    global $user, $error, $error_die;
    if (!$user['admin_panel']) {
        $error_die[] = 'You do not have permission to do this';
        //No one should be able to actually use this function except an admin, its there just to be safe ;)
        return false;
    }
    if (empty($code)) {
        $error[] = 'You must specify the code';
        return false;
    }
    if (empty($image)) {
        $error[] = 'You must specify an image';
        return false;
    }
    if (empty($text)) {
        $error[] = 'You must specify text';
        return false;
    }
    if (!errors()) {
        $query = call('sql_query', "UPDATE emoticons SET code='{$code}', image='{$image}', alt='{$text}' WHERE id='{$id}'");
        if ($query) {
            return true;
        }
    }
}
Пример #8
0
function klan_odrzuc_podanie($gracz, $id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    //jeżeli gracz nie jest  w klanie to nie może nic usunąć
    if ($gracz['id_klanu'] == 0) {
        $msg = "nie jesteś w klanie";
    } else {
        //sprawdź rangę gracza w klanie
        $ranga = one("select status from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $gracz['id_klanu'] . " limit 1");
        //jeżeli to nie mistrz klanu to nie może usunąć nic
        if ($ranga == 1) {
            $msg = "nie jesteś mistrzem klanu ani jego zastępcą";
        } else {
            //odrzuć podanie
            call("delete from tribal_klany_gracze where id = " . $id . " and klan_id = " . $gracz['id_klanu'] . " and status = 0");
            //nic nie usunięto
            if (mysql_affected_rows() == 0) {
                $msg = "nie ma takiego podania";
            } else {
                //odrzucono podanie
                $msg = "odrzucono podanie";
            }
        }
    }
    return $msg;
}
Пример #9
0
function usersonline()
{
    global $user;
    //set the amount of time the number of guests and users stored as online
    $timeout = time() - 600;
    //delete anyone that is greate than the $timeout
    $deleteuseronline = call('sql_query', "DELETE FROM user_online WHERE time_online<{$timeout}");
    if ($user['guest']) {
        //visiting person is a guest, check to see if they are already in the table
        $check_table = call('sql_query', "SELECT ip FROM user_online WHERE ip = '" . call('visitor_ip') . "'");
    } else {
        //person is a user, check to see if they are in the table
        $check_table = call('sql_query', "SELECT user_id FROM user_online WHERE user_id = '" . $user['id'] . "'");
    }
    //check the number of rows returned, if 0 insert them
    if (call('sql_num_rows', $check_table) == 0) {
        if ($user['guest']) {
            //insert user as a guest
            $insertuseronline = call('sql_query', "INSERT INTO user_online (user_id, time_online, ip) VALUES ('0', '" . time() . "', '" . call('visitor_ip') . "')");
        } else {
            //insert user
            $insertuseronline = call('sql_query', "INSERT INTO user_online (user_id, time_online, ip) VALUES ('" . $user['id'] . "', '" . time() . "', '" . call('visitor_ip') . "')");
            //update the last active
            call('sql_query', "UPDATE users SET lastlogin = '******', time_online = '" . ($user['time_online'] + 600) . "' WHERE id = '" . $user['id'] . "'");
        }
    }
}
Пример #10
0
 public function route($model, $form, $fieldName, $fieldType, $path)
 {
     $field = $form->fields()->{$fieldName};
     if (!$field or $field->type() !== $fieldType) {
         throw new Exception('Invalid field');
     }
     $routes = $field->routes();
     $router = new Router($routes);
     if ($route = $router->run($path)) {
         if (is_callable($route->action()) and is_a($route->action(), 'Closure')) {
             return call($route->action(), $route->arguments());
         } else {
             $controllerFile = $field->root() . DS . 'controller.php';
             $controllerName = $fieldType . 'FieldController';
             if (!file_exists($controllerFile)) {
                 throw new Exception(l('fields.error.missing.controller'));
             }
             require_once $controllerFile;
             if (!class_exists($controllerName)) {
                 throw new Exception(l('fields.error.missing.class'));
             }
             $controller = new $controllerName($model, $field);
             return call(array($controller, $route->action()), $route->arguments());
         }
     } else {
         throw new Exception(l('fields.error.route.invalid'));
     }
 }
Пример #11
0
function showposts($id)
{
    global $settings, $user;
    if (!$user['guest']) {
        if ($user['posts_topic'] != '0' && $user['posts_topic'] != '') {
            $settings['posts_topic'] = $user['posts_topic'];
        }
    }
    // how many rows to show per page
    $rowsPerPage = $settings['posts_topic'];
    // by default we show first page
    $pageNum = 1;
    // if $_GET['page'] defined, use it as page number
    if (isset($_GET['page'])) {
        $pageNum = $_GET['page'];
    }
    // counting the offset
    $offset = ($pageNum - 1) * $rowsPerPage;
    $sql = call('sql_query', "SELECT t.board_id, p.id, p.post_time, p.subject, p.message, p.disable_smiley, b.visible, b.board_name, t.replies, t.topic_id FROM forum_posts AS p LEFT OUTER JOIN forum_topics AS t ON p.topic_id=t.topic_id LEFT OUTER JOIN forum_boards AS b ON t.board_id = b.id WHERE p.author_id = '{$id}' ORDER BY p.post_time DESC LIMIT {$offset}, {$rowsPerPage}");
    $num = call('sql_num_rows', $sql);
    if ($num != 0) {
        $fetch = array();
        while ($row = call('sql_fetch_array', $sql)) {
            if (call('visiblecheck', $user['membergroup_id'], $row[6])) {
                $fetch[] = array('board_id' => $row[0], 'post_id' => $row[1], 'post_time' => $row[2], 'subject' => $row[3], 'message' => $row[4], 'disable_smiley' => $row[5], 'board_name' => $row[7], 'replies' => ceil($row[8] / $settings['posts_topic']), 'topic_id' => $row[9]);
            }
        }
        $fetch['num'] = $num;
        return $fetch;
    }
}
Пример #12
0
function addarticle($subject, $summary, $full_article, $cat, $rating, $comment)
{
    global $user, $error, $error_die;
    if (!$user['admin_panel']) {
        $error_die = 'You do not have permission to do this';
        //No one should be able to actually use this function except an admin, its there just to be safe ;)
        return false;
    }
    if (empty($subject)) {
        $error[] = 'You must specify a subject';
        return false;
    }
    if (empty($summary)) {
        $error[] = 'You must specify a summary';
        return false;
    }
    if (!isset($comment)) {
        $comment = 0;
    } else {
        $comment = 1;
    }
    if (!isset($rating)) {
        $rating = 0;
    } else {
        $rating = 1;
    }
    if (empty($error) && empty($error_die)) {
        $query = call('sql_query', "INSERT INTO articles (subject, summary, full_article, time_created, author_id, name_author, cat, views, ratings, comments) VALUES ('{$subject}', '{$summary}', '{$full_article}', '" . time() . "', '" . $user['id'] . "', '" . $user['user'] . "', '{$cat}', '0', '{$rating}', '{$comment}')");
        if ($query) {
            return true;
        }
    }
}
Пример #13
0
function zaloz_ciuch($gracz, $id)
{
    $gracz = (int) $gracz;
    $id = (int) $id;
    $dane = row("select * from driver_gracze where gracz = " . $gracz);
    $ciuch = row($q = "select * from driver_ciuchy_gracze   inner join driver_ciuchy on id = c_id and gracz_id = " . $gracz . " where id = {$id} and status = 0 and gracz_id = " . $gracz . "");
    if (empty($ciuch)) {
        return "nie masz takiego sprzętu";
    } else {
        switch ($ciuch['typ']) {
            case 1:
                $zajety = one("select 1 from driver_ciuchy_gracze inner join driver_ciuchy on c_id = id where typ = 1 and status = 1 and gracz_id = " . $gracz);
                break;
            case 2:
                $zajety = one("select 1 from driver_ciuchy_gracze inner join driver_ciuchy on c_id = id where typ = 2 and status = 1 and gracz_id = " . $gracz);
                break;
            case 3:
                $zajety = one("select 1 from driver_ciuchy_gracze inner join driver_ciuchy on c_id = id where typ = 3 and status = 1 and gracz_id = " . $gracz);
                break;
            case 4:
                $zajety = one("select 1 from driver_ciuchy_gracze inner join driver_ciuchy on c_id = id where typ = 4 and status = 1 and gracz_id = " . $gracz);
                break;
        }
        if ($zajety == 1) {
            return "masz już założony sprzęt tego typu";
        }
        call("update driver_gracze set bonus_vmax = bonus_vmax + " . $ciuch['vmax'] . ", bonus_do100 = bonus_do100 + " . $ciuch['do100'] . " where gracz = {$gracz}");
        call("update driver_ciuchy_gracze set status = 1 where gracz_id = {$gracz} and c_id = {$id} limit 1");
        return "założono sprzęt";
    }
}
Пример #14
0
function szpiegowanie($event)
{
    fx('dodaj_event');
    //atakujący
    $miasto1 = row("select * from tribal_miasta inner join tribal_gracze on gracz_id = gracz where miasto = " . $event['miasto_id']);
    //obrońca
    $miasto2 = row("select * from tribal_miasta inner join tribal_gracze on gracz_id = gracz  where miasto = " . $event['podtyp']);
    //pobierz dane broniących się szpiegów
    $obronca = row("select * from tribal_jednostki_miasta inner join tribal_jednostki on jednostka_id = jednostka where miasto_id = " . $event['podtyp'] . " and jednostka_id = 5 and ilosc > 0");
    $tekst1 = "Twoi szpiedzy z miasta " . $miasto1['nazwa'] . " szpiegują miasto " . $miasto2['nazwa'] . "<br/>";
    if (empty($obronca)) {
        $tekst1 .= "Nie napotkano oporu<br/>";
        $tekst2 = "Szpiedzy z wrogiego  szpiegują Twoje miasto " . $miasto2['nazwa'] . "<br/>";
    } else {
        //zabij odpowiednią ilość szpiegów po obu stronach
        $ilu = $event['ilosc'];
        $event['ilosc'] -= $obronca['ilosc'];
        $obronca['ilosc'] -= $ilu;
        if ($event['ilosc'] < 0) {
            $event['ilosc'] = 0;
        }
        if ($obronca['ilosc'] < 0) {
            $obronca['ilosc'] = 0;
        }
        //jeżeli obrońca w ogóle zabił jakiegoś szpiego to pokaż mu info z którego miasta przyszedł atak
        if ($ilu == $event['ilosc']) {
            $tekst2 = "Szpiedzy z miasta " . $miasto1['nazwa'] . " szpiegują Twoje miasto " . $miasto2['nazwa'] . "<br/>";
        } else {
            $tekst2 = "Szpiedzy z wrogiego  szpiegują Twoje miasto " . $miasto2['nazwa'] . "<br/>";
        }
    }
    if (empty($obronca['ilosc']) && !empty($event['ilosc'])) {
        $zwyciezca = 1;
        //zabij obrońcę
        call("update tribal_jednostki_miasta set ilosc = 0 where miasto_id = " . $miasto2['miasto'] . " and jednostka_id = 5");
        $tekst1 .= "Udało Ci się przeszpiegować miasto<br/>\n\t\t\tZdobyte informacje:<br/>\n\t\t\tDrewno: " . $miasto2['drewno'] . "\n\t\t\tKamień: " . $miasto2['kamien'] . "\n\t\t\tŻelazo: " . $miasto2['zelazo'] . "\n\t\t\tJedzenie: " . $miasto2['jedzenie'] . "\n\t\t\tPopulacja: " . $miasto2['populacja'] . "/" . $miasto2['populacja_max'] . "\n\t\t\t";
        $tekst2 .= "Twoi szpiedzy ponieśli klęskę<br/>";
    } elseif (empty($obronca['ilosc']) && empty($event['ilosc'])) {
        $zwyciezca = 0;
        //zabij obrońcę
        call("update tribal_jednostki_miasta set ilosc = 0 where miasto_id = " . $miasto2['miasto'] . " and jednostka_id = 5");
        $tekst1 .= "Twoi szpiedzy ponieśli klęskę<br/>";
        $tekst2 .= "Twoi szpiedzy zginęli ale nie dopuścili do infiltracji miasta<br/>";
    } else {
        $zwyciezca = 2;
        //zabij obrońcę
        call("update tribal_jednostki_miasta set ilosc = " . $obronca['ilosc'] . " where miasto_id = " . $miasto2['miasto'] . " and jednostka_id = 5");
        $tekst1 .= "Twoi szpiedzy ponieśli klęskę<br/>";
        $tekst2 .= "Twoi szpiedzy nie dopuścili do infiltracji miasta<br/>";
    }
    fx('wiadomosc_wyslij');
    $a = wiadomosc_wyslij(1, $miasto1['login'], $tekst1);
    $a = wiadomosc_wyslij(1, $miasto2['login'], $tekst2);
    if ($zwyciezca == 1) {
        //jeżeli wygrał to resztę szpiegów wyślij do domu
        $czas = $event['koniec'] - $event['start'];
        fx('dodaj_event');
        dodaj_event($event['miasto_id'], 21, $event['podtyp'], $event['ilosc'], $czas);
    }
}
Пример #15
0
function ulepsz_auto($gracz, $id, $czesc)
{
    //zabezpiecz zmienne
    $gracz = (int) $gracz;
    $id = (int) $id;
    $czesc = (int) $czesc;
    //pobierz dane auta o podanym $id - sprawdź czy gracz takie posiada
    $auto = row("select * from driver_auta_gracze where id_gracza = {$gracz} and id_auta = {$id} limit 1");
    if (empty($auto)) {
        //jeżeli nie ma takiego auta
        return "nie ma takiego auta";
    } else {
        $sprzet = row("select * from driver_czesci where czesc = {$czesc} ");
        if (empty($sprzet)) {
            return "nie ma takiej części";
        } else {
            //pobierz dane gracza
            $data = row("select * from driver_gracze where gracz = {$gracz}");
            //jeżeli gracz ma za mało kasy
            if ($data['kasa'] < $sprzet['cena']) {
                return "masz za mało gotówki";
            } else {
                //ma kasę, zapłać za sprzęt
                call("update driver_gracze set kasa = kasa - " . $sprzet['cena'] . " where gracz = {$gracz}");
                call("update driver_auta_gracze set vmax = vmax + " . $sprzet['vmax'] . ", do100 = do100 + " . $sprzet['do100'] . ", wartosc = wartosc + " . $sprzet['cena'] * 0.9 . " where id_gracza = {$gracz} and id_auta = {$id} limit 1");
                call("update driver_auta_gracze set do100 = 3 where do100 < 3");
                return "ulepszono auto";
            }
        }
    }
}
Пример #16
0
function addcomment($id, $type, $message, $token)
{
    global $user, $error, $error_die;
    call('checktoken', $token);
    if (!$user['post_comment']) {
        $error[] = 'You do not have permission to post a comment';
        return false;
    }
    $existcheck = call('sql_query', "SELECT id, comments FROM {$type} WHERE id = '{$id}'");
    $fetch = call('sql_fetch_array', $existcheck);
    if (call('sql_num_rows', $existcheck) == 0) {
        $error_die[] = 'This ' . $type . ' no longer exists so adding a comment was not possible';
        return false;
    }
    if ($fetch['comments'] != '1') {
        $error_die[] = 'Posting of comments on this ' . $type . ' is disabled';
        return false;
    }
    if (empty($message)) {
        $error[] = 'Please enter a message';
        return false;
    }
    if (!errors()) {
        $sql = call('sql_query', "INSERT INTO comments (comment_type, type_id, message, author, author_id, ip, post_time) VALUES ('{$type}', '{$id}', '{$message}', '" . $user['user'] . "', '" . $user['id'] . "', '" . call('visitor_ip') . "', '" . time() . "' ) ");
        if ($sql) {
            return true;
        }
    }
}
Пример #17
0
function deletetheme($themeid, $reset)
{
    global $user, $FUNCTIONS_LANG, $error, $error_die;
    if (!$user['admin_panel']) {
        # No one should be able to actually use this function except an admin,
        #  its there just to be safe ;)
        $error_die[] = $FUNCTIONS_LANG["e_permissions"];
        return false;
    }
    if (empty($themeid)) {
        # tut tut, dont mess around with the URLs
        $error[] = $FUNCTIONS_LANG["e_th_specify_delete"];
        return false;
    }
    # tut tut, dont mess around with the URLs
    if (empty($reset)) {
        $error[] = $FUNCTIONS_LANG["e_th_specify_everyone"];
        return false;
    }
    if (!errors()) {
        $themes = call('sql_query', "SELECT * FROM themes WHERE theme_id = '{$themeid}'");
        $r = call('sql_fetch_array', $themes);
        $query = call('sql_query', "DELETE FROM themes WHERE theme_id = '{$themeid}'");
        $sql = call('sql_query', "DELETE FROM theme_settings WHERE theme_id = '{$themeid}'");
        $sql = call('sql_query', "UPDATE users SET theme = '{$reset}' WHERE theme = '" . $r['theme_name'] . "'");
        if ($sql) {
            return true;
        }
    }
}
Пример #18
0
function editarticle($subject, $summary, $full_article, $cat, $rating, $comment, $id)
{
    global $user, $error, $error_die;
    if (!$user['admin_panel']) {
        $error_die[] = 'You do not have permission to do this';
        //No one should be able to actually use this function except an admin, its there just to be safe ;)
        return false;
    }
    if (empty($subject)) {
        $error[] = 'You must specify a subject';
        return false;
    }
    if (empty($summary)) {
        $error[] = 'You must specify a summary for your article';
        return false;
    }
    $comment = !isset($comment) ? 0 : 1;
    $rating = !isset($rating) ? 0 : 1;
    if (!errors()) {
        $query = call('sql_query', "UPDATE articles SET subject = '{$subject}', summary = '{$summary}', full_article = '{$full_article}', cat = '{$cat}', ratings = '{$rating}', comments = '{$comment}' WHERE id = '{$id}'");
        if ($query) {
            return true;
        }
    }
}
Пример #19
0
 public function data()
 {
     $data = $this->data;
     $defaults = $this->defaults();
     if (lab::$mode == 'preview') {
         $callback = a::get($this->config(), 'preview');
         $previewData = (array) call($callback);
         $defaults = array_merge($defaults, $previewData);
     }
     foreach ($defaults as $key => $value) {
         if (!isset($this->data[$key]) and !isset(tpl::$data[$key])) {
             if (is_a($value, 'Closure')) {
                 $data[$key] = call($value, [$this]);
             } else {
                 $data[$key] = $value;
             }
         } else {
             if (isset($this->data[$key])) {
                 $data[$key] = $this->data[$key];
             } else {
                 $data[$key] = tpl::$data[$key];
             }
         }
     }
     return $data;
 }
Пример #20
0
 public function upload($id = null)
 {
     $page = $this->page($id);
     $blueprint = blueprint::find($page);
     $filename = $blueprint->files()->sanitize() ? '{safeFilename}' : '{filename}';
     $upload = new Upload($page->root() . DS . $filename, array('overwrite' => true, 'accept' => function ($file) {
         $callback = kirby()->option('panel.upload.accept');
         if (is_callable($callback)) {
             return call($callback, $file);
         } else {
             return true;
         }
     }));
     if ($file = $upload->file()) {
         try {
             $this->checkUpload($file, $blueprint);
             kirby()->trigger('panel.file.upload', $file);
             return response::success('success');
         } catch (Exception $e) {
             $file->delete();
             return response::error($e->getMessage());
         }
     } else {
         return response::error($upload->error()->getMessage());
     }
 }
Пример #21
0
 public function upload($id = null)
 {
     if (!get('_csrf') or !csrf(get('_csrf'))) {
         return response::error('unauthenticated access');
     }
     $page = $this->page($id);
     $blueprint = blueprint::find($page);
     $filename = $blueprint->files()->sanitize() ? '{safeFilename}' : '{filename}';
     $upload = new Upload($page->root() . DS . $filename, array('overwrite' => true, 'accept' => function ($file) {
         $callback = kirby()->option('panel.upload.accept');
         if (is_callable($callback)) {
             return call($callback, $file);
         } else {
             return true;
         }
     }));
     if ($file = $upload->file()) {
         try {
             $this->checkUpload($file, $blueprint);
             // flush all cached files
             $page->reset();
             if ($pagefile = $page->file($file->filename())) {
                 kirby()->trigger('panel.file.upload', $pagefile);
                 return response::success('success');
             } else {
                 throw new Exception('The file object could not be found');
             }
         } catch (Exception $e) {
             $file->delete();
             return response::error($e->getMessage());
         }
     } else {
         return response::error($upload->error()->getMessage());
     }
 }
Пример #22
0
function nowa_osada($gracz)
{
    if ($gracz['id_miasta'] == 0) {
        $posiadane = one("select miasto from tribal_miasta where gracz_id = " . $gracz['gracz'] . " limit 1");
        if (empty($posiadane)) {
            call("insert into tribal_miasta (nazwa, gracz_id, ochrona) value ('" . $gracz['nazwa_miasta'] . "'," . $gracz['gracz'] . ", " . (time() + 10 * 86400) . ")");
            $id = mysql_insert_id();
            if ($id == 0) {
                call("insert into tribal_miasta (nazwa, gracz_id, czas_przyrostu, ochrona) value ('" . $gracz['nazwa_miasta'] . date("His") . "'," . $gracz['gracz'] . ", " . time() . ", " . (time() + 10 * 86400) . ")");
                $id = mysql_insert_id();
            }
            if ($id > 0) {
                $map = row("select count(*) as wolne, (select max(x) from tribal_mapa) as x_max, (select max(y) from tribal_mapa) as y_max from tribal_mapa where miasto_id = 0");
                if ($map['wolne'] < 30) {
                    $x = $map['x_max'];
                    $y = $map['y_max'];
                    $insert = "insert into tribal_mapa(x,y) values ";
                    for ($i = 1; $i < $x + 6; $i++) {
                        for ($j = 1; $j < $y + 6; $j++) {
                            if ($i > $x || $j > $y) {
                                $insert .= "({$i},{$j}),";
                            }
                        }
                    }
                    $insert = substr($insert, 0, -1);
                    call($insert);
                }
                call("update tribal_gracze set id_miasta = {$id} where gracz = " . $gracz['gracz']);
                call("update tribal_mapa set miasto_id = {$id} where miasto_id = 0 order by rand() limit 1");
            }
        } else {
            call("update tribal_gracze set id_miasta = " . $posiadane . " where gracz = " . $gracz['gracz']);
        }
    }
}
Пример #23
0
function userprofilelink($userid, $colour = '')
{
    global $userprofilelink, $settings;
    if (!$userprofilelink) {
        $userprofilelink = array();
        $sql = call('sql_query', "SELECT u.id, u.user, m.colour FROM users u LEFT JOIN membergroups m ON u.membergroup=m.membergroup_id");
        while ($p = call('sql_fetch_array', $sql)) {
            $userprofilelink[] = array('id' => $p[0], 'user' => $p[1], 'colour' => $p[2]);
        }
    }
    foreach ($userprofilelink as $fetch) {
        if (is_numeric($userid) && $fetch['id'] == $userid || !is_numeric($userid) && $fetch['user'] == $userid) {
            $profilelink = '<a href="' . $settings['site_url'] . '/index.php?act=profile&amp;id=' . $fetch['id'] . '" title="View profile of ' . $fetch['user'] . '">';
            //check if colour is wanted
            if ($colour != '' && !empty($fetch['colour'])) {
                //add a span class to make it that colour
                $profilelink .= '<span style="color: #' . $fetch['colour'] . '">';
            }
            $profilelink .= $fetch['user'];
            if ($colour != '' && !empty($fetch['colour'])) {
                //close the span tag
                $profilelink .= '</span>';
            }
            $profilelink .= '</a>';
            return $profilelink;
        }
    }
    return false;
}
Пример #24
0
 public function parse()
 {
     if (!$this->field) {
         return '';
     }
     $text = $this->field->value;
     // pre filters
     foreach (static::$pre as $filter) {
         $text = call_user_func_array($filter, array($this, $text));
     }
     // tagsify
     $text = preg_replace_callback('!(?=[^\\]])\\([a-z0-9_-]+:.*?\\)!is', array($this, 'tag'), $text);
     // markdownify
     if (kirby()->option('markdown')) {
         $text = call(kirby::instance()->option('markdown.parser'), $text);
     }
     // smartypantsify
     if (kirby()->option('smartypants')) {
         $text = str_replace('&quot;', '"', $text);
         $text = call(kirby::instance()->option('smartypants.parser'), $text);
     }
     // post filters
     foreach (static::$post as $filter) {
         $text = call_user_func_array($filter, array($this, $text));
     }
     return $text;
 }
Пример #25
0
function trackip($ip)
{
    global $settings;
    // how many rows to show per page
    $rowsPerPage = $settings['topics_page'];
    // by default we show first page
    $pageNum = 1;
    // if $_GET['page'] defined, use it as page number
    if (isset($_GET['page'])) {
        $pageNum = $_GET['page'];
    }
    // counting the offset
    $offset = ($pageNum - 1) * $rowsPerPage;
    $fetch = array();
    if (!errors()) {
        $sql = call('sql_query', "SELECT id, topic_id, author_id, post_time, subject, ip FROM forum_posts WHERE ip LIKE '%{$ip}%' ORDER BY post_time DESC LIMIT {$offset}, {$rowsPerPage}");
        if (call('sql_num_rows', $sql) != 0) {
            while ($r = call('sql_fetch_array', $sql)) {
                $fetch[] = array('post_id' => $r['id'], 'topic_id' => $r['topic_id'], 'author' => call('userprofilelink', $r['author_id']), 'post_time' => call('dateformat', $r['post_time']), 'subject' => '<a href="' . $settings['site_url'] . '/index.php?act=viewtopic&id=' . $r['topic_id'] . '&page=' . ceil($r['id'] / $settings['posts_topic']) . '#' . $r['id'] . '" target="_blank">' . $r['subject'] . '</a>', 'ip' => $r['ip'], 'type' => 'post');
            }
        } else {
            $fetch[] = array('ip' => 'The search returned zero results', 'type' => 'post');
        }
        $sql = call('sql_query', "SELECT id, ip FROM users WHERE ip LIKE '%{$ip}%'");
        if (call('sql_num_rows', $sql) != 0) {
            while ($r = call('sql_fetch_array', $sql)) {
                $fetch[] = array('user' => call('userprofilelink', $r['id']), 'ip' => $r['ip'], 'type' => 'user');
            }
        } else {
            $fetch[] = array('ip' => 'The search returned zero results', 'type' => 'user');
        }
    }
    return $fetch;
}
Пример #26
0
function klan_ustaw_zastepce($gracz, $id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    //jeżeli gracz nie jest  w klanie to nie może nic usunąć
    if ($gracz['id_klanu'] == 0) {
        $msg = "nie jesteś w klanie";
    } else {
        //sprawdź rangę gracza w klanie
        $ranga = one($q = "select status from tribal_klany_gracze where gracz_id = " . $gracz['gracz'] . " and klan_id = " . $gracz['id_klanu'] . " limit 1");
        //jeżeli to nie mistrz klanu
        if ($ranga != 3) {
            $msg = "nie jesteś mistrzem klanu";
        } else {
            //pobierz dane klanowicza
            $podanie = row("select * from tribal_klany_gracze where gracz_id = " . $id . " and klan_id = " . $gracz['id_klanu'] . " and status = 1");
            if (empty($podanie)) {
                $msg = "nie ma takiego klanowicza";
            } else {
                //ustaw prawa zastępcy
                call("update tribal_klany_gracze set status = 2 where gracz_id = " . $id);
                $msg = "ustawiono zastępcę mistrza klanu";
            }
        }
    }
    return $msg;
}
Пример #27
0
function deleteuser($id)
{
    global $user, $error, $error_die;
    if (!$user['admin_panel']) {
        $error_die[] = 'You do not have permission to do this';
        //No one should be able to actually use this function except an admin, its there just to be safe ;)
        return false;
    }
    if ($user['id'] == $id) {
        $error_die[] = 'You can not delete your own account';
        //why would you want to delete your own account in the admin panel? Makes no sense
        return false;
    }
    $sql = call('sql_query', "SELECT * FROM users WHERE id = '{$id}'");
    if (call('sql_num_rows', $sql) == 0) {
        $error[] = 'This user no longer exists';
        return false;
    }
    if (!errors()) {
        $query = call('sql_query', "DELETE FROM users WHERE id = '{$id}'");
        if ($query) {
            return true;
        }
    }
}
 public function show($id)
 {
     if (isset($_GET['param1'])) {
         return call('main', 'error');
     }
     $hero = Heroes::find($_GET['param1']);
 }
Пример #29
0
function uninstallplugin($id)
{
    global $user, $error, $error_die;
    if (!$user['admin_panel']) {
        $error_die[] = 'You do not have permission to do this';
        //No one should be able to actually use this function except an admin, its there just to be safe ;)
        return false;
    }
    if (empty($id)) {
        $error[] = 'No Plugin was selected';
        return false;
    }
    $sql = call('sql_query', "SELECT folder FROM plugins WHERE id = '{$id}'");
    if (call('sql_num_rows', $sql) == 0) {
        $error[] = 'This Plugin does not exist';
        return false;
    }
    if (!errors()) {
        $fetch = call('sql_fetch_array', $sql);
        include './Plugins/' . $fetch['folder'] . '/plugin-info.php';
        $delete = call('sql_query', "DELETE FROM plugins WHERE id = '{$id}'");
        if (isset($plugin['uninstall']) && is_array($plugin['uninstall'])) {
            foreach ($plugin['uninstall'] as $uninstall) {
                call('sql_query', $uninstall);
            }
        }
        if ($delete) {
            return true;
        }
    }
}
Пример #30
0
function editpage($name, $content, $id, $comment, $rating)
{
    global $user, $error, $error_die;
    if (!$user['admin_panel']) {
        $error_die[] = 'You do not have permission to do this';
        //No one should be able to actually use this function except an admin, its there just to be safe ;)
        return false;
    }
    $sql = call('sql_query', "SELECT * FROM pages WHERE id = '{$id}'");
    if (call('sql_num_rows', $sql) == 0) {
        $error[] = 'This page no longer exists';
        return false;
    }
    if (empty($content)) {
        $error[] = 'You must specify content for the page';
        return false;
    }
    if (empty($name)) {
        $error[] = 'You must specify a name for the page';
        return false;
    }
    if (!errors()) {
        $comment = !isset($comment) ? 0 : 1;
        $rating = !isset($rating) ? 0 : 1;
        $query = call('sql_query', "UPDATE pages SET pagename = '{$name}', content = '{$content}', comments = '{$comment}', ratings = '{$rating}' WHERE id = '{$id}'");
        if ($query) {
            return true;
        }
    }
}