本文整理汇总了PHP中Scalr_Util_DateTime类的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Util_DateTime类的具体用法?PHP Scalr_Util_DateTime怎么用?PHP Scalr_Util_DateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Scalr_Util_DateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xListTasksAction
public function xListTasksAction()
{
$this->request->defineParams(array('sort' => array('type' => 'json', 'default' => array('property' => 'dtadded', 'direction' => 'DESC'))));
$sql = "SELECT id FROM dm_deployment_tasks WHERE status !='" . Scalr_Dm_DeploymentTask::STATUS_ARCHIVED . "' AND env_id = '{$this->getEnvironmentId()}'";
$response = $this->buildResponseFromSql($sql, array("id"));
foreach ($response["data"] as $k => $row) {
$data = false;
try {
$deploymentTask = Scalr_Dm_DeploymentTask::init()->loadById($row['id']);
$application = $deploymentTask->getApplication();
try {
$dbServer = DBServer::LoadByID($deploymentTask->serverId);
$serverIndex = $dbServer->index;
} catch (Exception $e) {
}
$data = array('id' => $deploymentTask->id, 'application_name' => $application->name, 'application_id' => $deploymentTask->applicationId, 'server_id' => $deploymentTask->serverId, 'server_index' => $serverIndex, 'remote_path' => $deploymentTask->remotePath, 'status' => $deploymentTask->status, 'dtadded' => $deploymentTask->dtAdded ? Scalr_Util_DateTime::convertTz($deploymentTask->dtAdded) : "", 'dtdeployed' => $deploymentTask->dtDeployed ? Scalr_Util_DateTime::convertTz($deploymentTask->dtDeployed) : "Never");
try {
$dbFarmRole = DBFarmRole::LoadByID($deploymentTask->farmRoleId);
$data['farm_roleid'] = $dbFarmRole->ID;
$data['role_name'] = $dbFarmRole->GetRoleObject()->name;
$data['farm_id'] = $dbFarmRole->FarmID;
$data['farm_name'] = $dbFarmRole->GetFarmObject()->Name;
} catch (Exception $e) {
}
} catch (Exception $e) {
}
$response["data"][$k] = $data;
}
$this->response->data($response);
}
示例2: xListEventsAction
public function xListEventsAction()
{
$this->request->defineParams(array('farmId' => array('type' => 'int'), 'eventServerId', 'eventId', 'query' => array('type' => 'string'), 'sort' => array('type' => 'string', 'default' => 'id'), 'dir' => array('type' => 'string', 'default' => 'DESC')));
$sql = "SELECT farmid, message, type, dtadded, event_server_id, event_id FROM events WHERE farmid='{$this->dbFarm->ID}'";
if ($this->getParam('eventServerId')) {
$sql .= " AND event_server_id = " . $this->db->qstr($this->getParam('eventServerId'));
}
if ($this->getParam('eventId')) {
$sql .= " AND event_id = " . $this->db->qstr($this->getParam('eventId'));
}
$response = $this->buildResponseFromSql($sql, array("message", "type", "dtadded", "event_server_id", "event_id"));
$cache = array();
foreach ($response['data'] as &$row) {
$row['message'] = nl2br($row['message']);
$row["dtadded"] = Scalr_Util_DateTime::convertTz($row["dtadded"]);
$row['scripts'] = $this->db->GetOne("SELECT COUNT(*) FROM scripting_log WHERE event_id = ?", array($row['event_id']));
if ($row['event_server_id']) {
$esInfo = $this->db->GetRow("SELECT role_id, farm_roleid, `index`, farm_id FROM servers WHERE server_id = ? LIMIT 1", array($row['event_server_id']));
if ($esInfo) {
if (!$cache['farm_names'][$esInfo['farm_id']]) {
$cache['farm_names'][$esInfo['farm_id']] = $this->db->GetOne("SELECT name FROM farms WHERE id=?", array($esInfo['farm_id']));
}
$row['event_farm_name'] = $cache['farm_names'][$esInfo['farm_id']];
$row['event_farm_id'] = $esInfo['farm_id'];
$row['event_farm_roleid'] = $esInfo['farm_roleid'];
if (!$cache['role_names'][$esInfo['role_id']]) {
$cache['role_names'][$esInfo['role_id']] = $this->db->GetOne("SELECT name FROM roles WHERE id=?", array($esInfo['role_id']));
}
$row['event_role_name'] = $cache['role_names'][$esInfo['role_id']];
$row['event_server_index'] = $esInfo['index'];
}
}
}
$this->response->data($response);
}
示例3: getAccountEnvironmentsList
public function getAccountEnvironmentsList()
{
$environments = $this->user->getEnvironments();
$result = array();
foreach ($environments as &$row) {
$env = Scalr_Environment::init()->loadById($row['id']);
$row['platforms'] = $env->getEnabledPlatforms();
$row['teams'] = array();
if ($this->getContainer()->config->get('scalr.auth_mode') == 'ldap') {
$row['teamIds'] = array();
}
foreach ($env->getTeams() as $teamId) {
if ($this->getContainer()->config->get('scalr.auth_mode') == 'ldap') {
$team = new Scalr_Account_Team();
$team->loadById($teamId);
$row['teams'][] = $team->name;
$row['teamIds'][] = $teamId;
} else {
$row['teams'][] = $teamId;
}
}
$row['dtAdded'] = Scalr_Util_DateTime::convertTz($env->dtAdded);
$row['status'] = $env->status;
if ($this->getContainer()->analytics->enabled) {
$row['ccId'] = $env->getPlatformConfigValue(Scalr_Environment::SETTING_CC_ID);
}
$result[] =& $row;
}
return $result;
}
示例4: testIncrescentTimeInterval
/**
* @test
* @dataProvider providerIncrescentTimeInterval
*/
public function testIncrescentTimeInterval($date, $curDate, $expected)
{
$this->assertEquals($expected, \Scalr_Util_DateTime::getIncrescentTimeInterval($date, $curDate));
$date = DateTime::createFromFormat('Y-m-d H:i:s', $date);
$curDate = DateTime::createFromFormat('Y-m-d H:i:s', $curDate);
$this->assertEquals($expected, \Scalr_Util_DateTime::getIncrescentTimeInterval($date, $curDate));
}
示例5: xListTasksAction
public function xListTasksAction()
{
$this->request->defineParams(array('sort' => array('type' => 'json', 'default' => array('property' => 'dtadded', 'direction' => 'DESC'))));
$sql = "\n SELECT\n dt.id, dma.name AS application_name, servers.index AS server_index, farms.name AS farm_name, roles.name AS role_name,\n dt.status AS status, dt.dtadded AS dtadded\n FROM dm_deployment_tasks dt\n LEFT JOIN dm_applications dma ON dt.dm_application_id = dma.id\n LEFT JOIN servers ON servers.id = dt.server_id\n LEFT JOIN farms ON servers.farm_id = farms.id\n LEFT JOIN roles ON servers.farm_roleid = roles.id\n WHERE dt.`status` != ? AND dt.env_id = ?\n ";
$args = array(Scalr_Dm_DeploymentTask::STATUS_ARCHIVED, $this->getEnvironmentId());
list($sql, $args) = $this->request->prepareFarmSqlQuery($sql, $args, 'farms');
$response = $this->buildResponseFromSql2($sql, array('id', 'application_name', 'farm_name', 'role_name', 'server_index', 'status', 'dtadded', 'dtdeployed'), array(), $args);
foreach ($response["data"] as $k => $row) {
$data = false;
try {
$deploymentTask = Scalr_Dm_DeploymentTask::init()->loadById($row['id']);
$application = $deploymentTask->getApplication();
try {
$dbServer = DBServer::LoadByID($deploymentTask->serverId);
$serverIndex = $dbServer->index;
} catch (Exception $e) {
}
$data = array('id' => $deploymentTask->id, 'application_name' => $application->name, 'application_id' => $deploymentTask->applicationId, 'server_id' => $deploymentTask->serverId, 'server_index' => $serverIndex, 'remote_path' => $deploymentTask->remotePath, 'status' => $deploymentTask->status, 'dtadded' => $deploymentTask->dtAdded ? Scalr_Util_DateTime::convertTz($deploymentTask->dtAdded) : "", 'dtdeployed' => $deploymentTask->dtDeployed ? Scalr_Util_DateTime::convertTz($deploymentTask->dtDeployed) : "Never");
try {
$dbFarmRole = DBFarmRole::LoadByID($deploymentTask->farmRoleId);
$data['farm_roleid'] = $dbFarmRole->ID;
$data['role_name'] = $dbFarmRole->GetRoleObject()->name;
$data['farm_id'] = $dbFarmRole->FarmID;
$data['farm_name'] = $dbFarmRole->GetFarmObject()->Name;
} catch (Exception $e) {
}
} catch (Exception $e) {
}
$response["data"][$k] = $data;
}
$this->response->data($response);
}
示例6: getBackupDetails
private function getBackupDetails($backupId)
{
$links = array();
$backup = Scalr_Db_Backup::init()->loadById($backupId);
$this->user->getPermissions()->validate($backup);
$data = array('backup_id' => $backup->id, 'farm_id' => $backup->farmId, 'type' => ROLE_BEHAVIORS::GetName($backup->service) ? ROLE_BEHAVIORS::GetName($backup->service) : 'unknown', 'date' => Scalr_Util_DateTime::convertTz($backup->dtCreated), 'size' => $backup->size ? round($backup->size / 1024 / 1024, 2) : 0, 'provider' => $backup->provider, 'cloud_location' => $backup->cloudLocation, 'farmName' => DBFarm::LoadByIDOnlyName($backup->farmId));
$downloadParts = $backup->getParts();
foreach ($downloadParts as $part) {
$part['size'] = $part['size'] ? round($part['size'] / 1024 / 1024, 2) : '';
if ($part['size'] == 0) {
$part['size'] = 0.01;
}
if ($data['provider'] == 's3') {
$part['link'] = $this->getS3SignedUrl($part['path']);
} else {
if ($data['provider'] == 'cf') {
if ($backup->platform == SERVER_PLATFORMS::RACKSPACE) {
$part['link'] = $this->getCfSignedUrl($part['path'], $data['cloud_location'], $backup->platform);
} else {
$part['link'] = "swift://{$part['path']}";
}
} else {
continue;
}
}
$part['path'] = pathinfo($part['path']);
$links[$part['number']] = $part;
}
$data['links'] = $links;
return $data;
}
示例7: xListTasksAction
public function xListTasksAction()
{
$this->request->defineParams(array('bundleTaskId' => array('type' => 'int'), 'sort' => array('type' => 'string', 'default' => 'id'), 'dir' => array('type' => 'string', 'default' => 'DESC')));
$sql = "SELECT * FROM bundle_tasks WHERE env_id = '" . $this->getEnvironmentId() . "'";
if ($this->getParam('id') > 0) {
$sql .= " AND id = " . $this->db->qstr($this->getParam('bundleTaskId'));
}
$response = $this->buildResponseFromSql($sql, array("server_id", "rolename", "failure_reason", "snapshot_id", "id"));
foreach ($response["data"] as &$row) {
$row['server_exists'] = DBServer::IsExists($row['server_id']);
$row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
if (!$row['bundle_type']) {
$row['bundle_type'] = "*";
}
if ($row['dtfinished'] && $row['dtstarted']) {
$row['duration'] = Scalr_Util_DateTime::getDateTimeDiff($row['dtfinished'], $row['dtstarted']);
}
if ($row['dtfinished']) {
$row['dtfinished'] = Scalr_Util_DateTime::convertTz($row['dtfinished']);
}
if ($row['dtstarted']) {
$row['dtstarted'] = Scalr_Util_DateTime::convertTz($row['dtstarted']);
}
}
$this->response->data($response);
}
示例8: xGetListAction
public function xGetListAction()
{
$this->request->defineParams(array('query', 'sort' => array('type' => 'json')));
$hist = new WebhookHistory();
$sql = "SELECT " . $hist->fields('h') . ", w.name AS webhookName, e.url\n FROM " . $hist->table() . " h\n INNER JOIN webhook_endpoints e ON h.endpoint_id = e.endpoint_id\n INNER JOIN webhook_configs w ON h.webhook_id = w.webhook_id\n WHERE e.env_id = ?\n AND :FILTER:\n ";
$args = array($this->getEnvironmentId());
if ($this->getParam('eventId')) {
$sql .= ' AND h.event_id = ?';
$args[] = $this->getParam('eventId');
}
$response = $this->buildResponseFromSql2($sql, array('created'), array('e.url', 'h.event_type'), $args);
foreach ($response['data'] as $index => $row) {
$hist = new WebhookHistory();
$hist->load($row);
$item = array();
foreach (get_object_vars($hist) as $k => $v) {
$item[$k] = $v;
}
$item['url'] = $row['url'];
$item['webhookName'] = $row['webhookName'];
$item['created'] = Scalr_Util_DateTime::convertTz($hist->created);
unset($hist);
$response['data'][$index] = $item;
}
$this->response->data($response);
}
示例9: xListAction
/**
* @param string $query
* @param string $platform
* @param string $cloudLocation
* @param JsonData $sort
* @param int $start
* @param int $limit
* @throws Exception
*/
public function xListAction($query = null, $platform = null, $cloudLocation = null, JsonData $sort, $start = 0, $limit = 20)
{
$this->request->restrictAccess(Acl::RESOURCE_FARMS_ROLES);
$criteria = [];
$criteria[] = ['envId' => $this->getEnvironmentId()];
if ($query) {
$querySql = '%' . $query . '%';
$criteria[] = ['$or' => [['id' => ['$like' => $querySql]]]];
}
if ($platform) {
$criteria[] = ['platform' => $platform];
}
if ($cloudLocation) {
$criteria[] = ['cloudLocation' => $cloudLocation];
}
$result = Image::find($criteria, \Scalr\UI\Utils::convertOrder($sort, ['id' => 'ASC'], ['id', 'platform', 'cloudLocation', 'os', 'dtAdded', 'architecture', 'source']), $limit, $start, true);
$data = [];
foreach ($result as $image) {
/* @var Image $image */
$s = get_object_vars($image);
$s['dtAdded'] = Scalr_Util_DateTime::convertTz($image->dtAdded);
$s['status'] = $image->isUsed() ? 'In use' : 'Not used';
$data[] = $s;
}
$this->response->data(['total' => $result->totalNumber, 'data' => $data]);
}
示例10: xListTasksAction
public function xListTasksAction()
{
$this->request->defineParams(array('bundleTaskId' => array('type' => 'int'), 'sort' => array('type' => 'json', 'default' => array('property' => 'id', 'direction' => 'DESC'))));
$sql = "SELECT * FROM bundle_tasks WHERE env_id = ?";
$args = array($this->getEnvironmentId());
if ($this->getParam('id') > 0) {
$sql .= " AND id = ?";
$args[] = $this->getParam('bundleTaskId');
}
$response = $this->buildResponseFromSql2($sql, array('id', 'server_id', 'rolename', 'status', 'os_family', 'dtadded', 'dtstarted', 'created_by_email'), array(), $args);
foreach ($response["data"] as &$row) {
$row['server_exists'] = DBServer::IsExists($row['server_id']);
$row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
if (!$row['bundle_type']) {
$row['bundle_type'] = "*";
}
if ($row['dtfinished'] && $row['dtstarted']) {
$row['duration'] = Scalr_Util_DateTime::getDateTimeDiff($row['dtfinished'], $row['dtstarted']);
}
if ($row['dtfinished']) {
$row['dtfinished'] = Scalr_Util_DateTime::convertTz($row['dtfinished']);
}
if ($row['dtstarted']) {
$row['dtstarted'] = Scalr_Util_DateTime::convertTz($row['dtstarted']);
}
}
$this->response->data($response);
}
示例11: getRevisions
/**
* @return array
*/
public function getRevisions()
{
$revisions = $this->db->GetAll("SELECT id, revision, script, dtcreated as dtCreated, variables FROM script_revisions WHERE scriptid=? ORDER BY revision DESC", array($this->id));
foreach ($revisions as $index => $rev) {
$revisions[$index]['dtCreated'] = Scalr_Util_DateTime::convertTz($rev['dtCreated']);
$revisions[$index]['variables'] = unserialize($revisions[$index]['variables']);
}
return $revisions;
}
示例12: xListEventsAction
public function xListEventsAction()
{
$this->request->defineParams(array('farmId' => array('type' => 'int'), 'query' => array('type' => 'string'), 'sort' => array('type' => 'string', 'default' => 'id'), 'dir' => array('type' => 'string', 'default' => 'DESC')));
$sql = "SELECT farmid, message, type, dtadded FROM events WHERE farmid='{$this->dbFarm->ID}'";
$response = $this->buildResponseFromSql($sql, array("message", "type", "dtadded"));
foreach ($response['data'] as &$row) {
$row['message'] = nl2br($row['message']);
$row["dtadded"] = Scalr_Util_DateTime::convertTz($row["dtadded"]);
}
$this->response->data($response);
}
示例13: xGetClusterLogAction
public function xGetClusterLogAction()
{
$dbFarmRole = $this->getFarmRole();
$sql = "SELECT id, severity, dtadded, message FROM services_mongodb_cluster_log WHERE farm_roleid=" . $this->db->qstr($dbFarmRole->ID);
$response = $this->buildResponseFromSql($sql, array("message", "severity"), " ORDER BY id DESC");
foreach ($response["data"] as &$row) {
$row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
$row['message'] = nl2br(htmlspecialchars($row['message']));
}
$this->response->data($response);
}
示例14: xListAccountsAction
public function xListAccountsAction()
{
$this->request->defineParams(array('sort' => array('type' => 'json'), 'accountId' => array('type' => 'int')));
$sql = "SELECT id, name, dtadded, status FROM clients WHERE :FILTER:";
$args = array();
if ($this->getParam('serverId')) {
$sql .= " AND `id` IN (SELECT `client_id` FROM `servers_history` WHERE `server_id` = ?)";
$args[] = $this->getParam('serverId');
}
if ($this->getParam('farmId')) {
$sql .= ' AND id IN (SELECT clientid FROM farms WHERE id = ?)';
$args[] = $this->getParam('farmId');
}
if ($this->getParam('owner')) {
$sql .= ' AND id IN (SELECT account_id FROM account_users WHERE `type` = ? AND email LIKE ?)';
$args[] = Scalr_Account_User::TYPE_ACCOUNT_OWNER;
$args[] = '%' . $this->getParam('owner') . '%';
}
if ($this->getParam('user')) {
$sql .= ' AND id IN (SELECT account_id FROM account_users WHERE email LIKE ?)';
$args[] = '%' . $this->getParam('user') . '%';
}
if ($this->getParam('envId')) {
$sql .= ' AND id IN (SELECT client_id FROM client_environments WHERE id = ?)';
$args[] = $this->getParam('envId');
}
$response = $this->buildResponseFromSql2($sql, array('id', 'name', 'dtadded', 'status'), array('id', 'name'), $args);
foreach ($response['data'] as &$row) {
$account = Scalr_Account::init()->loadById($row['id']);
try {
$owner = $account->getOwner();
$row['ownerEmail'] = $owner->getEmail();
$row['ownerLocked'] = $owner->status == User::STATUS_INACTIVE;
} catch (Exception $e) {
$row['ownerEmail'] = '*No owner*';
}
$row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
$row['isTrial'] = (int) $account->getSetting(Scalr_Account::SETTING_IS_TRIAL);
$limit = Scalr_Limits::init()->Load(Scalr_Limits::ACCOUNT_ENVIRONMENTS, $row['id']);
$row['envs'] = $limit->getCurrentUsage();
$row['limitEnvs'] = $limit->getLimitValue() > -1 ? $limit->getLimitValue() : '-';
$limit = Scalr_Limits::init()->Load(Scalr_Limits::ACCOUNT_FARMS, $row['id']);
$row['farms'] = $limit->getCurrentUsage();
$row['limitFarms'] = $limit->getLimitValue() > -1 ? $limit->getLimitValue() : '-';
$limit = Scalr_Limits::init()->Load(Scalr_Limits::ACCOUNT_USERS, $row['id']);
$row['users'] = $limit->getCurrentUsage();
$row['limitUsers'] = $limit->getLimitValue() > -1 ? $limit->getLimitValue() : '-';
$limit = Scalr_Limits::init()->Load(Scalr_Limits::ACCOUNT_SERVERS, $row['id']);
$row['servers'] = $limit->getCurrentUsage();
$row['limitServers'] = $limit->getLimitValue() > -1 ? $limit->getLimitValue() : '-';
$row['dnsZones'] = $this->db->GetOne("SELECT COUNT(*) FROM dns_zones WHERE client_id = ?", array($row['id']));
}
$this->response->data($response);
}
示例15: xGetClusterLogAction
public function xGetClusterLogAction()
{
$dbFarmRole = $this->getFarmRole();
$sql = "SELECT id, severity, dtadded, message FROM services_mongodb_cluster_log WHERE farm_roleid = ? AND :FILTER:";
$args = [$dbFarmRole->ID];
$response = $this->buildResponseFromSql2($sql, ['id', 'severity', 'message', 'dtadded'], ['message', 'severity'], $args);
foreach ($response["data"] as &$row) {
$row['dtadded'] = Scalr_Util_DateTime::convertTz($row['dtadded']);
$row['message'] = nl2br(htmlspecialchars($row['message']));
}
$this->response->data($response);
}