コード例 #1
1
ファイル: attendees.php プロジェクト: reeleis/ohiocitycycles
 function export()
 {
     global $mainframe;
     $model = $this->getModel('attendees');
     $datas = $model->getData();
     header('Content-Type: text/x-csv');
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Disposition: attachment; filename=attendees.csv');
     header('Pragma: no-cache');
     $k = 0;
     $export = '';
     $col = array();
     for ($i = 0, $n = count($datas); $i < $n; $i++) {
         $data =& $datas[$i];
         $col[] = str_replace("\"", "\"\"", $data->name);
         $col[] = str_replace("\"", "\"\"", $data->username);
         $col[] = str_replace("\"", "\"\"", $data->email);
         $col[] = str_replace("\"", "\"\"", JHTML::Date($data->uregdate, JText::_('DATE_FORMAT_LC2')));
         $col[] = str_replace("\"", "\"\"", $data->uid);
         for ($j = 0; $j < count($col); $j++) {
             $export .= "\"" . $col[$j] . "\"";
             if ($j != count($col) - 1) {
                 $export .= ";";
             }
         }
         $export .= "\r\n";
         $col = '';
         $k = 1 - $k;
     }
     echo $export;
     $mainframe->close();
 }
コード例 #2
1
 /**
  * Returns the cookie as a string.
  *
  * @return string The cookie
  */
 public function __toString()
 {
     $str = urlencode($this->getName()) . '=';
     if ('' === (string) $this->getValue()) {
         $str .= 'deleted; expires=' . gmdate('D, d-M-Y H:i:s T', time() - 31536001);
     } else {
         $str .= urlencode($this->getValue());
         if ($this->getExpiresTime() !== 0) {
             $str .= '; expires=' . gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime());
         }
     }
     if ($this->path) {
         $str .= '; path=' . $this->path;
     }
     if ($this->getDomain()) {
         $str .= '; domain=' . $this->getDomain();
     }
     if (true === $this->isSecure()) {
         $str .= '; secure';
     }
     if (true === $this->isHttpOnly()) {
         $str .= '; httponly';
     }
     return $str;
 }
コード例 #3
1
 /**
  * {@inheritdoc}
  */
 protected function transfer()
 {
     while (!$this->stopped && !$this->source->isConsumed()) {
         if ($this->source->getContentLength() && $this->source->isSeekable()) {
             // If the stream is seekable and the Content-Length known, then stream from the data source
             $body = new ReadLimitEntityBody($this->source, $this->partSize, $this->source->ftell());
         } else {
             // We need to read the data source into a temporary buffer before streaming
             $body = EntityBody::factory();
             while ($body->getContentLength() < $this->partSize && $body->write($this->source->read(max(1, min(10 * Size::KB, $this->partSize - $body->getContentLength()))))) {
             }
         }
         // @codeCoverageIgnoreStart
         if ($body->getContentLength() == 0) {
             break;
         }
         // @codeCoverageIgnoreEnd
         $params = $this->state->getUploadId()->toParams();
         $command = $this->client->getCommand('UploadPart', array_replace($params, array('PartNumber' => count($this->state) + 1, 'Body' => $body, 'ContentMD5' => (bool) $this->options['part_md5'], Ua::OPTION => Ua::MULTIPART_UPLOAD)));
         // Notify observers that the part is about to be uploaded
         $eventData = $this->getEventData();
         $eventData['command'] = $command;
         $this->dispatch(self::BEFORE_PART_UPLOAD, $eventData);
         // Allow listeners to stop the transfer if needed
         if ($this->stopped) {
             break;
         }
         $response = $command->getResponse();
         $this->state->addPart(UploadPart::fromArray(array('PartNumber' => count($this->state) + 1, 'ETag' => $response->getHeader('ETag', true), 'Size' => $body->getContentLength(), 'LastModified' => gmdate(DateFormat::RFC2822))));
         // Notify observers that the part was uploaded
         $this->dispatch(self::AFTER_PART_UPLOAD, $eventData);
     }
 }
