Example #1
0
function start_comment_feed()
{
    global $atom, $atom_items, $build, $Current_user, $Weblogs, $Current_weblog, $Paths, $Users, $Cfg;
    $link = $Paths['host'] . fixPath($Paths['pivot_url'] . $Weblogs[$Current_weblog]['front_path'] . $Weblogs[$Current_weblog]['front_filename']);
    $link_self = $Paths['host'] . $Paths['pivot_url'] . "commentsfeed.php";
    if (!empty($_SERVER['QUERY_STRING'])) {
        $link_self .= "?" . $_SERVER['QUERY_STRING'];
    }
    $atom_preamble = '<?xml version="1.0" encoding="%charset%"?' . '>
<feed xmlns="http://www.w3.org/2005/Atom"
	xml:lang="%lang%">
	<title>%title% - Comments</title>
	<subtitle>%description%</subtitle>
	<link rel="alternate" type="text/html" href="%link%"/>
	<link rel="self" type="application/atom+xml" href="%link_self%"/>
        <updated>%date%</updated>
        <author>
		<name>%admin-nick%</name>
		<uri>%link%</uri>
		<email>%admin-email%</email>
	</author>
	<id>tag:%sitename_safe%,%year%:%title_safe%</id>
	<generator uri="http://www.pivotlog.net" version="%version%">Pivot</generator>
	<rights>Copyright (c) %year%, Authors of %sitename%</rights>
';
    reset($Users);
    $user = each($Users);
    $user = $user['value'];
    $from = array("%title%", "%title_safe%", "%sitename%", "%sitename_safe%", "%link%", "%link_self%", "%description%", "%author%", "%admin-email%", "%admin-nick%", "%year%", "%date%", "%genagent%", "%version%", "%lang%", "%charset%");
    $to = array(str_replace("&", "&amp;", $Weblogs[$Current_weblog]['name']), str_replace("_", "", safe_string($Weblogs[$Current_weblog]['name'], TRUE)), $Cfg['sitename'], strtolower(str_replace("_", "", safe_string($Cfg['sitename'], TRUE))), $link, $link_self, $Weblogs[$Current_weblog]['payoff'], $Current_user, $user['email'], $user['nick'], date("Y"), date("Y-m-d\\TH:i:s") . rss_offset(), "http://www.pivotlog.net/?ver=" . urlencode($build), $build, snippet_lang(), snippet_charset());
    $atom = str_replace($from, $to, $atom_preamble);
    $atom_items = array();
}
Example #2
0
 /**
  * Makes the directory
  * @param string $dirname
  * @param integer $mode
  */
 public function mkDir($dirname, $mode = 0777)
 {
     $dirname = fixPath($dirname);
     if (!file_exists($dirname)) {
         $old = umask(0);
         mkdir($this->config('rootPath') . $dirname, $mode, true);
         chmod($this->config('rootPath') . $dirname, $mode);
         umask($old);
     }
 }
