Example #1
0
 /**
  * Video Validate.
  *
  * @return boolean
  * @throws \PH7\Framework\Error\CException\PH7BadMethodCallException If the video file is not found.
  */
 public function validate()
 {
     if (!is_file($this->aFile['tmp_name'])) {
         if (!isDebug()) {
             return false;
         } else {
             throw new \PH7\Framework\Error\CException\PH7BadMethodCallException('Video file not found: The video file \'' . $this->aFile['tmp_name'] . '\' could not be found.');
         }
     } else {
         switch ($this->sType) {
             // Files supported List.
             case 'mov':
             case 'avi':
             case 'flv':
             case 'mp4':
             case 'mpg':
             case 'mpeg':
             case 'wmv':
             case 'ogg':
             case 'ogv':
             case 'webm':
             case 'mkv':
                 return true;
                 break;
             default:
                 return false;
         }
     }
 }
Example #2
0
 public function __construct()
 {
     parent::__construct();
     /**
      * This can cause minor errors (eg if a user sent a file that is not a video).
      * So we hide the errors if we are not in development mode.
      */
     if (!isDebug()) {
         error_reporting(0);
     }
     // Resizing and saving the video album thumbnail
     $oPicture = new Image($_FILES['album']['tmp_name']);
     if (!$oPicture->validate()) {
         \PFBC\Form::setError('form_video_album', Form::wrongImgFileTypeMsg());
     } else {
         $iApproved = DbConfig::getSetting('videoManualApproval') == 0 ? '1' : '0';
         $sFileName = Various::genRnd($oPicture->getFileName(), 1) . '-thumb.' . $oPicture->getExt();
         (new VideoModel())->addAlbum($this->session->get('member_id'), $this->httpRequest->post('name'), $this->httpRequest->post('description'), $sFileName, $this->dateTime->get()->dateTime('Y-m-d H:i:s'), $iApproved);
         $iLastAlbumId = (int) Db::getInstance()->lastInsertId();
         $oPicture->square(200);
         /* Set watermark text on thumbnail */
         $sWatermarkText = DbConfig::getSetting('watermarkTextImage');
         $iSizeWatermarkText = DbConfig::getSetting('sizeWatermarkTextImage');
         $oPicture->watermarkText($sWatermarkText, $iSizeWatermarkText);
         $sPath = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'video/file/' . $this->session->get('member_username') . PH7_DS . $iLastAlbumId . PH7_DS;
         $this->file->createDir($sPath);
         $oPicture->save($sPath . $sFileName);
         /* Clean VideoModel Cache */
         (new Framework\Cache\Cache())->start(VideoModel::CACHE_GROUP, null, null)->clear();
         HeaderUrl::redirect(Uri::get('video', 'main', 'addvideo', $iLastAlbumId));
     }
 }
Example #3
0
 /**
  * DataPool constructor.
  * @param array $conf
  */
 public function __construct($conf = [])
 {
     if (!$conf) {
         $conf = \Flight::get('config')->get('datapool');
         $conf['debug'] = isDebug();
     }
     $this->dataPool = new DefaultDataPool($conf, ROOT);
 }
Example #4
0
 /**
  * 设置是否写SQL日志
  *
  * @return bool
  */
 public static function enableLogging($bool = null)
 {
     if (null !== $bool) {
         self::$_enableLogging = (bool) $bool;
     }
     // 非调试模式下永远为否
     return !isDebug() ? false : self::$_enableLogging;
 }
Example #5
0
function debug($msg, $debugReason = 'other')
{
    if (isDebug($debugReason)) {
        if (is_array($msg)) {
            $msg = print_r($msg, true);
        }
        echo PHP_EOL . '<!-- ' . date(DATE_RFC822) . PHP_EOL . $msg . PHP_EOL . ' -->' . PHP_EOL;
    }
}
Example #6
0
 public function __construct()
 {
     parent::__construct();
     /***** Securing the server for DDoS attack only! Not for the attacks DoS *****/
     if (!isDebug() && M\DbConfig::getSetting('DDoS')) {
         $oDDoS = new Stop();
         if ($oDDoS->cookie() || $oDDoS->session()) {
             sleep(PH7_DDOS_DELAY_SLEEP);
         }
         unset($oDDoS);
     }
     /*
     if ($this->browser->isMobile())
     {
         \PH7\Framework\Url\HeaderUrl::redirect('mobile');
     }
     */
     /***** Assign the values for Registry Class *****/
     // URL
     $this->registry->site_url = PH7_URL_ROOT;
     $this->registry->url_relative = PH7_RELATIVE;
     $this->registry->page_ext = PH7_PAGE_EXT;
     // Site Name
     $this->registry->site_name = M\DbConfig::getSetting('siteName');
     /***** Internationalization *****/
     // Default path language
     $this->lang->load('global', PH7_PATH_APP_LANG);
     /***** PH7Tpl Template Engine initialization *****/
     /*** Assign the global variables ***/
     /*** Objects ***/
     $this->view->config = $this->config;
     $this->view->design = $this->design;
     /***** Info *****/
     $oInfo = M\DbConfig::getMetaMain(PH7_LANG_NAME);
     $aMetaVars = ['site_name' => $this->registry->site_name, 'page_title' => $oInfo->pageTitle, 'slogan' => $oInfo->slogan, 'meta_description' => $oInfo->metaDescription, 'meta_keywords' => $oInfo->metaKeywords, 'meta_author' => $oInfo->metaAuthor, 'meta_robots' => $oInfo->metaRobots, 'meta_copyright' => $oInfo->metaCopyright, 'meta_rating' => $oInfo->metaRating, 'meta_distribution' => $oInfo->metaDistribution, 'meta_category' => $oInfo->metaCategory, 'header' => 0];
     $this->view->assigns($aMetaVars);
     unset($oInfo);
     /**
      * This test is not necessary because if there is no session,
      * the get() method of the \PH7\Framework\Session\Session object an empty value and revisit this avoids having undefined variables in some modules (such as the "connect" module).
      */
     //if (\PH7\UserCore::auth()) {
     $this->view->count_unread_mail = \PH7\MailCoreModel::countUnreadMsg($this->session->get('member_id'));
     $this->view->count_pen_friend_request = \PH7\FriendCoreModel::getPenFd($this->session->get('member_id'));
     //}
     /***** Display *****/
     $this->view->setTemplateDir($this->registry->path_module_views . PH7_TPL_MOD_NAME);
     /***** End Template Engine PH7Tpl *****/
     // For permission the modules
     if (is_file($this->registry->path_module_config . 'Permission.php')) {
         require $this->registry->path_module_config . 'Permission.php';
         new \PH7\Permission();
     }
 }
 /**
  * Video Validate.
  *
  * @return boolean
  * @throws \PH7\Framework\Error\CException\PH7BadMethodCallException If the video file is not found.
  */
 public function validate()
 {
     if (!is_uploaded_file($this->aFile['tmp_name'])) {
         if (!isDebug()) {
             return false;
         } else {
             throw new \PH7\Framework\Error\CException\PH7BadMethodCallException('The file could not be uploaded. Possibly too large.');
         }
     } else {
         return in_array($this->sType, $this->aAllowedTypes);
     }
 }