コード例 #4
0
ファイル: format.php プロジェクト: enormego/EightPHP
 /**
  * Formats a second into years, months, days, hours, minutes, seconds.
  * 
  * Example:
  * format::seconds(65) returns "1 minute, 5 seconds"
  * 
  * @param	int		number of seconds
  * @return	string	formatted seconds
  */
 public static function seconds($seconds)
 {
     list($years, $months, $days, $hours, $minutes, $seconds) = explode(":", gmdate("Y:n:j:G:i:s", $seconds));
     $years -= 1970;
     $months--;
     $days--;
     $parts = array();
     if ($years > 0) {
         $parts[] = $years . " " . str::plural("year", $years);
     }
     if ($months > 0) {
         $parts[] = $months . " " . str::plural("month", $months);
     }
     if ($days > 0) {
         $parts[] = $days . " " . str::plural("day", $days);
     }
     if ($hours > 0) {
         $parts[] = $hours . " " . str::plural("hour", $hours);
     }
     if ($minutes > 0) {
         $parts[] = sprintf("%d", $minutes) . " " . str::plural("minute", $minutes);
     }
     if ($seconds > 0) {
         $parts[] = sprintf("%d", $seconds) . " " . str::plural("second", $seconds);
     }
     return implode(", ", $parts);
 }
コード例 #5
0
function httpNoCache()
{
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Pragma: no-cache");
    header("Cache-Control: no-cache, must-revalidate");
}
コード例 #6
0
ファイル: Services.php プロジェクト: jacjimus/furahia_mis
 public function afterFind()
 {
     $this->cost = number_format($this->cost / 100, 2, '.', ',');
     $this->timestamp = gmdate('dS-M-Y', $this->timestamp);
     $this->service_status = $this->service_status === '1' ? "Active" : "Inactive";
     return parent::afterFind();
 }
コード例 #7
0
ファイル: Manifest.php プロジェクト: andygoo/cms
    public function action_index()
    {
        header("Last-Modified: " . gmdate('D, d M Y H:i:s T'));
        header("Expires: " . gmdate('D, d M Y H:i:s T', time() + 315360000));
        header("Cache-Control: max-age=315360000");
        header('Content-Type: text/cache-manifest; charset=utf-8');
        //header("HTTP/1.1 304 Not Modified");
        $version = date('Y-m-d H:i:s');
        echo <<<EOF
CACHE MANIFEST

# VERSION {$version}

# 直接缓存的文件
CACHE:
/media/MDicons/css/MDicon.min.css
/media/mdl/material.cyan-red.min.css
/media/mdl/material.min.js
/media/sidebarjs/sidebarjs.css
/media/css/weui.min.css
/media/js/jquery.min.js
/media/sidebarjs/sidebarjs.js
/media/MDicons/fonts/mdicon.woff
http://7xkkhh.com1.z0.glb.clouddn.com/2016/08/01/14700177870141.jpg?imageView2/1/w/600/h/302

# 需要在线访问的文件
NETWORK:
*

# 替代方案
FALLBACK:
#/ offline.html
EOF;
        exit;
    }