Example #3
0
function listPath($path)
{
    global $config;
    $path = fixPath($path);
    $path = rtrim($path, '/');
    if (accessLevel($path) < 1) {
        return array('type' => 'nope', 'path' => $path);
    }
    if (is_dir($config['files'] . $path)) {
        return listDir($path);
    }
    if (is_file($config['files'] . $path)) {
        return listFile($path);
    }
    return list404();
}
function GetDirs($path, $type)
{
    $ret = $sort = array();
    $files = listDirectory(fixPath($path), 0);
    foreach ($files as $f) {
        $fullPath = $path . '/' . $f;
        if (!is_dir(fixPath($fullPath)) || $f == '.' || $f == '..') {
            continue;
        }
        $tmp = getFilesNumber(fixPath($fullPath), $type);
        $ret[$fullPath] = array('path' => $fullPath, 'files' => $tmp['files'], 'dirs' => $tmp['dirs']);
        $sort[$fullPath] = $f;
    }
    natcasesort($sort);
    foreach ($sort as $k => $v) {
        $tmp = $ret[$k];
        echo ',{"p":"' . mb_ereg_replace('"', '\\"', $tmp['path']) . '","f":"' . $tmp['files'] . '","d":"' . $tmp['dirs'] . '"}';
        GetDirs($tmp['path'], $type);
    }
}
Example #5
0
  For licensing, see LICENSE.txt or http://RoxyFileman.com/license

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('DELETEFILE');
checkAccess('DELETEFILE');
$path = trim($_GET['f']);
verifyPath($path);
if (is_file(fixPath($path))) {
    if (unlink(fixPath($path))) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_DeletŠµFile') . ' ' . basename($path));
    }
} else {
    echo getErrorRes(t('E_DeleteFileInvalidPath'));
}
Example #6
0
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('MOVEFILE');
checkAccess('MOVEFILE');
$path = trim(empty($_GET['f']) ? '' : $_GET['f']);
$newPath = trim(empty($_GET['n']) ? '' : $_GET['n']);
if (!$newPath) {
    $newPath = getFilesPath();
}
verifyPath($path);
verifyPath($newPath);
if (is_file(fixPath($path))) {
    if (file_exists(fixPath($newPath))) {
        echo getErrorRes(t('E_MoveFileAlreadyExists') . ' ' . basename($newPath));
    } elseif (rename(fixPath($path), fixPath($newPath))) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_MoveFile') . ' ' . basename($path));
    }
} else {
    echo getErrorRes(t('E_MoveFileInvalisPath'));
}
function snippet_archive_list()
{
    global $Weblogs, $Current_weblog, $Archive_array, $Archive_array_html, $Paths;
    if ($Weblogs[$Current_weblog]['archive_unit'] == "none") {
        // if no archives are needed, just return.
        return "";
    }
    // if not yet done, load / make the array of archive filenames (together
    // with at least one date)
    if (!isset($Archive_array)) {
        make_archive_array();
    }
    // if not yet done, compile the html for this archive list
    if (!isset($Archive_array_html[$Current_weblog])) {
        $output = "";
        // maybe flip and reverse it.
        // 2004/11/23 =*=*= JM - changes to avoid array errors
        if (is_array($Archive_array[$Current_weblog])) {
            if ($Weblogs[$Current_weblog]['archive_order'] == 'descending') {
                $mylist = $Archive_array[$Current_weblog];
            } else {
                $mylist = array_reverse($Archive_array[$Current_weblog]);
            }
            foreach ($mylist as $file => $date) {
                // make Mark proud, and make a nice absolute url for the archive..
                $filelink = $Paths['pivot_url'] . $Weblogs[$Current_weblog]['archive_path'] . $file;
                $filelink = fixPath($filelink);
                // fix the rest of the string..
                list($start_date, $stop_date) = getdaterange($date, $Weblogs[$Current_weblog]['archive_unit']);
                $this_output = format_date_range($start_date, $stop_date, $Weblogs[$Current_weblog]['archive_linkfile']);
                $this_output = str_replace("%url%", $filelink, $this_output);
                $output .= "\n" . $this_output;
            }
        }
        // store it for quick access later on..
        $Archive_array_html[$Current_weblog] = $output;
    } else {
        // goodie, it's alread been done, so we just retrieve it.
        $output = $Archive_array_html[$Current_weblog];
    }
    return stripslashes($output);
}
Example #8
0
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('MOVEDIR');
checkAccess('MOVEDIR');
$path = trim(empty($_GET['d']) ? '' : $_GET['d']);
$newPath = trim(empty($_GET['n']) ? '' : $_GET['n']);
verifyPath($path);
verifyPath($newPath);
if (is_dir(fixPath($path))) {
    if (mb_strpos($newPath, $path) === 0) {
        echo getErrorRes(t('E_CannotMoveDirToChild'));
    } elseif (file_exists(fixPath($newPath) . '/' . basename($path))) {
        echo getErrorRes(t('E_DirAlreadyExists'));
    } elseif (rename(fixPath($path), fixPath($newPath) . '/' . basename($path))) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_MoveDir') . ' ' . basename($path));
    }
} else {
    echo getErrorRes(t('E_MoveDirInvalisPath'));
}
Example #9
0
 /**
  * Return path to the file which can be overridden in the theme
  * @static
  * @param string $theme_name
  * @param string $type
  * @param string $module
  * @param string $filename
  * @return string|false
  */
 public static function getFilePath($theme_name, $type, $module, $filename)
 {
     static $noOverrideTypes = array('models', 'structs', 'classes');
     if (in_array($type, $noOverrideTypes)) {
         $theme_name = 'default';
     }
     if (!$theme_name) {
         $theme_name = self::getCurrentTheme();
     }
     $filename = fixPath($filename);
     $tail = $module . DS . $type . DS . $filename;
     $overriddenThemes = array();
     while (!file_exists($originalFile = self::getFilePathInTheme($tail, $theme_name))) {
         if (empty($theme_name) || $theme_name == 'default') {
             return false;
         }
         //Found nothing!
         $overriddenThemes[] = $theme_name;
         $config = self::getThemeConfig($theme_name);
         $theme_name = $config && !empty($config['parent_theme']) && !in_array($theme_name, $overriddenThemes) && self::themeExists($config['parent_theme']) ? $config['parent_theme'] : 'default';
     }
     if (!is_file($originalFile)) {
         throw new rad_exception("Fatal error discovered while trying to find file {$filename} in module {$module}: {$originalFile} is not a file!");
     }
     return $originalFile;
 }
