本文整理汇总了PHP中Kurogo::tempDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Kurogo::tempDirectory方法的具体用法?PHP Kurogo::tempDirectory怎么用?PHP Kurogo::tempDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kurogo
的用法示例。
在下文中一共展示了Kurogo::tempDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveData
protected function retrieveData($url)
{
if (strpos($url, '.kmz') !== false) {
if (!class_exists('ZipArchive')) {
throw new KurogoException("class ZipArchive (php-zip) not available");
}
$tmpDir = Kurogo::tempDirectory();
if (!is_writable($tmpDir)) {
throw new KurogoConfigurationException("Temporary directory {$tmpDir} not available");
}
$tmpFile = $tmpDir . '/tmp.kmz';
copy($url, $tmpFile);
$zip = new ZipArchive();
$zip->open($tmpFile);
$contents = $zip->getFromIndex(0);
unlink($tmpFile);
return $contents;
// this is false on failure, same as file_get_contents
}
return parent::retrieveData($url);
}
示例2: exportStatsData
/**
* export the stats data to the database
*/
public static function exportStatsData($startTimestamp = null)
{
$site = Kurogo::sharedInstance()->getSite();
$baseLogDir = $site->getBaseLogDir();
$logDir = $site->getLogDir();
$statsLogFileName = Kurogo::getOptionalSiteVar('KUROGO_STATS_LOG_FILENAME', 'kurogo_stats_log_v1');
//if the base dir is different then the log dir then get all files with the log file name
if ($baseLogDir != $logDir) {
$logFiles = glob($baseLogDir . DIRECTORY_SEPARATOR . "*" . DIRECTORY_SEPARATOR . $statsLogFileName);
} else {
$logFiles = array($logDir . DIRECTORY_SEPARATOR . $statsLogFileName);
}
//cycle through all log files
foreach ($logFiles as $statsLogFile) {
if (!file_exists($statsLogFile)) {
continue;
}
$today = date('Ymd', time());
//copy the log file
$tempLogFolder = Kurogo::tempDirectory();
$statsLogFileCopy = rtrim($tempLogFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . "stats_log_copy.{$today}";
if (!is_writable($tempLogFolder)) {
throw new Exception("Unable to write to Temporary Directory {$tempLogFolder}");
}
if (!rename($statsLogFile, $statsLogFileCopy)) {
Kurogo::log(LOG_DEBUG, "Failed to rename {$statsLogFile} to {$statsLogFileCopy}", 'kurogostats');
return;
}
$handle = fopen($statsLogFileCopy, 'r');
$startDate = '';
while (!feof($handle)) {
$line = trim(fgets($handle, 1024));
$value = explode("\t", $line);
if (count($value) != count(self::validFields()) || !isset($value[0]) || intval($value[0]) <= 0) {
continue;
}
if (!$startDate) {
$startTimestamp = $value[0];
$startDate = date('Y-m-d', $startTimestamp);
// If startTimestamp is during today
// Set startTimestamp to the beginning of today
if ($startDate == date('Y-m-d')) {
list($year, $month, $day) = explode('-', $startDate);
$startTimestamp = mktime(0, 0, 0, $month, $day, $year);
}
}
//insert the raw data to the database
$logData = array_combine(self::validFields(), $value);
self::insertStatsToMainTable($logData);
}
fclose($handle);
unlink($statsLogFileCopy);
self::updateSummaryFromShards($startTimestamp);
}
}
示例3: exportStatsData
/**
* export the stats data to the database
*/
public static function exportStatsData($startTimestamp = null)
{
$statsLogFile = Kurogo::getOptionalSiteVar('KUROGO_STATS_LOG_FILE', LOG_DIR . "/kurogo_stats_log_v1");
if (!file_exists($statsLogFile)) {
Kurogo::log(LOG_DEBUG, "the stats log file not exists", 'kurogostats');
return false;
}
/* need an condition for export the stats data */
$today = date('Ymd', time());
//copy the log file
$tempLogFolder = Kurogo::tempDirectory();
$statsLogFileCopy = rtrim($tempLogFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . "stats_log_copy.{$today}";
if (!is_writable($tempLogFolder)) {
throw new Exception("Unable to write to Temporary Directory {$tempLogFolder}");
}
if (!rename($statsLogFile, $statsLogFileCopy)) {
Kurogo::log(LOG_DEBUG, "failed to rename {$statsLogFile} to {$statsLogFileCopy}", 'kurogostats');
return;
}
$handle = fopen($statsLogFileCopy, 'r');
$startDate = '';
while (!feof($handle)) {
$line = trim(fgets($handle, 1024));
$value = explode("\t", $line);
if (count($value) != count(self::validFields()) || !isset($value[0]) || intval($value[0]) <= 0) {
continue;
}
if (!$startDate) {
$startTimestamp = $value[0];
$startDate = date('Y-m-d', $startTimestamp);
// If startTimestamp is during today
// Set startTimestamp to the beginning of today
if ($startDate == date('Y-m-d')) {
list($year, $month, $day) = explode('-', $startDate);
$startTimestamp = mktime(0, 0, 0, $month, $day, $year);
}
}
//insert the raw data to the database
$logData = array_combine(self::validFields(), $value);
self::insertStatsToMainTable($logData);
}
fclose($handle);
unlink($statsLogFileCopy);
self::updateSummaryFromShards($startTimestamp);
}