Пример #1
0
function LOGGER($content)
{
    $fo = fopen("logger.txt", "a");
    $content = "[" . getNow() . "]:" . $content . "\r\n";
    fwrite($fo, $content);
    fclose($fo);
}
Пример #2
0
function logInfoEvent($message)
{
    $newEvent = new EventClass();
    $newEvent->setCreateDate(getNow());
    $newEvent->setType('Info');
    $newEvent->setMessage($message);
    logEvent($newEvent);
}
Пример #3
0
function generateInsertNoteSql($noteContent)
{
    $insertSql = "";
    $insertSql .= "INSERT INTO bc_note (bc_note, bc_created, bc_modified) VALUES(";
    $insertSql .= formatSqlStringValue($noteContent, true);
    $insertSql .= formatSqlStringValue(getNow(), true);
    $insertSql .= formatSqlStringValue(getNow(), false);
    $insertSql .= ")";
    return $insertSql;
}
Пример #4
0
function getMonthlyHits()
{
    $timestamp = convertToStamp(getNow());
    $mn = substr($timestamp, 4, 2);
    $yr = substr($timestamp, 0, 4);
    $months = array('this month', 'last month', '2 months ago', '3 months ago', '4 months ago', '5 months ago', '6 months ago', '7 months ago', '8 months ago', '9 months ago', '10 months ago', '11 months ago');
    $i = 0;
    foreach ($months as $d) {
        $out['first'] = date('Y-m', mktime('00', '00', '00', $mn - $i, '01', $yr));
        $id = $i <= 1 ? $d : $out['first'];
        $arr[$id] = array($out['first']);
        $i++;
    }
    return $arr;
}
Пример #5
0
/**
 * @param string
 * @param string
 * @param string
 * @todo messy
 * @return string
 **/
function convertDate($date = '', $offset = '', $format = '')
{
    $date = $date === '' ? getNow() : $date;
    $offset = $offset === '' ? 0 : $offset;
    $format = $format === '' ? '%d %B %Y' : $format;
    $timestamp = str_replace(array('-', ':', ' '), array('', '', ''), $date);
    $time[0] = substr($timestamp, 8, 2);
    // hours
    $time[1] = substr($timestamp, 10, 2);
    // min
    $time[2] = substr($timestamp, 12, 2);
    // seconds
    $time[3] = substr($timestamp, 6, 2);
    // day
    $time[4] = substr($timestamp, 4, 2);
    // month
    $time[5] = substr($timestamp, 0, 4);
    // year
    // we need to adjust for the time offset
    $new = date('Y-m-d H:i:s', mktime($time[0] + $offset, $time[1], $time[2], $time[4], $time[3], $time[5]));
    return strftime($format, strtotime($new));
}
Пример #6
0
function getTimeFormat($default = '', $name, $attr = '')
{
    $s = '';
    $default = $default === '' ? '%Y-%m-%d %T' : $default;
    $timestamp = getNow();
    $formats = array('%d %B %Y', '%A, %H:%M %p', '%Y-%m-%d %T');
    $timestamp = str_replace(array('-', ':', ' '), array('', '', ''), $timestamp);
    $time[0] = substr($timestamp, 8, 2);
    // hours
    $time[1] = substr($timestamp, 10, 2);
    // min
    $time[2] = substr($timestamp, 12, 2);
    // seconds
    $time[3] = substr($timestamp, 6, 2);
    // day
    $time[4] = substr($timestamp, 4, 2);
    // month
    $time[5] = substr($timestamp, 0, 4);
    // year
    foreach ($formats as $format) {
        $hello = date('Y-m-d H:i:s', mktime($time[0], $time[1], $time[2], $time[4], $time[3], $time[5]));
        $newdate = strftime($format, strtotime($hello));
        $default === $format ? $sl = "selected " : ($sl = "");
        $s .= option($format, $newdate, $default, $format);
    }
    return select($name, attr($attr), $s);
}
Пример #7
0
 // get user profile card
 case 'profile_card':
     $uid = $_POST['id'];
     die(View::userCard($uid));
     break;
 case 'feed_post':
     $id = $_GET['id'];
     die(View::getFeedPost($id));
     break;
 case 'feed':
     $data = $_POST;
     unset($data['action']);
     $user_id = $data['user_id'] ?? USER_ID;
     $content = $data['content'];
     $token = $data['token'];
     $now = getNow();
     // check token validation
     if (!Token::validateToken($token)) {
         die(json_encode(['status' => false, 'err' => 'Token is not valid.']));
     }
     $database = new Database();
     $data = ['user_id' => $user_id, 'content' => $content, 'poster_id' => USER_ID, 'date' => $now];
     $insert = $database->insert_data(TABLE_ACTIVITY, $data);
     if ($insert === true) {
         $id = $database->lastId;
         die(json_encode(['status' => true, 'id' => $id]));
     }
 case 'get_post':
     $id = sanitize_id($_GET['id']);
     $post = new Post();
     $comment = $post->get_post($id);