function jQuery_migrate_init()
{
    global $thisfile_GSJQM, $SITEURL;
    i18n_merge($thisfile_GSJQM) || i18n_merge($thisfile_GSJQM, GSDEFAULTLANG);
    # register plugin
    register_plugin($thisfile_GSJQM, i18n_r($thisfile_GSJQM . '/GSJQMigrate_TITLE'), '1.0', 'GetSimpleCMS', 'http://get-simple.info', i18n_r($thisfile_GSJQM . '/GSJQMigrate_DESC'), '', '');
    $asset = isDebug() ? 'jquery-migrate-1.2.1.js' : 'jquery-migrate-1.2.1.min.js';
    // when debug is on, migrate will output to console with deprecated notices.
    $url = $SITEURL . 'plugins/' . $thisfile_GSJQM . '/assets/js/' . $asset;
    register_script('jquerymigrate', $url, '', FALSE);
    queue_script('jquerymigrate', GSBACK);
}
 /**
  * Displaying the main homepage of the website.
  */
 public function index()
 {
     // We must not put the title as this is the homepage, so this is the default title is used.
     // For Profiles Carousel
     $this->view->userDesignModel = new UserDesignCoreModel();
     $this->view->userDesign = new UserDesignCore();
     // Only visitors
     if (!UserCore::auth()) {
         // Set CSS and JS files
         $this->design->addCss(PH7_LAYOUT . PH7_TPL . PH7_TPL_NAME . PH7_SH . PH7_CSS, 'splash.css,tooltip.css,js/jquery/carousel.css');
         $this->design->addJs(PH7_DOT, PH7_STATIC . PH7_JS . 'jquery/carouFredSel.js,' . PH7_LAYOUT . PH7_TPL . PH7_TPL_NAME . PH7_SH . PH7_JS . 'splash.js');
         // Assigns the promo text to the view
         $this->view->promo_text = DbConfig::getMetaMain(PH7_LANG_NAME)->promoText;
         // Assign the background video option
         $this->view->is_bg_video = DbConfig::getSetting('bgSplashVideo');
         // To check if the site is called by a mobile native app
         $bMobApp = $this->view->is_mobapp = MobApp::is();
         /**
          * When you are in the development mode, you can force the guest page by set a "force" GET request with the "splash" or "classic" parameter.
          * Example: "/?force=splash" or "/?force=classic"
          */
         if (isDebug() && $this->httpRequest->getExists('force')) {
             switch ($this->httpRequest->get('force')) {
                 case 'classic':
                     $sPage = 'index.guest';
                     break;
                 case 'splash':
                     $sPage = 'index.guest_splash';
                     break;
                 default:
                     exit('You can only choose between "classic" or "splash"');
             }
         } elseif ($bMobApp) {
             $sPage = 'index.guest_splash';
         } else {
             $bIsSplashPage = (bool) DbConfig::getSetting('splashPage');
             $sPage = $bIsSplashPage ? 'index.guest_splash' : 'index.guest';
         }
         $this->manualTplInclude($sPage . '.inc.tpl');
     } elseif (UserCore::auth()) {
         // Set CSS and JS files
         $this->design->addCss(PH7_LAYOUT . PH7_TPL . PH7_TPL_NAME . PH7_SH . PH7_CSS, 'zoomer.css');
         $this->design->addJs(PH7_STATIC . PH7_JS, 'zoomer.js,Wall.js');
         // Assigns the user's first name to the view for the Welcome Message
         $this->view->first_name = $this->session->get('member_first_name');
         $this->manualTplInclude('index.user.inc.tpl');
     }
     $this->output();
 }
 /**
  * @desc Image Validate.
  * @return boolean
  * @throws \PH7\Framework\Error\CException\PH7BadMethodCallException If the image file is not found.
  */
 public function validate()
 {
     $mImgType = $this->getType();
     if (!is_file($this->sFile) || !$mImgType) {
         if (isDebug()) {
             throw new \PH7\Framework\Error\CException\PH7BadMethodCallException('The file could not be uploaded. Possibly too large.');
         } else {
             return false;
         }
     } else {
         switch ($mImgType) {
             // JPG
             case static::JPG:
                 $this->rImage = imagecreatefromjpeg($this->sFile);
                 $this->sType = 'jpg';
                 break;
                 // PNG
             // PNG
             case static::PNG:
                 $this->rImage = imagecreatefrompng($this->sFile);
                 $this->sType = 'png';
                 break;
                 // GIF
             // GIF
             case static::GIF:
                 $this->rImage = imagecreatefromgif($this->sFile);
                 $this->sType = 'gif';
                 break;
             case static::WEBP:
                 $this->rImage = imagecreatefromgif($this->sFile);
                 $this->sType = 'webp';
                 break;
                 // Invalid Zone
             // Invalid Zone
             default:
                 return false;
                 // File type incompatible. Please save the image in .jpg, .png or .gif
         }
         $this->iWidth = imagesx($this->rImage);
         $this->iHeight = imagesy($this->rImage);
         // Automatic resizing if the image is too large
         if ($this->iWidth > $this->iMaxWidth or $this->iHeight > $this->iMaxHeight) {
             $this->dynamicResize($this->iMaxWidth, $this->iMaxHeight);
         }
         return true;
     }
 }
