function findReplies($a)
{
    $commentsReplies = Db::queryAll('SELECT * FROM comments_table WHERE item_id=? && reply_to=?', $_GET['item'], $a);
    for ($i = 0; $i < count($commentsReplies); $i++) {
        $date = date('d.m Y', strtotime($commentsReplies[$i]['comment_date']));
        echo '
            <li class="comment">
                <figure>
                    <div class="image">
                        <img alt="" src="' . $commentsReplies[$i]['image'] . '">
                    </div>
                </figure>
                <div class="comment-wrapper">
                    <div class="name pull-left">' . $commentsReplies[$i]['author_name'] . '</div>
                    <span class="date pull-right"><span class="fa fa-calendar"></span>' . $date . '</span>
                    <div class="rating rating-individual" data-score="' . $commentsReplies[$i]['rating'] . '"></div>
                    <p>' . $commentsReplies[$i]['comment_content'] . '</p>
                    <a href="#" class="reply"><span class="fa fa-reply"></span>Reply</a>
                    <hr>
                    <ul class="comment-reply">';
        findReplies($commentsReplies[$i]['comment_id']);
        echo '</ul>
                </div>
            </li>
        ';
    }
}
Example #2
0
 private function checkBrute($login)
 {
     $timeOfAttempt = date('Y-m-d H:i:s', time() - BRUTEFORCE_LOCKED_TIME);
     $attempts = Db::queryAll('SELECT `login`, `timestamp` FROM `login_attempts`
                               WHERE `login` = ? && `timestamp` > ? && `success` = 0', [$login, $timeOfAttempt]);
     if (BRUTEFORCE_NUMBER_OF_ATTEMPTS < count($attempts)) {
         return true;
     }
     return false;
 }
Example #3
0
 public function getMembers($adminId, $lang)
 {
     $placesIds = $this->returnAdminPlacesIds($adminId);
     $members = [];
     foreach ($placesIds as $placeID) {
         $tariffMembers = Db::queryAll('SELECT `id_user`,`first_name`,`last_name`,`telephone`,`active`,`email`,`tariffCZE`,`name`,`places`.`id` AS `id_of_place`
                                        FROM `users`
                                        JOIN `tariffs` ON `user_tariff` = `id_tariff`
                                        JOIN `places` ON `tariffs`.`place_id` = `places`.`id`
                                        WHERE `place_id` = ?
                                        ORDER BY `active` DESC, `invoicing_start_date` ASC', [$placeID]);
         //for equvivalent position between members
         foreach ($tariffMembers as $tm) {
             $members[] = $tm;
         }
     }
     //add first payment date to each member
     foreach ($members as &$m) {
         $m['firstPaymentDate'] = $this->getFirstPaymentDate($m['id_user'], $lang);
         $m['paymentFlag'] = $this->getPaymentFlag($m['id_user']);
     }
     return $members;
 }
<?php

if (isset($_POST['sorting'])) {
    $includePath = '';
    include_once 'connect_db.php';
    $sorting = Db::queryAll('SELECT sorting_option, sorting_option_title FROM sorting_options_table');
    $querySorting = $_GET;
    $querySorting['sort_by'] = $_POST['sorting'];
    header('Location: index.php?' . http_build_query($querySorting));
} else {
    $sorting = Db::queryAll('SELECT sorting_option, sorting_option_title FROM sorting_options_table');
}
?>
<form role="form" id="form-sorting" method="post" action="">
    <div class="form-group">
        <select name="sorting" id="item-sorting">
            <?php 
for ($i = 0; $i < count($sorting); $i++) {
    ?>
                <?php 
    if (isset($_GET['sort_by'])) {
        ?>
                    <?php 
        if ($_GET['sort_by'] == $sorting[$i]['sorting_option']) {
            ?>
                        <option value="<?php 
            echo $sorting[$i]['sorting_option'];
            ?>
"> <?php 
            echo $sorting[$i]['sorting_option_title'];
            ?>
<?php

$item = Db::queryAll('SELECT item_id, title, city, price, image FROM items_table ORDER BY date_created DESC LIMIT ?', $config['footer_items_number']);
$footerLinks = Db::queryAll('SELECT url, title FROM footer_links_table');
?>
<!-- Page Footer -->
<footer id="page-footer">
    <div class="inner">
        <section id="footer-main">
            <div class="container">
                <div class="row">
                    <div class="col-md-3 col-sm-3">
                        <article>
                            <h3>About Us</h3>
                            <p><?php 
echo $config['about_us'];
?>
</p>
                            <!--<hr>-->
                            <!--<a href="#" class="link-arrow">Read More</a>-->
                        </article>
                    </div><!-- /.col-sm-3 -->
                    <div class="col-md-3 col-sm-3">
                        <article>
                            <h3>Recent Properties</h3>
                            <?php 
for ($i = 0; $i < count($item); $i++) {
    ?>
                                <?php 
    if (!empty($item)) {
        ?>
Example #6
0
    private function getPaymentData($paymentId)
    {
        $payment = Db::queryOne('SELECT `id_payer`,`email`,`priceCZK`,`invoice_fakturoid_number` FROM `payments`
			JOIN `users` ON `users`.`id_user` = `payments`.`id_payer`
			JOIN `tariffs` ON `users`.`user_tariff` = `tariffs`.`id_tariff`
			WHERE `id_payment` = ?', [$paymentId]);
        //add sum of all extras
        $extras = Db::queryAll('SELECT `priceCZK` FROM `extras` WHERE `payment_id` = ?', [$paymentId]);
        $extrasSum = 0;
        foreach ($extras as $e) {
            $extrasSum += $e['priceCZK'];
        }
        $payment['priceCZK'] += $extrasSum;
        return $payment;
    }
Example #7
0
<?php

require './init.php';
$set_id = intval($_GET['id']);
$rows = Db::queryAll('SELECT * FROM key_to_values WHERE set_id=?', $set_id);
if (empty($rows)) {
    header('Location: ../index.php');
    exit;
}
$array_to_encode = [];
foreach ($rows as $keyvaluepair) {
    $array_to_encode[$keyvaluepair['key']] = json_decode($keyvaluepair['values']);
}
echo json_encode($array_to_encode);
?>
 ">
        <select name="district_id" id="district">
            <?php 
if (isset($_GET['district_id'])) {
    ?>
                <option value="<?php 
    echo $_GET['district_id'];
    ?>
"><?php 
    echo Db::querySingle('SELECT district_title FROM search_districts_table WHERE district_id=?', $_GET['district_id']);
    ?>
</option>
                <option value="">- District -</option>
                <?php 
    $districts = Db::queryAll('SELECT * FROM search_districts_table WHERE parent=?', $_GET['city_id']);
    ?>
                <?php 
    for ($i = 0; $i < count($districts); $i++) {
        ?>
                    <?php 
        if ($districts[$i]['district_id'] != $_GET['district_id']) {
            ?>
                        <option value="<?php 
            echo $districts[$i]['district_id'];
            ?>
"><?php 
            echo $districts[$i]['district_title'];
            ?>
</option>
                    <?php 
Example #9
0
><li><?php 
    echo $set['set_name'];
    ?>
</li></a>
                <?php 
}
?>
            </ul>
        </section>
        <section class="outline">
            <div class="heading">
                <h1>memorize the outline</h1>
            </div>
            <ul>
                <?php 
$set_names = Db::queryAll("SELECT * FROM outlines");
foreach ($set_names as $set) {
    ?>
                    <a class='set-tile' href=<?php 
    echo "'outline.php?id=" . urlencode($set['id']) . "'";
    ?>
><li><?php 
    echo $set['name'];
    ?>
</li></a>
                <?php 
}
?>
            </ul>
        </section>
        <div class="subheading">
<?php

$item = Db::queryAll('SELECT item_id, title, city, price, image FROM items_table ORDER BY date_created DESC LIMIT 3');
?>
<!-- sidebar -->
<div class="col-md-3 col-sm-3">
    <section id="sidebar">
        <aside id="edit-search">
            <header><h3>Search Properties</h3></header>
            <?php 
include_once $includePath . 'views/search_form.php';
?>
        </aside><!-- /#edit-search -->
            <aside id="recent-properties">
            <header><h3>Recent Properties</h3></header>
            <?php 
for ($i = 0; $i < $config['sidebar_items_number']; $i++) {
    ?>
                <?php 
    if ($item) {
        ?>
                    <?php 
        include $includePath . 'views/single_item_small.php';
        ?>
                <?php 
    }
    ?>
            <?php 
}
?>
        </aside><!-- /#featured-properties -->
Example #11
0
 public function getLastAttempts($numberOfAtetmpts)
 {
     $attempts = Db::queryAll('SELECT `id`, `uid_key` FROM `lock_attempts` ORDER BY `timestamp` DESC LIMIT ?', [$numberOfAtetmpts]);
     return $attempts;
 }
Example #12
0
 public static function getAll()
 {
     $db = new Db();
     $query = "SELECT * FROM photos";
     return $db->queryAll($query);
 }
Example #13
0
    public function getExpiredPayments($toleranceDays)
    {
        $dbResults = Db::queryAll('SELECT `price_CZK`, `email`, `id_user` FROM `payments`
			JOIN `users` ON `users`.`id_user` = `payments`.`id_payer`
			WHERE `status` != (? || ?)', ['confirmed', 'received']);
        $result = [];
        foreach ($dbResults as $r) {
            $result[] = ['id_user' => $r['id_user'], 'email' => $r['email'], 'price_CZK' => $r['price_CZK']];
        }
        return $result;
    }
Example #14
0
    public function getBlankExtras($id_user)
    {
        return Db::queryAll('SELECT `id_extra`,`description`,`priceCZK` FROM `extras`
			WHERE `blank_user_id` = ? AND `payment_id` IS NULL', [$id_user]);
    }
        for ($c = 0; $c < count($tempCountry); $c++) {
            Db::query('DELETE FROM search_countries_table WHERE country_id=?', $tempCountry[$c]['country_id']);
            $tempCity = Db::queryAll('SELECT * FROM search_cities_table WHERE parent=?', $tempCountry[$c]['country_id']);
            for ($ct = 0; $ct < count($tempCity); $ct++) {
                Db::query('DELETE FROM search_cities_table WHERE city_id=?', $tempCity[$ct]['city_id']);
                $tempDistrict = Db::queryAll('SELECT * FROM search_districts_table WHERE parent=?', $tempCity[$ct]['city_id']);
                for ($d = 0; $d < count($tempDistrict); $d++) {
                    Db::query('DELETE FROM search_districts_table WHERE district_id=?', $tempDistrict[$d]['district_id']);
                }
            }
        }
    } elseif ($_POST['itemType'] == 'country') {
        Db::query('DELETE FROM search_countries_table WHERE country_id=?', $_POST['id']);
        $tempCity = Db::queryAll('SELECT * FROM search_cities_table WHERE parent=?', $_POST['id']);
        for ($ct = 0; $ct < count($tempCity); $ct++) {
            Db::query('DELETE FROM search_cities_table WHERE city_id=?', $tempCity[$ct]['city_id']);
            $tempDistrict = Db::queryAll('SELECT * FROM search_districts_table WHERE parent=?', $tempCity[$ct]['city_id']);
            for ($d = 0; $d < count($tempDistrict); $d++) {
                Db::query('DELETE FROM search_districts_table WHERE district_id=?', $tempDistrict[$d]['district_id']);
            }
        }
    } elseif ($_POST['itemType'] == 'city') {
        Db::query('DELETE FROM search_cities_table WHERE city_id=?', $_POST['id']);
        $tempDistrict = Db::queryAll('SELECT * FROM search_districts_table WHERE parent=?', $_POST['id']);
        for ($d = 0; $d < count($tempDistrict); $d++) {
            Db::query('DELETE FROM search_districts_table WHERE district_id=?', $tempDistrict[$d]['district_id']);
        }
    } elseif ($_POST['itemType'] == 'district') {
        Db::query('DELETE FROM search_districts_table WHERE district_id=?', $_POST['id']);
    }
}
<?php

$includePath = '';
include_once 'Db.php';
include_once 'connect_db.php';
if ($_POST['action'] == 'find_persons') {
    $person = Db::queryAll('SELECT person_name, person_id, account_type, assigned_company FROM persons_table WHERE account_type=? AND assigned_company=? ORDER BY person_name', 'agent', $_POST['company_id']);
}
?>

<select name="assigned_person" id="assigned_person" class="selectpicker">
    <option value="">- Select Agent -</option>
    <?php 
for ($i = 0; $i < count($person); $i++) {
    ?>
        <option value="<?php 
    echo $person[$i]['person_id'];
    ?>
"><?php 
    echo $person[$i]['person_name'];
    ?>
</option>
    <?php 
}
?>
</select>
$tempCountryVar = -1;
$tempCityVar = -1;
$tempDistrictVar = -1;
for ($s = 0; $s < count($_POST['state_title']); $s++) {
    //    echo '<br><br>';
    //    echo $searchStates[$s]['state_title'] . ' ';
    //    echo '<br>';
    Db::query('UPDATE search_states_table SET state_title=? WHERE state_id=?', $_POST['state_title'][$s], $searchStates[$s]['state_id']);
    $searchCountries = Db::queryAll('SELECT * FROM search_countries_table WHERE parent=?', $searchStates[$s]['state_id']);
    for ($c = 0; $c < count($searchCountries); $c++) {
        $tempCountryVar++;
        //        echo '<br>';
        //        echo '- ' . $searchCountries[$c]['country_title'] . ' ' . $searchCountries[$c]['country_id'] . ' / '. $_POST['country_title'][$tempCountryVar];
        //        echo '<br>';
        Db::query('UPDATE search_countries_table SET country_title=? WHERE country_id=?', $_POST['country_title'][$tempCountryVar], $searchCountries[$c]['country_id']);
        $searchCities = Db::queryAll('SELECT * FROM search_cities_table WHERE parent=?', $searchCountries[$c]['country_id']);
        for ($ct = 0; $ct < count($searchCities); $ct++) {
            //            echo '--- ' . $searchCities[$ct]['city_title'] . ' ';
            //            echo '<br>';
            $tempCityVar++;
            Db::query('UPDATE search_cities_table SET city_title=? WHERE city_id=?', $_POST['city_title'][$tempCityVar], $searchCities[$ct]['city_id']);
            $searchDistricts = Db::queryAll('SELECT * FROM search_districts_table WHERE parent=?', $searchCities[$ct]['city_id']);
            for ($d = 0; $d < count($searchDistricts); $d++) {
                //                echo '------- ' . $searchDistricts[$d]['district_title'] . ' ';
                //                echo '<br>';
                $tempDistrictVar++;
                Db::query('UPDATE search_districts_table SET district_title=? WHERE district_id=?', $_POST['district_title'][$tempDistrictVar], $searchDistricts[$d]['district_id']);
            }
        }
    }
}
Example #18
0
<?php

require './init.php';
$outline_id = intval($_GET['id']);
$rows = Db::queryAll('SELECT * FROM outline_texts WHERE outline_id=?', $outline_id);
if (empty($rows)) {
    header('Location: ../index.php');
    exit;
}
//do stuff
$array_to_encode = [];
foreach ($rows as $outline_text) {
    $array_to_encode[$outline_text['parent_id']] = $outline_text['text'];
}
echo json_encode($array_to_encode);
Example #19
0
 public function returnTariffsData($lang)
 {
     if ($lang == 'cs') {
         return Db::queryAll('SELECT `id_tariff`, `tariffCZE`, `priceCZK`, `name`
         FROM `tariffs` JOIN places ON places.id = tariffs.place_id', []);
     }
     if ($lang == 'en') {
         return Db::queryAll('SELECT `id_tariff`, `tariffENG`, `priceCZK`, `name`
         FROM `tariffs` JOIN places ON places.id = tariffs.place_id', []);
     }
     return false;
 }
Example #20
0
</li></a>
            <?php 
    }
    ?>
        </ul>
        <div class="subheading">
        <h2>create your own set</h2>
        <a href="set.php?add_set">
            <span class="plus-set"></span>
        </a>
    </div>
    <?php 
} elseif (!empty($_GET['view_id'])) {
    $set_id = $_GET['view_id'];
    $set = Db::queryOne("SELECT * FROM set_names WHERE id=?", $set_id);
    $pairs = Db::queryAll("SELECT * FROM key_to_values WHERE set_id=?", $set_id);
    ?>
        <div class='heading'>
            <h1><?php 
    echo $set['set_name'];
    ?>
</h1>
        </div>
        <table id='pair-table'>
            <thead>
                <tr>
                    <th>Key</th>
                    <th>Values</th>
                </tr>
            </thead>
            <tbody>
Example #21
0
 public static function getAll()
 {
     $db = new Db();
     $query = "SELECT * FROM " . static::$table;
     return $db->queryAll($query, static::$class);
 }