コード例 #8
0
function graphs()
{
    $t = $_GET["t"];
    /*
    if($t=='day'){$day='id=tab_current';$title=$t;$t="1$t";}
    if($t=='week'){$week='id=tab_current';$t="2$t";}
    if($t=='month'){$month='id=tab_current';$t="3$t";}	
    
    <div id=tablist>
    <li><a href=\"javascript:LoadAjax2('graphs','$page?graph=yes&hostname={$_GET["hostname"]}&t=day');\">{day}</a></li>
    <li><a href=\"javascript:LoadAjax2('graphs','$page?graph=yes&hostname={$_GET["hostname"]}&t=week');\">{week}</a></li>
    <li><a href=\"javascript:LoadAjax2('graphs','$page?graph=yes&hostname={$_GET["hostname"]}&t=month');\">{month}</a></li>
    </div>*/
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("content-type:text/html");
    $md = md5(date('Ymdhis'));
    $users = new usersMenus(nul, 0, $_GET["hostname"]);
    $html = "\n<input type='hidden' id='t' value='{$t}'>\n<p class='caption'>{queue_flow_text}</p>\n<table style='width:600px' align=center>\n<tr>\n<td valign='top'>\n\t<center style='margin:4px'>\n\t\t<H5>{queue_flow_day}</H5>\n\t\t<img src='images.listener.php?uri=mailgraph/queuegraph_0.png&md={$md}'>\n\t</center>\n\t<center style='margin:4px'>\n\t\t<H5>{queue_flow_week}</H5>\n\t\t<img src='images.listener.php?uri=mailgraph/queuegraph_1.png&md={$md}'>\n\t</center>\n\t<center style='margin:4px'>\n\t\t<H5>{queue_flow_month}</H5>\n\t\t<img src='images.listener.php?uri=mailgraph/queuegraph_2.png&md={$md}'>\n\t</center>\n\t<center style='margin:4px'>\n\t\t<H5>{queue_flow_year}</H5>\n\t\t<img src='images.listener.php?uri=mailgraph/queuegraph_3.png&md={$md}'>\n\t</center>\t\t\t\t\t\t\n</td>\n</tr>\n</table>\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
コード例 #9
0
ファイル: model.php プロジェクト: khavq/smdemo
 /**
  * @author KhaVu
  * @copyright 2015-04-21
  * @param $param
  * @return 
  */
 function delete_multi($id)
 {
     $now = gmdate("Y-m-d H:i:s", time() + 7 * 3600);
     //$sql = "UPDATE `gds_stock_device` SET `del_if` = 1, `dateupdated` = '$now' WHERE `device_id` IN ($id)  and `device_id` > 0";
     //$this->model->query($sql)->execute();
     $this->model->table('gds_stock_device')->where("device_id in({$id})")->update(array('del_if' => 1, 'dateupdated' => $now));
 }
コード例 #10
0
ファイル: PageCache.php プロジェクト: ceko/concrete5-1
 public function getCacheHeaders(ConcretePage $c)
 {
     $lifetime = $c->getCollectionFullPageCachingLifetimeValue();
     $expires = gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT';
     $headers = array('Pragma' => 'public', 'Cache-Control' => 'max-age=' . $lifetime . ',s-maxage=' . $lifetime, 'Expires' => $expires);
     return $headers;
 }
コード例 #11
0
ファイル: CacheClient.php プロジェクト: kaibosh/nZEDb
 /**
  * Do a GET request.
  *
  * @param resource $ch
  * @param string $url
  * @throws CurlException
  * @return string
  */
 private function doGet($ch, $url)
 {
     $now = time();
     $resource = $this->getResourceName($url);
     $date = $this->cache->getDate($resource);
     $limit = $now - $this->ttl;
     //Return content if ttl has not yet expired.
     if ($date > 0 && $date > $limit) {
         return $this->cache->getContent($resource);
     }
     //Add the If-Modified-Since header
     if ($date > 0) {
         curl_setopt($ch, CURLOPT_HTTPHEADER, array(sprintf("If-Modified-Since: %s GMT", gmdate("D, d M Y H:i:s", $date))));
     }
     curl_setopt($ch, CURLOPT_FILETIME, true);
     $data = $this->curlExec($ch);
     $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     $date = curl_getinfo($ch, CURLINFO_FILETIME);
     curl_close($ch);
     //Return content from cache.
     if ($httpCode == 304) {
         $this->cache->setDate($resource, $date);
         return $this->cache->getContent($resource);
     }
     //Cache content
     if ($httpCode == 200) {
         $date = $date >= 0 ? $date : $now;
         $this->cache->cache($resource, $date, $data);
         return $data;
     }
     throw new CurlException(sprintf('Cannot fetch %s', $url), $httpCode);
 }
コード例 #12
0
ファイル: response.php プロジェクト: ateliee/pmp
 /**
  * @param $expires
  */
 public function setCacheHeader($expires)
 {
     $this->setHeader('Last-Modified', gmdate('D, d M Y H:i:s T', time()));
     $this->setHeader('Expires', gmdate('D, d M Y H:i:s T', time() + $expires));
     $this->setHeader('Cache-Control', 'private, max-age=' . $expires);
     $this->setHeader('Pragma', '');
 }
コード例 #13
0
 /**
  * Retrieves data from cache, if it's there.  If it is, but it's expired,
  * it performs a conditional GET to see if the data is updated.  If it
  * isn't, it down updates the modification time of the cache file and
  * returns the data.  If the cache is not there, or the remote file has been
  * modified, it is downloaded and cached.
  *
  * @param string URL of remote file to retrieve
  * @param int Length of time to cache file locally before asking the server
  *            if it changed.
  * @return string File contents
  */
 function retrieveFile($url, $cacheLength, $cacheDir)
 {
     $cacheID = md5($url);
     $cache = new Cache_Lite(array("cacheDir" => $cacheDir, "lifeTime" => $cacheLength));
     if ($data = $cache->get($cacheID)) {
         return $data;
     } else {
         // we need to perform a request, so include HTTP_Request
         include_once 'HTTP/Request.php';
         // HTTP_Request has moronic redirect "handling", turn that off (Alexey Borzov)
         $req = new HTTP_Request($url, array('allowRedirects' => false));
         // if $cache->get($cacheID) found the file, but it was expired,
         // $cache->_file will exist
         if (isset($cache->_file) && file_exists($cache->_file)) {
             $req->addHeader('If-Modified-Since', gmdate("D, d M Y H:i:s", filemtime($cache->_file)) . " GMT");
         }
         $req->sendRequest();
         if (!($req->getResponseCode() == 304)) {
             // data is changed, so save it to cache
             $data = $req->getResponseBody();
             $cache->save($data, $cacheID);
             return $data;
         } else {
             // retrieve the data, since the first time we did this failed
             if ($data = $cache->get($cacheID, 'default', true)) {
                 return $data;
             }
         }
     }
     Services_ExchangeRates::raiseError("Unable to retrieve file {$url} (unknown reason)", SERVICES_EXCHANGERATES_ERROR_RETRIEVAL_FAILED);
     return false;
 }
コード例 #14
0
 /**
  * checks the request for the order by and if that is not set then it checks the session for it
  *
  * @return array containing the keys orderBy => field being ordered off of and sortOrder => the sort order of that field
  */
 function getOrderBy($orderBy = '', $direction = '')
 {
     if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
         if (!empty($_REQUEST[$this->var_order_by])) {
             $direction = 'ASC';
             $orderBy = $_REQUEST[$this->var_order_by];
             if (!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0)) {
                 $direction = $_REQUEST['lvso'];
                 $trackerManager = TrackerManager::getInstance();
                 if ($monitor = $trackerManager->getMonitor('tracker')) {
                     $monitor->setValue('module_name', $GLOBALS['module']);
                     $monitor->setValue('item_summary', "lvso=" . $direction . "&" . $this->var_order_by . "=" . $_REQUEST[$this->var_order_by]);
                     $monitor->setValue('action', 'listview');
                     $monitor->setValue('user_id', $GLOBALS['current_user']->id);
                     $monitor->setValue('date_modified', gmdate($GLOBALS['timedate']->get_db_date_time_format()));
                     $monitor->save();
                 }
             }
         }
         $_SESSION[$this->var_order_by] = array('orderBy' => $orderBy, 'direction' => $direction);
         $_SESSION['lvd']['last_ob'] = $orderBy;
     } else {
         if (!empty($_SESSION[$this->var_order_by])) {
             $orderBy = $_SESSION[$this->var_order_by]['orderBy'];
             $direction = $_SESSION[$this->var_order_by]['direction'];
         }
     }
     return array('orderBy' => $orderBy, 'sortOrder' => $direction);
 }