Example #11
0
 /**
  * 记录异常处理日志
  *
  * @param Exception $e
  * @param string $msg
  * @return boolean
  */
 public static function process($e, $msg, $sqlInfo = array())
 {
     $msg .= "\n";
     if ($sqlInfo) {
         $msg .= self::_sqlInfoToString($sqlInfo) . "\n";
     }
     $msg .= $e->getMessage() . "\n";
     foreach ($e->getTrace() as $key => $trace) {
         if (!isset($trace['file']) && !isset($trace['line'])) {
             continue;
         }
         $msg .= $key + 1 . ' File:' . $trace['file'] . ' Line:' . $trace['line'] . "\n";
     }
     if (isDebug()) {
         throw new self($msg);
     }
 }
 /**
  * @desc Image Validate.
  * @return boolean
  * @throws \PH7\Framework\Error\CException\PH7BadMethodCallException If the image file is not found.
  */
 public function validate()
 {
     if (!is_file($this->sFile)) {
         if (isDebug()) {
             throw new \PH7\Framework\Error\CException\PH7BadMethodCallException('Image file not found: The image file \'' . $this->sFile . '\' could not be found.');
         } else {
             return false;
         }
     } else {
         $this->aInfo = getimagesize($this->sFile);
         switch ($this->aInfo[2]) {
             // JPG
             case self::JPG:
                 $this->rImage = imagecreatefromjpeg($this->sFile);
                 $this->sType = 'jpg';
                 break;
                 // PNG
             // PNG
             case self::PNG:
                 $this->rImage = imagecreatefrompng($this->sFile);
                 $this->sType = 'png';
                 break;
                 // GIF
             // GIF
             case self::GIF:
                 $this->rImage = imagecreatefromgif($this->sFile);
                 $this->sType = 'gif';
                 break;
                 // Invalid Zone
             // Invalid Zone
             default:
                 return false;
                 // File type incompatible. Please save the image in .jpg, .png or .gif
         }
         $this->iWidth = imagesx($this->rImage);
         $this->iHeight = imagesy($this->rImage);
         // Automatic resizing if the image is too large
         if ($this->iWidth > $this->iMaxWidth or $this->iHeight > $this->iMaxHeight) {
             $this->dynamicResize($this->iMaxWidth, $this->iMaxHeight);
         }
         return true;
     }
 }
