Esempio n. 1
0
function getMaximumUploadSize()
{
    $upload_max = return_kbytes(ini_get('upload_max_filesize'));
    $post_max = return_kbytes(ini_get('post_max_size'));
    return $upload_max < $post_max ? $upload_max : $post_max;
}
Esempio n. 2
0
    // - login                     - to disable unautorized access when the response is modified
    // - maxfilesize               - to disable that bigger files can be uploaded when the response is modified
    // - allowed_file_extensions   - to disable that other then the allowed extensions can be uploaded when the response is modified
    // - registration data         - to secure your registration data that it can be monitored und used by someone else.
    // If you want to secure more of the sent parameters you have to change this here and in the flash
    sendConfigData();
} else {
    echo '
  <style type="text/css">
  body {   font-family : Arial, Helvetica, sans-serif; font-size: 12px; background-color:#ffffff; }
  td { vertical-align: top; font-size: 12px; }
  .install {  margin-left: auto;  margin-right: auto;  margin-top: 3em;  margin-bottom: 3em; padding: 10px; border: 1px solid #cccccc;  width: 650px; background: #F1F1F1; }
</style>
';
    echo "<br> <p><center>Some info's about your server. This limits are not TFU limits. You have to change the php.ini.</center></p>";
    echo "<div class='install'>";
    echo "<table><tr><td>";
    echo "<tr><td width='400'>Server name:</td><td width='250'>" . $_SERVER['SERVER_NAME'] . "</td></tr>";
    echo "<tr><td>PHP upload limit (in KB): </td><td>" . getMaximumUploadSize() . "</td></tr>";
    echo "<tr><td>PHP memory limit (in KB):&nbsp;&nbsp;&nbsp;</td><td>" . return_kbytes(ini_get('memory_limit')) . "</td></tr>";
    echo "<tr><td>Safe mode:</td><td>";
    echo ini_get('safe_mode') == 1 ? "ON<br>You maybe have some limitations creating folders or uploading<br>if the permissions are not set properly.<br>Please check the TWG FAQ 30 if you want to know more about<br>safe mode and the problems that comes with this setting." : "OFF";
    echo "</td></tr><tr><td>GD lib:</td><td>";
    echo !function_exists("imagecreatetruecolor") ? '<font color="red">GDlib is not installed properly.<br>TFU Preview does not work!</font>' : 'Available';
    echo "</td></tr>";
    echo "<tr><td>The times below have to be longer than the max. upload duration!<br>Otherwise the upload will fail.</td><td>&nbsp;</td></tr>";
    echo "<tr><td>PHP maximum execution time: </td><td>" . ini_get('max_execution_time') . " s</td></tr>";
    echo "<tr><td>PHP maximum input time: </td><td>" . ini_get('max_input_time') . " s</td></tr>";
    echo "</table>";
    echo "</div>";
}
function printServerInfo()
{
    global $m;
    echo '
  <style type="text/css">
  body { 	font-family : Arial, Helvetica, sans-serif; font-size: 12px; background-color:#ffffff; }
  td { vertical-align: top; font-size: 12px; }
  .install {  margin-left: auto;  margin-right: auto;  margin-top: 3em;  margin-bottom: 3em; padding: 10px; border: 1px solid #cccccc;  width: 650px; background: #F1F1F1; }
  </style>
';
    $limit = return_kbytes(ini_get('memory_limit'));
    echo '<br><p><center>Some info\'s about your server. This limits are not TFU limits. You have to change this in the php.ini.</center></p>';
    echo '<div class="install">';
    echo '<table><tr><td>';
    echo '<tr><td width="400">TFU version:</td><td width="250">2.9.1&nbsp;';
    // simply output the license type by checking the strings in the license. No real check like in the flash is done here.
    if ($m != "" && $m != "s" && $m != "w") {
        include dirname(__FILE__) . "/twg.lic.php";
        if ($l == $d) {
            echo " (Enterprise Edition License)";
        } else {
            if (strpos($d, "TWG_PROFESSIONAL") !== false) {
                echo " (Professional Edition License)";
            } else {
                if (strpos($d, "TWG_SOURCE") !== false) {
                    echo " (Source code Edition License)";
                } else {
                    echo " (Standart Edition License)";
                }
            }
        }
    } else {
        echo " (Freeware Edition)";
    }
    echo '</td></tr>';
    echo '<tr><td width="400">Server name:</td><td width="250">' . get_server_name() . '</td></tr>';
    echo '<tr><td>PHP upload limit (in KB): </td><td>' . getMaximumUploadSize() . '</td></tr>';
    echo '<tr><td>PHP memory limit (in KB):&nbsp;&nbsp;&nbsp;</td><td>' . $limit . '</td></tr>';
    echo '<tr><td>Safe mode:</td><td>';
    echo ini_get('safe_mode') == 1 ? 'ON<br>You maybe have some limitations creating folders or uploading<br>if the permissions are not set properly.<br>Please check the TWG FAQ 30 if you want to know more about<br>safe mode and the problems that comes with this setting.' : 'OFF';
    echo '</td></tr><tr><td>GD lib:</td><td>';
    echo !function_exists('imagecreatetruecolor') ? '<font color="red">GDlib is not installed properly.<br>TFU Preview does not work!</font>' : 'Available';
    echo '</td></tr>';
    echo '<tr><td>Max resize resolution (GDlib):</td><td>';
    if (!$limit) {
        echo '<font color="green">No limit</font>';
    } else {
        $xy = $limit * 1024 / 6;
        $x = floor(sqrt($xy / 0.75));
        $y = floor(sqrt($xy / 1.33));
        if ($x > 4000) {
            echo '<font color="green">~ ' . $x . ' x ' . $y . '</font>';
        } else {
            if ($x > 2000) {
                echo '<font color="orange">~ ' . $x . ' x ' . $y . '</font>';
            } else {
                echo '<font color="red">~ ' . $x . ' x ' . $y . '</font>';
            }
        }
    }
    echo '</td></tr>';
    echo '<tr><td>Image magick support:&nbsp;&nbsp;&nbsp;</td><td>' . (check_image_magic() ? '<font color="green">Available</font>' : '<b><font color="red">Not available</b><br>(or test could not be performed!)</font>') . '</td></tr>';
    echo '<tr><td>The times below have to be longer than the maximum<br>upload duration! Otherwise the upload will fail.</td><td>&nbsp;</td></tr>';
    echo '<tr><td>PHP maximum execution time: </td><td>' . ini_get('max_execution_time') . ' s</td></tr>';
    echo '<tr><td>PHP maximum input time: </td><td>' . ini_get('max_input_time') . ' s</td></tr>';
    echo '<tr><td>PHP default socket timeout: </td><td>' . ini_get('default_socket_timeout') . ' s</td></tr>';
    echo '</table>';
    echo '</div>';
}
    function showHelpRegister()
    {
        global $m;
        echo '

<style>
.install {
	margin-left: 5px;
	margin-right: 5px;
	margin-top: 10px;
	margin-bottom: 10px;
	padding: 10px;
	text-align:left;
	border: 1px solid #cccccc;
	width:720px;
	background: #F1F1F1;
}

.h3_help {
text-align:left;
border-bottom: 2px solid #DDDDDD;
}
</style>
<form action="index2.php" method="post" name="adminForm">
<h2>' . JText::_('H_TITLE') . '</h2>
	<h3 class="h3_help">' . JText::_('H_H3_HELP') . '</h3> 
	' . JText::_('H_H_TEXT') . '
	<div style="text-align:left;float:left;">
	<ul>
		<li>' . JText::_('H_H_OVERVIEW') . '</li>
		<li>' . JText::_('H_H_HELP') . '</li>
		<li>' . JText::_('H_H_TWG') . '</li>
		<li>' . JText::_('H_H_FORUM') . '</li>
		<li>' . JText::_('H_H_CONFIG') . '</li>
		<li>' . JText::_('H_H_MAMBOT') . '</li>
		<li>' . JText::_('H_H_REG') . '</li>
	</ul>
	</div>
	<h3 class="h3_help">' . JText::_('H_L_TITLE') . '</h3>
	<div style="text-align:left;float:left;">	
	  ' . JText::_('H_L_TEXT') . '  
	  <div class="install" style="width:600px;margin-left:50px;">
	  <b>' . JText::_('H_L_INFOS') . '</b><p> 
';
        $limit = return_kbytes(ini_get('memory_limit'));
        echo JText::_('H_L_NAME') . " " . $_SERVER['SERVER_NAME'] . "<br>";
        echo JText::_('H_L_LIMIT') . " " . getMaximumUploadSize() . "<br>";
        echo JText::_('H_L_MEMORY') . " " . $limit . " <br>";
        echo JText::_('H_L_RESOLUTION') . " ";
        if (!$limit) {
            echo '<font color="green">No limit</font>';
        } else {
            $xy = $limit * 1024 / 6;
            $x = floor(sqrt($xy / 0.75));
            $y = floor(sqrt($xy / 1.33));
            if ($x > 4000) {
                echo "<font color='green'>~ " . $x . " x " . $y . "</font>";
            } else {
                if ($x > 2000) {
                    echo "<font color='orange'>~ " . $x . " x " . $y . "</font>";
                } else {
                    echo "<font color='red'>~ " . $x . " x " . $y . "</font>";
                }
            }
        }
        echo "<br>";
        echo JText::_('H_L_INPUT') . " " . ini_get('max_input_time') . " s<br>";
        echo JText::_('H_L_EXECUT') . " " . ini_get('max_execution_time') . " s<br>";
        echo JText::_('H_L_SOCKET') . " " . ini_get('default_socket_timeout') . " s";
        if (substr(@php_uname(), 0, 7) != "Windows") {
            echo '<p>' . JText::_('H_L_CHMOD1') . ' ' . substr(sprintf('%o', fileperms(dirname(__FILE__) . "/tfu/tfu_config.php")), -4);
            echo '<br>' . JText::_('H_L_CHMOD2');
            echo '</p><p>
        <button onclick="this.form.task.value=\'chmod755\';this.form.submit();">' . JText::_('H_L_CHMOD755') . '</button> 
        <button onclick="this.form.task.value=\'chmod644\';this.form.submit();">' . JText::_('H_L_CHMOD644') . '</button> 
        <button onclick="this.form.task.value=\'chmod666\';this.form.submit();">' . JText::_('H_L_CHMOD666') . '</button> 
        <button onclick="this.form.task.value=\'chmod777\';this.form.submit();">' . JText::_('H_L_CHMOD777') . '</button> 
        </p>
        ';
        }
        echo '
	  </p>
	  </div>
	</div>
	
	<h3 class="h3_help">' . JText::_('H_R_TITLE') . '</h3>
	<div style="text-align:left;float:left;">
';
        if ($m == "") {
            echo JText::_('H_R_TEXT') . '<ul>
  <li>' . JText::_('H_R_FREEWARE') . '</li
  <li>' . JText::_('H_R_REG') . '</li></ul>
	  <div class="install" style="width:600px;margin-left:50px;">' . JText::_('H_R_BONUS') . '</div>';
            printf(JText::_('H_R_REG_10'), "<a href=\"http://www.tinywebgallery.com/en/register_tfu.php\"><b>", "</b></a>");
            echo '<p>' . JText::_('H_R_REG_HOWTO') . '</p>
<div class="install" style="width:600px;margin-left:50px;">
&lt;?php
<table><tr><td>
$l</td><td>=" <input type="text" name="l" size=80> ";</td></tr><tr><td>
$d</td><td>=" <input type="text" name="d" size=80> ";</td></tr><tr><td>
$s</td><td>=" <input type="text" name="s" size=80> ";</td></tr></table>
?&gt;
<p>
<input type="hidden" name="task" value="register" />
<button onclick="this.form.submit();">' . JText::_('H_R_REGISTER') . '</button>
</p>
</div>
';
        } else {
            if ($m != "" && $m != "s" && $m != "w") {
                include dirname(__FILE__) . "/tfu/twg.lic.php";
                echo JText::_('H_R_REG_TO') . " <b>{$l}</b>";
                if ($l == $d) {
                    echo " (Enterprise Edition License)";
                } else {
                    if (strpos($d, "TWG_PROFESSIONAL") !== false) {
                        echo " (Professional Edition License)";
                    } else {
                        if (strpos($d, "TWG_SOURCE") !== false) {
                            echo " (Source code Edition License)";
                        } else {
                            echo " (Standart Edition License)";
                        }
                    }
                }
                echo "<p>" . JText::_('H_R_REG_DEL');
                echo '
<input type="hidden" name="task" value="dellic" />
<button onclick="this.form.submit();">' . JText::_('H_R_UNREGISTER') . '</button>
</p>';
            } else {
                echo "<p>" . JText::_('H_R_REG_WRONG');
                echo '
<input type="hidden" name="task" value="dellic" />
<button onclick="this.form.submit();">' . JText::_('H_R_UNREGISTER') . '</button>
</p>';
            }
        }
        echo <<<HTML
</div>
\t      <input type="hidden" name="option" value="com_joomla_flash_uploader"/>
\t      <input type="hidden" name="boxchecked" value="0" />
  </form>
HTML;
    }
    function showHelpRegister()
    {
        global $m, $mybasedir;
        $canDo = JFUHelper::getActions();
        $language = JFactory::getLanguage();
        $lang = $language->getTag() == 'de-DE' ? 'de_DE' : 'en_US';
        echo '

<style>
.install {
	margin-left: 5px;
	margin-right: 5px;
	margin-top: 10px;
	margin-bottom: 10px;
	padding: 10px;
	text-align:left;
	border: 1px solid #cccccc;
	width:720px;
	background: #F1F1F1;
}

.h3_help {
text-align:left;
border-bottom: 2px solid #DDDDDD;
}
</style>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<h2>' . JText::_('H_TITLE') . '</h2>

	<!-- Facebook like button -->	  
  <p>	 
  <div id="fb-root"></div>
  <script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/' . $lang . '/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, \'script\', \'facebook-jssdk\'));</script>
 <div class="fb-like-box" data-href="http://www.facebook.com/tinywebgallery" data-width="700" data-border-color="white" data-show-faces="false" data-stream="true" data-header="false"></div>
	</p>
	<!-- end Facebook like button -->	

	<h3 class="h3_help">' . JText::_('H_H3_HELP') . '</h3> 
	' . JText::_('H_H_TEXT') . '
	<div style="text-align:left;float:left;">
	<ul>
		<li>' . JText::_('H_H_OVERVIEW') . '</li>
		<li>' . JText::_('H_H_HELP') . '</li>
		<li>' . JText::_('H_H_TWG') . '</li>
		<li>' . JText::_('H_H_FORUM') . '</li>
		<li>' . JText::_('H_H_CONFIG') . '</li>
		<li>' . JText::_('H_H_MAMBOT') . '</li>
		<li>' . JText::_('H_H_REG') . '</li>
	</ul>
	</div>
    <h3 class="h3_help">' . JText::_('H_L_TITLE') . '</h3>
	  <div style="text-align:left;float:left;">	
	  ' . JText::_('H_L_TEXT') . '   
	  <div class="install" style="width:600px;margin-left:50px;">
	  <b>' . JText::_('H_L_INFOS') . '</b><p> 
';
        $limit = return_kbytes(ini_get('memory_limit'));
        echo JText::_('H_L_NAME') . " " . $_SERVER['SERVER_NAME'] . "<br>";
        echo JText::_('H_L_LIMIT') . " " . getMaximumUploadSize() . "<br>";
        echo JText::_('H_L_MEMORY') . " " . $limit . " <br>";
        echo JText::_('H_L_RESOLUTION') . " ";
        if (!$limit) {
            echo '<font color="green">No limit</font>';
        } else {
            $xy = $limit * 1024 / 6.6;
            $x = floor(sqrt($xy / 0.75));
            $y = floor(sqrt($xy / 1.33));
            if ($x > 4000) {
                echo "<font color='green'>~ " . $x . " x " . $y . "</font>";
            } else {
                if ($x > 2000) {
                    echo "<font color='orange'>~ " . $x . " x " . $y . "</font>";
                } else {
                    echo "<font color='red'>~ " . $x . " x " . $y . "</font>";
                }
            }
        }
        echo "<br>";
        echo JText::_('H_L_INPUT') . " " . ini_get('max_input_time') . " s<br>";
        echo JText::_('H_L_EXECUT') . " " . ini_get('max_execution_time') . " s<br>";
        echo JText::_('H_L_SOCKET') . " " . ini_get('default_socket_timeout') . " s";
        if ($canDo->get('core.admin')) {
            if (substr(@php_uname(), 0, 7) != "Windows") {
                echo '<p>' . JText::_('H_L_CHMOD1') . ' ' . substr(sprintf('%o', @fileperms(dirname(__FILE__) . "/tfu/tfu_config.php")), -4);
                echo '<br>' . JText::_('H_L_CHMOD2');
                echo '</p><p>
        <button onclick="this.form.task.value=\'chmod755\';this.form.submit();">' . JText::_('H_L_CHMOD755') . '</button> 
        <button onclick="this.form.task.value=\'chmod644\';this.form.submit();">' . JText::_('H_L_CHMOD644') . '</button> 
        <button onclick="this.form.task.value=\'chmod666\';this.form.submit();">' . JText::_('H_L_CHMOD666') . '</button> 
        <button onclick="this.form.task.value=\'chmod777\';this.form.submit();">' . JText::_('H_L_CHMOD777') . '</button> 
        </p>
        ';
            }
        } else {
            echo '<p>' . JText::_('ACL_MANAGE_NEEDED') . '</p>';
        }
        echo '
	  </p>
	  </div>
	</div>
	
	<h3 class="h3_help">' . JText::_('H_R_TITLE') . '</h3>';
        if ($canDo->get('core.admin')) {
            echo '	
	<div style="text-align:left;float:left;">
';
            if ($m == "") {
                echo JText::_('H_R_TEXT') . '<ul>
  <li>' . JText::_('H_R_FREEWARE') . '</li
  <li>' . JText::_('H_R_REG') . '</li></ul>
	  <div class="install" style="width:600px;margin-left:50px;">' . JText::_('H_R_BONUS') . '</div>';
                printf(JText::_('H_R_REG_10'), "<a href=\"http://www.tinywebgallery.com/en/register_tfu.php\"><b>", "</b></a>");
                echo '<p>' . JText::_('H_R_REG_HOWTO') . '</p>
<div class="install" style="width:600px;margin-left:50px;">
&lt;?php
<table><tr><td>
$l</td><td>=" <input type="text" name="l" size=100> ";</td></tr><tr><td>
$d</td><td>=" <input type="text" name="d" size=100> ";</td></tr><tr><td>
$s</td><td>=" <input type="text" name="s" size=100> ";</td></tr></table>
?&gt;
<p>
<input type="hidden" name="task" value="register" />
<button onclick="this.form.submit();">' . JText::_('H_R_REGISTER') . '</button>
</p>
</div>
';
            } else {
                if ($m != "" && $m != "s" && $m != "w") {
                    include dirname(__FILE__) . '/' . $mybasedir . "tfu/twg.lic.php";
                    echo JText::_('H_R_REG_TO') . " <b>{$l}</b>";
                    if ($l == $d) {
                        echo " (Enterprise Edition License)";
                    } else {
                        if (strpos($d, "TWG_PROFESSIONAL") !== false) {
                            echo " (Professional Edition License)";
                        } else {
                            if (strpos($d, "TWG_SOURCE") !== false) {
                                echo " (Source code Edition License)";
                            } else {
                                echo " (Standart Edition License)";
                            }
                        }
                    }
                    echo "<p>" . JText::_('H_R_REG_DEL');
                    echo '
<input type="hidden" name="task" value="dellic" />
<button onclick="this.form.submit();">' . JText::_('H_R_UNREGISTER') . '</button>
</p>';
                } else {
                    echo "<p>" . JText::_('H_R_REG_WRONG');
                    echo '
<input type="hidden" name="task" value="dellic" />
<button onclick="this.form.submit();">' . JText::_('H_R_UNREGISTER') . '</button>
</p>';
                }
            }
            echo <<<HTML
</div>
\t      <input type="hidden" name="option" value="com_jfuploader"/>
\t      <input type="hidden" name="boxchecked" value="0" /> 
HTML;
        } else {
            echo JText::_('ACL_MANAGE_NEEDED');
        }
        echo '
	<div style="clear:both;"></div>	
  <h3 class="h3_help">' . JText::_('E_LOG_HEADER') . '</h3>';
        if ($canDo->get('core.admin')) {
            echo '
	  <div style="text-align:left;float:left;">
	  ' . JText::_('E_LOG_INTRO') . '  
	  </div> 
	 <div style="clear:both;"></div>	
   <p> 
	 <div class="logcontainer">';
            $debugfile = dirname(__FILE__) . '/' . $mybasedir . "tfu/tfu.log";
            if (file_exists($debugfile)) {
                $data = file_get_contents($debugfile);
                echo str_replace("\n", '<br>', $data);
            } else {
                echo 'No debug found';
            }
            echo '
	 </div>
	 </p>
   <p>&nbsp;<br>
	 <a class="jfu_button" href="#deletelog" onclick="return submitform(\'deletelog\')">
	 ' . JText::_('E_LOG_BUTTON') . ' 
	 </a>
   <p>';
        } else {
            echo JText::_('ACL_MANAGE_NEEDED');
        }
        echo '   
</form> 
';
    }
{
    $val = trim($val);
    $last = strtolower($val[strlen($val) - 1]);
    switch ($last) {
        // The 'G' modifier is available since PHP 5.1.0
        case 'g':
            $val *= 1024;
        case 'm':
            $val *= 1024;
            /*  case 'k':
                $val *= 1024;*/
    }
    return $val;
}
$post_max_size = ini_get('post_max_size');
$post_max_size = return_kbytes($post_max_size);
$IMConfig['max_filesize_kb_image'] = $post_max_size;
$IMConfig['max_filesize_kb_link'] = $post_max_size;
/* Maximum upload folder size in Megabytes. Use 0 to disable limit */
$IMConfig['max_foldersize_mb'] = 0;
/*
Allowed extensions that can be shown and allowed to upload.
Available icons are for "doc,fla,gif,gz,html,jpg,js,mov,pdf,php,png,ppt,rar,txt,xls,zip"
-Changed by AFRU.
*/
$IMConfig['allowed_image_extensions'] = array("jpg", "gif", "png", "bmp");
$IMConfig['allowed_link_extensions'] = array("jpg", "gif", "js", "php", "pdf", "zip", "rar", "txt", "psd", "png", "html", "swf", "xml", "xls", "mp3");
/*
 The default thumbnail and list view icon in case thumbnails are not created and the files are of unknown.
*/
$IMConfig['default_thumbnail'] = 'icons/def.gif';