function cot_getcountoffersofuser($userid) { global $sys, $db, $db_projects_offers; list($year, $month, $day) = explode('-', @date('Y-m-d', $sys['now_offset'])); $currentday = cot_mktime(0, 0, 0, $month, $day, $year); $sql = $db->query("SELECT COUNT(*) as count FROM {$db_projects_offers} WHERE offer_userid=" . $userid . " AND offer_date<" . $sys['now_offset'] . " AND offer_date>" . $currentday . ""); $count = $sql->fetchColumn(); return $count; }
/** * Imports date stamp * * @param string $name Variable name preffix * @param bool $usertimezone Use user timezone * @param bool $returnarray Return Date Array * @param string $source Source type: P (POST), C (COOKIE) or D (variable filtering) * @return mixed */ function cot_import_date($name, $usertimezone = true, $returnarray = false, $source = 'P') { global $usr; //$name = preg_match('#^(\w+)\[(.*?)\]$#', $name, $mt) ? $mt[1] : $name; $date = cot_import($name, $source, 'ARR'); $year = cot_import($date['year'], 'D', 'INT'); $month = cot_import($date['month'], 'D', 'INT'); $day = cot_import($date['day'], 'D', 'INT'); $hour = cot_import($date['hour'], 'D', 'INT'); $minute = cot_import($date['minute'], 'D', 'INT'); if (count($date) > 0 && is_null($year) && is_null($month) && is_null($day) && is_null($hour) && is_null($minute)) { // Datetime field is present in form but it is set to zero date (empty) return NULL; } if ($month && $day && $year || $day && $minute) { $timestamp = cot_mktime($hour, $minute, 0, $month, $day, $year); } else { $string = cot_import($date['string'], 'D', 'TXT'); $format = cot_import($date['format'], 'D', 'TXT'); if ($string && $format) { $timestamp = cot_date2stamp($string, $format); } else { return NULL; } } if ($usertimezone) { $timestamp -= $usr['timezone'] * 3600; } if ($returnarray) { $result = array(); $result['stamp'] = $timestamp; $result['year'] = (int) date('Y', $timestamp); $result['month'] = (int) date('m', $timestamp); $result['day'] = (int) date('d', $timestamp); $result['hour'] = (int) date('H', $timestamp); $result['minute'] = (int) date('i', $timestamp); return $result; } return $timestamp; }
/** * Imports date stamp * * @param string $name Variable name preffix * @param bool $usertimezone Use user timezone * @param bool $returnarray Return Date Array * @param string $source Source type: P (POST), C (COOKIE) or D (variable filtering) * @return mixed */ function cot_import_date($name, $usertimezone = true, $returnarray = false, $source = 'P') { if (function_exists('cot_import_date_custom')) { return cot_import_date_custom($name, $usertimezone, $returnarray, $source); } $result = NULL; /* === Hook === */ foreach (cot_getextplugins('import.date') as $pl) { include $pl; } /* ===== */ if ($result !== NULL) { return $result; } //$name = preg_match('#^(\w+)\[(.*?)\]$#', $name, $mt) ? $mt[1] : $name; $date = cot_import($name, $source, 'ARR'); $year = cot_import($date['year'], 'D', 'INT'); $month = cot_import($date['month'], 'D', 'INT'); $day = cot_import($date['day'], 'D', 'INT'); $hour = cot_import($date['hour'], 'D', 'INT'); $minute = cot_import($date['minute'], 'D', 'INT'); if (count($date) > 0 && is_null($year) && is_null($month) && is_null($day) && is_null($hour) && is_null($minute)) { // Datetime field is present in form but it is set to zero date (empty) return NULL; } if ($month && $day && $year || $day && $minute) { $timestamp = cot_mktime($hour, $minute, 0, $month, $day, $year); } else { $string = cot_import($date['string'], 'D', 'TXT'); $format = cot_import($date['format'], 'D', 'TXT'); if ($string && $format) { $timestamp = cot_date2stamp($string, $format); } else { return NULL; } } if ($usertimezone) { $timestamp -= cot::$usr['timezone'] * 3600; } if ($returnarray) { $result = array(); $result['stamp'] = $timestamp; $result['year'] = (int) date('Y', $timestamp); $result['month'] = (int) date('m', $timestamp); $result['day'] = (int) date('d', $timestamp); $result['hour'] = (int) date('H', $timestamp); $result['minute'] = (int) date('i', $timestamp); return $result; } return $timestamp; }