Пример #8
0
}
switch ($action) {
    case 'create':
        $title = $data['title'];
        $content = $data['content'];
        $section = $data['section'];
        $token = $data['token'];
        if (empty($title) || empty($content) || $section == 0) {
            die(json_encode(['status' => false, 'err' => 'data is not valid']));
        }
        if (!Token::validateToken($token)) {
            die(json_encode(['status' => false, 'err' => 'Token is not valid']));
        }
        unset($data['token']);
        $data['uid'] = USER_ID;
        $data['created'] = getNow();
        $QNA = new QNA();
        $create = $QNA->create($data);
        if (is_int($create)) {
            die(json_encode(['status' => true, 'id' => $create]));
        } else {
            die(json_encode(['status' => false, 'err' => $create]));
        }
        break;
    case 'upvote':
        $PostID = sanitize_id($data['id']);
        $post = new Post();
        $QNA = new QNA();
        // check if question exists
        if (!is_object($QNA->get_question($PostID)) && !is_array($post->get_post($PostID, true))) {
            die(json_encode(['status' => false, 'err' => 'Post was not found.']));
Пример #9
0
//$errors = validateFields('add_hunt', $_POST, $rules);
//var_dump_j("jeff errors", $errors);
//exit;
// if there were errors, re-populate the form fields
if (!empty($errors)) {
    $fields = $_POST;
    header("Location: /HuntingHarvestAddHunt.php");
} else {
    // They are trying to insert a new hunt.
    try {
        $lastName = $_POST['last_name'];
        $firstName = $_POST['first_name'];
        $newHunter = new hunter_info();
        $newHunter->setLastName($lastName);
        $newHunter->setFirstName($firstName);
        $createdDateString = getNow();
        $newHunter->setCreated($createdDateString);
        saveNewHunter($newHunter);
        header("Location: /php/hunters_admin_home.php");
    } catch (Exception $e) {
        // Unsuccessful login
        if ($e->getMessage() == 'no user found') {
            addError('login', 'We could not find you in our system');
            header('Location: /index.php');
        } else {
            if ($e->getMessage() == 'no results') {
                addError('login', 'Opps, looks like our system is down right now.');
                header('Location: /index.php');
            }
        }
    }
Пример #10
0
 public function stat_insertHit()
 {
     $OBJ =& get_instance();
     $stat = $this->stat_doStats();
     // ignore ip's listed in the config file
     if ($this->stat_ignore_hit($stat['ip']) === true) {
         return;
     }
     // it needs to end with a '/' for it to be a stat
     if (substr($stat['uri'], -1) !== '/') {
         return;
     }
     // we don't refer to ourselves
     $found = strpos($this->stat_reduceURL($stat['ref']), $this->stat_reduceURL(BASEURL));
     $stat['ref'] = $found === false ? $stat['ref'] : '';
     $clean['hit_addr'] = $stat['ip'];
     $clean['hit_country'] = $this->stat_getCountry($stat['ip']);
     $clean['hit_lang'] = $stat['lang'];
     $clean['hit_domain'] = $stat['domain'];
     $clean['hit_referrer'] = $stat['ref'];
     $clean['hit_page'] = $stat['uri'];
     $clean['hit_agent'] = $stat['agent'];
     $clean['hit_keyword'] = $stat['keywords'];
     $clean['hit_os'] = $stat['browser']['platform'];
     $clean['hit_browser'] = $stat['browser']['browser'];
     $clean['hit_time'] = getNow();
     $OBJ->db->insertArray('statistic', $clean);
     return;
 }
Пример #11
0
 public function __construct()
 {
     $this->timeline = getNow();
     $this->maxTime = date('Y-m-d H:i:s', strtotime('3 weeks ago'));
 }
Пример #12
0
 function page_hits()
 {
     global $go;
     // default/validate $_GET
     $go['page'] = getURI('page', 0, 'digit', 5);
     $this->template->location = $this->lang->word('main');
     // sub-locations
     $this->template->sub_location[] = array($this->lang->word('referrers'), "?a={$go['a']}&amp;q=refer");
     $this->template->sub_location[] = array($this->lang->word('main'), "?a={$go['a']}");
     load_module_helper('files', $go['a']);
     $today = convertToStamp(getNow());
     $day = substr($today, 6, 2);
     $mn = substr($today, 4, 2);
     $yr = substr($today, 0, 4);
     $thirtydays = date('Y-m-d', mktime('00', '00', '00', $mn - 1, $day, $yr));
     $rs = $this->db->fetchArray("SELECT hit_page, \n            COUNT(hit_page) AS 'total' \n            FROM " . PX . "stats \n            GROUP by hit_page \n            ORDER BY total DESC");
     // ++++++++++++++++++++++++++++++++++++++++++++++++++++
     // table for all our results
     $body = "<table cellpadding='0' cellspacing='0' border='0'>\n";
     $body .= "<tr class='top'>\n";
     $body .= "<th width='90%' class='toptext'><strong>" . $this->lang->word('page') . "</strong></th>\n";
     $body .= "<th width='10%' class='toptext'><strong>" . $this->lang->word('visits') . "</strong></th>\n";
     $body .= "</tr>\n";
     $body .= "</table>\n";
     // dynamic output for table
     $body .= "<table cellpadding='0' cellspacing='0' border='0'>\n";
     if (!$rs) {
         $body .= tr(td('No hits yet', "colspan='2'"));
     } else {
         foreach ($rs as $ar) {
             $body .= tr(td($ar['hit_page'], "width='90%' class='cell-doc'") . td($ar['total'], "width='10%' class='cell-mid'"), row_color(" class='color'"));
         }
     }
     // end dynamic rows output
     $body .= "</table>\n";
     $this->template->body = $body;
     return;
 }
Пример #13
0
function markHuntDetailsDeleted($huntDetailsId)
{
    $huntDetails = readHuntDetails($huntDetailsId);
    $huntDetails->setCreated(getNow());
    $huntDetails->setStatus('DELETED');
    saveNewHuntDetails($huntDetails);
}
Пример #14
0
 /**
  * edit a question title
  *
  * @param $content string
  *
  * @return array|string
  */
 public function edit_title($title)
 {
     $database = new Database();
     $now = getNow();
     $update = $database->update_data(TABLE_QUESTIONS, ['title', 'last_modified'], [$title, $now], 'id', $this->PostID);
     if ($update !== true || $database->error) {
         return array_shift($database->errors);
     }
     return true;
 }
Пример #15
0
 function sbmt_upd_jxtext()
 {
     global $go;
     header('Content-type: text/html; charset=utf-8');
     load_module_helper('files', $go['a']);
     $clean['id'] = (int) $_POST['id'];
     $_POST['content'] = $_POST['v'] === '' ? '' : utf8Urldecode($_POST['v']);
     //$_POST['content'] = ($_POST['v'] === '') ? '' : $_POST['v'];
     //echo $_POST['content']; exit;
     // we need $clean['id'] on processing
     $rs = $this->db->fetchRecord("SELECT process\n            FROM " . PX . "objects\n            WHERE id = '{$clean['id']}'");
     $processor =& load_class('processor', true, 'lib');
     load_helper('textprocess');
     $clean['content'] = $processor->process('content', array('nophp'));
     $clean['content'] = textProcess($clean['content'], $rs['process']);
     $clean['udate'] = getNow();
     $clean['object'] = OBJECT;
     $this->db->updateArray('object', $clean, "id={$clean['id']}");
     header('Content-type: text/html; charset=utf-8');
     echo "<span class='notify'>" . $this->lang->word('updating') . "</span>";
     exit;
 }
Пример #16
0
function generateBCSpeciesUpdateSql($oneSpecies, $birdGroupId, $speciesSeq)
{
    $updateSql = "";
    $updateSql .= "UPDATE bc_species SET ";
    $updateSql .= formatSqlSetNumericValue("bird_group_id", $birdGroupId, true);
    $updateSql .= formatSqlSetNumericValue("bc_species_id", $oneSpecies->getSpeciesId(), true);
    $updateSql .= formatSqlSetNumericValue("bc_harvest_count", $oneSpecies->getHarvestCount(), true);
    $updateSql .= formatSqlSetNumericValue("bc_species_seq", $speciesSeq, true);
    $updateSql .= formatSqlSetStringValue("bc_modified", getNow(), false);
    $updateSql .= " WHERE id=" . $oneSpecies->getId();
    return $updateSql;
}