Example #13
0
function getPage($url)
{
    debug($url, 'json');
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_TIMEOUT, 90);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.5 Safari/537.17");
    $page = curl_exec($ch);
    if (curl_errno($ch)) {
        echo '<font color=red> Database temporarily unavailable: ';
        echo curl_errno($ch) . ' ' . curl_error($ch);
        if (isDebug()) {
            echo $url;
        }
        echo '</font><br>';
    }
    curl_close($ch);
    debug(print_r($page, true), 'json');
    return $page;
}
Example #14
0
    }
}
echo '</div>';
if ($allowcreatefolder) {
    echo '<div id="new-folder">
      			<a href="#" id="createfolder">' . i18n_r('CREATE_FOLDER') . '</a>
				<form action="upload.php">&nbsp;<input type="hidden" name="path" value="' . $subPath . '" />
					<input type="hidden" name="nonce" value="' . get_nonce("createfolder") . '" />
					<input type="text" class="text" name="newfolder" id="foldername" /> 
					<input type="submit" class="submit" value="' . i18n_r('CREATE_FOLDER') . '" />&nbsp; 
					<a href="#" class="cancel">' . i18n_r('CANCEL') . '</a>
				</form>
			</div>';
}
echo '</div>';
$showperms = $isUnixHost && isDebug() && function_exists('posix_getpwuid');
echo '<table class="highlight" id="imageTable"><thead>';
echo '<tr><th class="imgthumb" ></th><th>' . i18n_r('FILE_NAME') . '</th>';
echo '<th class="file_size right">' . i18n_r('FILE_SIZE') . '</th>';
if ($showperms) {
    echo '<th class="file_perms right">' . i18n_r('PERMS') . '</th>';
}
echo '<th class="file_date right">' . i18n_r('DATE') . '</th>';
echo '<th class="file_actions"><!-- actions --></th></tr>';
echo '</thead><tbody>';
if (count($dirsSorted) != 0) {
    $foldercount = 0;
    // show folders
    foreach ($dirsSorted as $upload) {
        # check to see if folder is empty
        $directory_delete = null;
 /**
  * Set a background on user profile.
  *
  * @param integer $iProfileId
  * @param string $sUsername
  * @param string $sFile
  * @param integer $iApproved (1 = approved 0 = pending) Default 1
  * @return boolean TRUE if succes, FALSE if the extension is wrong.
  */
 public function setBackground($iProfileId, $sUsername, $sFile, $iApproved = 1)
 {
     /**
      * This can cause minor errors (eg if a user sent a file that is not a photo).
      * So we hide the errors if we are not in development mode.
      */
     if (!isDebug()) {
         error_reporting(0);
     }
     $oWallpaper = new Framework\Image\Image($sFile, 600, 800);
     if (!$oWallpaper->validate()) {
         return false;
     }
     // We removes the old background if it exists and we delete the cache at the same time.
     $this->deleteBackground($iProfileId, $sUsername);
     $sPath = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'user/background/img/' . $sUsername . PH7_SH;
     (new File())->createDir($sPath);
     $sFileName = Various::genRnd($oWallpaper->getFileName(), 1);
     $sFile = $sFileName . '.' . $oWallpaper->getExt();
     // Add the profile background
     (new UserCoreModel())->addBackground($iProfileId, $sFile, $iApproved);
     // Saved the new background
     $oWallpaper->save($sPath . $sFile);
     unset($oWallpaper);
     return true;
 }
Example #16
0
 * GetSimple API Handler
 *
 * @package GetSimple
 * @subpackage API
 */
include 'inc/common.php';
include 'inc/api.class.php';
#step 1 - check for post
if (empty($_POST)) {
    exit;
}
if (!getDef('GSEXTAPI', true)) {
    exit;
}
// disable libxml error output
if (!isDebug()) {
    libxml_use_internal_errors(true);
}
// disable entity loading to avoid xxe
libxml_disable_entity_loader();
#step 1 - check post for data
if (!isset($_POST['data'])) {
    $message = array('status' => 'error', 'message' => i18n_r('API_ERR_MISSINGPARAM'));
    echo json_encode($message);
    exit;
}
#step 2 - setup request
$in = simplexml_load_string($_POST['data'], 'SimpleXMLExtended', LIBXML_NOCDATA);
$request = new API_Request();
$request->add_data($in);
#step 3 - verify a compatible method was provided
 private function _check()
 {
     if (!AdminCore::auth()) {
         // It rechecks if the administrator is always connected
         $this->_aErrors[] = t('You must be logged in as administrator to upgrade your site.');
     }
     if (DbConfig::getSetting('siteStatus') !== DbConfig::MAINTENANCE_SITE) {
         $this->_aErrors[] = t('Your site must be in maintenance mode to begin the upgrade.');
     }
     if (!isDebug()) {
         $this->_aErrors[] = t('You must put your site in development mode in order to launch the upgrade of your site!') . '<br />' . t('1) Please change the permission of the ~%0% file for writing for all groups (0666 in octal).', PH7_PATH_APP_CONFIG . PH7_CONFIG_FILE) . '<br />' . t('2) Edit ~%0% file and find the code:', PH7_PATH_APP_CONFIG . PH7_CONFIG_FILE) . '<br />' . '"<code>environment = production ; production or development</code>"<br />' . t('and replace it with the code:') . '<br />' . '"<code>environment = development ; production or development</code>"<br />' . t('3) After installation, please edit ~%0% file and find the code:', PH7_PATH_APP_CONFIG . PH7_CONFIG_FILE) . '<br />' . '"<code>environment = development ; production or development</code>"<br />' . t('and replace it with the code:') . '<br />' . '"<code>environment = production ; production or development</code>"<br />' . t('4) Change the permission of the file to write only for users and reading for the other groups (0644 in octal).');
     }
 }
Example #18
0
/**
 * @param String $name
 * @throws Exception
 */
function __autoload($name)
{
    $found = FALSE;
    if (isDebug()) {
        echo "Document Root:" . $_SERVER['DOCUMENT_ROOT'] . "<br/>";
        if (defined('__BASE_URL__')) {
            echo "Base URL:" . __BASE_URL__ . "<br/>";
        }
    }
    $baseDir = dirname(dirname(__FILE__));
    if (isDebug()) {
        echo 'dir:' . $baseDir . "<br/>";
    }
    // 	if (defined('__BASE_URL__')){
    // 		$parts=explode("/", __BASE_URL__,4);
    // 	 if (count($parts)<4){
    // 		  $classPath = $_SERVER['DOCUMENT_ROOT']."/oxygen-webhelp/resources/php/classes/";
    //     }else{
    //       $classPath = $_SERVER['DOCUMENT_ROOT']."/".$parts[3]."/oxygen-webhelp/resources/php/classes/";
    //     }
    // 	}else{
    $classPath = $baseDir . "/php/classes/";
    // 	}
    if (isDebug()) {
        echo 'classPath:' . $classPath . "<br/>";
    }
    $directory = $classPath;
    $path = $classPath . $name . ".php";
    if (file_exists($path)) {
        require_once $path;
        $found = TRUE;
    } else {
        $found = loadClassFromDir($classPath, $name);
    }
    if (!$found) {
        echo "Can not load {$name} from {$classPath}" . "<br/>\n";
        throw new Exception("Unable to load {$name}.");
    }
}
 /**
  * This method has two different behavior compared to the mode site.
  * 1. In production mode: Displays the page not found using the system module "error".
  * 2. In development mode: It throws an Exception with displaying an explanatory message that indicates why this page was not found.
  *
  * @access private
  * @param string $sMsg
  * @param string $iRedirect 1 = redirect
  * @return void
  * @throws \PH7\Framework\Error\CException\PH7Exception If the site is in development mode, displays an explanatory message that indicates why this page was not found.
  */
 private function notFound($sMsg = null, $iRedirect = null)
 {
     if (isDebug() && !empty($sMsg)) {
         throw new \PH7\Framework\Error\CException\PH7Exception($sMsg);
     } else {
         if (empty($iRedirect)) {
             $this->oRegistry->module = 'error';
         } else {
             \PH7\Framework\Url\Header::redirect(UriRoute::get('error', 'http', 'index'));
         }
     }
 }
}
?>
	
	<?php 
exec_action("files-sidebar");
?>

<?php 
if (!getDef('GSNOUPLOADIFY', true)) {
    ?>
	
	<li class="upload" id="sb_uploadify" >
		<div id="uploadify"></div>
	<?php 
    // create Uploadify uploader
    $debug = isDebug() ? 'true' : 'false';
    $fileSizeLimit = toBytes(ini_get('upload_max_filesize')) / 1024;
    echo "\n\t<script type=\"text/javascript\">\n\tjQuery(document).ready(function() {\n\t\tif(jQuery().uploadify) {\n\t\t\$('#uploadify').uploadify({\n\t\t\t'debug'\t\t\t: " . $debug . ",\n\t\t\t'buttonText'\t: '" . i18n_r('UPLOADIFY_BUTTON') . "',\n\t\t\t'buttonCursor'\t: 'pointer',\n\t\t\t'uploader'\t\t: 'upload-uploadify.php',\n\t\t\t'swf'\t\t\t: 'template/js/uploadify/uploadify.swf',\n\t\t\t'multi'\t\t\t: true,\n\t\t\t'auto'\t\t\t: true,\n\t\t\t'height'\t\t: '25',\n\t\t\t'width'\t\t\t: '100%',\n\t\t\t'requeueErrors'\t: false,\n\t\t\t'fileSizeLimit'\t: '" . $fileSizeLimit . "', // expects input in kb\n\t\t\t'cancelImage'\t: 'template/images/cancel.png',\n\t\t\t'checkExisting'\t: 'uploadify-check-exists.php?path=" . $path . "',\n\t\t\t'postData'\t\t: {\n\t\t\t'sessionHash' : '" . $SESSIONHASH . "',\n\t\t\t'path' : '" . $path . "'\n\t\t\t},\n\t\t\tonUploadProgress: function() {\n\t\t\t\t\$('#loader').show();\n\t\t\t},\n\t\t\tonUploadComplete: function() {\n\t\t\t\t\$('#loader').fadeOut(500);\n\t\t\t\t\$('#maincontent').load(location.href+' #maincontent > *');\n\t\t\t},\n\t\t\tonSelectError: function(file,errorCode,errorMsg) {\n\t\t\t\tnotifyError('<strong>Uploadify:</strong> ' + file.name + ' <br/>Error ' + errorCode +':'+errorMsg).popit().removeit();\n\t\t\t},\n\t\t\tonUploadSuccess: function(file,data,response) {\t\n\t\t\t\tif(data != 1){\n\t\t\t\t\tnotifyError('<strong>Uploadify:</strong>' + data + ' ('+file.name+')').popit().removeit();\n\t\t\t\t\tjQuery('#' + file.id).addClass('uploadifyError');\n\t\t\t\t\tjQuery('#' + file.id).find('.uploadifyProgressBar').css('width','1px');\n\t\t\t\t\tjQuery('#' + file.id).find('.data').html(' - ' + 'Failed');\t\t\t\t\t\n\t\t\t\t}\t \n\t\t\t},\t\t\t\t\n\t\t\tonUploadError: function(file,errorCode,errorMsg, errorString) {\n\t\t\t\tnotifyError('<strong>Uploadify:</strong> ' + errorMsg).popit().removeit();\n\t\t\t}\n\t\t});\n\t\t}\n\t});\n\t</script>";
    ?>
	</li>
<?php 
}
?>
	<li style="float:right;" id="sb_filesize" ><small><?php 
i18n('MAX_FILE_SIZE');
?>
: <strong><?php 
echo toBytes(ini_get('upload_max_filesize')) / 1024 / 1024;
?>
MB</strong></small></li>
</ul>
Example #21
0
                # get external thumbnail link
                $thumbLinkExternal = 'data/thumbs/' . $urlPath . 'thumbnail.' . $upload['name'];
                if (file_exists('../' . $thumbLinkExternal)) {
                    $thumbnailLink = '<span>&nbsp;&ndash;&nbsp;&nbsp;</span><a href="javascript:void(0)" onclick="submitLink(' . $CKEditorFuncNum . ',\'' . $sitepath . $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>';
        }
        echo '<td style="width:85px;text-align:right;" ><span>' . shtDate($upload['date']) . '</span></td>';
        echo '</tr>';
    }
}
echo '</table>';
echo '<p><em><b>' . $counter . '</b> ' . i18n_r('TOTAL_FILES') . ' (' . fSize($totalsize) . ')</em></p>';
?>
	
	</div>
  </div>
 </div>	