Example #10
0
 /**
  * Updates a menu item to have at least a 'link' key.
  *
  * @param  array $item
  * @return array Keys 'link' and possibly 'label', 'title' and 'path'
  */
 private function menuHelper($item)
 {
     if (isset($item['submenu']) && is_array($item['submenu'])) {
         $item['submenu'] = $this->menuHelper($item['submenu']);
     }
     if (isset($item['path']) && $item['path'] == "homepage") {
         $item['link'] = $this->app['paths']['root'];
     } elseif (isset($item['route'])) {
         $param = empty($item['param']) ? array() : $item['param'];
         $add = empty($item['add']) ? '' : $item['add'];
         $item['link'] = path($item['route'], $param, $add);
     } elseif (isset($item['path'])) {
         // if the item is like 'content/1', get that content.
         if (preg_match('#^([a-z0-9_-]+)/([a-z0-9_-]+)$#i', $item['path'])) {
             $content = $this->app['storage']->getContent($item['path']);
         }
         if (!empty($content) && is_object($content) && get_class($content) == 'Bolt\\Content') {
             // We have content.
             if (empty($item['label'])) {
                 $item['label'] = !empty($content->values['title']) ? $content->values['title'] : "";
             }
             if (empty($item['title'])) {
                 $item['title'] = !empty($content->values['subtitle']) ? $content->values['subtitle'] : "";
             }
             if (is_object($content)) {
                 $item['link'] = $content->link();
             }
             $item['record'] = $content;
         } else {
             // we assume the user links to this on purpose.
             $item['link'] = fixPath($this->app['paths']['root'] . $item['path']);
         }
     }
     return $item;
 }
Example #11
0
verifyAction('FILESLIST');
checkAccess('FILESLIST');
$path = empty($_GET['d']) ? getFilesPath() : $_GET['d'];
$type = empty($_GET['type']) ? '' : strtolower($_GET['type']);
if ($type != 'image' && $type != 'flash') {
    $type = '';
}
verifyPath($path);
$files = listDirectory(fixPath($path), 0);
natcasesort($files);
$str = '';
echo '[';
foreach ($files as $f) {
    $fullPath = $path . '/' . $f;
    if (!is_file(fixPath($fullPath)) || $type == 'image' && !RoxyFile::IsImage($f) || $type == 'flash' && !RoxyFile::IsFlash($f)) {
        continue;
    }
    $size = filesize(fixPath($fullPath));
    $time = filemtime(fixPath($fullPath));
    $tmp = @getimagesize(fixPath($fullPath));
    $w = 0;
    $h = 0;
    if ($tmp) {
        $w = $tmp[0];
        $h = $tmp[1];
    }
    $str .= '{"p":"' . mb_ereg_replace('"', '\\"', $fullPath) . '","s":"' . $size . '","t":"' . $time . '","w":"' . $w . '","h":"' . $h . '"},';
}
$str = mb_substr($str, 0, -1);
echo $str;
echo ']';
<?php