コード例 #15
0
ファイル: Time.php プロジェクト: smartboyathome/Known
 /**
  * Convert an epoch timestamp into an RFC2616 (HTTP) compatible date.
  * @param type $timestamp Optionally, an epoch timestamp. Defaults to the current time.
  */
 public static function timestampToRFC2616($timestamp = false)
 {
     if ($timestamp === false) {
         $timestamp = time();
     }
     return gmdate('D, d M Y H:i:s T', (int) $timestamp);
 }
コード例 #16
0
ファイル: htmlWriter.php プロジェクト: Naatan/CrossORM
    /** Build the HTML header. Includes doctype definition, <html> and <head>
     * sections, meta data and window title.
     *
     * @return str
     */
    function _htmlHeader($title)
    {
        $output = $this->_doctype();
        $output .= '<html lang="en">' . "\n";
        $output .= "<head>\n\n";
        $output .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n\n";
        $output .= '<meta name="generator" content="PHPDoctor ' . $this->_doclet->version() . ' (http://peej.github.com/phpdoctor/)">' . "\n";
        $output .= '<meta name="when" content="' . gmdate('r') . '">' . "\n\n";
        $output .= '<link rel="stylesheet" type="text/css" href="' . str_repeat('../', $this->_depth) . 'stylesheet.css">' . "\n";
        $output .= '<link rel="start" href="' . str_repeat('../', $this->_depth) . 'overview-summary.html">' . "\n\n";
        $output .= '<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>' . "\n";
        $output .= '<script type="text/javascript">
			$(document).ready(function() {
				$(\'iframe\').load(function() {
				  this.style.height =
				  this.contentWindow.document.body.offsetHeight + \'px\';
				});
			});
		</script>' . "\n";
        $output .= '<title>';
        if ($title) {
            $output .= $title . ' (' . $this->_doclet->windowTitle() . ')';
        } else {
            $output .= $this->_doclet->windowTitle();
        }
        $output .= "</title>\n\n";
        $output .= "</head>\n";
        return $output;
    }