Example #22
0
/**
 * Redirect URL
 *
 * @since 3.0
 * @author schlex
 *
 * @param string $url
 */
function redirect($url)
{
    global $i18n;
    // handle expired sessions for ajax requests
    if (requestIsAjax() && !cookie_check()) {
        header('HTTP/1.1 401 Unauthorized', true, 401);
        header('WWW-Authenticate: FormBased');
        die;
    }
    if (!headers_sent($filename, $linenum)) {
        header('Location: ' . $url);
    } else {
        echo "<html><head><title>" . i18n_r('REDIRECT') . "</title></head><body>";
        if (!isDebug()) {
            echo '<script type="text/javascript">';
            echo 'window.location.href="' . $url . '";';
            echo '</script>';
            echo '<noscript>';
            echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />';
            echo '</noscript>';
        }
        echo i18n_r('ERROR') . ": Headers already sent in " . $filename . " on line " . $linenum . "\n";
        printf(i18n_r('REDIRECT_MSG'), $url);
        echo "</body></html>";
    }
    exit;
}
Example #23
0
 /**
  * Add twig extended functions
  */
 protected function addFunctions()
 {
     // isDebug
     $func = new \Twig_SimpleFunction('isDebug', function () {
         return isDebug();
     });
     $this->twig->addFunction($func);
     // debugbarHead
     $func = new \Twig_SimpleFunction('debugbarHead', function () {
         $debugbar = \Flight::get('debugbar');
         if ($debugbar) {
             $debugRender = $debugbar->getJavascriptRenderer();
             $debugRender->setBaseUrl(U('assets/debugbar'));
             return $debugRender->renderHead();
         }
         return '';
     }, ['is_safe' => ['html']]);
     $this->twig->addFunction($func);
     // renderDubugbar
     $func = new \Twig_SimpleFunction('renderDebugbar', function () {
         $debugbar = \Flight::get('debugbar');
         if ($debugbar) {
             $debugRender = $debugbar->getJavascriptRenderer();
             return $debugRender->render();
         }
         return '';
     }, ['is_safe' => ['html']]);
     $this->twig->addFunction($func);
     // renderAssets
     $func = new \Twig_SimpleFunction('renderAssets', function ($addlib = []) {
         $ass = getAssets();
         if ($addlib) {
             $ass->addLibrary($addlib);
         }
         return $ass->renderCss() . $ass->renderJs();
     }, ['is_safe' => ['html']]);
     $this->twig->addFunction($func);
     // get resource
     $func = new \Twig_SimpleFunction('resource', function ($name, $prefix = '') {
         return getAssets()->getResource($name, $prefix);
     });
     $this->twig->addFunction($func);
     // isLogin
     $func = new \Twig_SimpleFunction('isLogin', function () {
         return getAuth()->isLogin();
     });
     $this->twig->addFunction($func);
     // isSuperuser
     $func = new \Twig_SimpleFunction('isSuperuser', function () {
         return getAuth()->isSuperuser();
     });
     $this->twig->addFunction($func);
     // hasRole
     $func = new \Twig_SimpleFunction('hasRole', function ($role) {
         return getAuth()->hasRole($role);
     });
     $this->twig->addFunction($func);
     // getConfig
     $func = new \Twig_SimpleFunction('getConfig', function ($name) {
         return \Flight::get('config')->get($name);
     });
     $this->twig->addFunction($func);
     // getUser
     $func = new \Twig_SimpleFunction('getUser', function () {
         return getAuth()->getUser();
     });
     $this->twig->addFunction($func);
     // old value
     $func = new \Twig_SimpleFunction('old', function ($name, $def = '') {
         return getOld($name, $def);
     });
     $this->twig->addFunction($func);
     // log
     $func = new \Twig_SimpleFunction('log', function ($level, $msg, $context = []) {
         return getLog()->log($level, $msg, $context);
     });
     $this->twig->addFunction($func);
 }