error_reporting(E_ALL);
require_once dirname(__FILE__) . '/../infra/kConf.php';
$interactive = true;
if ($argc == 2 && $argv[1] == '-y') {
    $interactive = false;
}
// clear kConf defined cache directories
$path = realpath(kConf::get('cache_root_path'));
askToDelete(fixPath(kConf::get('general_cache_dir')), $interactive);
askToDelete(fixPath(kConf::get('response_cache_dir')), $interactive);
askToDelete(fixPath(kConf::get('cache_root_path')), $interactive);
// clear APC cache
if (function_exists('apc_clear_cache')) {
    // clear apc system cache
    if (!apc_clear_cache()) {
        echo 'Unable to clear APC SYSTEM cache!' . PHP_EOL;
    }
    // clear apc user cache
    if (!apc_clear_cache('user')) {
        echo 'Unable to clear APC USER cache!' . PHP_EOL;
    }
}
function fixPath($path)
{
    $path = str_replace('\\', '/', $path);
    return realpath($path);
}
function askToDelete($path, $interactive)
{
Example #13
0
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('RENAMEDIR');
checkAccess('RENAMEDIR');
$path = trim(empty($_POST['d']) ? '' : $_POST['d']);
$name = trim(empty($_POST['n']) ? '' : $_POST['n']);
verifyPath($path);
if (is_dir(fixPath($path))) {
    if (fixPath($path . '/') == fixPath(getFilesPath() . '/')) {
        echo getErrorRes(t('E_CannotRenameRoot'));
    } elseif (rename(fixPath($path), dirname(fixPath($path)) . '/' . $name)) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_RenameDir') . ' ' . basename($path));
    }
} else {
    echo getErrorRes(t('E_RenameDirInvalidPath'));
}
Example #14
0
 /**
  * Makes the directory
  * @param string $dirname
  * @param integer $mode
  */
 public function mkDir($dirname, $mode = 0777)
 {
     $dirname = fixPath($dirname);
     $root = '';
     foreach (explode(DS, $dirname) as $cat) {
         $root .= $cat . DS;
         if (!file_exists($root)) {
             $old = umask(0);
             mkdir($root, $mode, true);
             chmod($root, $mode);
             umask($old);
         }
     }
 }
Example #15
0
 private static function _renewCache($module, $file, $type)
 {
     $filename = fixPath($file);
     $cacheFile = CACHEPATH . $type . DS . self::$themeName . DS . $module . DS . $filename;
     $cachePath = dirname($cacheFile);
     if (!file_exists($cachePath)) {
         recursive_mkdir($cachePath);
     }
     if (file_exists($cacheFile) && time() - filemtime($cacheFile) < rad_config::getParam('cache.power.time')) {
         return true;
     }
     if ($fname = rad_themer::getFilePath(self::$themeName, 'jscss', $module, $filename)) {
         return self::copyToCache($fname, $cacheFile);
     }
     return false;
 }
Example #16
0
 /**
  * Ajax helper function to facilitate the selection of files from the images/
  * folder.
  *
  */
 public static function ext_fileSelector()
 {
     global $PIVOTX;
     $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
     $path = $PIVOTX['paths']['upload_base_path'];
     $url = $PIVOTX['paths']['upload_base_url'];
     if (empty($path) || empty($url)) {
         echo "Can't continue: paths not set..";
         die;
     }
     $breadcrumbs = array("<a href='#' onclick=\"fileSelectorChangefolder('')\">" . basename($path) . "</a>");
     if (!empty($_POST['folder'])) {
         $folder = fixPath($_POST['folder']) . "/";
         $path .= $folder;
         $url .= $folder;
         $incrementalpath = "";
         foreach (explode("/", $folder) as $item) {
             if (!empty($item)) {
                 $incrementalpath = $incrementalpath . $item . "/";
                 $breadcrumbs[] = sprintf("<a href='#' onclick=\"fileSelectorChangefolder('%s')\">%s</a>", $incrementalpath, $item);
             }
         }
     }
     $breadcrumbs = implode(" &raquo; ", $breadcrumbs);
     $files = array();
     $folders = array();
     $d = dir($path);
     while (false !== ($filename = $d->read())) {
         if (strpos($filename, '.thumb.') !== false || strpos($filename, '._') !== false || $filename == ".DS_Store" || $filename == "Thumbs.db" || $filename == "." || $filename == ".." || $filename == ".svn") {
             // Skip this one..
             continue;
         }
         if (is_file($path . $filename)) {
             $files[$filename]['link'] = $url . urlencode($filename);
             $files[$filename]['name'] = trimText($filename, 50);
             $ext = strtolower(getExtension($filename));
             $files[$filename]['ext'] = $ext;
             $files[$filename]['bytesize'] = filesize($path . "/" . $filename);
             $files[$filename]['size'] = formatFilesize($files[$filename]['bytesize']);
             if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png'))) {
                 $dim = getimagesize($path . "/" . $filename);
                 $files[$filename]['dimension'] = sprintf('%s &#215; %s', $dim[0], $dim[1]);
                 $files[$filename]['image_type'] = $ext;
             }
             $files[$filename]['path'] = $folder . $filename;
         }
         if (is_dir($path . $filename)) {
             $folders[$filename] = array('link' => $url . urlencode($filename), 'name' => trimText($filename, 50), 'path' => $folder . $filename);
         }
     }
     $d->close();
     ksort($folders);
     ksort($files);
     echo "<div id='fileselector'>";
     printf("<p><strong>%s:</strong> %s </p>", __("Current path"), $breadcrumbs);
     foreach ($folders as $folder) {
         printf("<div class='folder'><a href='#' onclick=\"fileSelectorChangefolder('%s'); return false;\">%s</a></div>", addslashes($folder['path']), $folder['name']);
     }
     foreach ($files as $file) {
         if ($PIVOTX['config']->get('fileselector_thumbs') && !empty($file['image_type'])) {
             $height = getDefault($PIVOTX['config']->get('fileselector_thumbs_height'), 40);
             $link_text = sprintf("<img src='%sincludes/timthumb.php?h=%s&amp;src=%s' alt='%s' title='%s'>", $PIVOTX['paths']['pivotx_url'], $height, $file['path'], $file['name'], $file['name']);
             $extra_style = "style='height: {$height}px; margin-bottom: 5px;'";
         } else {
             $link_text = $file['name'];
             $extra_style = "";
         }
         printf("<div class='file' {$extra_style}><a href='#' onclick=\"fileSelectorChoose('%s'); return false;\">%s</a> <span>(%s%s)</span></div>", addslashes($file['path']), $link_text, $file['size'], !empty($file['dimension']) ? " - " . $file['dimension'] . " px" : "");
     }
     echo "</div>";
     //echo "<pre>\n"; print_r($folders); echo "</pre>";
     //echo "<pre>\n"; print_r($files); echo "</pre>";
 }