コード例 #17
0
 /**
  * setting methods
  */
 public function setStatus($status)
 {
     $user = $this->getUser();
     switch ($status) {
         case 'pending':
             $this->decline_date = null;
             $this->accept_date = null;
             $this->save();
             $user->owner_flag = 0;
             break;
         case 'denied':
             $this->decline_date = gmdate('Y-m-d H:i:s');
             $this->accept_date = null;
             $this->save();
             Mail::send('emails.ownership-denied', array('user' => $user), function ($message) {
                 $message->to($this->getUser()->email, $this->getUser()->getFullName());
                 $message->subject('SWAMP Owner Application Denied');
             });
             $user->owner_flag = 0;
             break;
         case 'approved':
             $this->accept_date = gmdate('Y-m-d H:i:s');
             $this->decline_date = null;
             $this->save();
             Mail::send('emails.ownership-approved', array('user' => $user), function ($message) {
                 $message->to($this->getUser()->email, $this->getUser()->getFullName());
                 $message->subject('SWAMP Owner Application Approved');
             });
             $user->owner_flag = 1;
             break;
     }
 }
コード例 #18
0
ファイル: Farms.php プロジェクト: sacredwebsite/scalr
 /**
  * Gets the list of farms
  *
  * @param string $query optional Search query
  * @return array        Retuens array of farms
  */
 private function getFarmsList($query = null)
 {
     $farms = [];
     $collection = $this->getContainer()->analytics->usage->findFarmsByKey($this->environment->id, $query);
     if ($collection->count()) {
         $iterator = ChartPeriodIterator::create('month', gmdate('Y-m-01'), null, 'UTC');
         $criteria = ['envId' => $this->environment->id];
         //It calculates usage for all provided cost centres
         $usage = $this->getContainer()->analytics->usage->getFarmData($this->environment->clientId, $criteria, $iterator->getStart(), $iterator->getEnd(), [TagEntity::TAG_ID_FARM, TagEntity::TAG_ID_FARM_ROLE, TagEntity::TAG_ID_PLATFORM]);
         //It calculates usage for previous period same days
         $prevusage = $this->getContainer()->analytics->usage->getFarmData($this->environment->clientId, $criteria, $iterator->getPreviousStart(), $iterator->getPreviousEnd(), [TagEntity::TAG_ID_FARM]);
         foreach ($collection as $dbFarm) {
             /* @var $dbFarm \DBFarm */
             $totalCost = round(isset($usage['data'][$dbFarm->ID]) ? $usage['data'][$dbFarm->ID]['cost'] : 0, 2);
             $farms[$dbFarm->ID] = $this->getFarmData($dbFarm);
             if (isset($usage['data'][$dbFarm->ID]['data'])) {
                 $farms[$dbFarm->ID]['topSpender'] = $this->getFarmRoleTopSpender($usage['data'][$dbFarm->ID]['data']);
             } else {
                 $farms[$dbFarm->ID]['topSpender'] = null;
             }
             $prevCost = round(isset($prevusage['data'][$dbFarm->ID]) ? $prevusage['data'][$dbFarm->ID]['cost'] : 0, 2);
             $farms[$dbFarm->ID] = $this->getWrappedUsageData(['farmId' => $dbFarm->ID, 'iterator' => $iterator, 'usage' => $totalCost, 'prevusage' => $prevCost]) + $farms[$dbFarm->ID];
         }
     }
     return array_values($farms);
 }
コード例 #19
0
function gzipoutput($text)
{
    global $HTTP_ACCEPT_ENCODING;
    $returntext = $text;
    if (function_exists("crc32") and function_exists("gzcompress")) {
        if (strpos(" " . $HTTP_ACCEPT_ENCODING, "x-gzip")) {
            $encoding = "x-gzip";
        }
        if (strpos(" " . $HTTP_ACCEPT_ENCODING, "gzip")) {
            $encoding = "gzip";
        }
        if ($encoding) {
            header("Content-Encoding: {$encoding}");
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
            // Date in the past
            header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
            // always modified
            header("Cache-Control: no-store, no-cache, must-revalidate");
            // HTTP/1.1
            header("Cache-Control: post-check=0, pre-check=0", false);
            header("Pragma: no-cache");
            // HTTP/1.0
            $size = strlen($text);
            $crc = crc32($text);
            $returntext = "‹";
            $returntext .= substr(gzcompress($text, 1), 0, -4);
            $returntext .= pack("V", $crc);
            $returntext .= pack("V", $size);
        }
    }
    return $returntext;
}
コード例 #20
0
 private function _remakeURI($baseurl, $params)
 {
     // Timestamp パラメータを追加します
     // - 時間の表記は ISO8601 形式、タイムゾーンは UTC(GMT)
     $params['Timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z');
     // パラメータの順序を昇順に並び替えます
     ksort($params);
     // canonical string を作成します
     $canonical_string = '';
     foreach ($params as $k => $v) {
         $canonical_string .= '&' . $this->_urlencode_rfc3986($k) . '=' . $this->_urlencode_rfc3986($v);
     }
     $canonical_string = substr($canonical_string, 1);
     // 署名を作成します
     // - 規定の文字列フォーマットを作成
     // - HMAC-SHA256 を計算
     // - BASE64 エンコード
     $parsed_url = parse_url($baseurl);
     $string_to_sign = "GET\n{$parsed_url['host']}\n{$parsed_url['path']}\n{$canonical_string}";
     $signature = base64_encode(hash_hmac('sha256', $string_to_sign, SECRET_KEY, true));
     // URL を作成します
     // - リクエストの末尾に署名を追加
     $url = $baseurl . '?' . $canonical_string . '&Signature=' . $this->_urlencode_rfc3986($signature);
     return $url;
 }