Example #24
0
<?php

/**
 * Navigation Include Template
 *
 * @package GetSimple
 */
$debugInfoUrl = 'http://get-simple.info/docs/debugging';
if (cookie_check()) {
    echo '<ul id="pill"><li class="leftnav"><a href="logout.php" accesskey="' . find_accesskey(i18n_r('TAB_LOGOUT')) . '" >' . i18n_r('TAB_LOGOUT') . '</a></li>';
    if (isDebug()) {
        echo '<li class="debug"><a href="' . $debugInfoUrl . '" target="_blank">' . i18n_r('DEBUG_MODE') . '</a></li>';
    }
    echo '<li class="rightnav" ><a href="settings.php#profile">' . i18n_r('WELCOME') . ' <strong>' . $USR . '</strong>!</a></li></ul>';
}
//determine page type if plugin is being shown
if (get_filename_id() == 'load') {
    $plugin_class = $plugin_info[$plugin_id]['page_type'];
} else {
    $plugin_class = '';
}
?>
<h1 id="sitename"><a href="<?php 
echo $SITEURL;
?>
" target="_blank" ><?php 
echo cl($SITENAME);
?>
</a></h1>
<ul class="nav <?php 
echo $plugin_class;
 public function __construct()
 {
     parent::__construct();
     /**
      * This can cause minor errors (eg if a user sent a file that is not a video).
      * So we hide the errors if we are not in development mode.
      */
     if (!isDebug()) {
         error_reporting(0);
     }
     /**
      * Check if the video album ID is valid. The value must be numeric.
      * This test is necessary because when the selection exists but that no option is available (this can when a user wants to add a video but he has no album)
      * the return value is of type "string" and the value is "1".
      */
     if (!is_numeric($this->httpRequest->post('album_id'))) {
         \PFBC\Form::setError('form_video', t('Please add a category before you add a video.'));
         return;
         // Stop execution of the method.
     }
     $sAlbumTitle = $this->httpRequest->post('album_title');
     $iAlbumId = (int) $this->httpRequest->post('album_id');
     /** Default URL Thumbnail **/
     $sThumb = '';
     if ($this->httpRequest->postExists('embed_code')) {
         $sEmbedUrl = $this->httpRequest->post('embed_code');
         if (!($sFile = (new V\Api())->getVideo($sEmbedUrl))) {
             \PFBC\Form::setError('form_video', t('Oops, the link of the video looks bad? Check that the link is correct.'));
             return;
         }
         if (!($oInfo = (new V\Api())->getInfo($sEmbedUrl))) {
             \PFBC\Form::setError('form_video', t('Unable to retrieve information from the video. Are you sure that the URL of the video is correct?'));
             return;
         }
         $sTitle = $this->httpRequest->postExists('title') && $this->str->length($this->str->trim($this->httpRequest->post('title'))) > 2 ? $this->httpRequest->post('title') : ($oInfo->getTitle() ? $oInfo->getTitle() : t('Untitled'));
         $sDescription = $this->httpRequest->postExists('description') ? $this->httpRequest->post('description') : ($oInfo->getDescription() ? $oInfo->getDescription() : '');
         $sDuration = $oInfo->getDuration() ? $oInfo->getDuration() : '0';
         // Time in seconds
         if (!$sFile) {
             \PFBC\Form::setError('form_video', t('Invalid Api Video Type! Choose from Youtube, Vimeo, Dailymotion and Metacafe.'));
             return;
         }
     } elseif (!empty($_FILES['video']['tmp_name'])) {
         $oVideo = new V\Video($_FILES['video'], 2500, 2500);
         if (!$oVideo->validate()) {
             \PFBC\Form::setError('form_video', Form::wrongVideoFileTypeMsg());
             return;
         } elseif (!$oVideo->check()) {
             \PFBC\Form::setError('form_video', t('File exceeds maximum allowed video filesize of %0%!', F\Various::bytesToSize($oVideo->getMaxSize())));
             return;
         } else {
             // It creates a nice title if no title is specified.
             $sTitle = $this->httpRequest->postExists('title') && $this->str->length($this->str->trim($this->httpRequest->post('title'))) > 2 ? $this->httpRequest->post('title') : $this->str->upperFirst(str_replace(array('-', '_'), ' ', str_ireplace(PH7_DOT . $oVideo->getExt(), '', escape($_FILES['video']['name'], true))));
             $sDescription = $this->httpRequest->post('description');
             $sDuration = $oVideo->getDuration();
             $sPath = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'video/file/' . $this->session->get('member_username') . PH7_DS . $iAlbumId . PH7_DS;
             $sFileName = Various::genRnd($oVideo->getFileName(), 20);
             $sThumb = $sFileName . '.jpg';
             $sThumb1 = $sFileName . '-1.jpg';
             $sThumb2 = $sFileName . '-2.jpg';
             $sThumb3 = $sFileName . '-3.jpg';
             $sThumb4 = $sFileName . '-4.jpg';
             $sFile = $sFileName;
             $oVideo->thumbnail($sPath . $sThumb, 1, 320, 240);
             $oVideo->thumbnail($sPath . $sThumb1, 4, 320, 240);
             $oVideo->thumbnail($sPath . $sThumb2, 6, 320, 240);
             $oVideo->thumbnail($sPath . $sThumb3, 8, 320, 240);
             $oVideo->thumbnail($sPath . $sThumb4, 10, 320, 240);
             $oVideo->rename($sPath . $sFile . '.webm');
             $oVideo->rename($sPath . $sFile . '.mp4');
             //$oVideo->save($sPath . $sFile); // Original file type
         }
     } else {
         \PFBC\Form::setError('form_video', t('You must choose a type of video!'));
         return;
     }
     $iApproved = DbConfig::getSetting('videoManualApproval') == 0 ? '1' : '0';
     (new VideoModel())->addVideo($this->session->get('member_id'), $iAlbumId, $sTitle, $sDescription, $sFile, $sThumb, $sDuration, $this->dateTime->get()->dateTime('Y-m-d H:i:s'), $iApproved);
     /* Clean VideoModel Cache */
     (new Framework\Cache\Cache())->start(VideoModel::CACHE_GROUP, null, null)->clear();
     $sModerationText = t('Your video has been received! But it will be visible once approved by our moderators. Please do not send a new video because this is useless!');
     $sText = t('Your video has been added successfully!');
     $sMsg = $iApproved == '0' ? $sModerationText : $sText;
     Header::redirect(Uri::get('video', 'main', 'album', $this->session->get('member_username') . ',' . $sAlbumTitle . ',' . $iAlbumId), $sMsg);
 }
