Esempio n. 1
1
 /**
  * Return an associative array of [username] => [timestamp]
  * which contains the last timestamp on which a specific username
  * successfully opened the door
  *
  * @return array
  */
 public function getLastEntries()
 {
     // Query for usernames and last timestamps of access
     $query = $this->medoo->query('SELECT `username`, MAX(`timestamp`) AS last_entry
         FROM `attempts`
         WHERE `username` IS NOT NULL
         AND `access_granted` = 1
         GROUP BY `username`')->fetchAll();
     // Construct associative array
     $output = [];
     $tz = new DateTimeZone('Europe/Amsterdam');
     $one_week_ago = new DateTime('-1 week', $tz);
     $one_month_ago = new DateTime('-1 month', $tz);
     foreach ($query as $row) {
         // Convert to human diff (1 month ago, 1 week ago, etc..)
         $entry = new DateTime($row['last_entry'], $tz);
         $result = '';
         if (!$entry) {
             $result = 'Voor 1 september 2015 (of nooit)';
         } elseif ($entry < $one_month_ago) {
             $result = 'Meer dan een maand geleden';
         } elseif ($entry < $one_week_ago) {
             $result = 'Meer dan een week geleden';
         } else {
             $result = 'Minder dan een week geleden';
         }
         $output[$row['username']] = $result;
     }
     return $output;
 }
Esempio n. 2
0
 public static function getSysInfo()
 {
     $sys_info_array = array();
     $sys_info_array['gmt_time'] = gmdate("Y年m月d日 H:i:s", time());
     $sys_info_array['bj_time'] = gmdate("Y年m月d日 H:i:s", time() + 8 * 3600);
     $sys_info_array['server_ip'] = gethostbyname($_SERVER["SERVER_NAME"]);
     $sys_info_array['software'] = $_SERVER["SERVER_SOFTWARE"];
     $sys_info_array['port'] = $_SERVER["SERVER_PORT"];
     $sys_info_array['admin'] = $_SERVER["SERVER_ADMIN"];
     $sys_info_array['diskfree'] = intval(diskfreespace(".") / (1024 * 1024)) . 'Mb';
     $sys_info_array['current_user'] = @get_current_user();
     $sys_info_array['timezone'] = date_default_timezone_get();
     $db = new Medoo(OSA_DB_ID);
     $mysql_version = $db->query("select version()")->fetchAll();
     $sys_info_array['mysql_version'] = $mysql_version[0]['version()'];
     return $sys_info_array;
 }
<?php

require_once 'settings.php';
require_once 'Medoo/medoo.php';
$database = new Medoo($conSettings);
$hardLinksToRoot = array('http://www.cesr.org', 'http://cesr.org', 'https://www.cesr.org', 'https://cesr.org', 'http://cesr.live.radicaldesigns.org', 'https://cesr.live.radicaldesigns.org');
$pathForAditionalFiles['doc'] = 'public://amp_migration/doc/';
$pathForAditionalFiles['img'] = 'public://amp_migration/img/';
$specialChractersToUnderscore = array(' ', '%20');
$whitespaceChractersToNull = array("\t", "\n", "\r", "", "\r\n", "\v", "€", '\\x82', '\\x83', "„", "“", "�");
$results = $database->query("SELECT articles.id, articles.title, articles.test AS body, articles.publish, articles.datecreated, articles.shortdesc, articles.doc, articles.picture, articles.custom2 AS amp_ref_id, articles.custom3 AS language, GROUP_CONCAT(tags.name) AS tag_name FROM articles LEFT JOIN tags_items ON tags_items.item_id = articles.id LEFT JOIN tags ON tags.id = tags_items.tag_id GROUP BY articles.id")->fetchAll();
// removed WHERE tags_items.item_type = 'article' from the where clause
$error = $database->error();
if ($error[0] != '00000') {
    echo PHP_EOL;
    echo '__SQL Errors Found__' . PHP_EOL;
    var_dump($database->error());
    die;
    echo PHP_EOL;
}
$csv = '';
// First row is the header row
$csv .= 'id, title, body, publish, datecreated, shortdesc, doc_path, doc_description, img_name, img_path, img_title, amp_ref_id, language, tag_names' . "\n";
foreach ($results as $result) {
    if ($result['datecreated'] == '0000-00-00 00:00:00') {
        $result['datecreated'] = '1999-01-01 00:00:01';
    }
    // Drupal has a hard char limit on the title field of 128
    // If it is longer than 125 lets truncate it and append ...
    if (strlen($result['title']) > 125) {
        $result['title'] = substr(trim($result['title']), 0, 125) . '...';
Esempio n. 4
0
 public static function getProductType()
 {
     $db = new Medoo(OSA_DB_ID);
     $r = $db->query('SELECT `buss_class` FROM `co_complaints` GROUP BY `buss_class`')->fetchAll();
     $result = array();
     foreach ($r as $key => $value) {
         $result[] = $value['buss_class'];
     }
     return $result;
     // $r = $db->select('co_complaints','product_type',array('group'=>'product_type'));
     var_dump($r);
     exit;
 }