コード例 #21
0
/**
 * Get all the necessary details to directly upload a private file to S3
 * asynchronously with JavaScript.
 *
 * @param string $s3Bucket your bucket's name on s3.
 * @param string $region   the bucket's location, see here for details: http://amzn.to/1FtPG6r
 * @param string $acl      the visibility/permissions of your file, see details: http://amzn.to/18s9Gv7
 *
 * @return array ['url', 'inputs'] the forms url to s3 and any inputs the form will need.
 */
function getS3Details($s3Bucket, $region, $acl = 'private')
{
    // Options and Settings
    $algorithm = "AWS4-HMAC-SHA256";
    $service = "s3";
    $date = gmdate('Ymd\\THis\\Z');
    $shortDate = gmdate('Ymd');
    $requestType = "aws4_request";
    $expires = '86400';
    // 24 Hours
    $successStatus = '201';
    $url = '//' . $s3Bucket . '.' . $service . '-' . $region . '.amazonaws.com';
    // Step 1: Generate the Scope
    $scope = [AWS_ACCESS_KEY, $shortDate, $region, $service, $requestType];
    $credentials = implode('/', $scope);
    // Step 2: Making a Base64 Policy
    $policy = ['expiration' => gmdate('Y-m-d\\TG:i:s\\Z', strtotime('+6 hours')), 'conditions' => [['bucket' => $s3Bucket], ['acl' => $acl], ['starts-with', '$key', ''], ['starts-with', '$Content-Type', ''], ['success_action_status' => $successStatus], ['x-amz-credential' => $credentials], ['x-amz-algorithm' => $algorithm], ['x-amz-date' => $date], ['x-amz-expires' => $expires]]];
    $base64Policy = base64_encode(json_encode($policy));
    // Step 3: Signing your Request (Making a Signature)
    $dateKey = hash_hmac('sha256', $shortDate, 'AWS4' . AWS_SECRET, true);
    $dateRegionKey = hash_hmac('sha256', $region, $dateKey, true);
    $dateRegionServiceKey = hash_hmac('sha256', $service, $dateRegionKey, true);
    $signingKey = hash_hmac('sha256', $requestType, $dateRegionServiceKey, true);
    $signature = hash_hmac('sha256', $base64Policy, $signingKey);
    // Step 4: Build form inputs
    // This is the data that will get sent with the form to S3
    $inputs = ['Content-Type' => '', 'acl' => $acl, 'success_action_status' => $successStatus, 'policy' => $base64Policy, 'X-amz-credential' => $credentials, 'X-amz-algorithm' => $algorithm, 'X-amz-date' => $date, 'X-amz-expires' => $expires, 'X-amz-signature' => $signature];
    return compact('url', 'inputs');
}
コード例 #22
0
ファイル: expires.php プロジェクト: Juuro/Dreamapp-Website
 /**
  * Checks to see if a page should be updated or send Not Modified status
  *
  * @param   integer  Seconds added to the modified time received to calculate what should be sent
  * @return  bool     FALSE when the request needs to be updated
  */
 public static function check($seconds = 60)
 {
     if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) and expires::check_headers()) {
         if (($strpos = strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], ';')) !== FALSE) {
             // IE6 and perhaps other IE versions send length too, compensate here
             $mod_time = substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, $strpos);
         } else {
             $mod_time = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
         }
         $mod_time = strtotime($mod_time);
         $mod_time_diff = $mod_time + $seconds - time();
         if ($mod_time_diff > 0) {
             // Re-send headers
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', $mod_time));
             header('Expires: ' . gmdate('D, d M Y H:i:s T', time() + $mod_time_diff));
             header('Cache-Control: max-age=' . $mod_time_diff);
             header('Status: 304 Not Modified', TRUE, 304);
             // Prevent any output
             Event::add('system.display', array('expires', 'prevent_output'));
             // Exit to prevent other output
             exit;
         }
     }
     return FALSE;
 }