Example #17
0
 public static function getLinkToImage($module, $file, $preset)
 {
     if (empty($preset)) {
         //TODO: maybe it'd be better to set "original" preset by default?
         throw new RuntimeException('"Preset" parameter is required in {url type="image"} TAG');
     }
     $fnameOriginal = rad_themer::getFilePath(null, 'img', $module, $file);
     if (!$fnameOriginal) {
         throw new RuntimeException("File {$file} not found in module {$module} for {url type='image'}");
     }
     $theme = rad_themer::getCurrentTheme();
     $tail = "img/{$theme}/{$module}/{$preset}/{$file}";
     $fnameCached = CACHEPATH . fixPath($tail);
     self::renewCache($fnameOriginal, $fnameCached, $preset);
     return SITE_URL . 'cache/' . $tail;
 }
Example #18
0
	<?php 
$config = array('files' => $_SERVER['TURBOFILE_ROOT']);
require __DIR__ . '/lib.php';
$path_unsafe = $_SERVER['DOCUMENT_URI'];
$path = fixPath($path_unsafe);
if (is_dir($config['files'] . $path)) {
    $path .= '/';
}
if ($path !== $path_unsafe) {
    redirect($path);
}
if (preg_match('#^/_turbofile_api/(\\w+)$#', $path, $matches)) {
    $input = json_decode(file_get_contents('php://input'), true);
    if (json_last_error() !== JSON_ERROR_NONE) {
        $input = $_POST;
    }
    foreach ($_GET as $key => $value) {
        $input[$key] = $value;
    }
    require __DIR__ . '/api/' . $matches[1] . '.php';
} else {
    if (accessLevel($path) < 1) {
        Auth::redirectToLogin();
    }
    $qs = $_SERVER['QUERY_STRING'];
    if ($qs) {
        $qs = '?' . $qs;
    }
    if (is_dir($config['files'] . $path)) {
        if (is_file($config['files'] . $path . 'index.php')) {
            header("X-Accel-Redirect: /_files" . $path . "index.php" . $qs);
Example #19
0
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('COPYFILE');
checkAccess('COPYFILE');
$path = trim(empty($_POST['f']) ? '' : $_POST['f']);
$newPath = trim(empty($_POST['n']) ? '' : $_POST['n']);
if (!$newPath) {
    $newPath = getFilesPath();
}
verifyPath($path);
verifyPath($newPath);
if (is_file(fixPath($path))) {
    $newPath = $newPath . '/' . RoxyFile::MakeUniqueFilename(fixPath($newPath), basename($path));
    if (copy(fixPath($path), fixPath($newPath))) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_CopyFile'));
    }
} else {
    echo getErrorRes(t('E_CopyFileInvalisPath'));
}
Example #20
0
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
header("Pragma: cache");
header("Cache-Control: max-age=3600");
verifyAction('GENERATETHUMB');
checkAccess('GENERATETHUMB');
$path = urldecode(empty($_GET['f']) ? '' : $_GET['f']);
verifyPath($path);
@chmod(fixPath(dirname($path)), octdec(DIRPERMISSIONS));
@chmod(fixPath($path), octdec(FILEPERMISSIONS));
$w = intval(empty($_GET['width']) ? '100' : $_GET['width']);
$h = intval(empty($_GET['height']) ? '0' : $_GET['height']);
header('Content-type: ' . RoxyFile::GetMIMEType(basename($path)));
if ($w && $h) {
    RoxyImage::CropCenter(fixPath($path), null, $w, $h);
} else {
    RoxyImage::Resize(fixPath($path), null, $w, $h);
}
Example #21
0
verifyAction('COPYDIR');
checkAccess('COPYDIR');
$path = trim(empty($_GET['d']) ? '' : $_GET['d']);
$newPath = trim(empty($_GET['n']) ? '' : $_GET['n']);
verifyPath($path);
verifyPath($newPath);
function copyDir($path, $newPath)
{
    $items = listDirectory($path);
    if (!is_dir($newPath)) {
        mkdir($newPath, octdec(DIRPERMISSIONS));
    }
    foreach ($items as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }
        $oldPath = RoxyFile::FixPath($path . '/' . $item);
        $tmpNewPath = RoxyFile::FixPath($newPath . '/' . $item);
        if (is_file($oldPath)) {
            copy($oldPath, $tmpNewPath);
        } elseif (is_dir($oldPath)) {
            copyDir($oldPath, $tmpNewPath);
        }
    }
}
if (is_dir(fixPath($path))) {
    copyDir(fixPath($path . '/'), fixPath($newPath . '/' . basename($path)));
    echo getSuccessRes();
} else {
    echo getErrorRes(t('E_CopyDirInvalidPath'));
}
Example #22
0
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
@ini_set('memory_limit', -1);
verifyAction('DOWNLOADDIR');
checkAccess('DOWNLOADDIR');
$path = trim($_GET['d']);
verifyPath($path);
$path = fixPath($path);
if (!class_exists('ZipArchive')) {
    echo '<script>alert("Cannot create zip archive - ZipArchive class is missing. Check your PHP version and configuration");</script>';
} else {
    try {
        $filename = basename($path);
        $zipFile = $filename . '.zip';
        $zipPath = BASE_PATH . '/tmp/' . $zipFile;
        RoxyFile::ZipDir($path, $zipPath);
        header('Content-Disposition: attachment; filename="' . $zipFile . '"');
        header('Content-Type: application/force-download');
        readfile($zipPath);
        function deleteTmp($zipPath)
        {
            @unlink($zipPath);
        }
Example #23
0
  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('UPLOAD');
checkAccess('UPLOAD');
$path = trim(empty($_POST['d']) ? getFilesPath() : $_POST['d']);
verifyPath($path);
$res = '';
if (is_dir(fixPath($path))) {
    if (!empty($_FILES['files']) && is_array($_FILES['files']['tmp_name'])) {
        $errors = $errorsExt = array();
        foreach ($_FILES['files']['tmp_name'] as $k => $v) {
            $filename = $_FILES['files']['name'][$k];
            $filename = RoxyFile::MakeUniqueFilename(fixPath($path), $filename);
            $filePath = fixPath($path) . '/' . $filename;
            if (!RoxyFile::CanUploadFile($filename)) {
                $errorsExt[] = $filename;
            } elseif (!move_uploaded_file($v, $filePath)) {
                $errors[] = $filename;
            }
            if (is_file($filePath)) {
                @chmod($filePath, octdec(FILEPERMISSIONS));
            }
            if (RoxyFile::IsImage($filename) && (intval(MAX_IMAGE_WIDTH) > 0 || intval(MAX_IMAGE_HEIGHT) > 0)) {
                RoxyImage::Resize($filePath, $filePath, intval(MAX_IMAGE_WIDTH), intval(MAX_IMAGE_HEIGHT));
            }
        }
        if ($errors && $errorsExt) {
            $res = getSuccessRes(t('E_UploadNotAll') . ' ' . t('E_FileExtensionForbidden'));
        } elseif ($errorsExt) {
  the Free Software Foundation, either version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('CREATEDIR');
checkAccess('CREATEDIR');
$path = trim(empty($_GET['d']) ? '' : $_GET['d']);
$name = trim(empty($_GET['n']) ? '' : $_GET['n']);
verifyPath($path);
if (is_dir(fixPath($path))) {
    if (mkdir(fixPath($path) . '/' . $name, octdec(DIRPERMISSIONS))) {
        $temp = file_get_contents(fixPath($path) . '/index.php');
        $temp = str_replace('Settings.php', '../Settings.php', $temp);
        file_put_contents(fixPath($path) . '/' . $name . '/index.php', $temp);
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_CreateDirFailed') . ' ' . basename($path));
    }
} else {
    echo getErrorRes(t('E_CreateDirInvalidPath'));
}
Example #25
0
/**
 * Generates the head for the XML feeds.
 *
 * @uses feedtemplate loads the head template for XML feeds.
 */
function start_rss()
{
    global $rss, $rss_items, $atom, $atom_items, $items_added, $db, $build, $Current_user, $Weblogs, $Current_weblog, $Paths, $Users, $Cfg;
    $rss_preamble = feedtemplate('feed_rss_template.xml', 'head');
    $atom_preamble = feedtemplate('feed_atom_template.xml', 'head');
    if (strlen($Weblogs[$Current_weblog]['rss_link']) > 2) {
        $link = trim($Weblogs[$Current_weblog]['rss_link']);
    } else {
        if (gethost() != $Paths['host']) {
            // use the override value from weblog config..
            $link = gethost();
        } else {
            // determine the value ourselves..
            $link = gethost() . fixPath($Paths['pivot_url'] . $Weblogs[$Current_weblog]['front_path'] . $Weblogs[$Current_weblog]['front_filename']);
        }
    }
    $link_self = gethost() . fixPath($Paths['pivot_url'] . $Weblogs[$Current_weblog]['rss_path'] . $Weblogs[$Current_weblog]['atom_filename']);
    if (strlen($Weblogs[$Current_weblog]['rss_img']) > 2) {
        $image = trim($Weblogs[$Current_weblog]['rss_img']);
    } else {
        // if no image is set, we will also have to remove the <image> .. </image>
        // part from the feed.. Bit hackish, but it works.
        $image = "";
        $rss_preamble = preg_replace("/<image>(.*)<\\/image>/msi", "", $rss_preamble);
    }
    $charset = snippet_charset();
    $lang = str_replace("_utf8", "", snippet_lang());
    reset($Users);
    $user = each($Users);
    $user = $user['value'];
    $from = array("%sitename%", "%title%", "%sitename_safe%", "%title_safe%", "%link%", "%link_self%", "%description%", "%author%", "%admin-email%", "%admin-nick%", "%year%", "%date%", "%date_rfc%", "%genagent%", "%version%", "%lang%", "%charset%", "%image%");
    $to = array($Cfg['sitename'], str_replace("&", "&amp;", $Weblogs[$Current_weblog]['name']), strtolower(str_replace("_", "", safe_string($Cfg['sitename'], TRUE))), str_replace("_", "", safe_string($Weblogs[$Current_weblog]['name'], TRUE)), $link, $link_self, $Weblogs[$Current_weblog]['payoff'], $Current_user, $user['email'], $user['nick'], date("Y"), date("Y-m-d\\TH:i:s") . rss_offset(), get_rfcdate(mktime()), "http://www.pivotlog.net/?ver=" . urlencode($build), $build, $lang, $charset, $image);
    $rss = str_replace($from, $to, $rss_preamble);
    $atom = str_replace($from, $to, $atom_preamble);
    $items_added = array();
    $rss_items = array();
    $atom_items = array();
}
Example #26
0
  the Free Software Foundation, either version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('DELETEDIR');
checkAccess('DELETEDIR');
$path = trim(empty($_GET['d']) ? '' : $_GET['d']);
verifyPath($path);
if (is_dir(fixPath($path))) {
    if (fixPath($path . '/') == fixPath(getFilesPath() . '/')) {
        echo getErrorRes(t('E_CannotDeleteRoot'));
    } elseif (count(glob(fixPath($path) . "/*"))) {
        echo getErrorRes(t('E_DeleteNonEmpty'));
    } elseif (rmdir(fixPath($path))) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_CannotDeleteDir') . ' ' . basename($path));
    }
} else {
    echo getErrorRes(t('E_DeleteDirInvalidPath') . ' ' . $path);
}
Example #27
0
File: lib.php Project: LeonB/site
/**
 * Serializes some data and then saves it.
 *
 * @param string $filename
 * @param mixed $data
 * @return boolean
 */
function saveSerialize($filename, &$data)
{
    $filename = fixPath($filename);
    $ser_string = "<?php /* bolt */ die(); ?" . ">json:" . json_encode($data);
    // disallow user to interrupt
    ignore_user_abort(true);
    $old_umask = umask(0111);
    // open the file and lock it.
    if ($fp = fopen($filename, 'a')) {
        if (flock($fp, LOCK_EX | LOCK_NB)) {
            // Truncate the file (since we opened it for 'appending')
            ftruncate($fp, 0);
            // Write to our locked, empty file.
            if (fwrite($fp, $ser_string)) {
                flock($fp, LOCK_UN);
                fclose($fp);
            } else {
                flock($fp, LOCK_UN);
                fclose($fp);
                // todo: handle errors better.
                die('Error opening file<br/><br/>' . 'The file <b>' . $filename . '</b> could not be written! <br /><br />' . 'Try logging in with your ftp-client and check to see if it is chmodded to be readable by ' . 'the webuser (ie: 777 or 766, depending on the setup of your server). <br /><br />' . 'Current path: ' . getcwd() . '.');
            }
        } else {
            fclose($fp);
            // todo: handle errors better.
            die('Error opening file<br/><br/>' . 'Could not lock <b>' . $filename . '</b> for writing! <br /><br />' . 'Try logging in with your ftp-client and check to see if it is chmodded to be readable by the ' . 'webuser (ie: 777 or 766, depending on the setup of your server). <br /><br />' . 'Current path: ' . getcwd() . '.');
        }
    } else {
        // todo: handle errors better.
        print 'Error opening file<br/><br/>' . 'The file <b>' . $filename . '</b> could not be opened for writing! <br /><br />' . 'Try logging in with your ftp-client and check to see if it is chmodded to be readable by the ' . 'webuser (ie: 777 or 766, depending on the setup of your server). <br /><br />' . 'Current path: ' . getcwd() . '.';
        debug_print_backtrace();
        die;
    }
    umask($old_umask);
    // reset the users ability to interrupt the script
    ignore_user_abort(false);
    return true;
}
Example #28
0
  Can be easily integrated with any other WYSIWYG editor or CMS.

  Copyright (C) 2013, RoxyFileman.com - Lyubomir Arsov. All rights reserved.
  For licensing, see LICENSE.txt or http://RoxyFileman.com/license

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('DOWNLOAD');
checkAccess('DOWNLOAD');
$path = trim($_GET['f']);
verifyPath($path);
if (is_file(fixPath($path))) {
    $file = urldecode(basename($path));
    header('Content-Disposition: attachment; filename="' . $file . '"');
    header('Content-Type: application/force-download');
    readfile(fixPath($path));
}
Example #29
0
            $cropHeight = $h;
            $cropWidth = $h * $ratio;
        }
        if ($cropWidth < $w) {
            $left = floor(($w - $cropWidth) / 2);
        }
        if ($cropHeight < $h) {
            $top = floor(($h - $cropHeight) / 2);
        }
        self::Crop($source, $destination, $left, $top, $cropWidth, $cropHeight, $width, $height, $quality);
    }
    public static function Crop($source, $destination, $x, $y, $cropWidth, $cropHeight, $width, $height, $quality = 90)
    {
        $thumbImg = imagecreatetruecolor($width, $height);
        $img = self::GetImage($source);
        imagecopyresampled($thumbImg, $img, 0, 0, $x, $y, $width, $height, $cropWidth, $cropHeight);
        self::OutputImage($thumbImg, RoxyFile::GetExtension(basename($source)), $destination, $quality);
    }
}
$tmp = json_decode(file_get_contents(BASE_PATH . '/conf.json'), true);
if ($tmp) {
    foreach ($tmp as $k => $v) {
        define($k, $v);
    }
} else {
    die('Error parsing configuration');
}
$FilesRoot = fixPath(getFilesPath());
if (!is_dir($FilesRoot)) {
    @mkdir($FilesRoot, octdec(DIRPERMISSIONS));
}
Example #30
0
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('CREATEDIR');
checkAccess('CREATEDIR');
$path = trim(empty($_GET['d']) ? '' : $_GET['d']);
$name = trim(empty($_GET['n']) ? '' : $_GET['n']);
verifyPath($path);
if (is_dir(fixPath($path))) {
    if (mkdir(fixPath($path) . '/' . $name, octdec(DIRPERMISSIONS))) {
        echo getSuccessRes();
    } else {
        echo getErrorRes(t('E_CreateDirFailed') . ' ' . basename($path));
    }
} else {
    echo getErrorRes(t('E_CreateDirInvalidPath'));
}