function getRelPath($a, $b) { if ($a[0] != $b[0]) { return $a; } return getRelPath(substr($a, 1), substr($b, 1)); }
} else { $imgSrc = '<img class="' . $ext . '" src="' . tsl($SITEURL) . getRelPath(GSTHUMBNAILPATH) . $thumbLinkEncoded . '" />'; } // thumbnail link lightbox echo '<a href="' . tsl($SITEURL) . getRelPath($path) . rawurlencode($upload['name']) . '" title="' . rawurlencode($upload['name']) . '" rel="fancybox_i" >' . $imgSrc . '</a>'; # get external thumbnail link # if not exist generate it if (!file_exists(GSTHUMBNAILPATH . $thumbLinkExternal) || isset($_REQUEST['regenthumbnail'])) { genStdThumb($subPath, $upload['name']); } $thumbnailLink = '<a href="' . tsl($SITEURL) . getRelPath(GSTHUMBNAILPATH) . $thumbLinkExternal . '" class="label label-ghost thumblinkexternal" data-fileurl="' . getRelPath(GSTHUMBNAILPATH) . $thumbLinkExternal . '">' . i18n_r('THUMBNAIL') . '</a>'; } else { // other files $gallery = ''; $controlpanel = ''; $pathlink = tsl($SITEURL) . getRelPath($path) . $upload['name']; } // name column linked echo '</td><td>' . getUploadIcon($upload['name']) . '<a title="' . i18n_r('VIEW_FILE') . ': ' . htmlspecialchars($upload['name']) . '" href="' . $pathlink . '" class="primarylink" data-fileurl="' . $primarylink . '">' . htmlspecialchars($upload['name']) . '</a>' . $thumbnailLink . '</td>'; // size column echo '<td class="file_size right"><span>' . $upload['size'] . '</span></td>'; // file perms column if ($showperms) { $filePerms = substr(sprintf('%o', fileperms($path . $upload['name'])), -4); if ($isUnixHost) { $fileOwner = function_exists('posix_getpwuid') ? posix_getpwuid(fileowner($path . $upload['name'])) : ''; $fileOwnerName = isset($fileOwner['name']) ? $fileOwner['name'] : ''; } else { $fileOwnerName = getenv('USERNAME'); } echo '<td style="width:70px;text-align:right;"><span>' . $fileOwnerName . '/' . $filePerms . '</span></td>';
} if ($kill) { die('Getsimple Install Cannot Continue'); } } check_php_requirements(); $kill = ''; # setup inclusions $load['plugin'] = true; if (isset($_GET['lang'])) { $LANG = $_GET['lang']; } include 'inc/common.php'; # variable setup // attempt to fix permissions issues $dirsArray = array(GSDATAPATH, GSCACHEPATH, GSDATAOTHERPATH, GSDATAOTHERPATH . 'logs/', GSDATAPAGESPATH, GSDATAUPLOADPATH, GSTHUMBNAILPATH, GSBACKUPSPATH, GSBACKUPSPATH . getRelPath(GSDATAOTHERPATH, GSDATAPATH), GSBACKUPSPATH . getRelPath(GSDATAPAGESPATH, GSDATAPATH), GSBACKUPSPATH . 'zip/', GSBACKUSERSPATH, GSUSERSPATH, GSAUTOSAVEPATH); // tmp-404.xml used as temporary write tester // removed afterwards foreach ($dirsArray as $dir) { $tmpfile = GSADMININCPATH . 'tmp/tmp-404.xml'; if (file_exists($dir)) { gs_chmod($dir, 0755); $result_755 = copy_file($tmpfile, $dir . 'tmp.tmp'); if (!$result_755) { gs_chmod($dir, 0777); $result_777 = copy_file($tmpfile, $dir . 'tmp.tmp'); if (!$result_777) { $kill = i18n_r('CHMOD_ERROR'); } } } else {
<?php if ($HTMLEDITOR != '') { ?> <script type="text/javascript" src="template/js/ckeditor/ckeditor.js"></script> <script type="text/javascript"> var editor = CKEDITOR.replace( 'codetext', { language : '<?php echo $EDLANG; ?> ', <?php if (file_exists(GSTHEMESPATH . $TEMPLATE . "/editor.css")) { $fullpath = $SITEURL; ?> contentsCss : '<?php echo $fullpath . getRelPath(GSTHEMESPATH) . $TEMPLATE; ?> /editor.css', <?php } ?> height : '<?php echo $EDHEIGHT; ?> ', baseHref : '<?php echo $SITEURL; ?> ', toolbar : [['Source']], removePlugins: 'image,link,elementspath,resize'
/** * Get Theme URL * * This will return the current active theme's full URL * * @since 1.0 * @uses $SITEURL * @uses $TEMPLATE * * @param bool $echo Optional, default is true. False will 'return' value * @return string Echos or returns based on param $echo */ function get_theme_url($echo = true) { global $SITEURL, $TEMPLATE; $str = trim($SITEURL . getRelPath(GSTHEMESPATH) . $TEMPLATE); return echoReturn($str, $echo); }
} } if ($kill) { die('Getsimple Install Cannot Continue'); } } check_php_requirements(); $load['plugin'] = true; include 'inc/common.php'; /* delete caches */ delete_cache(); /* * Updates below here */ $message = null; $create_dirs = array(GSCACHEPATH, GSAUTOSAVEPATH, GSBACKUPSPATH, GSBACKUPSPATH . getRelPath(GSDATAOTHERPATH, GSDATAPATH), GSBACKUPSPATH . getRelPath(GSDATAPAGESPATH, GSDATAPATH), GSBACKUSERSPATH, GSBACKUPSPATH . 'zip/'); $create_files = array(); $delete_files = array(GSADMININCPATH . 'xss.php', GSADMININCPATH . 'nonce.php', GSADMININCPATH . 'install.php', GSADMINPATH . 'load-ajax.php', GSADMINPATH . 'cron.php', GSADMINPATH . 'loadtab.php'); function msgOK($msg) { return '<div class="notify">' . $msg . '</div>'; } function msgError($msg) { return '<div class="notify notify_error">' . $msg . '</div>'; } # create default 404.xml page $init = GSDATAOTHERPATH . GSHTTPPREFIX . '404.xml'; $temp = GSADMININCPATH . 'tmp/tmp-404.xml'; if (!file_exists($init)) { if (copy($temp, $init)) {
if ($type == 'images') { if ($upload['type'] == i18n_r('IMAGES') . ' Images') { # get internal thumbnail to show beside link in table $thumb = '<td class="imgthumb" style="display:table-cell" >'; $thumbLink = $urlPath . 'thumbsm.' . $upload['name']; if (file_exists(GSTHUMBNAILPATH . $thumbLink . 'a')) { $imgSrc = '<img src="' . tsl($SITEURL) . getRelPath(GSTHUMBNAILPATH) . $thumbLink . '" />'; } else { $imgSrc = '<img src="inc/thumb.php?src=' . $urlPath . $upload['name'] . '&dest=' . $thumbLink . '&x=65&f=1" />'; } $thumb .= '<a ' . $selectLink . ' >' . $imgSrc . '</a>'; $thumb .= '</td>'; # get external thumbnail link $thumbLinkExternal = $urlPath . 'thumbnail.' . $upload['name']; if (file_exists(GSTHUMBNAILPATH . $thumbLinkExternal)) { $thumbnailLink = '<span> – </span><a href="javascript:void(0)" onclick="submitLink(' . $CKEditorFuncNum . ',\'' . $sitepath . getRelPath(GSTHUMBNAILPATH) . $thumbLinkExternal . '\')">' . i18n_r('THUMBNAIL') . '</a>'; } } else { continue; } } $counter++; echo '<tr class="All ' . $upload['type'] . '" >'; echo $thumb == '' ? '<td style="display: none"></td>' : $thumb; echo '<td><a ' . $selectLink . ' class="primarylink">' . htmlspecialchars($upload['name']) . '</a>' . $thumbnailLink . '</td>'; echo '<td style="width:80px;text-align:right;" ><span>' . $upload['size'] . '</span></td>'; // get the file permissions. if ($isUnixHost && isDebug() && function_exists('posix_getpwuid')) { $filePerms = substr(sprintf('%o', fileperms($path . $upload['name'])), -4); $fileOwner = posix_getpwuid(fileowner($path . $upload['name'])); echo '<td style="width:70px;text-align:right;"><span>' . $fileOwner['name'] . '/' . $filePerms . '</span></td>';
include 'inc/common.php'; login_cookie_check(); # variable settings $path = GSDATAOTHERPATH; $file = GSWEBSITEFILE; $theme_options = ''; # was the form submitted? if (isset($_POST['submitted']) && isset($_POST['template'])) { check_for_csrf("activate"); # get passed value from form $newTemplate = var_in($_POST['template']); if (!path_is_safe(GSTHEMESPATH . $newTemplate, GSTHEMESPATH)) { die; } # backup old GSWEBSITEFILE (website.xml) file $bakpath = GSBACKUPSPATH . getRelPath(GSDATAOTHERPATH, GSDATAPATH); // backups/other/ createBak($file, $path, $bakpath); # udpate GSWEBSITEFILE (website.xml) file with new theme $xml = new SimpleXMLExtended('<item></item>'); $note = $xml->addChild('SITENAME'); $note->addCData($SITENAME); $note = $xml->addChild('SITEURL'); $note->addCData($SITEURL); $note = $xml->addChild('TEMPLATE'); $note->addCData($newTemplate); $xml->addChild('PRETTYURLS', $PRETTYURLS); $xml->addChild('PERMALINK', $PERMALINK); XMLsave($xml, $path . $file); $success = i18n_r('THEME_CHANGED'); $TEMPLATE = $newTemplate;
* @package GetSimple * @subpackage Images */ // Setup inclusions $load['plugin'] = true; // Include common.php include 'inc/common.php'; login_cookie_check(); // Variable Settings $subPath = isset($_GET['path']) ? $_GET['path'] : ""; if ($subPath != '') { $subPath = tsl($subPath); } $uploadsPath = GSDATAUPLOADPATH; $uploadsPathRel = getRelPath(GSDATAUPLOADPATH); $thumbPathRel = getRelPath(GSTHUMBNAILPATH); $src = strippath($_GET['i']); $thumb_folder = GSTHUMBNAILPATH . $subPath; $src_folder = $uploadsPath; $src_url = tsl($SITEURL) . $uploadsPathRel . $subPath; $thumb_folder_rel = $thumbPathRel . $subPath; $thumb_url = tsl($SITEURL) . $thumb_folder_rel; if (!is_file($src_folder . $subPath . $src)) { redirect("upload.php"); } // handle jcrop thumbnail creation if ($_SERVER['REQUEST_METHOD'] == 'POST') { require_once 'inc/imagemanipulation.php'; $objImage = new ImageManipulation($src_folder . $subPath . $src); if ($objImage->imageok) { $objImage->setCrop($_POST['x'], $_POST['y'], $_POST['w'], $_POST['h']);
public function all_files_read() { if ($this->auth()) { $patho = (string) $this->xml->data->path; $path = tsl(GSDATAUPLOADPATH . $patho); $url = tsl($SITEURL . getRelPath(GSDATAUPLOADPATH) . $patho); $filesArray = array(); $count = 0; global $SITEURL; $filenames = getFiles($path); if (count($filenames) != 0) { foreach ($filenames as $file) { if ($file == "." || $file == ".." || $file == ".htaccess") { // not a upload file } else { $filesArray[$count]['name'] = $file; if (is_dir($path . $file)) { $filesArray[$count]['type'] = 'folder'; } else { $filesArray[$count]['type'] = 'file'; $filesArray[$count]['url'] = $url . $file; $ext = pathinfo($file, PATHINFO_EXTENSION); $extention = get_FileType($ext); $filesArray[$count]['category'] = $extention; clearstatcache(); $ss = stat($path . $file); $filesArray[$count]['date'] = date('c', $ss['mtime']); $filesArray[$count]['size'] = $ss['size']; } } $count++; } } $filesArray = subval_sort($filesArray, 'name'); $filesArray = subval_sort($filesArray, 'type'); $wrapper = array('status' => 'success', 'message' => 'all_files_read ok', 'response' => $filesArray); return json_encode($wrapper); } }
/** * checks if the template file is open for editing * @return bool true if template_file is being edited */ function editor_fileIsOpen($path, $file) { global $template, $template_file; $file = $path . $file; $filenamefull = substr(strstr($file, getRelPath(GSTHEMESPATH) . $template . '/'), strlen(getRelPath(GSTHEMESPATH) . $template . '/')); return $template_file == $filenamefull; }
} echo '</td></tr>'; } echo '</table>'; /////////////////////////////////////////////// // htaccess existance /////////////////////////////////////////////// if (server_is_apache()) { echo '<h3>' . sprintf(i18n_r('EXISTANCE'), '.htaccess') . '</h3>'; echo '<table class="highlight healthcheck">'; $dirsArray = array(GSROOTPATH, GSDATAPATH, GSDATAUPLOADPATH, GSUSERSPATH, GSCACHEPATH, GSTHUMBNAILPATH, GSDATAPAGESPATH, GSPLUGINPATH, GSDATAOTHERPATH, GSDATAOTHERPATH . 'logs/', GSTHEMESPATH); $aDirs = array(GSDATAUPLOADPATH, GSTHUMBNAILPATH); $noFile = array(GSTHEMESPATH); $required = array(GSROOTPATH); foreach ($dirsArray as $path) { $relpath = '/' . getRelPath($path); echo "<tr><td class=\"hc_item\" >{$relpath}</td>"; $file = $path . ".htaccess"; if (!file_exists($file)) { // no file is all good if (in_array($path, $noFile)) { echo '<td>' . i18n_r('NO_FILE') . '</td><td><span class="label label-ok">' . i18n_r('OK') . '</span></td>'; continue; } // file is missing ! echo '<td><span class="WARNmsg" >' . i18n_r('MISSING_FILE') . '</span></td><td><span class="label label-warn">' . i18n_r('WARNING') . '</span></td>'; } else { // no file preffered but we found one if (in_array($path, $noFile)) { echo '<td>.htaccess</td><td><span class="label label-info">' . i18n_r('OK') . '</span></td>'; continue;
queue_script('gscodeeditor', GSBACK); } if ((get_filename_id() == 'edit' || get_filename_id() == 'backup-edit') && getGlobal('HTMLEDITOR')) { queue_script('gshtmleditor', GSBACK); } if ((get_filename_id() == 'upload' || get_filename_id() == 'image') && !getDef('GSNOUPLOADIFY', true)) { queue_script('gsuploader', GSBACK); } if (get_filename_id() == 'image') { queue_script('gscrop', GSBACK); queue_style('gscrop', GSBACK); } // HTMLEDITOR INIT if (getGlobal('HTMLEDITOR') != '') { if (file_exists(GSTHEMESPATH . getGlobal('TEMPLATE') . "/editor.css")) { $contentsCss = $SITEURL . getRelPath(GSTHEMESPATH) . getGlobal('TEMPLATE') . '/editor.css'; } } ?> <script type="text/javascript"> // init gs namespace and i18n var GS = {}; GS.i18n = <?php echo json_encode($jsi18n); ?> ; GS.debug = <?php echo isDebug() === true ? 'true' : 'false'; ?> ;
// init gs namespace and i18n var GS = {}; GS.i18n = <?php echo json_encode($jsi18n); ?> ; GS.debug = <?php echo isDebug() === true ? 'true' : 'false'; ?> ; GS.siteurl = '<?php echo $SITEURL; ?> '; GS.uploads = '<?php echo tsl($SITEURL) . getRelPath(GSDATAUPLOADPATH); ?> '; var uploadSession = '<?php echo $SESSIONHASH; ?> '; var uploadPath = '<?php echo isset($_GET['path']) ? $_GET['path'] : ""; ?> '; var maxFileSize = '<?php echo toBytesShorthand(getMaxUploadSize(), 'M'); ?> ';
/** * get array of thumbnails and info * @param string $upload_path the upload sub path * @param string $type optional thumbnail type eg thumbsm, thumbnail to filter by * @param string $filename optional filename to filter * @param boolean $recurse optional true: recurse into subdirectories * @return array assoc array with thumbnail attributes */ function getThumbnails($upload_path = '', $type = '', $filename = '', $recurse = false) { $thumbs_array = array(); $files = directoryToArray(GSTHUMBNAILPATH . tsl($upload_path), $recurse); foreach ($files as $file) { $split = strpos(basename($file), '.'); $thumbtype = substr(basename($file), 0, $split); $origfile = substr(basename($file), $split + 1); if (!empty($filename) && $filename !== $origfile) { continue; } if (empty($thumbtype) || !empty($type) && $type !== $thumbtype) { continue; } // debugLog('thumbnail ' . $file); $thumb = getimagesize($file); $thumb['width'] = $thumb[0]; unset($thumb[0]); $thumb['height'] = $thumb[1]; unset($thumb[1]); $thumb['type'] = $thumb[2]; unset($thumb[2]); $thumb['attrib'] = $thumb[3]; unset($thumb[3]); $thumb['uploadpath'] = tsl(getRelPath($upload_path, GSTHUMBNAILPATH)); $thumb['primaryfile'] = GSDATAUPLOADPATH . $thumb['uploadpath'] . $origfile; $thumb['filesize'] = filesize($file); $thumb['primaryurl'] = getUploadURI($origfile, $thumb['uploadpath']); $thumb['thumbfile'] = getThumbnailFile(basename($file), $upload_path, ''); $thumb['thumburl'] = getThumbnailURI(basename($file), $upload_path, ''); $thumb['thumbtype'] = $thumbtype; $thumbs_array[$upload_path . basename($file)] = $thumb; } return $thumbs_array; }
/** * convert array of file paths to relative paths to gsroot * @since 3.4 * @param array $args full filepaths * @return returns array of relative filepaths */ function convertPathArgs($args) { foreach ($args as &$arg) { if (!is_string($arg)) { continue; } if (strpos($arg, GSROOTPATH) !== false) { $arg = getRelPath($arg); } } return $args; }
/** * All Backups * * Displays all available page backups. * * @package GetSimple * @subpackage Backups * @link http://get-simple.info/docs/restore-page-backup */ // Setup inclusions $load['plugin'] = true; // Include common.php include 'inc/common.php'; // Variable settings login_cookie_check(); $path = GSBACKUPSPATH . getRelPath(GSDATAPAGESPATH, GSDATAPATH); // backups/pages/ $counter = '0'; $table = ''; // delete all backup files if the ?deleteall session parameter is set if (isset($_GET['deleteall'])) { check_for_csrf("deleteall"); $filenames = getFiles($path); foreach ($filenames as $file) { if (file_exists($path . $file)) { if (isFile($file, $path, 'bak')) { unlink($path . $file); } } } $success = i18n_r('ER_FILE_DEL_SUC');
// $GS_script_assets = array( // 'jquery' => array( // 'cdn' => array( // 'url' => '//ajax.googleapis.com/ajax/libs/jquery/'.$jquery_ver.'/jquery.min.js', // 'ver' => $jquery_ver // ), // 'local' => array( // 'url' => $ASSETURL.$GSADMIN.'/template/js/jquery/jquery-'.$jquery_ver.'.min.js', // 'ver' => $jquery_ver // ) // ) // ) /** * Core assets */ $ASSETPATH = $ASSETURL . tsl(getRelPath(GSADMINTPLPATH)); // core $GS_script_assets['getsimple']['local']['url'] = $ASSETPATH . 'js/jquery.getsimple.js'; $GS_script_assets['getsimple']['local']['ver'] = $getsimple_ver; // lazyload (lazy loading assets js/css) $GS_script_assets['lazyload']['local']['url'] = $ASSETPATH . 'js/lazyload.js'; $GS_script_assets['lazyload']['local']['ver'] = $getsimple_ver; // gstree (collpaseble heirarchy table tree) $GS_script_assets['gstree']['local']['url'] = $ASSETPATH . 'js/jquery-gstree.js'; $GS_script_assets['gstree']['local']['ver'] = $getsimple_ver; // spin (ajax spinners) $GS_script_assets['spin']['local']['url'] = $ASSETPATH . 'js/spin.js'; $GS_script_assets['spin']['local']['ver'] = $getsimple_ver; // dropzone (ajax/html uploader w drag and drop) $GS_script_assets['dropzone']['local']['url'] = $ASSETPATH . 'js/dropzone.js'; $GS_script_assets['dropzone']['local']['ver'] = $getsimple_ver;
$cclass = ''; } echo '<tr class="All ' . $upload['type'] . ' ' . $cclass . '" >'; echo '<td class="imgthumb" >'; if ($upload['type'] == i18n_r('IMAGES') . ' Images') { $gallery = 'rel=" facybox_i"'; $pathlink = 'image.php?i=' . rawurlencode($upload['name']) . '&path=' . $subPath; $thumbLink = $urlPath . 'thumbsm.' . $upload['name']; $thumbLinkEncoded = $urlPath . 'thumbsm.' . rawurlencode($upload['name']); if (file_exists(GSTHUMBNAILPATH . $thumbLink)) { $imgSrc = '<img src="' . tsl($SITEURL) . getRelPath(GSTHUMBNAILPATH) . $thumbLinkEncoded . '" />'; } else { $imgSrc = '<img src="inc/thumb.php?src=' . $urlPath . rawurlencode($upload['name']) . '&dest=' . $thumbLinkEncoded . '&f=1" />'; } // thumbnail link lightbox echo '<a href="' . tsl($SITEURL) . getRelPath($path) . rawurlencode($upload['name']) . '" title="' . rawurlencode($upload['name']) . '" rel=" facybox_i" >' . $imgSrc . '</a>'; } else { $gallery = ''; $controlpanel = ''; $pathlink = $path . $upload['name']; } // name column linked echo '</td><td><a title="' . i18n_r('VIEW_FILE') . ': ' . htmlspecialchars($upload['name']) . '" href="' . $pathlink . '" class="primarylink">' . htmlspecialchars($upload['name']) . '</a></td>'; // size column echo '<td style="width:80px;text-align:right;" ><span>' . $upload['size'] . '</span></td>'; // get the file permissions. if ($isUnixHost && isDebug() && function_exists('posix_getpwuid')) { $filePerms = substr(sprintf('%o', fileperms($path . $upload['name'])), -4); $fileOwner = posix_getpwuid(fileowner($path . $upload['name'])); echo '<td style="width:70px;text-align:right;"><span>' . $fileOwner['name'] . '/' . $filePerms . '</span></td>'; }