コード例 #23
0
 public function sortTweets($tweets, $tweetLimit = 100)
 {
     $activity = array();
     foreach ($tweets as $t) {
         $text = $t->text;
         // Convert URLs into hyperlinks
         $text = preg_replace("/(http:\\/\\/)(.*?)\\/([\\w\\.\\/\\&\\=\\?\\-\\,\\:\\;\\#\\_\\~\\%\\+]*)/", "<a href=\"\\0\">\\0</a>", $text);
         // Convert usernames (@) into links
         $text = preg_replace("(@([a-zA-Z0-9\\_]+))", '<a target="_blank" href="http://www.twitter.com/\\1">\\0</a>', $text);
         // Convert hash tags (#) to links
         $text = preg_replace('/(^|\\s)#(\\w+)/', '\\1<a href="http://search.twitter.com/search?q=%23\\2">#\\2</a>', $text);
         //Specifically for non-English tweets, converts UTF-8 into ISO-8859-1
         //$text = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text);
         $text = utf8_decode($text);
         // get the URL of the status..
         $status = "https://twitter.com/ppi_framework/status/" . (string) $t->id;
         $timestamp = strtotime($t->created_at . ' UTC');
         $propertime = gmdate('F jS Y, H:i', $timestamp);
         //Customize this to your liking
         //Store tweet and time into the array
         $tweet_item = array('title' => $text, 'url' => $status, 'date' => $propertime, 'source' => 'twitter');
         $activity[$timestamp] = $tweet_item;
         if (count($activity) >= $tweetLimit) {
             break;
         }
     }
     krsort($activity);
     return $activity;
 }
コード例 #24
0
function wapfooter()
{
    global $discuz_uid, $discuz_user, $lang, $action, $settings, $timestamp, $timeoffset, $wapdateformat, $timeformat;
    echo "<p>" . gmdate("{$wapdateformat} {$timeformat}", $timestamp + $timeoffset * 3600) . "<br />" . ($action != 'home' ? "<anchor title=\"confirm\"><prev/>{$lang['return']}</anchor> <a href=\"index.php\">{$lang['home_page']}</a><br />" : '') . ($discuz_uid ? "<a href=\"index.php?action=login&amp;logout=yes&amp;formhash=" . FORMHASH . "\">{$discuz_user}:{$lang['logout']}</a>" : "<a href=\"index.php?action=login\">{$lang['login']}</a> <a href=\"index.php?action=register\">{$lang['register']}</a>") . "<br /><br />\n" . "<small>Powered by Discuz!</small></p>\n" . "</card>\n" . "</wml>";
    updatesession();
    wmloutput();
}
コード例 #25
0
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     // Ensure that the signable query string parameters are sorted
     sort($this->signableQueryString);
     // Add the security token header if one is being used by the credentials
     if ($token = $credentials->getSecurityToken()) {
         $request->setHeader('x-amz-security-token', $token);
     }
     $request->removeHeader('x-amz-date');
     $request->setHeader('Date', gmdate(\DateTime::RFC2822));
     $stringToSign = $this->createCanonicalizedString($request);
     $request->getParams()->set('aws.string_to_sign', $stringToSign);
     $request->setHeader('Authorization', 'AWS ' . $credentials->getAccessKeyId() . ':' . $this->signString($stringToSign, $credentials));
     //         COMMONLOG(DEBUG, "send header:%s",$request->getRawHeaders());
     //         if(self::$isFile)
     //         {
     //         	if(self::$filePath)
     //         		COMMONLOG(DEBUG, "souce file:%s",self::$filePath);
     //         }
     //         else
     //        {
     //        		if(get_class($request) === 'Guzzle\Http\Message\EntityEnclosingRequest' && get_class($request->getBody()) === 'Guzzle\Http\EntityBody' &&  $request->getBody()->getContentLength() != 0)
     //        		{
     //        			COMMONLOG(DEBUG, "send msg:%s",$request->getBody());
     //        		}
     //         }
 }
