public function onCreate($credit, $input) { if ((int) $credit->user_id !== 0 or !empty($credit->email)) { // Compile the basic data $data = ['type' => $credit->type, 'value' => $credit->present()->valueLong]; // Compile the user account info if ((int) $credit->user_id !== 0) { // Set the email info $email = $credit->user->email; $data['subject'] = $subject = "Credit Has Been Added to Your Account"; $data['email'] = "user"; // Start the expiration timer if ($credit->type == 'time') { $credit->update(['expires' => \Date::now()->addDay()->addYear()->startOfDay()]); } } // Compile the email address info if (!empty($credit->email)) { $email = $credit->email; $data['subject'] = $subject = "You've Been Given Credit with Brian Jacobs Golf"; $data['email'] = "email"; } // Send the email Mail::send('emails.creditAdded', $data, function ($msg) use($email, $subject) { $msg->to($email)->subject(Config::get('bjga.email.subject') . " {$subject}")->replyTo(Config::get('bjga.email.contact')); }); } }
/** * Generate the complete comment entry default structure. * * @param int $comment_ID The comment id. * @param int $comment_post_ID The if of the post the comment refers to. * * @return array An associative array of column/default values. */ protected static function generateDefaultsFor($comment_ID, $comment_post_ID) { $randIP = "" . mt_rand(0, 255) . "." . mt_rand(0, 255) . "." . mt_rand(0, 255) . "." . mt_rand(0, 255); $content = self::generateCommentContent(); $defaults = array('comment_ID' => $comment_ID, 'comment_post_ID' => $comment_post_ID, 'comment_author' => 'John Doe', 'comment_author_email' => '*****@*****.**', 'comment_author_url' => 'http://www.johndoe.com', 'comment_author_IP' => $randIP, 'comment_date' => Date::now(), 'comment_date_gmt' => Date::gmtNow(), 'comment_content' => $content, 'comment_karma' => 0, 'comment_approved' => 1, 'comment_agent' => '', 'comment_type' => '', 'comment_parent' => 0, 'user_id' => 0); return $defaults; }
/** * @return string * @param string|Date $from * @param string|Date $to * @param string $glue * @param string $separator */ public static function interval($from, $to, $glue = ' ', $separator = ' ') { $fromDate = self::create($from)->midnight(); $toDate = self::create($to)->midnight(); if ($fromDate->getTimestamp() === $toDate->getTimestamp()) { return $fromDate->format('j') . $glue . $fromDate->month() . $glue . $fromDate->format('Y') . $glue . self::YEAR_STRING; } $nowYear = Date::now()->format('Y'); $isOneYear = $fromDate->format('Y') === $toDate->format('Y'); $isOneMonth = $isOneYear && $fromDate->format('m') === $toDate->format('m'); $toString = ''; $fromString = ''; $toString .= $toDate->format('Y') . $glue . self::YEAR_STRING; if (!$isOneYear) { $fromString .= $fromDate->format('Y') . $glue . self::YEAR_STRING; } $toString = $toDate->month() . (empty($toString) ? '' : $glue . $toString); if (!$isOneMonth) { $fromString = $fromDate->month() . (empty($fromString) ? '' : $glue . $fromString); } $toString = $toDate->format('j') . (empty($toString) ? '' : $glue . $toString); $fromString = $fromDate->format('j') . (empty($fromString) ? '' : $glue . $fromString); $result = self::FROM_STRING . $glue . $fromString . $separator . self::TO_STRING . $glue . $toString; $result = str_replace($glue . $glue, $glue, $result); return $result; }
public function save() { if (!$this->created_on) { $this->created_on = Date::now(); } return parent::save(); }
/** * Calculates end of DST (daylight savings time) * This is the last Sunday of October * * @param int year default -1 Year, defaults to current year * @return util.Date */ public static function dstEnd($year = -1) { $date = $year == -1 ? Date::now() : Date::create($year, 1, 1, 0, 0, 0); $transition = TimeZoneTransition::nextTransition(new TimeZone('Europe/Berlin'), $date); while ($transition->isDst()) { $transition->next(); } return $transition->getDate(); }
public static function get($key, $group = 'default') { $full_file = self::$dir . '/' . serialize($group . $key); if ($file = File::load($full_file)) { if (Date::dateDiff(Date::now(), $file->getModifiedDate(), 's') > self::$cacheTime) { File::remove($full_file); return false; } return unserialize($file->content()); } return false; }
public function log($context, $appMessages) { $logFile = _hx_string_or_null($context->get_contentDirectory()) . _hx_string_or_null($this->path); $req = $context->request; $res = $context->response; $userDetails = $req->get_clientIP(); if ((null !== $context->session ? $context->session->get_id() : null) !== null) { $userDetails .= " " . _hx_string_or_null(null !== $context->session ? $context->session->get_id() : null); } if (($context->auth !== null && $context->auth->get_currentUser() !== null ? $context->auth->get_currentUser()->get_userID() : null) !== null) { $userDetails .= " " . _hx_string_or_null($context->auth !== null && $context->auth->get_currentUser() !== null ? $context->auth->get_currentUser()->get_userID() : null); } $content = "" . Std::string(Date::now()) . " [" . _hx_string_or_null($req->get_httpMethod()) . "] [" . _hx_string_or_null($req->get_uri()) . "] from [" . _hx_string_or_null($userDetails) . "], response: [" . _hx_string_rec($res->status, "") . " " . _hx_string_or_null($res->get_contentType()) . "]\n"; $_g = 0; $_g1 = $context->messages; while ($_g < $_g1->length) { $msg = $_g1[$_g]; ++$_g; $content .= "\t" . _hx_string_or_null(ufront_log_FileLogger::format($msg)) . "\n"; unset($msg); } if ($appMessages !== null) { $_g2 = 0; while ($_g2 < $appMessages->length) { $msg1 = $appMessages[$_g2]; ++$_g2; $content .= "\t" . _hx_string_or_null(ufront_log_FileLogger::format($msg1)) . "\n"; unset($msg1); } } $path = haxe_io_Path::directory($logFile); $path1 = haxe_io_Path::addTrailingSlash($path); $_p = null; $parts = new _hx_array(array()); while ($path1 !== ($_p = haxe_io_Path::directory($path1))) { $parts->unshift($path1); $path1 = $_p; } $_g3 = 0; while ($_g3 < $parts->length) { $part = $parts[$_g3]; ++$_g3; if (_hx_char_code_at($part, strlen($part) - 1) !== 58 && !file_exists($part)) { @mkdir($part, 493); } unset($part); } $file = sys_io_File::append(_hx_string_or_null($context->get_contentDirectory()) . _hx_string_or_null($this->path), null); $file->writeString($content); $file->close(); return ufront_core_SurpriseTools::success(); }
function check_login(&$system) { if (!isset($_SESSION)) { session_start(); } if (isset($_GET['logout'])) { if ($_GET['logout'] == '') { $_GET['logout'] = $_SESSION['RheinaufCMS_User']['Anrede'] . ' ' . $_SESSION['RheinaufCMS_User']['Name']; } unset($_SESSION['RheinaufCMS_User']); setcookie('RheinaufCMS_user', false, time() - 3600, '/'); } if ($_SESSION['RheinaufCMS_User']) { $system->user = $_SESSION['RheinaufCMS_User']; $system->valid_user = true; return true; } $user = General::input_clean($_POST['user']); $pass = General::input_clean($_POST['pass']); $a = array(); foreach ($system->user_tables as $t) { $sql = "SELECT * FROM `{$t}` WHERE `Login`='{$user}' AND `Password`='{$pass}'"; $result = $system->connection->db_single_row($sql); if ($result) { break; } } if ($user && $pass && $result['Login'] == $user && $result['Password'] == $pass && $_SESSION['uuid'] == $_POST['uuid']) { $_SESSION['RheinaufCMS_User'] = $system->user = General::multi_unserialize($result); $_SESSION['RheinaufCMS_User']['user_found_in'] = $t; setcookie('RheinaufCMS_user', $user, 0, '/'); $system->connection->db_update($t, array('last_login' => Date::now()), "id = '" . $result['id'] . "'"); if (isset($_SESSION['RheinaufCMS_User'])) { $system->rechte = array(); if ($_SESSION['RheinaufCMS_User']['Group'] == 'dev') { $rechte = $system->connection->db_assoc("SELECT * FROM `RheinaufCMS>Rechte`"); for ($i = 0; $i < count($rechte); $i++) { $system->rechte[] = $rechte[$i]['id']; } $_SESSION['RheinaufCMS_User']['allowed_actions'] = $system->rechte; } else { $rechte = General::multi_unserialize($system->connection->db_single_row("SELECT * FROM `RheinaufCMS>Groups` WHERE `Name` ='" . $_SESSION['RheinaufCMS_User']['Group'] . "'")); $_SESSION['RheinaufCMS_User']['allowed_actions'] = $system->rechte = $rechte['Rechte']; } } unset($_SESSION['uuid']); $system->valid_user = true; return true; } else { } return false; }
/** * Throws an deprecated exception if given date was before the * current date. * * If no message is given, an auto-generated message will be used * which contains type/method & location where this method has been * invoked - respectively the location of the deprecated code. * * @param string $namespace_ * @param \Components\Date $date_ * @param string $message_ * * @throws \Components\Deprecated */ public static function sinceDate($namespace_, Date $date_, $message_ = null) { // ignore for production. if (Environment::isLive()) { return; } if (Date::now()->isAfter($date_)) { if (null === $message_) { throw static::createDefaultException($namespace_); } throw new static($namespace_, $message_, null, true); } }
function make_scaffold() { if (!class_exists('FormScaffold')) { include_once 'FormScaffold.php'; } $this->scaff = new FormScaffold('RheinaufCMS>Kalender>Termine', $this->connection); //$this->scaff->re_entry = true; $this->scaff->cols_array['UID']['type'] = 'hidden'; $this->scaff->cols_array['UID']['value'] = $uniqid = $_POST['UID'] ? $_POST['UID'] : 'online_' . md5(uniqid(rand(), true)); $this->scaff->cols_array['SUMMARY']['type'] = 'textarea'; $this->scaff->cols_array['SUMMARY']['name'] = 'Zusammenfassung'; $this->scaff->cols_array['SUMMARY']['required'] = true; $this->scaff->cols_array['SUMMARY']['attributes'] = array('rows' => '1', 'cols' => '80'); $this->scaff->cols_array['DESCRIPTION']['name'] = 'Beschreibung'; $this->scaff->cols_array['DESCRIPTION']['attributes'] = array('rows' => '10', 'cols' => '80'); $this->scaff->cols_array['DESCRIPTION']['html'] = true; $this->scaff->cols_array['LOCATION']['name'] = 'Ort'; $this->scaff->cols_array['LOCATION']['value'] = $_POST['LOCATION'] ? $_POST['LOCATION'] : 'Wachsfabrik'; $this->scaff->cols_array['STATUS']['name'] = 'Status'; $this->scaff->cols_array['STATUS']['type'] = 'select'; $this->scaff->cols_array['STATUS']['value'] = $_POST['STATUS'] ? $_POST['STATUS'] : 'CONFIRMED'; $this->scaff->cols_array['STATUS']['options'] = array('CONFIRMED' => 'fest', 'TENTATIVE' => 'vorläufig', 'CANCELLED' => 'storniert'); $this->scaff->cols_array['CLASS']['name'] = 'Klassifizierung'; $this->scaff->cols_array['CLASS']['type'] = 'select'; $this->scaff->cols_array['CLASS']['value'] = $_POST['CLASS'] ? $_POST['CLASS'] : 'PUBLIC'; $this->scaff->cols_array['CLASS']['options'] = array('PUBLIC' => 'öffentlich', 'PRIVATE' => 'nicht öffentlich'); $this->scaff->cols_array['CATEGORIES']['name'] = 'Kategorie'; $this->scaff->cols_array['CATEGORIES']['type'] = 'select'; $this->scaff->cols_array['CATEGORIES']['required'] = true; $this->scaff->cols_array['CATEGORIES']['options'] = array(); foreach ($this->connection->db_assoc("SELECT * FROM `RheinaufCMS>Kalender>Kategorien` ORDER BY `id`") as $category) { $this->scaff->cols_array['CATEGORIES']['options'][$category['Name']] = $category['Name']; } $this->scaff->cols_array['DTSTART']['name'] = 'Beginn'; $this->scaff->cols_array['DTSTART']['type'] = 'timestamp'; $this->scaff->cols_array['DTSTART']['required'] = true; $this->scaff->cols_array['DTSTART']['value'] = $_GET['new'] ? Date::unify_timestamp($_GET['new']) : ''; $this->scaff->cols_array['DTEND']['name'] = 'Ende'; $this->scaff->cols_array['DTEND']['type'] = 'timestamp'; $this->scaff->cols_array['DTSTAMP']['type'] = 'hidden'; $this->scaff->cols_array['DTSTAMP']['value'] = Date::now(); $this->scaff->cols_array['X-RHEINAUF-LOGO']['type'] = 'ignore'; $this->scaff->cols_array['X-RHEINAUF-BILD']['type'] = 'ignore'; $this->scaff->cols_array['X-RHEINAUF-PREIS']['type'] = 'ignore'; $this->scaff->cols_array['X-RHEINAUF-EVENT']['type'] = 'ignore'; $this->scaff->cols_array['CONTACT']['name'] = 'Kontakt'; $this->scaff->cols_array['CONTACT']['type'] = 'email'; $this->scaff->cols_array['CONTACT']['value'] = ''; $this->scaff->cols_array['X-OTHER-VCAL']['type'] = 'hidden'; include 'Kalender/DefaultValues.php'; }
/** * Lorem ipsum. * * @param string $param1 * @param bool $param2 lorem ipsum * @param string $param3 lorem ipsum * * @return int lorem ipsum */ public function saveRevision(BaseCollection $old_data, $new_data = null, $options = []) { $table = $this->getRevisionsTableName(); $entity = $this->collectionToRevisionEntity($old_data); $data = $entity->getData(); $data = $this->filterFields($data); $uuid1 = Uuid::uuid1(); $data['rev_id'] = $uuid1->toString(); $data['rev_hash'] = $entity->hash(); $data['rev_date'] = Date::now()->toSql(); $data['rev_author'] = $this->user->getFullName(); $status = $this->db->insert($table, $data); return $status; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { if ($this->sampleList === null) { $d1 = new Date(2012, 5, 21); $d2 = new Datetime(2012, 5, 21, 7, 30); $d3 = new Timestamp(2012, 5, 21, 7, 30, 9); $d4 = new Date(2012, 3, 7); $d5 = new Datetime(2012, 3, 7, 0, 0); $d6 = new Timestamp(2012, 3, 7, 0, 0, 0); $d7 = Date::now(); $d8 = Datetime::now()->setAll(array("hour" => 8, "minute" => 6)); $d9 = Timestamp::now()->setAll(array("hour" => 8, "minute" => 6, "second" => 4)); $this->sampleList = array(new SimpleFormatTest_Sample("YmdHis", new SimpleFormatTest_ParseData("20120521073009", "2012052112345", $d1, $d2, $d3), new SimpleFormatTest_FormatData($d1, "20120521000000"), new SimpleFormatTest_FormatData($d2, "20120521073000"), new SimpleFormatTest_FormatData($d3, "20120521073009")), new SimpleFormatTest_Sample("Y年n月j日G時f分b秒", new SimpleFormatTest_ParseData("2012年5月21日7時30分9秒", "2012年05月21日07時30分09秒", $d1, $d2, $d3), new SimpleFormatTest_FormatData($d1, "2012年5月21日0時0分0秒"), new SimpleFormatTest_FormatData($d2, "2012年5月21日7時30分0秒"), new SimpleFormatTest_FormatData($d3, "2012年5月21日7時30分9秒")), new SimpleFormatTest_Sample("\\Y=Y \\n=n \\j=j \\H=H \\i=i \\s=s", new SimpleFormatTest_ParseData("Y=2012 n=5 j=21 H=07 i=30 s=09", "Y=2012 n=5 j=21 H=7 i=30 s=9", $d1, $d2, $d3), new SimpleFormatTest_FormatData($d1, "Y=2012 n=5 j=21 H=00 i=00 s=00"), new SimpleFormatTest_FormatData($d2, "Y=2012 n=5 j=21 H=07 i=30 s=00"), new SimpleFormatTest_FormatData($d3, "Y=2012 n=5 j=21 H=07 i=30 s=09")), new SimpleFormatTest_Sample("Y/m/d", new SimpleFormatTest_ParseData("2012/03/07", "2012-03-07", $d4, $d5, $d6), new SimpleFormatTest_FormatData($d1, "2012/05/21"), new SimpleFormatTest_FormatData($d2, "2012/05/21"), new SimpleFormatTest_FormatData($d3, "2012/05/21")), new SimpleFormatTest_Sample("Y.n.j", new SimpleFormatTest_ParseData("2012.3.7", "hogehoge", $d4, $d5, $d6), new SimpleFormatTest_FormatData($d1, "2012.5.21"), new SimpleFormatTest_FormatData($d2, "2012.5.21"), new SimpleFormatTest_FormatData($d3, "2012.5.21")), new SimpleFormatTest_Sample("H:i:s", new SimpleFormatTest_ParseData("08:06:04", "8:06:04", $d7, $d8, $d9), new SimpleFormatTest_FormatData($d1, "00:00:00"), new SimpleFormatTest_FormatData($d2, "07:30:00"), new SimpleFormatTest_FormatData($d3, "07:30:09")), new SimpleFormatTest_Sample("G時f分b秒", new SimpleFormatTest_ParseData("8時6分4秒", "8じ6分4秒", $d7, $d8, $d9), new SimpleFormatTest_FormatData($d1, "0時0分0秒"), new SimpleFormatTest_FormatData($d2, "7時30分0秒"), new SimpleFormatTest_FormatData($d3, "7時30分9秒")), new SimpleFormatTest_Sample("Y年n月j日(E)", new SimpleFormatTest_ParseData("2012年3月7日(水)", "2012年3月7日(無)", $d4, $d5, $d6), new SimpleFormatTest_FormatData($d1, "2012年5月21日(月)"), new SimpleFormatTest_FormatData($d2, "2012年5月21日(月)"), new SimpleFormatTest_FormatData($d3, "2012年5月21日(月)"))); } }
/** * Constructor * * @param var... parts */ public function __construct() { $this->name = ''; $args = func_get_args(); foreach ($args as $part) { if ($part instanceof ZipDirEntry) { $this->name .= $part->getName(); } else { $this->name .= strtr($part, '\\', '/') . '/'; } } $this->name = rtrim($this->name, '/'); $this->mod = Date::now(); $this->compression = array(Compression::$NONE, 6); }
/** * @see \Components\Ui_Panel::onRetrieveValue() onRetrieveValue */ protected function onRetrieveValue() { $params = $this->scriptlet->request->getParams(); $id = $this->id(); if ($params->containsKey("{$id}-date")) { $date = $params->get("{$id}-date"); } else { $date = Date::now()->formatLocalized('common/date/pattern/short'); } if ($params->containsKey("{$id}-time")) { $time = $params->get("{$id}-time"); } else { $time = Date::now()->formatLocalized('common/time/pattern/short'); } $this->value(Date::parse("{$date} {$time}", Timezone::systemDefault())); }
/** * Creates new version object relating on latest version * * @param org.webdav.version.Webdav*Version * @param io.File file * @return org.webdav.version.Webdav*Version */ public function getNextVersion($actVersion, $file) { // Load same type of version as before $obj = XPClass::forName(XP::typeOf($actVersion)); // Get name of file, without extension $fname = basename($actVersion->getFilename(), '.' . $file->getExtension()); // Get name of directory $dir = substr(dirname($actVersion->getHref()), 12); // Create new version object with($version = $obj->newInstance($actVersion->getFilename())); $version->setVersionNumber($actVersion->getVersionNumber() + 0.1); $version->setHref('../versions/' . $dir . '/' . $fname . '[' . $version->getVersionNumber() . '].' . $file->getExtension()); $version->setVersionName($fname . '[' . $version->getVersionNumber() . '].' . $file->getExtension()); $version->setContentLength($file->size()); $version->setLastModified(Date::now()); return $version; }
public function __construct($message, $Http_Code, $info = null) { if (!php_Boot::$skip_constructor) { parent::__construct(null, _hx_anonymous(array("fileName" => "Error.hx", "lineNumber" => 50, "className" => "system.base.Http_exception", "methodName" => "new"))); while (!system_base_Cache::$cookie_buffer->isEmpty()) { system_base_Wet_base::send_cookie(system_base_Cache::$cookie_buffer->pop()); } header("X-Powered-By" . ": " . "Webrathea/0.4 (PHP)"); $value = DateTools::format(Date::now(), "%a, %d %b %Y %X %Z"); header("Date" . ": " . _hx_string_or_null($value)); header("X-Frame-Options" . ": " . "sameorigin"); header("X-XSS-Protection" . ": " . "1; mode=block"); php_Web::setReturnCode($Http_Code); $message1 = null; $message1 = Std::string($message); haxe_Log::trace("DEPRECATED FUNCTION: " . _hx_string_or_null($message1), _hx_anonymous(array("fileName" => "Base.hx", "lineNumber" => 449, "className" => "system.base.Wet_base", "methodName" => "echo"))); } }
public static function sum($time1, $time2, $op = 'add') { $now = new \DateTime(Date::now(Date::FORMAT_DATE)); if ($op != 'add') { $op == 'sub'; } $time1_slices = explode(':', $time1); $time1_hour = isset($time1_slices[0]) ? (int) $time1_slices[0] : '00'; $time1_min = isset($time1_slices[1]) ? (int) $time1_slices[1] : '00'; $time1_sec = isset($time1_slices[2]) ? (int) $time1_slices[2] : '00'; $time2_slices = explode(':', $time2); $time2_hour = isset($time2_slices[0]) ? (int) $time2_slices[0] : '00'; $time2_min = isset($time2_slices[1]) ? (int) $time2_slices[1] : '00'; $time2_sec = isset($time2_slices[2]) ? (int) $time2_slices[2] : '00'; $now->add(new \DateInterval("PT{$time1_hour}H{$time1_min}M{$time1_sec}S")); $now->{$op}(new \DateInterval("PT{$time2_hour}H{$time2_min}M{$time2_sec}S")); $time = $now->format('H:i:s'); return $time; }
public function toString() { if ($this->data->error->message === null) { $this->data->error->message = "no error message available"; } $str = "Error: " . _hx_string_or_null($this->data->error->message); $_g = 0; $_g1 = $this->data->error->crumbs; while ($_g < $_g1->length) { $crumb = $_g1[$_g]; ++$_g; $str .= "\n- " . _hx_string_or_null($crumb->classPath); if ($crumb->methodName !== null) { $str .= " -> " . _hx_string_or_null($crumb->methodName); } unset($crumb); } return _hx_string_or_null($str) . "\n" . _hx_string_or_null(Date::now()->toString()); }
/** * Execute the email command. * * @return mixed */ public function fire() { $schedule = $this->argument('schedule'); if ($schedule == "DAY") { $schedule = '1 Day'; } elseif ($schedule == "WEEK") { $schedule = '7 Day'; } else { $schedule = '31 Day'; } $emails = Emails::where('when', '=', $schedule)->get(); foreach ($emails as $email) { $tjobs = Job::where('jobstatus', '=', 'T')->where('starttime', '>=', Date::now()->sub($schedule))->where('endtime', '<=', Date::now())->whereIn('clientid', unserialize($email->clients))->get(); $data['table'] = $tjobs; /* sends Email */ Mail::send('emails.report', $data, function ($message, $schedule) { $message->to($email->emails)->subject('Backups Stats ' . $schedule . ' Report'); }); } }
/** * Helper method * * @param string input * @param bool lower whether this is the lower boundary * @return util.Date */ protected function parseDate($input, $lower) { switch ($input) { case '__NOW__': if ($lower) { $r = DateUtil::getMidnight(Date::now()); } else { $r = DateUtil::getMidnight(DateUtil::addDays(Date::now(), 1)); } break; case '__FUTURE__': $r = Date::now(); break; case '__UNLIMITED__': $r = NULL; break; default: $r = DateParser::parse($input); } return $r; }
/** * Parse raw listing entry. * * @param string raw a single line * @param peer.ftp.FtpConnection connection * @param string base default "/" * @param util.Date ref default NULL * @return peer.ftp.FtpEntry */ public function entryFrom($raw, FtpConnection $conn = NULL, $base = '/', Date $ref = NULL) { sscanf($raw, '%s %d %s %s %d %s %d %[^ ] %[^$]', $permissions, $numlinks, $user, $group, $size, $month, $day, $date, $filename); // Only qualify filenames if they appear unqualified in the listing if ('/' !== $filename[0]) { $filename = $base . $filename; } // Create a directory or an entry if ('d' === $permissions[0]) { $e = new FtpDir($filename, $conn); } else { $e = new FtpFile($filename, $conn); } // If the entry contains a timestamp, the year is omitted, "Apr 4 20:16" // instead of "Apr 4 2009". This compact format is used when the file // time is within six months* from the current date, in either direction! // // *] #define SIXMONTHS ((365 / 2) * 86400) := 15724800 // See http://svn.freebsd.org/base/projects/releng_7_xen/bin/ls/print.c if (strstr($date, ':')) { $ref || ($ref = Date::now()); $d = new Date($month . ' ' . $day . ' ' . $ref->getYear() . ' ' . $date); if ($d->getTime() - $ref->getTime() > 15724800) { $d = DateUtil::addMonths($d, -12); } } else { $d = new Date($month . ' ' . $day . ' ' . $date); } try { $e->setPermissions(substr($permissions, 1)); $e->setNumlinks($numlinks); $e->setUser($user); $e->setGroup($group); $e->setSize($size); $e->setDate($d); } catch (IllegalArgumentException $e) { throw new FormatException('Cannot parse "' . $raw . '": ' . $e->getMessage()); } return $e; }
function grabarUsuario() { header('Content-Type: application/json'); if ($_POST['id_personal'] == '') { $error['id'] = 0; $error['mensaje'] = "Seleccione al personal"; echo json_encode($error); } else { if ($_POST['nom_usuario'] == '') { $error['id'] = 0; $error['mensaje'] = "Ingrese un nombre de usuario valido"; echo json_encode($error); } else { if ($_POST['password'] == '') { $error['id'] = 0; $error['mensaje'] = "Ingrese una Contraseña"; echo json_encode($error); } else { $funcion = new funciones(); Session::init(); $dataUsuario['id_usuario'] = $funcion->model->getLastID('s_usuario', 5); $dataUsuario['id_personal'] = $_POST['id_personal']; $dataUsuario['nom_usuario'] = $_POST['nom_usuario']; $dataUsuario['password'] = Hash::create(ALGO, $_POST["password"], HASH_KEY); $dataUsuario['id_estado'] = '01'; $dataUsuario['id_usuario_crea'] = Session::getValue('ID'); $dataUsuario['fecha_crea'] = Date::invertDate2(Date::today()) . ' ' . Date::now(); if ($this->model->grabarUsuario($dataUsuario)) { echo 1; } else { $error['id'] = 0; $error['mensaje'] = "No se registró"; echo json_encode($error); } } } } }
public function requestIn($ctx) { $_g = $this; if (strtolower($ctx->request->get_httpMethod()) === "post" && $ctx->request->isMultipart()) { $file = null; $postName = null; $origFileName = null; $size = 0; $tmpFilePath = null; $dateStr = DateTools::format(Date::now(), "%Y%m%d-%H%M"); $dir = _hx_string_or_null($ctx->get_contentDirectory()) . _hx_string_or_null(haxe_io_Path::addTrailingSlash(ufront_web_upload_TmpFileUploadMiddleware::$subDir)); $path = haxe_io_Path::removeTrailingSlashes($dir); $path1 = haxe_io_Path::addTrailingSlash($path); $_p = null; $parts = new _hx_array(array()); while ($path1 !== ($_p = haxe_io_Path::directory($path1))) { $parts->unshift($path1); $path1 = $_p; } $_g1 = 0; while ($_g1 < $parts->length) { $part = $parts[$_g1]; ++$_g1; if (_hx_char_code_at($part, strlen($part) - 1) !== 58 && !file_exists($part)) { @mkdir($part, 493); } unset($part); } $onPart = array(new _hx_lambda(array(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$origFileName, &$postName, &$size, &$tmpFilePath), "ufront_web_upload_TmpFileUploadMiddleware_0"), 'execute'); $onData = array(new _hx_lambda(array(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$onPart, &$origFileName, &$postName, &$size, &$tmpFilePath), "ufront_web_upload_TmpFileUploadMiddleware_1"), 'execute'); $onEndPart = array(new _hx_lambda(array(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$onData, &$onPart, &$origFileName, &$postName, &$size, &$tmpFilePath), "ufront_web_upload_TmpFileUploadMiddleware_2"), 'execute'); return tink_core__Future_Future_Impl_::map($ctx->request->parseMultipart($onPart, $onData, $onEndPart), array(new _hx_lambda(array(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$onData, &$onEndPart, &$onPart, &$origFileName, &$postName, &$size, &$tmpFilePath), "ufront_web_upload_TmpFileUploadMiddleware_3"), 'execute'), null); } else { return ufront_core_SurpriseTools::success(); } }
static function main() { haxe_Log::$trace = isset(me_cunity_php_Debug::$_trace) ? me_cunity_php_Debug::$_trace : array("me_cunity_php_Debug", "_trace"); S::$conf = Config::load("appData.js"); php_Session::start(); $pd = php_Web::getPostData(); haxe_Log::trace($pd, _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 54, "className" => "S", "methodName" => "main"))); $params = php_Web::getParams(); if ($params->get("debug") === "1") { header("Content-Type" . ": " . "text/html; charset=utf-8"); S::$headerSent = true; php_Lib::println("<div><pre>"); php_Lib::println($params); } haxe_Log::trace(Date::now()->toString(), _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 63, "className" => "S", "methodName" => "main"))); haxe_Log::trace($params, _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 64, "className" => "S", "methodName" => "main"))); $action = $params->get("action"); if (strlen($action) === 0 || $params->get("className") === null) { S::dump(_hx_anonymous(array("error" => "required params missing"))); return; } S::$my = new MySQLi("localhost", S::$dbUser, S::$dbPass, S::$db, null, null); $auth = S::checkAuth(); haxe_Log::trace(_hx_string_or_null($action) . ":" . Std::string($auth), _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 77, "className" => "S", "methodName" => "main"))); if (!$auth) { S::hexit("AUTH FAILURE"); return; } $result = Model::dispatch($params); haxe_Log::trace($result, _hx_anonymous(array("fileName" => "S.hx", "lineNumber" => 85, "className" => "S", "methodName" => "main"))); if (!S::$headerSent) { header("Content-Type" . ": " . "application/json"); S::$headerSent = true; } php_Lib::println($result); }
public function applyCredit() { // Get an instance of the credits repo $credits = App::make('CreditRepository'); // Find the code $item = $credits->findByCode(Input::get('code')); // Setup the return $return = ['code' => 0, 'message' => 'An error occurred.']; if ($item) { if ((int) $item->user_id === 0 and empty($item->email)) { $updateData['user_id'] = $this->currentUser->id; if ($item->type == 'time') { $updateData['expires'] = \Date::now()->addDay()->addYear()->startOfDay(); } // Update the credit $credits->update($item->id, $updateData); // Set a successful return code $return['code'] = 1; } else { // Set the flash message $return['message'] = "The user credit code you've entered is already in use and cannot be applied to your account. Please contact Brian Jacobs Golf for further help."; } } else { // Set the flash message $return['message'] = "User credit code not found!"; } return json_encode($return); }
* @return Func */ static function getGlobalConstructor() { $Date = new Func(function () { $date = new Date(); $date->init(func_get_args()); return $date; }); $Date->set('prototype', Date::$protoObject); $Date->setMethods(Date::$classMethods, true, false, true); return $Date; } } Date::$classMethods = array('now' => function () { return Date::now(); }, 'parse' => function ($str) { $date = new Date($str); return $date->value; }, 'UTC' => function () { $date = new Date(); $date->_initFromParts(func_get_args(), 'UTC'); return $date->value; }); Date::$protoMethods = array('valueOf' => function () { $self = Func::getContext(); return $self->value; }, 'toJSON' => function () { $self = Func::getContext(); //2014-08-09T12:00:00.000Z return $self->toJSON();
public function tempoAtras($date) { $time = Date::format($date, 'U'); $now = Date::now('U'); $diff = $now - $time; $output = null; switch ($diff) { case $diff < 0: $output = 'back to the future'; case $diff < 5: $output = 'neste instante'; break; case $diff < 50: $output = $diff . ' segundos atrás'; break; case $diff < 100: $output = '1 minuto atrás'; break; case $diff < 3400: $output = (int) ($diff / 60) . ' minutos atrás'; break; case $diff < 3600: $output = 'menos de 1 hora atrás'; break; case $diff < 7200: $output = (int) ($diff / 3600) . ' hora atrás'; break; case $diff < 43200: $output = (int) ($diff / 3600) . ' horas atrás'; break; //case $diff < 172800: $output = 'Ontem'; break; //case $diff < 345600: $output = (int)($diff/86400) . ' dias atrás'; break; } //echo Date::now('W') .'-'. (Date::format($date, 'W') - 1); if (empty($output)) { //Faz mais de 12 horas if ($diff >= 43200 && $diff <= 86400) { //É no dia de hoje? Exiba as horas if (Date::now('dmy') == Date::format($date, 'dmy')) { $output = (int) $diff / 3600 . ' horas atrás'; } else { $output = 'Ontem'; } } elseif (Date::now('ymd') == Date::format($date, 'ymd') - 1) { $ouput = 'Ontem'; } elseif ($diff < 345600) { $output = (int) ($diff / 86400) . ' dias atrás'; } elseif (Date::now('W') == Date::format($date, 'W') - 1) { $output = 'Semana passada'; } else { $output = 'Em ' . Date::format($date, 'd/m/Y'); } } return $output; }
/** * Generated the entry for the users table. * * @param string $user_login The user login slug * @param int $user_id The user id * @param string $role The user role * * @return array An associtive array of column/values for the "users" table. */ protected static function generateUserDefaultsFrom($user_login, $user_id, $role = 'subscriber') { $usersTableDefaults = array('ID' => $user_id, 'user_login' => $user_login, 'user_pass' => '' . md5($user_login), 'user_nicename' => $user_login, 'user_email' => $user_login . "@example.com", 'user_url' => 'http://www.example.com', 'user_registered' => Date::now(), 'user_status' => '0', 'display_name' => $user_login); return $usersTableDefaults; }
public static function today() { $date = Date::now(); $date->hour = 0; $date->minute = 0; $date->second = 0; return $date; }
/** * LIST: This command causes a list of file names and file details * to be sent from the FTP site to the client. * * @param peer.Socket socket * @param string params */ public function onList($socket, $params) { if (!($dataSocket = $this->openDatasock($socket))) { return; } // Split options from arguments if (substr($params, 0, 1) === '-') { list($options, $params) = explode(' ', substr($params, 1), 2); $this->cat && $this->cat->debug('+++ Options:', $options); } else { $options = ''; } if (!($entry = $this->storage->lookup($socket->hashCode(), $params))) { $this->answer($socket, 550, $params . ': No such file or directory'); $dataSocket->close(); delete($dataSocket); $this->cat && $this->cat->debug($socket, $this->datasock[$socket->hashCode()]); return; } // Invoke interceptor if (!$this->checkInterceptors($socket, $entry, 'onRead')) { $dataSocket->close(); return; } $this->answer($socket, 150, sprintf('Opening %s mode data connection for filelist', $this->sessions[$socket->hashCode()]->typeName())); // If a collection was specified, list its elements, otherwise, // list the single element if ($entry instanceof StorageCollection && !strstr($options, 'd')) { $elements = $entry->elements(); } else { $elements = array($entry); } $before6Months = DateUtil::addMonths(Date::now(), -6)->getTime(); for ($i = 0, $s = sizeof($elements); $i < $s; $i++) { $buf = sprintf('%s %2d %s %s %8d %s %s', $this->permissionString($elements[$i]->getPermissions()), $elements[$i]->numLinks(), $elements[$i]->getOwner(), $elements[$i]->getGroup(), $elements[$i]->getSize(), date($elements[$i]->getModifiedStamp() < $before6Months ? 'M d Y' : 'M d H:i', $elements[$i]->getModifiedStamp()), $elements[$i]->getName()); $this->cat && $this->cat->debug(' ', $buf); $dataSocket->write($buf . $this->eol($this->sessions[$socket->hashCode()]->getType())); } $dataSocket->close(); $this->answer($socket, 226, 'Transfer complete'); }