Example #26
0
if (file_exists(GSTHEMESPATH . getDef('GSEDITORCONFIGFILE'))) {
    $configjs = $SITEURL . getRelPath(GSTHEMESPATH) . getDef('GSEDITORCONFIGFILE');
}
?>

    <script type="text/javascript">
    	// @todo clean this up, use a better bridge to initialize config variables in js
    	
        // 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;
?>
';
Example #27
0
/**
 * Redirect URL
 *
 * @since 3.0
 * @author schlex
 *
 * @param string $url
 * @param bool ajax force redirects if ajax
 */
function redirect($url, $ajax = false)
{
    global $i18n;
    $url = var_out($url, 'url');
    // filter url here since it can come from alot of places, specifically redirectto user input
    // handle expired sessions for ajax requests
    if (requestIsAjax()) {
        if (!cookie_check()) {
            header('HTTP/1.1 401 Unauthorized');
            header('WWW-Authenticate: FormBased');
            // @note this is not a security function for ajax, just a session timeout handler
            die;
        } else {
            if ($ajax) {
                header('HTTP/1.1 302 Redirect');
                echo $url;
                // header('Location: '.$url);
                // @note this is not a security function for ajax, just a session timeout handler
                die;
            }
        }
    }
    if (function_exists('exec_action')) {
        exec_action('redirect');
    }
    // @hook redirect a redirect is occuring
    $debugredirect = getDef('GSDEBUGREDIRECTS', true);
    if (!headers_sent($filename, $linenum) && !$debugredirect) {
        header('Location: ' . $url);
    } else {
        // @todo not sure this ever gets used or headers_sent is reliable ( turn output buffering off to test )
        echo "<html><head><title>" . i18n_r('REDIRECT') . "</title></head><body>";
        if (!isDebug()) {
            echo '<script type="text/javascript">';
            echo 'window.location.href="' . $url . '";';
            echo '</script>';
            echo '<noscript>';
            echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />';
            echo '</noscript>';
        }
        if (headers_sent()) {
            echo i18n_r('ERROR') . ": Headers already sent in " . $filename . " on line " . $linenum . "<br/><br/>\n\n";
        }
        printf(i18n_r('REDIRECT_MSG'), $url);
        if (!isAuthPage()) {
            if (isDebug()) {
                debugLog(debug_backtrace());
                outputDebugLog();
            }
        }
        echo "</body></html>";
    }
    exit;
}
Example #28
0
/**
 * Redirect URL
 *
 * @since 3.0
 * @author schlex
 *
 * @param string $url
 */
function redirect($url)
{
    global $i18n;
    // handle expired sessions for ajax requests
    if (requestIsAjax() && !cookie_check()) {
        header('HTTP/1.1 401 Unauthorized');
        header('WWW-Authenticate: FormBased');
        // @note this is not a security function for ajax, just a handler
        die;
    }
    if (function_exists('exec_action')) {
        exec_action('redirect');
    }
    if (!headers_sent($filename, $linenum)) {
        header('Location: ' . $url);
    } else {
        // @todo not sure this ever gets used or headers_sent is reliable ( turn output buffering off to test )
        echo "<html><head><title>" . i18n_r('REDIRECT') . "</title></head><body>";
        if (!isDebug()) {
            echo '<script type="text/javascript">';
            echo 'window.location.href="' . $url . '";';
            echo '</script>';
            echo '<noscript>';
            echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />';
            echo '</noscript>';
        }
        echo i18n_r('ERROR') . ": Headers already sent in " . $filename . " on line " . $linenum . "<br/><br/>\n\n";
        printf(i18n_r('REDIRECT_MSG'), $url);
        if (!isAuthPage()) {
            if (isDebug()) {
                global $GS_debug;
                echo '<h2>' . i18n_r('DEBUG_CONSOLE') . '</h2><div id="gsdebug">';
                echo '<pre>';
                foreach ($GS_debug as $log) {
                    print $log . '<br/>';
                }
                echo '</pre>';
                echo '</div>';
            }
        }
        echo "</body></html>";
    }
    exit;
}
Example #29
0
/**
 * Execute commands on local machine.
 * @param string $command Command to run locally.
 * @param int $timeout (optional) Override process command timeout in seconds.
 * @return Result Output of command.
 * @throws \RuntimeException
 */