コード例 #26
0
ファイル: attendees.php プロジェクト: JKoelman/JEM-3
 function export()
 {
     $app = JFactory::getApplication();
     $model = $this->getModel('attendees');
     $datas = $model->getItems();
     header('Content-Type: text/csv');
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Disposition: attachment; filename=attendees.csv');
     header('Pragma: no-cache');
     $export = '';
     $col = array();
     for ($i = 0; $i < count($datas); $i++) {
         $data = $datas[$i];
         $col[] = str_replace("\"", "\"\"", $data->name);
         $col[] = str_replace("\"", "\"\"", $data->username);
         $col[] = str_replace("\"", "\"\"", $data->email);
         $col[] = str_replace("\"", "\"\"", JHtml::_('date', $data->uregdate, JText::_('DATE_FORMAT_LC2')));
         $col[] = str_replace("\"", "\"\"", $data->uid);
         for ($j = 0; $j < count($col); $j++) {
             $export .= "\"" . $col[$j] . "\"";
             if ($j != count($col) - 1) {
                 $export .= ";";
             }
         }
         $export .= "\r\n";
         $col = '';
     }
     echo $export;
     $app->close();
 }
コード例 #27
0
 /**
  *    Send the headers necessary to ensure the page is
  *    reloaded on every request. Otherwise you could be
  *    scratching your head over out of date test data.
  *    @access public
  *    @static
  */
 function sendNoCacheHeaders() {
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
 }
コード例 #28
0
function wfSpecialYouTubePost ($url, $content, $headers = null) {
	// Set the date of your post
	$issued=gmdate("Y-m-d\TH:i:s\Z", time());

	if ($headers == null)
	$headers  =  array( "Content-type: application/x-www-form-urlencoded" );

	// Use curl to post to your blog.
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 4);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
	curl_setopt($ch, CURLOPT_VERBOSE, 1);

	$data = curl_exec($ch);

	if (curl_errno($ch)) {
		print curl_error($ch);
	}
	else {
		curl_close($ch);
	}

	// $data contains the result of the post...
	return $data;
}
コード例 #29
0
 function expense_tracker_export()
 {
     $this->layout = "";
     $this->ath();
     $filename = "expense_tracker_import";
     header("Expires: 0");
     header("Last-Modified: " . gmdate("D,d M YH:i:s") . "GMT");
     header("Cache-Control: no-cache, must-revalidate");
     header("Pragma: no-cache");
     header("Content-type: application/vnd.ms-excel");
     header("Content-Disposition: attachment; filename=" . $filename . ".csv");
     header("Content-Description: Generated Report");
     $s_role_id = $this->Session->read('hm_role_id');
     $s_society_id = (int) $this->Session->read('hm_society_id');
     $s_user_id = (int) $this->Session->read('hm_user_id');
     $date = date("d-m-Y");
     $excel = "Posting Date,Date of invoice,Due Date,Party account head,Invoice Reference,Expense Head,Amount of invoice, Description \n";
     $this->loadmodel('accounts_group');
     $conditions = array("accounts_id" => 4);
     $result_account_group = $this->accounts_group->find('all', array('conditions' => $conditions));
     //pr($result_account_group);
     $auto_id = $result_account_group[0]['accounts_group']['auto_id'];
     $result_ledger_account = $this->requestAction(array('controller' => 'hms', 'action' => 'expense_tracker_fetch2'), array('pass' => array($auto_id)));
     $expense_head = @$result_ledger_account[0]['ledger_account']['ledger_name'];
     $this->loadmodel('ledger_sub_account');
     $conditions = array("ledger_id" => 15, "society_id" => $s_society_id);
     $result_ledger_sub_account = $this->ledger_sub_account->find('all', array('conditions' => $conditions));
     $party_ac_head = @$result_ledger_sub_account[0]['ledger_sub_account']['name'];
     $excel .= "" . $date . "," . $date . "," . $date . "," . $party_ac_head . ",test," . $expense_head . ",100,description";
     echo $excel;
 }
コード例 #30
0
ファイル: images.php プロジェクト: andrewkrug/repucaution
 public function display()
 {
     //parse image uri
     $preset = $this->uri->segment(2);
     $fileId = $this->uri->segment(3);
     $file = new File($fileId);
     if (!$file->isFileOfUser($this->c_user->id)) {
         return false;
     }
     $imageFile = $file->image->get();
     $updated = (string) $file->image->updated;
     $manipulator = $this->get('core.image.manipulator');
     if ($this->input->post()) {
         $this->cropParamUpdate($file);
         echo 'images/' . $preset . '/' . $fileId . '/' . $imageFile->updated . '?prev=' . $updated;
     } else {
         $path = FCPATH . $file->path . '/' . $file->fullname;
         $output = $manipulator->getImagePreset($path, $preset, $imageFile, Arr::get($_GET, 'prev', null));
         if ($output) {
             $info = getimagesize($output);
             header("Content-Disposition: filename={$output};");
             header("Content-Type: {$info["mime"]}");
             header('Content-Transfer-Encoding: binary');
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
             readfile($output);
         }
     }
 }