private function ShowList($list) { $groups_array = GroupModel::GetList(); $groups_array[0] = 'Не определено'; $regions_array = RegionModel::GetList(); $regions_array[0] = 'Вся Россия'; $companys = SQL::Query('SELECT * FROM `companys` WHERE `id` IN (' . $list . ') ORDER BY `rate` DESC')->fetchAll(PDO::FETCH_OBJ); $this->Render('index', ['company' => $this->company, 'companys' => $companys, 'group_tags' => $groups_array, 'region_tags' => $regions_array]); }
public static function Get($group_id = 0, $word = '') { if ($word != '') { $res = SQL::Query('SELECT * FROM adw_words WHERE word Like ?', [0 => '%' . $word . '%'])->fetch(PDO::FETCH_OBJ); } else { $res = SQL::Query('SELECT * FROM adw_groups WHERE group_id = ?', [0 => $group_id])->fetch(PDO::FETCH_OBJ); } return SQL::Count() > 0 ? CompanyModel::GetObj()->id($res->company_id) : null; }
private function GetSimmilar() { $search_tags = ''; $tmp = explode(',', $this->company->tags); foreach ($tmp as $key => $value) { $search_tags .= '"' . trim($value) . '"'; } return SQL::Query('SELECT * FROM `companys` WHERE MATCH (name, about, tags) AGAINST (? IN BOOLEAN MODE) AND id != ? AND group_id = ? LIMIT 5', [0 => $search_tags, 1 => $this->company->id, 2 => $this->company->group_id])->fetchAll(PDO::FETCH_OBJ); }
public function IndexAction() { $top = CompanyModel::GetAll('id, name')->order('rate DESC', 10); $top_groups = GroupModel::GetAll('id, name')->order('qty DESC', 10); $last_company = CompanyModel::GetObj()->where('id = (select max(id) from companys)'); $products = SQL::Query('SELECT * FROM `products` ORDER BY id DESC LIMIT 3')->fetchAll(PDO::FETCH_OBJ); $company_count = SQL::Query('SELECT count(*) as total FROM `companys`')->fetch(PDO::FETCH_OBJ)->total; $groups_count = SQL::Query('SELECT count(*) as total FROM `groups`')->fetch(PDO::FETCH_OBJ)->total; Site::$sub = '<div class="div30 center">' . "\n" . 'Компаний на портале <h1><a href="' . Site::Link('list') . '">' . $company_count . '</a></h1>' . "\n" . '</div>' . "\n" . '<div class="div30 center">' . "\n" . 'Сфер деятельности <h1><a href="' . Site::Link('list/setgroup') . '">' . $groups_count . '</a></h1>' . "\n" . '</div>' . "\n"; $this->render('index', ['top_arr' => $top, 'top_groups' => $top_groups, 'last' => $last_company, 'products' => $products]); }
public function start() { if (User::isLogged() == false) { Site::Message('Неверная ссылка'); $this->route(); } else { $this->company = CompanyModel::GetObj()->id(User::company()); if ($this->company->id == 0) { SQL::Query('INSERT INTO `companys` (id) VALUES (null);'); $this->company->id = SQL::$db->lastInsertId(); $user = UserModel::GetObj()->id(User::GetID()); $user->companyid = $this->company->id; $user->save(); } } }
public function UpdateAction() { Site::Message('Обновление файла sitemap.xml'); $companys = SQL::Query('SELECT id FROM `companys` ORDER BY id;')->FetchAll(PDO::FETCH_OBJ); $sitelink = Site::link(); $this->sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n"; $this->addurl($sitelink); $this->addurl($sitelink . 'list'); $this->addurl($sitelink . 'list/setgroup'); $this->addurl($sitelink . 'feedback'); foreach ($companys as $company) { $this->addurl($sitelink . $company->id); } $this->sitemap .= '</urlset>'; file_put_contents('./sitemap.xml', $this->sitemap); }
/** * Create Labels * * @version 1 * @author Rick de Man <*****@*****.**> * * @param string $S * Place offset for each Line * @return number|string * */ public function CreateAddLabels($S) { // File to be loaded $File = __DIR__ . '/' . $this->ClassName . '/' . $this->Template . '/labels.html'; // Validate file exists if (!file_exists($File)) { return 500; } // Load the Contents of the file $Template = file_get_contents($File); // Query Setup $Query = 'SELECT * FROM `%component_messages_labels` WHERE 1'; $Comment = 'Loading message Labels'; $Values = array($this->User['ID']); // Prepare the SQL statement $Labels = $this->SQL->Query($Query, $Comment, true); // Let the Template Builder create the content return placeOffset($S, WMS::Html_TemplateBuilder($this, $Template, $Labels)); }
<?php require 'lib/globals.php'; print_r(SQL::Query(1, 'QUERY', 'PARAMS', array('DBHost' => 'localhost', 'DBName' => 'noz_db', 'DBUser' => 'root', 'DBPass' => 'abc123')));
public static function SingleQuery($sql) { SQL::Query($sql); SQL::execute(); if (SQL::RowCount() > 0) { return SQL::DecryptSingleArray(SQL::$stmt->fetch(PDO::FETCH_ASSOC)); } else { return SQL::$stmt->fetch(PDO::FETCH_ASSOC); } }
public static function TagSearch($search, $limit = 15, $offset = 0) { return SQL::Query('SELECT SQL_CALC_FOUND_ROWS * FROM `companys` WHERE tags LIKE ? ORDER BY `rate` DESC LIMIT ' . $limit . ' OFFSET ' . $offset, [0 => '%' . $search . '%'])->fetchAll(PDO::FETCH_OBJ); }
* Upload a file by URL * * @param url url to upload to imagescript */ case 'uploadByURL': if (!isset($_GET['url'])) { echo "-20 URL not set!"; break; } $upload = new Upload(); echo $upload->byURL($_GET['url']); break; case 'getImage': if (!isset($_GET['image']) || !is_numeric($_GET['image'])) { echo "-10 Image id not valid"; break; } $result = SQL::Query("SELECT * FROM images" . " WHERE id = '" . $_GET['image'] . "' LIMIT 1"); if ($result->num_rows == 0) { echo "-11 No image at this ID!"; break; } echo json_encode($result->fetch_assoc()); break; default: if (isset($_GET['do'])) { echo "-10 Operation '" . $_GET['do'] . "' not valid!"; } else { echo "-11 No operation set!"; } }
public static function Dec($id) { if ($id != 0) { SQL::Query('UPDATE `groups` SET qty = qty - 1 WHERE id = ? LIMIT 1', [0 => $id]); } }
public static function GetList() { $arr = array(); $STH = SQL::Query('SELECT id, name FROM ' . static::TableName()); if ($STH->rowCount() > 0) { $arr = $STH->fetchAll(PDO::FETCH_KEY_PAIR); } return $arr; }
<tr> <td>Config::cKey()</td> <td>String <strong>KeyName</strong>, Array <strong>ContainingKeyName</strong></td> <td>This function will get the variable that the <strong>KeyName</strong> is holding. This is useful when you know the key is in the array, but do not want to "navigate" all the way through the array manually. <strong>This will return a string or array</strong>.</td> <td>Config::cKey('SiteTitle', Config::C());</td> </tr> </tbody> </table> </div> </div> </div> </div> <hr> <?php $result = SQL::Query(2, 'SELECT `usernae` FROM `test` LIMIT 10'); if ($result['Success'] === false) { if (class_exists('MessageHandler')) { new MessageHandler($result['Result'], 'ERR'); } else { echo $result['Result']; } } ?> </div> <div class="col-lg-2"></div> </div> </div> </body> </html>
/** * Action:Message - Message drop down for navigation bar * * @version 1 * @author Rick de Man <*****@*****.**> * */ protected function Action_Navbar() { // Variable for the Result $Result = ''; // User must be Signed in if ($this->User['loggedIn'] !== true) { return $Result; } // Load all Messages $Messages = $this->SQL->Query('SELECT * FROM `%component_tasks` WHERE Assignee LIKE \'%"' . $this->User['ID'] . '"%\' AND Parent = 0 AND Completed < 100 Limit 10', 'Loading messages for current User', true); // Load the 'Start' in a simple variable $S = $this->S; // Item Counter 0-9, 9+ $Count = $Messages !== false ? '<em>' . (count($Messages) > 9 ? '9+' : count($Messages)) . '</em>' : ''; // Max message Length $MaxLenght = $this->Settings->NavbarMessageLenght->value; if (isset($this->Attributes['NavbarMessageLenght'])) { $MaxLenght = intval($this->Attributes['NavbarMessageLenght']); } $Result .= $S . "<li class='dropdown'>" . EOL; $Result .= $S . ' <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-tasks fa-fw"></i>' . $Count . ' <i class="fa fa-caret-down"></i></a>' . EOL; // Messages if (is_array($Messages)) { // Load all usernames //$this->GetUserNames ( $Messages ); $Result .= $S . ' <ul class="dropdown-menu dropdown-tasks dropdown-items">' . EOL; // Create the messages foreach ($Messages as $K => $V) { if (strlen($V['Description']) > $MaxLenght) { $Description = $V['Description']; $Description = substr($Description, 0, $MaxLenght); if (preg_match('/.([\\w]{0,})[ ]{1,}$/', $Description, $Match)) { $Description = substr($Description, 0, -strlen($Match[0])) . '...'; } $V['Description'] = $Description; } $Task = '<strong>' . $V['Name'] . '</strong>'; $Progress = '<span class="pull-right text-muted">' . $V['Completed'] . '% ' . $this->Language->Complete . '</span></p>'; $Aria = 'aria-valuenow="' . $V['Completed'] . '" aria-valuemin="0" aria-valuemax="100"'; $ProgressBar = ''; foreach ($this->ProgressScale as $Key => $Value) { if ($V['Completed'] >= $Key) { $ProgressBar = $Value; } } $Result .= $S . ' <li>' . EOL; $Result .= $S . ' <a href="' . $this->ComponentUrl . 'View/' . $V['ID'] . '">' . EOL; $Result .= $S . ' <p>' . $Task . $Progress . EOL; $Result .= $S . ' <div class="progress progress-striped active">' . EOL; $Result .= $S . ' <div class="progress-bar progress-bar-' . $ProgressBar . '" role="progressbar" ' . $Aria . ' style="width: ' . $V['Completed'] . '%"></div>' . EOL; $Result .= $S . ' </div>' . EOL; $Result .= $S . ' </a>' . EOL; $Result .= $S . ' </li>' . EOL; // Ad a divided at the last message if ($K + 1 !== count($Messages)) { $Result .= $S . ' <li class="divider"></li>' . EOL; } } $Result .= $S . ' </ul>' . EOL; } // Read all Tasks $Result .= $S . ' <ul class="dropdown-menu dropdown-messages dropdown-footer">' . EOL; $Result .= $S . ' <li>' . EOL; $Result .= $S . ' <a class="text-center" href="' . $this->ComponentUrl . 'ViewAll/">' . EOL; $Result .= $S . ' <strong>' . $this->Language->ShowAllMessages . '</strong>' . EOL; $Result .= $S . ' </a>' . EOL; $Result .= $S . ' </li>' . EOL; $Result .= $S . ' </ul>' . EOL; $Result .= $S . '</li> <!--Minify-->' . EOL; // Return HTML return $Result; }
/** * Returns all the sitevars on the database * @return array Sitevars */ static function getVars() { $query = SQL::Query("SELECT * FROM sitevars"); if (!$query) { Kernel::Log('Could not retrieve sitevars.'); trigger_error('Could not retrieve sitevars.', E_USER_ERROR); return false; } foreach ($query as $reg) { $sitevars[$reg['name']] = $reg['value']; } return $sitevars; }
public static function drop($id) { SQL::Query('UPDATE `companys` SET rate = rate - 1 WHERE id = ?', [0 => $id]); SQL::Query('DELETE FROM `favorites` WHERE host_id = ? AND fav_id = ?', [0 => User::company(), 1 => $id]); }