function runLocally($command, $timeout = 60)
{
    $command = env()->parse($command);
    if (isVeryVerbose()) {
        writeln("<comment>Run locally</comment>: {$command}");
    }
    $process = new Symfony\Component\Process\Process($command);
    $process->setTimeout($timeout);
    $process->run(function ($type, $buffer) {
        if (isDebug()) {
            if ('err' === $type) {
                write("<fg=red>></fg=red> {$buffer}");
            } else {
                write("<fg=green>></fg=green> {$buffer}");
            }
        }
    });
    if (!$process->isSuccessful()) {
        throw new \RuntimeException($process->getErrorOutput());
    }
    return new Result($process->getOutput());
}
 public function __construct()
 {
     parent::__construct();
     /**
      * @desc This can cause minor errors (eg if a user sent a file that is not a photo).
      * So we hide the errors if we are not in development mode.
      */
     if (!isDebug()) {
         error_reporting(0);
     }
     /**
      * @desc
      * Check if the photo album ID is valid. The value must be numeric.
      * This test is necessary because when the selection exists but that no option is available (this can when a user wants to add photos but he has no album)
      * the return value is of type "string" and the value is "1".
      */
     if (!is_numeric($this->httpRequest->post('album_id'))) {
         \PFBC\Form::setError('form_picture', t('Please add a category before you add some photos.'));
         return;
         // Stop execution of the method.
     }
     /**
      * @desc Resizing and saving some photos
      */
     $aPhotos = $_FILES['photos']['tmp_name'];
     for ($i = 0, $iNumPhotos = count($aPhotos); $i < $iNumPhotos; $i++) {
         $oPicture1 = new Image($aPhotos[$i], 2500, 2500);
         if (!$oPicture1->validate()) {
             \PFBC\Form::setError('form_picture', Form::wrongImgFileTypeMsg());
             return;
             // Stop execution of the method.
         }
         $sAlbumTitle = $this->httpRequest->post('album_title');
         $iAlbumId = (int) $this->httpRequest->post('album_id');
         $oPicture2 = clone $oPicture1;
         $oPicture3 = clone $oPicture1;
         $oPicture4 = clone $oPicture1;
         $oPicture5 = clone $oPicture1;
         $oPicture6 = clone $oPicture1;
         $oPicture2->square(400);
         $oPicture3->square(600);
         $oPicture4->square(800);
         $oPicture5->square(1000);
         $oPicture6->square(1200);
         /* Set watermark text on images */
         $sWatermarkText = DbConfig::getSetting('watermarkTextImage');
         $iSizeWatermarkText = DbConfig::getSetting('sizeWatermarkTextImage');
         $oPicture1->watermarkText($sWatermarkText, $iSizeWatermarkText);
         $oPicture2->watermarkText($sWatermarkText, $iSizeWatermarkText);
         $oPicture3->watermarkText($sWatermarkText, $iSizeWatermarkText);
         $oPicture4->watermarkText($sWatermarkText, $iSizeWatermarkText);
         $oPicture5->watermarkText($sWatermarkText, $iSizeWatermarkText);
         $oPicture6->watermarkText($sWatermarkText, $iSizeWatermarkText);
         $sPath = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'picture/img/' . $this->session->get('member_username') . PH7_DS . $iAlbumId . PH7_DS;
         $sFileName = Various::genRnd($oPicture1->getFileName(), 20);
         $sFile1 = $sFileName . '-original.' . $oPicture1->getExt();
         // Original
         $sFile2 = $sFileName . '-400.' . $oPicture2->getExt();
         $sFile3 = $sFileName . '-600.' . $oPicture3->getExt();
         $sFile4 = $sFileName . '-800.' . $oPicture4->getExt();
         $sFile5 = $sFileName . '-1000.' . $oPicture5->getExt();
         $sFile6 = $sFileName . '-1200.' . $oPicture6->getExt();
         $oPicture1->save($sPath . $sFile1);
         $oPicture2->save($sPath . $sFile2);
         $oPicture3->save($sPath . $sFile3);
         $oPicture4->save($sPath . $sFile4);
         $oPicture5->save($sPath . $sFile5);
         $oPicture6->save($sPath . $sFile6);
         $iApproved = DbConfig::getSetting('pictureManualApproval') == 0 ? '1' : '0';
         // It creates a nice title if no title is specified.
         $sTitle = $this->httpRequest->postExists('title') && $this->str->length($this->str->trim($this->httpRequest->post('title'))) > 2 ? $this->httpRequest->post('title') : $this->str->upperFirst(str_replace(array('-', '_'), ' ', str_ireplace(PH7_DOT . $oPicture1->getExt(), '', escape($_FILES['photos']['name'][$i], true))));
         (new PictureModel())->addPhoto($this->session->get('member_id'), $iAlbumId, $sTitle, $this->httpRequest->post('description'), $sFile1, $this->dateTime->get()->dateTime('Y-m-d H:i:s'), $iApproved);
     }
     /* Clean PictureModel Cache */
     (new Framework\Cache\Cache())->start(PictureModel::CACHE_GROUP, null, null)->clear();
     $sModerationText = t('Your photo(s) has been received! But it will be visible once approved by our moderators. Please do not send a new photo(s) because this is useless!');
     $sText = t('Your photo(s) has been added successfully!');
     $sMsg = $iApproved == '0' ? $sModerationText : $sText;
     Header::redirect(Uri::get('picture', 'main', 'album', $this->session->get('member_username') . ',' . $sAlbumTitle . ',' . $iAlbumId), $sMsg);
 }