public function testPerformance()
 {
     $config['router.routing_table']['protocol'] = 'rewrite';
     // 初始化LtUrl
     $url = new LtUrl();
     $url->configHandle->addConfig($config);
     $url->init();
     // 初始化结束
     // 测试生成超链接
     $href = $url->generate('news', 'list', array('catid' => 4, 'page' => 10));
     $this->assertEquals('/news-list-catid-4-page-10.html', $href);
     /**
      * 运行 10,000 次,要求在1秒内运行完
      */
     $base_memory_usage = memory_get_usage();
     $times = 10000;
     $startTime = microtime(true);
     for ($i = 0; $i < $times; $i++) {
         $url->generate('news', 'list', array('catid' => 4, 'page' => 10));
     }
     $endTime = microtime(true);
     $totalTime = round($endTime - $startTime, 6);
     $averageTime = round($totalTime / $times, 6);
     $memory_usage = memory_get_usage() - $base_memory_usage;
     $averageMemory = formatSize($memory_usage / $times);
     $memory_usage = formatSize($memory_usage);
     if (LOTUS_UNITTEST_DEBUG) {
         echo "\n----------------------Url-----------------------------\n";
         echo "times      \t{$times}\n";
         echo "totalTime   \t{$totalTime}s\taverageTime   \t{$averageTime}s\n";
         echo "memoryUsage \t{$memory_usage}\taverageMemory \t{$averageMemory}";
         echo "\n---------------------------------------------------------\n";
     }
     $this->assertTrue(1 > $totalTime);
 }
 /**
  * 测试CPU消耗
  */
 public function testPerformance()
 {
     /**
      * 运行500次,要求在1秒内运行完
      */
     $times = 500;
     $file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid();
     $bf = new LtBloomFilter();
     $bf->setBucketSize(PHP_INT_MAX);
     $bf->setSyncThreshHold($times + 1);
     $bf->setImageFile($file);
     $bf->init();
     $base_memory_usage = memory_get_usage();
     $startTime = microtime(true);
     for ($i = 0; $i < $times; $i++) {
         $str = uniqid();
         $bf->add($str);
         $bf->has($str);
     }
     $endTime = microtime(true);
     $memory_usage = memory_get_usage() - $base_memory_usage;
     unlink($file);
     $totalTime = round($endTime - $startTime, 6);
     $averageTime = round($totalTime / $times, 6);
     $averageMemory = formatSize($memory_usage / $times);
     $memory_usage = formatSize($memory_usage);
     if (LOTUS_UNITTEST_DEBUG) {
         echo "\n---------------------Bloom Filter--------------------------\n";
         echo "times      \t{$times}\n";
         echo "totalTime   \t{$totalTime}s\taverageTime   \t{$averageTime}s\n";
         echo "memoryUsage \t{$memory_usage}\taverageMemory \t{$averageMemory}";
         echo "\n---------------------------------------------------------\n";
     }
     $this->assertTrue(1 > $totalTime);
 }
 /**
  * 本测试展示了如何用LtCache给LtDb提高性能
  */
 public function testPerformance()
 {
     /**
      * 配置数据库连接信息
      */
     $dcb = new LtDbConfigBuilder();
     $dcb->addSingleHost(array("adapter" => "mysql", "username" => "test", "password" => "", "dbname" => "test"));
     /**
      * 实例化组件入口类
      */
     $db = new LtDb();
     $db->configHandle->addConfig(array("db.servers" => $dcb->getServers()));
     $db->init();
     /**
     * 用法 1: 直接操作数据库
     
     * 优点:学习成本低,快速入门
     
     * 适用场景:
          1. 临时写个脚本操作数据库,不想花时间学习LtDb的查询引擎
          2. 只写少量脚本,不是一个完整持续的项目,不需要SqlMap来管理SQL语句
     */
     $dbh = $db->getDbHandle();
     $dbh->query("DROP TABLE IF EXISTS test_user");
     $dbh->query("\n\t\t\tCREATE TABLE test_user (\n\t\t\tid INT NOT NULL AUTO_INCREMENT,\n\t\t\tname VARCHAR( 20 ) NOT NULL ,\n\t\t\tage INT NOT NULL ,\n\t\t\tPRIMARY KEY ( id ) \n\t\t)");
     /**
     * 用法 2: 使用Table Gateway查询引擎
     * 
     * 优点:自动生成SQL语句
     * 
     * 适用场景:
          1. 对数据表进行增简单的删查改操作,尤其是单条数据的操作
     *      2. 简单的SELECT,动态合成WHERE子句
     */
     $tg = $db->getTDG("test_user");
     /**
      * 运行100次,要求在1秒内运行完
      */
     $base_memory_usage = memory_get_usage();
     $times = 100;
     $startTime = microtime(true);
     for ($i = 0; $i < $times; $i++) {
         $tg->insert(array("id" => $i, "name" => "lotusphp", "age" => 1));
     }
     $dbh->query("DROP TABLE IF EXISTS test_user");
     $endTime = microtime(true);
     $totalTime = round($endTime - $startTime, 6);
     $averageTime = round($totalTime / $times, 6);
     $memory_usage = memory_get_usage() - $base_memory_usage;
     $averageMemory = formatSize($memory_usage / $times);
     $memory_usage = formatSize($memory_usage);
     if (LOTUS_UNITTEST_DEBUG) {
         echo "\n----------------db getTDG insert----------------\n";
         echo "times      \t{$times}\n";
         echo "totalTime   \t{$totalTime}s\taverageTime   \t{$averageTime}s\n";
         echo "memoryUsage \t{$memory_usage}\taverageMemory \t{$averageMemory}";
         echo "\n---------------------------------------------------------\n";
     }
     $this->assertTrue(1 > $totalTime);
 }
Esempio n. 4
0
 /**
  * getPhotoFileSize 
  * 
  * @param string $file 
  * 
  * @return string
  */
 public function getPhotoFileSize($file)
 {
     $size = '0';
     if (file_exists($file)) {
         $size = filesize($file);
         $size = formatSize($size);
     }
     return $size;
 }
 public function testPerformance()
 {
     /**
      * 构造缓存配置
      */
     $ccb = new LtCacheConfigBuilder();
     // $ccb->addSingleHost(array("adapter" => "apc"));
     // $ccb->addSingleHost(array("adapter" => "eAccelerator"));
     // $ccb->addSingleHost(array("adapter" => "file"));
     // $ccb->addSingleHost(array("adapter" => "memcache", "host" => "localhost", "port" => 11211));
     // $ccb->addSingleHost(array("adapter" => "memcached", "host" => "localhost", "port" => 11211));
     $ccb->addSingleHost(array("adapter" => "file"));
     // $ccb->addSingleHost(array("adapter" => "Xcache", "key_prefix" => "test_xcache_"));
     /**
      * 实例化组件入口类
      */
     $cache = new LtCache();
     $cache->configHandle->addConfig(array("cache.servers" => $ccb->getServers()));
     $cache->init();
     // 初始化完毕,测试其效果
     $ch = $cache->getTDG('test-performance');
     $this->assertTrue($ch->add("test_key", "test_value"));
     $this->assertEquals("test_value", $ch->get("test_key"));
     $this->assertTrue($ch->update("test_key", "new_value"));
     $this->assertEquals("new_value", $ch->get("test_key"));
     $this->assertTrue($ch->del("test_key"));
     $this->assertFalse($ch->get("test_key"));
     /**
      * 运行500次,要求在1秒内运行完
      */
     $base_memory_usage = memory_get_usage();
     $times = 500;
     $startTime = microtime(true);
     // ----------------------------测试读取
     $ch->add("test_key", "test_value");
     for ($i = 0; $i < $times; $i++) {
         $ch->get("test_key");
     }
     $ch->update("test_key", "new_value");
     $ch->del("test_key");
     // ----------------------------测试完成
     $endTime = microtime(true);
     $totalTime = round($endTime - $startTime, 6);
     $averageTime = round($totalTime / $times, 6);
     $memory_usage = memory_get_usage() - $base_memory_usage;
     $averageMemory = formatSize($memory_usage / $times);
     $memory_usage = formatSize($memory_usage);
     if (LOTUS_UNITTEST_DEBUG) {
         echo "\n--------------LtCache     get          -----------------\n";
         echo "times      \t{$times}\n";
         echo "totalTime   \t{$totalTime}s\taverageTime   \t{$averageTime}s\n";
         echo "memoryUsage \t{$memory_usage}\taverageMemory \t{$averageMemory}";
         echo "\n---------------------------------------------------------\n";
     }
     $this->assertTrue(1 > $totalTime);
 }
 public function testPerformance()
 {
     // 准备autoloadPath
     $autoloadPath = array(dirname(__FILE__) . "/test_data/class_dir_1", dirname(__FILE__) . "/test_data/class_dir_2", dirname(__FILE__) . "/test_data/function_dir_1", dirname(__FILE__) . "/test_data/function_dir_2");
     /**
      * 用LtStoreFile作存储层提升性能
      */
     $cacheHandle = new LtStoreFile();
     $prefix = sprintf("%u", crc32(serialize($autoloadPath)));
     $cacheHandle->prefix = 'Lotus-' . $prefix;
     $cacheHandle->init();
     /**
      * 运行autoloader成功加载一个类
      * 这是为了证明:使用LtCache作为LtAutoloader的存储,功能是正常的
      */
     $autoloader = new LtAutoloader();
     $autoloader->devMode = false;
     // 关闭开发模式
     $autoloader->storeHandle = $cacheHandle;
     $autoloader->autoloadPath = $autoloadPath;
     $autoloader->init();
     $this->assertTrue(class_exists("HelloWorld"));
     /**
      * 运行1500次,要求在1秒内运行完
      */
     $base_memory_usage = memory_get_usage();
     $times = 1500;
     $startTime = microtime(true);
     for ($i = 0; $i < $times; $i++) {
         $autoloader = new LtAutoloader();
         $autoloader->devMode = false;
         // 关闭开发模式
         $autoloader->storeHandle = $cacheHandle;
         $autoloader->autoloadPath = $autoloadPath;
         $autoloader->init();
         unset($autoloader);
     }
     $endTime = microtime(true);
     $totalTime = round($endTime - $startTime, 6);
     $averageTime = round($totalTime / $times, 6);
     $memory_usage = memory_get_usage() - $base_memory_usage;
     $averageMemory = formatSize($memory_usage / $times);
     $memory_usage = formatSize($memory_usage);
     if (LOTUS_UNITTEST_DEBUG) {
         echo "\n---------------------autoloader--------------------------\n";
         echo "times      \t{$times}\n";
         echo "totalTime   \t{$totalTime}s\taverageTime   \t{$averageTime}s\n";
         echo "memoryUsage \t{$memory_usage}\taverageMemory \t{$averageMemory}";
         echo "\n---------------------------------------------------------\n";
     }
     $this->assertTrue(1 > $totalTime);
 }
 /**
  * 模板编译性能测试
  */
 public function testPerformance()
 {
     /**
      * 加载Action类文件
      */
     $appDir = dirname(__FILE__) . "/test_data/simplest_app";
     require_once "{$appDir}/action/User-Add.Action.php";
     require_once "{$appDir}/action/stock-Price.Component.php";
     /**
      * 实例化
      */
     $dispatcher = new LtDispatcher();
     $dispatcher->viewDir = "{$appDir}/view/";
     $dispatcher->viewTplDir = "/tmp/Lotus/unittest/MVC/";
     ob_start();
     $dispatcher->dispatchAction("User", "Add");
     ob_end_clean();
     touch($dispatcher->viewDir . "User-Add.php");
     unlink($dispatcher->viewTplDir . "layout/top_navigator@User-Add.php");
     /**
      * 运行100次,要求在1秒内运行完
      */
     $base_memory_usage = memory_get_usage();
     $times = 100;
     $startTime = microtime(true);
     for ($i = 0; $i < $times; $i++) {
         ob_start();
         $dispatcher->dispatchAction("User", "Add");
         ob_end_clean();
         touch($dispatcher->viewDir . "User-Add.php");
     }
     $endTime = microtime(true);
     $totalTime = round($endTime - $startTime, 6);
     $averageTime = round($totalTime / $times, 6);
     $memory_usage = memory_get_usage() - $base_memory_usage;
     $averageMemory = formatSize($memory_usage / $times);
     $memory_usage = formatSize($memory_usage);
     if (LOTUS_UNITTEST_DEBUG) {
         echo "\n------------------MVC Template View----------------------\n";
         echo "times      \t{$times}\n";
         echo "totalTime   \t{$totalTime}s\taverageTime   \t{$averageTime}s\n";
         echo "memoryUsage \t{$memory_usage}\taverageMemory \t{$averageMemory}";
         echo "\n---------------------------------------------------------\n";
     }
     $this->assertTrue(1 > $totalTime);
 }
 public function testPerformance()
 {
     $option['proj_dir'] = dirname(__FILE__) . '/proj_dir/';
     $option['app_name'] = 'app_name2';
     /**
      * 初始化Lotus类
      */
     $lotus = new Lotus();
     $lotus->devMode = false;
     $lotus->defaultStoreDir = '/tmp';
     $lotus->option = $option;
     $lotus->init();
     /**
      * class_exists默认调用自动加载
      */
     $this->asserttrue(class_exists("LtCaptcha"));
     /**
      * 运行100次,要求在1秒内运行完
      */
     $base_memory_usage = memory_get_usage();
     $times = 100;
     $startTime = microtime(true);
     for ($i = 0; $i < $times; $i++) {
         $lotus = new Lotus();
         $lotus->devMode = false;
         $lotus->defaultStoreDir = '/tmp';
         $lotus->option = $option;
         $lotus->init();
         unset($lotus);
     }
     $endTime = microtime(true);
     $totalTime = round($endTime - $startTime, 6);
     $averageTime = round($totalTime / $times, 6);
     $memory_usage = memory_get_usage() - $base_memory_usage;
     $averageMemory = formatSize($memory_usage / $times);
     $memory_usage = formatSize($memory_usage);
     if (LOTUS_UNITTEST_DEBUG) {
         echo "\n---------------------Lotus------------------------------\n";
         echo "times      \t{$times}\n";
         echo "totalTime   \t{$totalTime}s\taverageTime   \t{$averageTime}s\n";
         echo "memoryUsage \t{$memory_usage}\taverageMemory \t{$averageMemory}";
         echo "\n---------------------------------------------------------\n";
     }
     $this->assertTrue(1 > $totalTime);
 }
 public function testPerformance()
 {
     /**
      * 用LtStoreFile作存储层提升性能
      */
     $cacheHandle = new LtStoreFile();
     $cacheHandle->init();
     // 准备confif_file
     $config_file = dirname(__FILE__) . "/test_data/conf.php";
     /**
      * 运行autoloader成功取到一个配置 
      * 这是为了证明:使用LtCache作为LtConfig的存储,功能是正常的
      */
     $conf = new LtConfig();
     $conf->storeHandle = $cacheHandle;
     $conf->loadConfigFile($config_file);
     $conf->init();
     $this->assertEquals("localhost", $conf->get("db.conn.host"));
     /**
      * 运行100次,要求在1秒内运行完
      */
     $base_memory_usage = memory_get_usage();
     $times = 100;
     $startTime = microtime(true);
     for ($i = 0; $i < $times; $i++) {
         $conf->get('db.conn.host');
     }
     $endTime = microtime(true);
     $totalTime = round($endTime - $startTime, 6);
     $averageTime = round($totalTime / $times, 6);
     $memory_usage = memory_get_usage() - $base_memory_usage;
     $averageMemory = formatSize($memory_usage / $times);
     $memory_usage = formatSize($memory_usage);
     if (LOTUS_UNITTEST_DEBUG) {
         echo "\n----------------------config-----------------------------\n";
         echo "times      \t{$times}\n";
         echo "totalTime   \t{$totalTime}s\taverageTime   \t{$averageTime}s\n";
         echo "memoryUsage \t{$memory_usage}\taverageMemory \t{$averageMemory}";
         echo "\n---------------------------------------------------------\n";
     }
     $this->assertTrue(1 > $totalTime);
 }
Esempio n. 10
0
						<th>Note</th>
						<th>Derniere MaJ</th>
					</tr>
				</thead>
				<tbody>
					<?php 
foreach ($maps as $map) {
    echo '<tr>';
    if ($_SESSION['id'] && $_SESSION['level'] >= 2) {
        echo '<td><a href="map.php?id=' . $map['id'] . '">' . $map['name'] . '</a></td>';
    } else {
        echo '<td>' . $map['name'] . '</td>';
    }
    echo '<td>' . $map['file_rar'] . '</td>';
    echo '<td>' . formatSize($map['size_rar']) . '</td>';
    echo '<td>' . formatSize($map['size_vpk']) . '</td>';
    echo '<td>' . ($map['type'] ? $map['type'] : '--') . '</td>';
    if ($map['note'] >= 4) {
        echo '<td><span class="label label-success">' . $map['note'] . '</span></td>';
    } else {
        if ($map['note'] == 3) {
            echo '<td><span class="label label-warning">' . $map['note'] . '</span></td>';
        } else {
            if ($map['note'] >= 1) {
                echo '<td><span class="label label-important">' . $map['note'] . '</span></td>';
            } else {
                echo '<td>--</td>';
            }
        }
    }
    echo '<td>' . date('d/m/Y', $map['date']) . '</td>';
Esempio n. 11
0
 function list_file($cur)
 {
     global $PHP_SELF, $order, $asc, $order0;
     if ($dir = opendir($cur)) {
         /* tableaux */
         $tab_dir = array();
         $tab_file = array();
         /* extraction */
         while ($file = readdir($dir)) {
             if (is_dir($cur . "/" . $file)) {
                 if (!in_array($file, array(".", ".."))) {
                     $tab_dir[] = addScheme($file, $cur, 'dir');
                 }
             } else {
                 $tab_file[] = addScheme($file, $cur, 'file');
             }
         }
         /* tri */
         // usort($tab_dir,"cmp_".$order);
         // usort($tab_file,"cmp_".$order);
         /* affichage */
         //*********************************************************************************************************
         echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
         echo "<tr style=\"font-size:8pt;font-family:arial;\">\n    <th>" . ($order == 'name' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Nom</th><td>&nbsp;</td>\n    <th>" . ($order == 'size' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Taille</th><td>&nbsp;</td>\n\t<th>" . ($order == 'date' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Derniere modification</th><td>&nbsp;</td>\n\t</tr>";
         //*********************************************************************************************************
         foreach ($tab_file as $elem) {
             if ($_SESSION['privilege'] == 1) {
                 $cheminWeb = "#";
             } else {
                 $cheminWeb = "pages/force-download.php?file=" . INI_Conf_Moteur($_SESSION['opensim_select'], "address") . $elem['name'];
             }
             if (assocExt($elem['ext']) != 'inconnu') {
                 echo "<tr><td>";
                 echo '<FORM METHOD=POST ACTION=""><INPUT TYPE="submit" VALUE="Telecharger" NAME="cmd" ' . $btnN3 . '><INPUT TYPE="submit" VALUE="Supprimer" NAME="cmd" ' . $btnN3 . '><INPUT TYPE="hidden" VALUE="' . $_SESSION['opensim_select'] . '" NAME="name_sim"><INPUT TYPE="hidden" VALUE="' . $elem['name'] . '" NAME="name_file">&nbsp;&nbsp;&nbsp;' . $elem['name'] . '&nbsp;&nbsp;&nbsp;</FORM>';
                 echo "</td><td>&nbsp;</td>\n\t\t  <td align=\"right\">" . formatSize($elem['size']) . "</td><td>&nbsp;</td>\n\t\t  <td>" . date("d/m/Y H:i:s", $elem['date']) . "</td><td>&nbsp;</td></tr>";
             }
         }
         echo "</table>";
         closedir($dir);
         //*********************************************************************************************************
     }
 }
Esempio n. 12
0
        if (($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/jpg" || $_FILES["file"]["type"] == "image/pjpeg") && $_FILES["file"]["size"] < $max_size_picture) {
            if ($_FILES["file"]["error"] > 0) {
                echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
            } else {
                if (file_exists("phpThumb/images/" . $new_name)) {
                    echo '<img src="custom/SynoFieldPhoto/phpThumb/phpThumb.php?src=images/' . $new_name . '&h=150&w=150&t=' . time() . '">';
                } else {
                    if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
                        chmod($target_path, 0644);
                        //echo $target_path;
                        echo '<img src="custom/SynoFieldPhoto/phpThumb/phpThumb.php?src=images/' . $new_name . '&h=150&w=150&t=' . time() . '">';
                    }
                }
            }
        } elseif ($_FILES["file"]["size"] >= $max_size_picture) {
            echo "Error: File too big " . formatSize($_FILES["file"]["size"]) . ": " . formatSize($max_size_picture) . " Max <br />";
        } else {
            echo "Error: " . $_FILES["file"]["type"] . " not allowded <br />";
        }
    } else {
        echo 'Not allowed to Edit this ' . $class_name;
    }
}
function formatSize($size)
{
    switch (true) {
        case $size > 1099511627776:
            $size /= 1099511627776;
            $suffix = 'To';
            break;
        case $size > 1073741824:
Esempio n. 13
0
        $bytes = $bytes . ' bytes';
    } elseif ($bytes == 1) {
        $bytes = $bytes . ' byte';
    } else {
        $bytes = '0 bytes';
    }
    return $bytes;
}
// Loop through array and print
for ($index = 0; $index < $indexCount; $index++) {
    // Declare variables for the current directory item
    $filename = $dirArray[$index];
    $filetype = filetype($dirArray[$index]);
    $size = filesize($dirArray[$index]);
    $modified = date("M j Y g:i A", filemtime($dirArray[$index]));
    $size = formatSize($size);
    // Split the filename at the "."
    list($name, $extension) = explode(".", $filename);
    // Switch block for file extension names
    switch ($extension) {
        case "png":
            $extension = "PNG Image";
            break;
        case "jpg":
            $extension = "JPEG Image";
            break;
        case "svg":
            $extension = "SVG Image";
            break;
        case "gif":
            $extension = "GIF Image";
?>
</td>
                            </tr>
                            <tr>
                                <td class="descr">
                                    <?php 
echo UCFirst(t('maximum_file_upload_size', 'Maximum file upload size'));
?>
:
                                </td>
                                <td><?php 
echo SITE_CONFIG_FREE_USER_MAX_UPLOAD_FILESIZE > 0 ? formatSize(SITE_CONFIG_FREE_USER_MAX_UPLOAD_FILESIZE) : UCFirst(t('unlimited', 'unlimited'));
?>
</td>
                                <td><?php 
echo SITE_CONFIG_PREMIUM_USER_MAX_UPLOAD_FILESIZE > 0 ? formatSize(SITE_CONFIG_PREMIUM_USER_MAX_UPLOAD_FILESIZE) : UCFirst(t('unlimited', 'unlimited'));
?>
</td>
                            </tr>
                            <tr>
                                <td class="descr">
                                    <?php 
echo UCFirst(t('interface_to_manage_uploaded_files', 'interface to manage uploaded files'));
?>
:
                                </td>
                                <td><?php 
echo UCFirst(t('not_available', 'not available'));
?>
</td>
                                <td><?php 
Esempio n. 15
0
$du3 = formatSize($du3);
$ftp3_t = formatSize($ftp3_t);
/* ----------------- FTP 3 --------------- */
/* ----------------- FTP 4 --------------- */
/* get disk space free (in bytes) */
$ftp4_f = disk_free_space("/var/www/html/directlink/FTP4");
/* and get disk space total (in bytes)  */
$ftp4_t = disk_total_space("/var/www/html/directlink/FTP4");
/* now we calculate the disk space used (in bytes) */
$du4 = $ftp4_t - $ftp4_f;
/* percentage of disk used - this will be used to also set the width % of the progress bar */
$dp4 = sprintf('%.2f', $du4 / $ftp4_t * 100);
/* and we formate the size from bytes to MB, GB, etc. */
$ftp4_f = formatSize($ftp4_f);
$du4 = formatSize($du4);
$ftp4_t = formatSize($ftp4_t);
/* ----------------- FTP 4 --------------- */
function formatSize($bytes)
{
    $types = array('B', 'KB', 'MB', 'GB', 'TB');
    for ($i = 0; $bytes >= 1024 && $i < count($types) - 1; $bytes /= 1024, $i++) {
    }
    return round($bytes, 2) . " " . $types[$i];
}
?>

<style type='text/css'>

body {
  background: #f3f3f3;
}
Esempio n. 16
0
    /**
     * showPhoto 
     * 
     * Displays the current photo, info, comments, next/prev butons etc.
     *
     * The following views use this function:
     *     Latest Comments - uid=0         cid=comments
     *     Top Rated       - uid=0         cid=toprated
     *     Most  Viewed    - uid=userid    cid=mostviewed
     *     Tagged Users    - uid=0         cid=tagged# (where # is the id of the tagged user)
     *     All for User    - uid=userid    cid=all
     *
     * @param string $uid the user's id or 0
     * @param string $cid the category id, 'tagged#', 'comments', 'toprated', 'mostviewed' or 'all'
     * @param string $pid the photo id 
     *
     * @return  void
     */
    function showPhoto($uid, $cid, $pid)
    {
        $uid = (int) $uid;
        $pid = (int) $pid;
        list($breadcrumbs, $cid, $urlcid, $sql) = $this->getShowPhotoParams($uid, $cid);
        $rows = $this->fcmsDatabase->getRows($sql);
        if ($rows === false) {
            $this->fcmsError->displayError();
            return;
        }
        // Save filenames in an array, so we can see next/prev, etc
        foreach ($rows as $row) {
            $photo_arr[] = $row['filename'];
            $photoIdLookup[] = $row['id'];
        }
        // No photos exist for the current view/category
        // Even though we are in photo view, bump them back to the category view
        // and let the user know that this category is now empty
        if (count($rows) <= 0) {
            $this->displayGalleryMenu($uid, $cid);
            echo '
            <div class="info-alert">
                <h2>' . T_('Oops!') . '</h2>
                <p>' . T_('The Category you are trying to view is Empty.') . '</p>
            </div>';
            return;
        }
        // Select Current Photo to view
        $sql = "SELECT p.`id`, p.`user` AS uid, `filename`, `caption`, `category` AS cid, p.`date`, \n                    `name` AS category_name, `views`, `votes`, `rating`, p.`external_id`, \n                    e.`thumbnail`, e.`medium`, e.`full`\n                FROM `fcms_gallery_photos` AS p\n                LEFT JOIN `fcms_category` AS c ON p.`category` = c.`id`\n                LEFT JOIN `fcms_gallery_external_photo` AS e ON p.`external_id` = e.`id`\n                WHERE p.`id` = ?";
        $r = $this->fcmsDatabase->getRow($sql, $pid);
        if ($r === false) {
            $this->fcmsError->displayError();
            return;
        }
        if (empty($r)) {
            echo '
            <p class="error-alert">' . T_('The Photo you are trying to view can not be found.') . '</p>';
            return;
        }
        // Save info about current photo
        $_SESSION['photo-path-data'][$r['id']] = array('id' => $r['id'], 'user' => $r['uid'], 'filename' => $r['filename'], 'external_id' => $r['external_id'], 'thumbnail' => $r['thumbnail'], 'medium' => $r['medium'], 'full' => $r['full']);
        $displayname = getUserDisplayName($r['uid']);
        // Update View count
        $sql = "UPDATE `fcms_gallery_photos` \n                SET `views` = `views`+1 \n                WHERE `id` = ?";
        if (!$this->fcmsDatabase->update($sql, $pid)) {
            // Just show error and continue
            $this->fcmsError->displayError();
        }
        // Get photo comments
        $comments = $this->getPhotoComments($pid);
        $total = count($photo_arr);
        $current = array_search($pid, $photoIdLookup);
        $prev = $this->getPrevId($photo_arr, $photoIdLookup, $current);
        $next = $this->getNextId($photo_arr, $photoIdLookup, $current);
        $photos_of = '<i>(' . sprintf(T_('%d of %d'), $current + 1, $total) . ')</i>';
        $prev_next = '';
        if ($total > 1) {
            $prev_next .= '
                <div class="prev_next">
                    <a class="previous" href="?uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $prev . '">' . T_('Previous') . '</a>
                    <a class="next" href="?uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $next . '">' . T_('Next') . '</a>
                </div>
                <script type="text/javascript">
                function keyHandler(e) {
                    if (!e) { e = window.event; }
                    arrowRight = 39;
                    arrowLeft = 37;
                    switch (e.keyCode) {
                        case arrowRight:
                        document.location.href = "index.php?uid=' . $uid . '&cid=' . $urlcid . '&pid=' . $next . '";
                        break;
                        case arrowLeft:
                        document.location.href = "index.php?uid=' . $uid . '&cid=' . $urlcid . '&pid=' . $prev . '";
                        break;
                    }
                }
                document.onkeydown = keyHandler;
                </script>';
        }
        // special view detail
        $special = '
                <div id="special">
                    ' . T_('From the Category:') . ' <a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '">' . cleanOutput($r['category_name']) . '</a> 
                    ' . T_('by') . ' 
                    <a class="u" href="../profile.php?member=' . $r['uid'] . '">' . $displayname . '</a>
                </div>';
        // if breadcrumbs haven't been defined, give the default
        if ($breadcrumbs == '') {
            $breadcrumbs = '
                <a href="?uid=0">' . T_('Members') . '</a> &gt; 
                <a href="?uid=' . $uid . '">' . $displayname . '</a> &gt; 
                <a href="?uid=' . $uid . '&amp;cid=' . $cid . '">' . cleanOutput($r['category_name']) . '</a>
                ' . $photos_of;
            $special = '';
        }
        // setup some vars to hold photo details
        if ($r['filename'] == 'noimage.gif' && $r['external_id'] != null) {
            $photo_path_middle = $r['medium'];
            $photo_path_full = $r['full'];
            $size = T_('Unknown');
        } else {
            $photo_path = $this->getPhotoPath($r['filename'], $r['uid']);
            $photo_path_middle = $photo_path[0];
            $photo_path_full = $photo_path[1];
            $size = filesize($photo_path_full);
            $size = formatSize($size);
        }
        $r['user'] = $r['uid'];
        // Figure out where we are currently saving photos, and create new destination object
        $photoDestinationType = getDestinationType() . 'PhotoGalleryDestination';
        $photoDestination = new $photoDestinationType($this->fcmsError, $this->fcmsUser);
        $mediumSrc = $this->getPhotoSource($r, 'medium');
        $fullSrc = $this->getPhotoSource($r, 'full');
        $caption = cleanOutput($r['caption']);
        $dimensions = $photoDestination->getImageSize($photo_path_full);
        $date_added = fixDate(T_('F j, Y g:i a'), $this->fcmsUser->tzOffset, $r['date']);
        // Calculate rating
        if ($r['votes'] <= 0) {
            $rating = 0;
            $width = 0;
        } else {
            $rating = $r['rating'] / $r['votes'] * 100;
            $rating = round($rating, 0);
            $width = $rating / 5;
        }
        // Get Tagged Members
        $sql = "SELECT u.`id`, u.`fname`, u.`lname` \n                FROM `fcms_users` AS u, `fcms_gallery_photos_tags` AS t \n                WHERE t.`photo` = '{$pid}' \n                AND t.`user` = u.`id`\n                ORDER BY u.`lname`";
        $rows = $this->fcmsDatabase->getRows($sql, $pid);
        if ($rows === false) {
            $this->fcmsError->displayError();
            return;
        }
        $tagged_mem_list = '<li>' . T_('none') . '</li>';
        if (count($rows) > 0) {
            $tagged_mem_list = '';
            foreach ($rows as $t) {
                $taggedName = cleanOutput($t['fname']) . ' ' . cleanOutput($t['lname']);
                $tagged_mem_list .= '<li><a href="?uid=0&cid=' . $t['id'] . '" ';
                $tagged_mem_list .= 'title="' . sprintf(T_('Click to view more photos of %s.'), $taggedName) . '">' . $taggedName . '</a></li>';
            }
        }
        // Edit / Delete Photo options
        $edit_del_options = '';
        if ($this->fcmsUser->id == $r['uid'] || $this->fcmsUser->access < 2) {
            $edit_del_options = '
                            <li>
                                <input type="submit" name="editphoto" id="editphoto" value="' . T_('Edit') . '" class="editbtn"/>
                            </li>
                            <li>
                                <input type="submit" name="deletephoto" id="deletephoto" value="' . T_('Delete') . '" class="delbtn"/>
                            </li>';
        }
        // Display
        echo '
            <div class="breadcrumbs">
                ' . $breadcrumbs . '
                ' . $prev_next . '
            </div>
            <div id="photo">
                <a href="' . $fullSrc . '"><img class="photo" src="' . $mediumSrc . '" alt="' . $caption . '" title="' . $caption . '"/></a>
            </div>

            <div id="photo_details">

                <div id="caption">
                    ' . $caption . '
                    <ul class="star-rating small-star">
                        <li class="current-rating" style="width:' . $width . '%">' . sprintf(T_('Currently %s/5 Starts'), $r['rating']) . '</li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=1" title="' . sprintf(T_('%s out of 5 Stars', '1'), '1') . '" class="one-star">1</a></li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=2" title="' . sprintf(T_('%s out of 5 Stars', '2'), '2') . '" class="two-stars">2</a></li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=3" title="' . sprintf(T_('%s out of 5 Stars', '3'), '3') . '" class="three-stars">3</a></li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=4" title="' . sprintf(T_('%s out of 5 Stars', '4'), '4') . '" class="four-stars">4</a></li>
                        <li><a href="?uid=' . $r['uid'] . '&amp;cid=' . $r['cid'] . '&amp;pid=' . $pid . '&amp;vote=5" title="' . sprintf(T_('%s out of 5 Stars', '5'), '5') . '" class="five-stars">5</a></li>
                    </ul>
                </div>

                <div id="photo_stats">
                    <form action="index.php" method="post">
                        <ul>
                            <li class="photo_views">' . $r['views'] . '</li>
                            <li class="photo_comments">' . count($comments) . '</li> 
                            ' . $edit_del_options . '
                        </ul>
                        <div>
                            <input type="hidden" name="photo" id="photo" value="' . $pid . '"/>
                            <input type="hidden" name="url" id="url" value="uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $pid . '"/>
                        </div>
                    </form>
                </div>

                <div id="members_in_photo">
                    <b>' . T_('Members in Photo') . '</b>
                    <ul>
                        ' . $tagged_mem_list . '
                    </ul>
                </div>

                ' . $special . '

                <div id="more_details">
                    <div id="photo_details_sub">
                        <p><b>' . T_('Filename') . ':</b> ' . $r['filename'] . '</p>
                        <p><b>' . T_('Photo Size') . ':</b> ' . $size . '</p>
                        <p><b>' . T_('Dimensions') . ':</b> ' . $dimensions[0] . ' x ' . $dimensions[1] . '</p>
                        <p><b>' . T_('Date Added') . ':</b> ' . $date_added . '</p>
                    </div>
                </div>

            </div>';
        // Display Comments
        if ($this->fcmsUser->access <= 8 && $this->fcmsUser->access != 7 && $this->fcmsUser->access != 4) {
            echo '
            <h3 id="comments">' . T_('Comments') . '</h3>';
            if (count($comments) > 0) {
                foreach ($comments as $row) {
                    // Setup some vars for each comment block
                    $del_comment = '';
                    $date = fixDate(T_('F j, Y g:i a'), $this->fcmsUser->tzOffset, $row['date']);
                    $displayname = getUserDisplayName($row['user']);
                    $comment = $row['comment'];
                    if ($this->fcmsUser->id == $row['user'] || $this->fcmsUser->access < 2) {
                        $del_comment .= '<input type="submit" name="delcom" value="' . T_('Delete') . '" class="gal_delcombtn" title="' . T_('Delete this Comment') . '"/>';
                    }
                    echo '
            <div id="comment' . $row['id'] . '" class="comment_block">
                <form action="?uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $pid . '" method="post">
                    ' . $del_comment . '
                    <img class="avatar" alt="avatar" src="' . getCurrentAvatar($row['user'], true) . '"/>
                    <b>' . $displayname . '</b>
                    <span>' . $date . '</span>
                    <p>
                        ' . parse($comment, '../') . '
                    </p>
                    <input type="hidden" name="uid" value="' . $uid . '"/>
                    <input type="hidden" name="cid" value="' . $cid . '"/>
                    <input type="hidden" name="pid" value="' . $pid . '"/>
                    <input type="hidden" name="id" value="' . $row['id'] . '">
                </form>
            </div>';
                }
            }
            echo '
            <div class="add_comment_block">
                <form action="?uid=' . $uid . '&amp;cid=' . $urlcid . '&amp;pid=' . $pid . '" method="post">
                    ' . T_('Add Comment') . '<br/>
                    <textarea class="frm_textarea" name="post" id="post" rows="3" cols="63"></textarea>
                    <input type="submit" name="addcom" id="addcom" value="' . T_('Add Comment') . '" title="' . T_('Add Comment') . '" class="gal_addcombtn"/>
                </form>
            </div>';
        }
    }
		<div class="accountBenefit">
			Unlimited storage.
		</div>
	</div>
	<div class="accountBenefitWrapper">
		<div class="accountBenefit">
			Files kept for <?php 
echo strlen(SITE_CONFIG_PREMIUM_USER_UPLOAD_REMOVAL_DAYS) ? SITE_CONFIG_PREMIUM_USER_UPLOAD_REMOVAL_DAYS : 'unlimited';
?>
 days.
		</div>
	</div>
	<div class="accountBenefitWrapper">
		<div class="accountBenefit">
			Upload files up to <?php 
echo formatSize(SITE_CONFIG_PREMIUM_USER_MAX_UPLOAD_FILESIZE);
?>
 in size.
		</div>
	</div>
	<div class="accountBenefitWrapper">
		<div class="accountBenefit">
			No limits on the amount of downloads.
		</div>
	</div>
	<div class="accountBenefitWrapper">
		<div class="accountBenefit">
			Low price per day.
		</div>
	</div>
	<div class="accountBenefitWrapper">
function bytes2str($val, $round = 0)
{
    return formatSize($val);
}
			<tr valign="top">
				<th scope="row">
					<?php 
_e('browscap Cache File', 'wp_statistics');
?>
:
				</th>
				
				<td>
					<strong><?php 
$browscap_filename = $upload_dir['basedir'] . '/wp-statistics/cache.php';
$browscap_filedate = @filemtime($browscap_filename);
if ($browscap_filedate === FALSE) {
    _e('browscap cache file does not exist.', 'wp_statistics');
} else {
    echo formatSize(@filesize($browscap_filename)) . __(', created on ', 'wp_statistics') . date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), $browscap_filedate);
}
?>
</strong>
					<p class="description"><?php 
_e('The file size and date of the browscap cache file.', 'wp_statistics');
?>
</p>
				</td>
			</tr>
			
			<tr valign="top">
				<th scope="row" colspan="2"><h3><?php 
_e('Client Info', 'wp_statistics');
?>
</h3></th>
Esempio n. 20
0
            echo "<p><a href=\"db_filedetails.php?SoundID={$SoundID}&amp;d={$d}&amp;hidekml={$hidekml}\">Show marks on spectrogram</a><br>";
        }
        echo "<a href=\"#\" onclick=\"window.open('db_filemarks.php?SoundID={$SoundID}', 'marks', 'width=600,height=550,status=yes,resizable=yes,scrollbars=auto')\">Show list of marks</a><br>";
    }
}
echo "\n\t\t\t\t\t<dl class=\"dl-horizontal\">\n\t\t\t\t\t\t<dt>Original filename</dt>\n\t\t\t\t\t\t<dd>{$OriginalFilename}</dd>";
#Check if the file size is in the database
if ($FileSize == NULL || $FileSize == 0) {
    $file_filesize = filesize("sounds/sounds/{$ColID}/{$DirID}/{$OriginalFilename}");
    #$result_size = mysqli_query($connection, "UPDATE Sounds SET FileSize='$file_filesize' WHERE SoundID='$SoundID' LIMIT 1")
    #	or die (mysqli_error($connection));
    $this_array = array('FileSize' => $file_filesize);
    DB::update('Sounds', $this_array, $SoundID, 'SoundID');
    $FileSize = formatSize($file_filesize);
} else {
    $FileSize = formatSize($FileSize);
}
echo "<dt>File Format</dt><dd>{$SoundFormat}</dd>\n\t\t\t\t\t\t<dt>Sampling rate</dt><dd>{$SamplingRate} Hz</dd>\n\t\t\t\t\t\t<dt>Number of channels</dt><dd>{$Channels}</dd>";
echo "\n\t\t\t\t\t\t<dt>File size</dt>\n\t\t\t\t\t\t<dd>{$FileSize}</dd>";
if ($Duration > 60) {
    $formated_Duration = formatTime(round($Duration));
    echo "<dt>Duration</dt><dd>{$formated_Duration} (hh:mm:ss)</dd>";
} else {
    echo "<dt>Duration</dt><dd>{$Duration} seconds</dd>";
}
#Check if from a sample set
if ($pumilio_loggedin) {
    $sample_check = mysqli_query($connection, "SELECT Samples.SampleName,Samples.SampleID FROM\n\t\t\t\t\t\t\tSamples,SampleMembers WHERE Samples.SampleID=SampleMembers.SampleID \n\t\t\t\t\t\t\tAND SampleMembers.SoundID='{$SoundID}'") or die(mysqli_error($connection));
    $check_nrows = mysqli_num_rows($sample_check);
    if ($check_nrows > 0) {
        $check_row = mysqli_fetch_array($sample_check);
Esempio n. 21
0
/**
 * @param $title
 * @param int $refresh
 * @param bool|true $cacheable
 * @param bool|false $report
 * @return Filter|int
 */
function html_start($title, $refresh = 0, $cacheable = true, $report = false)
{
    if (!$cacheable) {
        // Cache control (as per PHP website)
        header("Expires: Sat, 10 May 2003 00:00:00 GMT");
        header("Last-Modified: " . gmdate("D, M d Y H:i:s") . " GMT");
        header("Cache-Control: no-store, no-cache, must-revalidate");
        header("Cache-Control: post-check=0, pre-check=0", false);
    } else {
        // calc an offset of 24 hours
        $offset = 3600 * 48;
        // calc the string in GMT not localtime and add the offset
        $expire = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
        //output the HTTP header
        Header($expire);
        header("Cache-Control: store, cache, must-revalidate, post-check=0, pre-check=1");
        header("Pragma: cache");
    }
    //security headers
    header('X-XSS-Protection: 1; mode=block');
    header('X-Frame-Options: SAMEORIGIN');
    header('X-Content-Type-Options: nosniff');
    echo page_creation_timer();
    echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' . "\n";
    echo '<html>' . "\n";
    echo '<head>' . "\n";
    echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
    echo '<link rel="shortcut icon" href="images/favicon.png" >' . "\n";
    echo '<script type="text/javascript">';
    echo '' . java_time() . '';
    //$current_url = "".MAILWATCH_HOME."/status.php";
    //if($_SERVER['SCRIPT_FILENAME'] == $active_url){
    echo '' . row_highandclick() . '';
    echo '</script>';
    if ($report) {
        echo '<title>MailWatch Filter Report: ' . $title . ' </title>' . "\n";
        echo '<link rel="StyleSheet" type="text/css" href="./style.css">' . "\n";
        if (!isset($_SESSION["filter"])) {
            require_once __DIR__ . '/filter.inc';
            $filter = new Filter();
            $_SESSION["filter"] = $filter;
        } else {
            // Use existing filters
            $filter = $_SESSION["filter"];
        }
        audit_log('Ran report ' . $title);
    } else {
        echo '<title>MailWatch for Mailscanner - ' . $title . '</title>' . "\n";
        echo '<link rel="StyleSheet" type="text/css" href="style.css">' . "\n";
    }
    if ($refresh > 0) {
        echo '<meta http-equiv="refresh" content="' . $refresh . '">' . "\n";
    }
    if (isset($_GET['id'])) {
        $message_id = sanitizeInput($_GET['id']);
    } else {
        $message_id = " ";
    }
    $message_id = safe_value($message_id);
    $message_id = htmlentities($message_id);
    $message_id = trim($message_id, " ");
    echo '</head>' . "\n";
    echo '<body onload="updateClock(); setInterval(\'updateClock()\', 1000 )">' . "\n";
    echo '<table border="0" cellpadding="5" width="100%">' . "\n";
    echo '<tr>' . "\n";
    echo '<td>' . "\n";
    echo '<table border="0" cellpadding="0" cellspacing="0">' . "\n";
    echo '<tr>' . "\n";
    echo '<td align="left"><a href="index.php" class="logo"><img src="' . IMAGES_DIR . MW_LOGO . '" alt="MailWatch for MailScanner"></a></td>' . "\n";
    echo '</tr>' . "\n";
    echo '<tr>' . "\n";
    echo '<td valign="bottom" align="left" class="jump">' . "\n";
    echo '<form action="./detail.php">' . "\n";
    echo '<p>' . __('jumpmessage03') . '<input type="text" name="id" value="' . $message_id . '"></p>' . "\n";
    echo '</form>' . "\n";
    echo '</table>' . "\n";
    echo '<table cellspacing="1" class="mail">' . "\n";
    echo '<tr><td class="heading" align="center">' . __('cuser03') . '</td><td class="heading" align="center">' . __('cst03') . '</td></tr>' . "\n";
    echo '<tr><td>' . $_SESSION['fullname'] . '</td><td><span id="clock">&nbsp;</span></td></tr>' . "\n";
    echo '</table>' . "\n";
    echo '</td>' . "\n";
    echo '<td align="left" valign="top">' . "\n";
    echo '   <table border="0" cellpadding="1" cellspacing="1" class="mail">' . "\n";
    echo '    <tr> <th colspan="2">' . __('colorcodes03') . '</th> </tr>' . "\n";
    echo '    <tr> <td>' . __('badcontentinfected03') . '</TD> <td class="infected"></TD> </TR>' . "\n";
    echo '    <tr> <td>Spam</td> <td class="spam"></td> </tr>' . "\n";
    echo '    <tr> <td>High Spam</td> <td class="highspam"></td> </tr>' . "\n";
    if (get_conf_truefalse('mcpchecks')) {
        echo '    <tr> <td>MCP</td> <td class="mcp"></td> </tr>' . "\n";
        echo '    <tr> <td>High MCP</td><td class="highmcp"></td></tr>' . "\n";
    }
    echo '    <tr> <td>' . __('whitelisted03') . '</td> <td class="whitelisted"></td> </tr>' . "\n";
    echo '    <tr> <td>' . __('blacklisted03') . '</td> <td class="blacklisted"></td> </tr>' . "\n";
    echo '        <tr> <td>' . __('notverified03') . '</td> <td class="notscanned"></td> </tr>' . "\n";
    echo '    <tr> <td>' . __('clean03') . '</td> <td></td> </tr>' . "\n";
    echo '   </table>' . "\n";
    echo '  </td>' . "\n";
    if (!DISTRIBUTED_SETUP && ($_SESSION['user_type'] == 'A' || $_SESSION['user_type'] == 'D')) {
        echo '  <td align="center" valign="top">' . "\n";
        // Status table
        echo '   <table border="0" cellpadding="1" cellspacing="1" class="mail" width="200">' . "\n";
        echo '    <tr><th colspan="3">Status</th></tr>' . "\n";
        // MailScanner running?
        if (!DISTRIBUTED_SETUP) {
            $no = '<span class="yes">&nbsp;NO&nbsp;</span>' . "\n";
            $yes = '<span class="no">&nbsp;YES&nbsp;</span>' . "\n";
            exec("ps ax | grep MailScanner | grep -v grep", $output);
            if (count($output) > 0) {
                $running = $yes;
                $procs = count($output) - 1 . " children";
            } else {
                $running = $no;
                $procs = count($output) . " proc(s)";
            }
            echo '     <tr><td>MailScanner:</td><td align="center">' . $running . '</td><td align="right">' . $procs . '</td></tr>' . "\n";
            // is MTA running
            $mta = get_conf_var('mta');
            exec("ps ax | grep {$mta} | grep -v grep | grep -v php", $output);
            if (count($output) > 0) {
                $running = $yes;
            } else {
                $running = $no;
            }
            $procs = count($output) . " proc(s)";
            echo '    <tr><td>' . ucwords($mta) . ':</td><td align="center">' . $running . '</td><td align="right">' . $procs . '</td></tr>' . "\n";
        }
        // Load average
        if (file_exists("/proc/loadavg") && !DISTRIBUTED_SETUP) {
            $loadavg = file("/proc/loadavg");
            $loadavg = explode(" ", $loadavg[0]);
            $la_1m = $loadavg[0];
            $la_5m = $loadavg[1];
            $la_15m = $loadavg[2];
            echo '    <tr><td>Load Average:</td><td align="right" colspan="2"><table width="100%" class="mail" cellpadding="0" cellspacing="0"><tr><td align="center">' . $la_1m . '</td><td align="center">' . $la_5m . '</td><td align="center">' . $la_15m . '</td></tr></table></td>' . "\n";
        } elseif (file_exists("/usr/bin/uptime") && !DISTRIBUTED_SETUP) {
            $loadavg = shell_exec('/usr/bin/uptime');
            $loadavg = explode(" ", $loadavg);
            $la_1m = rtrim($loadavg[count($loadavg) - 3], ",");
            $la_5m = rtrim($loadavg[count($loadavg) - 2], ",");
            $la_15m = rtrim($loadavg[count($loadavg) - 1]);
            echo '    <tr><td>Load Average:</td><td align="right" colspan="2"><table width="100%" class="mail" cellpadding="0" cellspacing="0"><tr><td align="center">' . $la_1m . '</td><td align="center">' . $la_5m . '</td><td align="center">' . $la_15m . '</td></tr></table></td>' . "\n";
        }
        // Mail Queues display
        $incomingdir = get_conf_var('incomingqueuedir');
        $outgoingdir = get_conf_var('outgoingqueuedir');
        // Display the MTA queue
        // Postfix if mta = postfix
        if ($mta == 'postfix' && $_SESSION['user_type'] == 'A') {
            if (is_readable($incomingdir) && is_readable($outgoingdir)) {
                $inq = postfixinq();
                $outq = postfixallq() - $inq;
                echo '    <tr><td colspan="3" class="heading" align="center">Mail Queues</td></tr>' . "\n";
                echo '    <tr><td colspan="2"><a href="postfixmailq.php">Inbound:</a></td><td align="right">' . $inq . '</td>' . "\n";
                echo '    <tr><td colspan="2"><a href="postfixmailq.php">Outbound:</a></td><td align="right">' . $outq . '</td>' . "\n";
            } else {
                echo '    <tr><td colspan="3">Please verify read permissions on ' . $incomingdir . ' and ' . $outgoingdir . '</td></tr>' . "\n";
            }
            // else use mailq which is for sendmail and exim
        } elseif (MAILQ && $_SESSION['user_type'] == 'A') {
            $inq = mysql_result(dbquery("SELECT COUNT(*) FROM inq WHERE " . $_SESSION['global_filter']), 0);
            $outq = mysql_result(dbquery("SELECT COUNT(*) FROM outq WHERE " . $_SESSION['global_filter']), 0);
            echo '    <tr><td colspan="3" class="heading" align="center">Mail Queues</td></tr>' . "\n";
            echo '    <tr><td colspan="2"><a href="mailq.php?queue=inq">Inbound:</a></td><td align="right">' . $inq . '</td>' . "\n";
            echo '    <tr><td colspan="2"><a href="mailq.php?queue=outq">Outbound:</a></td><td align="right">' . $outq . '</td>' . "\n";
        }
        // drive display
        if ($_SESSION['user_type'] == 'A') {
            echo '    <tr><td colspan="3" class="heading" align="center">' . __('freedspace03') . '</td></tr>' . "\n";
            foreach (get_disks() as $disk) {
                $free_space = disk_free_space($disk['mountpoint']);
                $total_space = disk_total_space($disk['mountpoint']);
                if (round($free_space / $total_space, 2) <= 0.1) {
                    $percent = '<span style="color:red">';
                } else {
                    $percent = '<span>';
                }
                $percent .= ' [';
                $percent .= round($free_space / $total_space, 2) * 100;
                $percent .= '%] ';
                $percent .= '</span>';
                echo '    <tr><td>' . $disk['mountpoint'] . '</td><td colspan="2" align="right">' . formatSize($free_space) . $percent . '</td>' . "\n";
            }
        }
        echo '  </table>' . "\n";
        echo '  </td>' . "\n";
    }
    echo '<td align="center" valign="top">' . "\n";
    $sql = "\n SELECT\n  COUNT(*) AS processed,\n  SUM(\n   CASE WHEN (\n    (virusinfected=0 OR virusinfected IS NULL)\n    AND (nameinfected=0 OR nameinfected IS NULL)\n    AND (otherinfected=0 OR otherinfected IS NULL)\n    AND (isspam=0 OR isspam IS NULL)\n    AND (ishighspam=0 OR ishighspam IS NULL)\n    AND (ismcp=0 OR ismcp IS NULL)\n    AND (ishighmcp=0 OR ishighmcp IS NULL)\n   ) THEN 1 ELSE 0 END\n  ) AS clean,\n  ROUND((\n   SUM(\n    CASE WHEN (\n     (virusinfected=0 OR virusinfected IS NULL)\n     AND (nameinfected=0 OR nameinfected IS NULL)\n     AND (otherinfected=0 OR otherinfected IS NULL)\n     AND (isspam=0 OR isspam IS NULL)\n     AND (ishighspam=0 OR ishighspam IS NULL)\n     AND (ismcp=0 OR ismcp IS NULL)\n     AND (ishighmcp=0 OR ishighmcp IS NULL)\n    ) THEN 1 ELSE 0 END\n   )/COUNT(*))*100,1\n  ) AS cleanpercent,\n  SUM(\n   CASE WHEN\n    virusinfected>0\n   THEN 1 ELSE 0 END\n  ) AS viruses,\n  ROUND((\n   SUM(\n    CASE WHEN\n     virusinfected>0\n    THEN 1 ELSE 0 END\n   )/COUNT(*))*100,1\n  ) AS viruspercent,\n  SUM(\n   CASE WHEN\n    nameinfected>0\n    AND (virusinfected=0 OR virusinfected IS NULL)\n    AND (otherinfected=0 OR otherinfected IS NULL)\n    AND (isspam=0 OR isspam IS NULL)\n    AND (ishighspam=0 OR ishighspam IS NULL)\n   THEN 1 ELSE 0 END\n  ) AS blockedfiles,\n  ROUND((\n   SUM(\n    CASE WHEN\n     nameinfected>0\n     AND (virusinfected=0 OR virusinfected IS NULL)\n     AND (otherinfected=0 OR otherinfected IS NULL)\n     AND (isspam=0 OR isspam IS NULL)\n     AND (ishighspam=0 OR ishighspam IS NULL)\n    THEN 1 ELSE 0 END\n   )/COUNT(*))*100,1\n  ) AS blockedfilespercent,\n  SUM(\n   CASE WHEN\n    otherinfected>0\n    AND (nameinfected=0 OR nameinfected IS NULL)\n    AND (virusinfected=0 OR virusinfected IS NULL)\n    AND (isspam=0 OR isspam IS NULL)\n    AND (ishighspam=0 OR ishighspam IS NULL)\n   THEN 1 ELSE 0 END\n  ) AS otherinfected,\n  ROUND((\n   SUM(\n    CASE WHEN\n     otherinfected>0\n     AND (nameinfected=0 OR nameinfected IS NULL)\n     AND (virusinfected=0 OR virusinfected IS NULL)\n     AND (isspam=0 OR isspam IS NULL)\n     AND (ishighspam=0 OR ishighspam IS NULL)\n    THEN 1 ELSE 0 END\n   )/COUNT(*))*100,1\n  ) AS otherinfectedpercent,\n  SUM(\n   CASE WHEN\n    isspam>0\n    AND (virusinfected=0 OR virusinfected IS NULL)\n    AND (nameinfected=0 OR nameinfected IS NULL)\n    AND (otherinfected=0 OR otherinfected IS NULL)\n    AND (ishighspam=0 OR ishighspam IS NULL)\n   THEN 1 ELSE 0 END\n  ) AS spam,\n  ROUND((\n   SUM(\n    CASE WHEN\n     isspam>0\n     AND (virusinfected=0 OR virusinfected IS NULL)\n     AND (nameinfected=0 OR nameinfected IS NULL)\n     AND (otherinfected=0 OR otherinfected IS NULL)\n     AND (ishighspam=0 OR ishighspam IS NULL)\n    THEN 1 ELSE 0 END\n   )/COUNT(*))*100,1\n  ) AS spampercent,\n  SUM(\n   CASE WHEN\n    ishighspam>0\n    AND (virusinfected=0 OR virusinfected IS NULL)\n    AND (nameinfected=0 OR nameinfected IS NULL)\n    AND (otherinfected=0 OR otherinfected IS NULL)\n   THEN 1 ELSE 0 END\n  ) AS highspam,\n  ROUND((\n   SUM(\n    CASE WHEN\n     ishighspam>0\n     AND (virusinfected=0 OR virusinfected IS NULL)\n     AND (nameinfected=0 OR nameinfected IS NULL)\n     AND (otherinfected=0 OR otherinfected IS NULL)\n    THEN 1 ELSE 0 END\n   )/COUNT(*))*100,1\n  ) AS highspampercent,\n  SUM(\n   CASE WHEN\n    ismcp>0\n    AND (virusinfected=0 OR virusinfected IS NULL)\n    AND (nameinfected=0 OR nameinfected IS NULL)\n    AND (otherinfected=0 OR otherinfected IS NULL)\n    AND (isspam=0 OR isspam IS NULL)\n    AND (ishighspam=0 OR ishighspam IS NULL)\n    AND (ishighmcp=0 OR ishighmcp IS NULL)\n   THEN 1 ELSE 0 END\n  ) AS mcp,\n  ROUND((\n   SUM(\n    CASE WHEN\n     ismcp>0\n     AND (virusinfected=0 OR virusinfected IS NULL)\n     AND (nameinfected=0 OR nameinfected IS NULL)\n     AND (otherinfected=0 OR otherinfected IS NULL)\n     AND (isspam=0 OR isspam IS NULL)\n     AND (ishighspam=0 OR ishighspam IS NULL)\n     AND (ishighmcp=0 OR ishighmcp IS NULL)\n    THEN 1 ELSE 0 END\n   )/COUNT(*))*100,1\n  ) AS mcppercent,\n  SUM(\n   CASE WHEN\n    ishighmcp>0\n    AND (virusinfected=0 OR virusinfected IS NULL)\n    AND (nameinfected=0 OR nameinfected IS NULL)\n    AND (otherinfected=0 OR otherinfected IS NULL)\n    AND (isspam=0 OR isspam IS NULL)\n    AND (ishighspam=0 OR ishighspam IS NULL)\n   THEN 1 ELSE 0 END\n  ) AS highmcp,\n  ROUND((\n   SUM(\n    CASE WHEN\n     ishighmcp>0\n     AND (virusinfected=0 OR virusinfected IS NULL)\n     AND (nameinfected=0 OR nameinfected IS NULL)\n     AND (otherinfected=0 OR otherinfected IS NULL)\n     AND (isspam=0 OR isspam IS NULL)\n     AND (ishighspam=0 OR ishighspam IS NULL)\n    THEN 1 ELSE 0 END\n   )/COUNT(*))*100,1\n  ) AS highmcppercent,\n  SUM(size) AS size\n FROM\n  maillog\n WHERE\n  date = CURRENT_DATE()\n AND\n  " . $_SESSION['global_filter'] . "\n";
    $sth = dbquery($sql);
    while ($row = mysql_fetch_object($sth)) {
        echo '<table border="0" cellpadding="1" cellspacing="1" class="mail" width="200">' . "\n";
        echo ' <tr><th align="center" colspan="3">' . __('todaystotals03') . '</th></tr>' . "\n";
        echo ' <tr><td>' . __('processed03') . ':</td><td align="right">' . number_format($row->processed) . '</td><td align="right">' . format_mail_size($row->size) . '</td></tr>' . "\n";
        echo ' <tr><td>' . __('cleans03') . ':</td><td align="right">' . number_format($row->clean) . '</td><td align="right">' . $row->cleanpercent . '%</td></tr>' . "\n";
        echo ' <tr><td>' . __('viruses03') . ':</td><td align="right">' . number_format($row->viruses) . '</td><td align="right">' . $row->viruspercent . '%</tr>' . "\n";
        echo ' <tr><td>Top Virus:</td><td colspan="2" align="right" style="white-space:nowrap">' . return_todays_top_virus() . '</td></tr>' . "\n";
        echo ' <tr><td>' . __('blockedfiles03') . ':</td><td align="right">' . number_format($row->blockedfiles) . '</td><td align="right">' . $row->blockedfilespercent . '%</td></tr>' . "\n";
        echo ' <tr><td>' . __('others03') . ':</td><td align="right">' . number_format($row->otherinfected) . '</td><td align="right">' . $row->otherinfectedpercent . '%</td></tr>' . "\n";
        echo ' <tr><td>Spam:</td><td align="right">' . number_format($row->spam) . '</td><td align="right">' . $row->spampercent . '%</td></tr>' . "\n";
        echo ' <tr><td style="white-space:nowrap">' . __('hscospam03') . ':</td><td align="right">' . number_format($row->highspam) . '</td><td align="right">' . $row->highspampercent . '%</td></tr>' . "\n";
        if (get_conf_truefalse('mcpchecks')) {
            echo ' <tr><td>MCP:</td><td align="right">' . number_format($row->mcp) . '</td><td align="right">' . $row->mcppercent . '%</td></tr>' . "\n";
            echo ' <tr><td style="white-space:nowrap">' . __('hscomcp03') . ':</td><td align="right">' . number_format($row->highmcp) . '</td><td align="right">' . $row->highmcppercent . '%</td></tr>' . "\n";
        }
        echo '</table>' . "\n";
    }
    // Navigation links - put them into an array to allow them to be switched
    // on or off as necessary and to allow for the table widths to be calculated.
    $nav = array();
    $nav['status.php'] = __('recentmessages03');
    if (LISTS) {
        $nav['lists.php'] = __('lists03');
    }
    if (!DISTRIBUTED_SETUP) {
        $nav['quarantine.php'] = __('quarantine03');
    }
    $nav['reports.php'] = __('reports03');
    $nav['other.php'] = __('toolslinks03');
    if (SHOW_SFVERSION == true) {
        if ($_SESSION['user_type'] === 'A') {
            $nav['sf_version.php'] = __('softwareversions03');
        }
    }
    if (SHOW_DOC == true) {
        $nav['docs.php'] = __('documentation03');
    }
    $nav['logout.php'] = __('logout03');
    //$table_width = round(100 / count($nav));
    //Navigation table
    echo '  </td>' . "\n";
    echo ' </tr>' . "\n";
    echo '<tr>' . "\n";
    echo '<td colspan="4">' . "\n";
    echo '<ul id="menu" class="yellow">' . "\n";
    // Display the different words
    foreach ($nav as $url => $desc) {
        $active_url = "" . MAILWATCH_HOME . "/" . $url . "";
        if ($_SERVER['SCRIPT_FILENAME'] == $active_url) {
            echo "<li class=\"active\"><a href=\"{$url}\">{$desc}</a></li>\n";
        } else {
            echo "<li><a href=\"{$url}\">{$desc}</a></li>\n";
        }
    }
    echo '
 </ul>
 </td>
 </tr>
 <tr>
  <td colspan="4">';
    if ($report) {
        $return_items = $filter;
    } else {
        $return_items = $refresh;
    }
    return $return_items;
}
                        <tbody>
                            <tr>
                                <td>
                                    <div style="padding: 14px;">
                                        <div style="float: right;">
                                            <?php 
echo recaptcha_get_html(SITE_CONFIG_CAPTCHA_PUBLIC_KEY);
?>
                                            <div class="clear"><!-- --></div>
                                        </div>
                                        <div style="text-align:left;">
                                            <strong><?php 
echo $file->originalFilename;
?>
 (<?php 
echo formatSize($file->fileSize);
?>
)</strong>
                                        </div>
                                        <div style="font-size: 12px; text-align:left; padding-top: 14px;">
                                            <?php 
echo t("in_order_to_prevent_abuse_captcha_intro", "In order to prevent abuse of this service, please copy the words into the text box on the right.");
?>
                                        </div>
                                        <div style="font-size: 12px; text-align:left; padding-top: 14px;">
                                            <input name="submit" type="submit" value="<?php 
echo t('continue', 'continue');
?>
" class="submitInput"/>
                                            <input type="hidden" name="submitted" value="1"/>
                                            <input type="hidden" name="d" value="1"/>
Esempio n. 23
0
        $sysSwapPercent = sprintf('%.2f', $sysSwapUsed / $system['mem_info']['SwapTotal'] * 100);
        echo "<tr><td class='subinfo'></td><td>Swap</td><td><div class='progress progress-info' style='margin-bottom: 0;'><div class='bar' style='width: " . $sysSwapPercent . "%;'>Used&nbsp;" . $sysSwapPercent . "%</div></div>";
        echo "<b>Total:</b> " . formatSize($system['mem_info']['SwapTotal']) . "<b> Used:</b> " . formatSize($sysSwapUsed) . "<b> Free:</b> " . formatSize($system['mem_info']['SwapFree']) . "</td></tr>\n";
    }
}
// Filesystem Information
if (count($system['partitions']) > 0) {
    echo "<tr><td><b>Disk</b></td><td><b>Mount</b></td><td><b>Stats</b></td></tr>\n";
    foreach ($system['partitions'] as $fs) {
        if (!$fs['Temporary']['bool'] && $fs['FileSystem']['text'] != "none" && $fs['FileSystem']['text'] != "udev") {
            $diskFree = $fs['Free']['value'];
            $diskTotal = $fs['Size']['value'];
            $diskUsed = $fs['Used']['value'];
            $diskPercent = sprintf('%.2f', $diskUsed / $diskTotal * 100);
            echo "<tr><td class='subinfo'></td><td>" . $fs['Partition']['text'] . "</td><td><div class='progress progress-info' style='margin-bottom: 0;'><div class='bar' style='width: " . $diskPercent . "%;'>Used&nbsp;" . $diskPercent . "%</div></div>";
            echo "<b>Total:</b> " . formatSize($diskTotal) . "<b> Used:</b> " . formatSize($diskUsed) . "<b> Free:</b> " . formatSize($diskFree) . "</td></tr>\n";
        }
    }
}
?>
              <tr><td><b>PHP</b></td><td>Version</td><td colspan="2"><?php 
echo $system['php'] . ' (' . "Zend Version" . ' ' . $system['zend'] . ')';
?>
</td></tr>
              <tr><td class="subinfo"></td><td>Modules</td><td colspan="2"><?php 
while (list($key, $val) = each($system['php_modules'])) {
    echo "{$val} &nbsp; ";
}
?>
</td></tr>
            </table>
Esempio n. 24
0
  <tbody>
  <tr>
    <td>Images on the Server:<?php 
/*echo $LocalPicturePath*/
?>
<br>
    <select id="filelist" name="filelist" style="width:200" size="10" onClick="CopyToURL(this[this.selectedIndex].value);">
<?php 
$d = @dir($LocalPicturePath);
while (false !== ($entry = $d->read())) {
    if (substr($entry, 0, 1) != '.') {
        //not a dot file or directory
        if ($entry == $DestFileName) {
            echo '<OPTION value="' . $PicturePath . $entry . '" selected="selected">' . $entry . '(' . formatSize(filesize($LocalPicturePath . '\\' . $entry)) . ')</OPTION>';
        } else {
            echo '<OPTION value="' . $PicturePath . $entry . '">' . $entry . '(' . formatSize(filesize($LocalPicturePath . '\\' . $entry)) . ')</OPTION>';
        }
    }
}
$d->close();
?>
    </select>

      <form method="post" action="" enctype="multipart/form-data">
        <input type="hidden" name="localpicturepath" value="<?php 
echo $LocalPicturePath;
?>
">
        <input type="hidden" name="picturepath" value="<?php 
echo $PicturePath;
?>
Esempio n. 25
0
            $row = $day == 'Saturday' || $day == 'Sunday' ? '3' : '1';
            # Print log file row
            echo <<<OUT
\t\t\t<tr class="row{$row}">
\t\t\t\t<td width="150">{$display}</td>
\t\t\t\t<td width="100">{$size}</td>
\t\t\t\t<td>
\t\t\t\t\t[<a href="{$self}?logs-view&file={$file}&show=raw" target="_blank" title="Opens in a new window">raw log</a>]
\t\t\t\t\t&nbsp;
\t\t\t\t\t[<a href="{$self}?logs-view&file={$file}&show=popular-sites">popular sites</a>]
\t\t\t\t</td>
\t\t\t</tr>
OUT;
        }
        # End table
        $total = formatSize($totalSize);
        echo <<<OUT
\t\t</table>
\t\t<p>Total space used by logs: <b>{$total}</b></p>
\t\t<p class="little">Note: Raw logs open in a new window.</p>
\t\t<p class="little">Note: You can set up your proxy to automatically delete old logs with the maintenance feature.</p>
OUT;
        break;
        /*****************************************************************
         * LOG VIEWER
         ******************************************************************/
    /*****************************************************************
     * LOG VIEWER
     ******************************************************************/
    case 'logs-view':
        $output->title = 'view log';
Esempio n. 26
0
    echo "<center><br><font color=red>{$strCantGetFileInfo}...</font><br><br></center>";
    exit;
}
echo "<table  cellspacing=1 cellpadding=0 style=\"margin: 3px;font-size: 10px; font-family: verdana,sans;\">";
if ($isdir) {
    echo "<tr><td>" . $strFileType . ":</td><td> Directory </td></tr>";
} else {
    $res = execute(which("file") . " " . escapeshellarg($file));
    $res = explode(":", $res);
    echo "<tr><td valign=\"top\">" . $strFileType . ":</td><td> " . array_pop($res) . "</td></tr>";
}
$stat = @stat($file);
$perms = @fileperms($file);
$dsize = @disk_total_space($file);
$fsize = @disk_free_space($file);
echo "<tr><td>{$strFileRights}:</td><td> " . getFilePerms($perms) . " (" . substr(sprintf('%o', $perms), -4) . ")</td></tr>";
$owner = posix_getpwuid($stat[4]);
$group = posix_getpwuid($stat[5]);
if (empty($group['name'])) {
    $group['name'] = "-1";
}
echo "<tr><td>{$strFileOwner}:</td><td>  " . $owner['name'] . "/" . $group['name'] . "</td></tr>";
echo "<tr><td>{$strFileSize}:</td><td>  " . $stat[7] . "</td></tr>";
echo "<tr><td>{$strFileLastAccess}:</td><td> " . dbformat_to_dt(date("Y-m-d H:i:s", $stat[8])) . "</td></tr>";
echo "<tr><td>{$strFileLastModified}:</td><td> " . dbformat_to_dt(date("Y-m-d H:i:s", $stat[9])) . "</td></tr>";
echo "<tr><td nowrap>{$strTotalSpace}:</td><td> " . formatSize($dsize) . "</td></tr>";
echo "<tr><td nowrap>{$strFreeSpace}:</td><td> " . formatSize($fsize) . "</td></tr>";
echo "</table>";
exit;
echo "</div>";
exit;
Esempio n. 27
0
            echo "<div style='width:80%;margin:0px auto;'><p>" . $vocables["{$lang}"]["message_from"] . $mail . " :</p><p id='message'>" . $messenger . "</p></div>";
        }
    }
    ?>
	<div style="height:30px;"></div>
	<!-- The template to display files available for download -->
	<table role="presentation" class="table table-striped">
		<tbody class="files">
			<?php 
    $dir = opendir($dirname);
    while ($file = readdir($dir)) {
        $filetype_explode = explode(".", $file);
        $fileext = $filetype_explode[count($filetype_explode) - 1];
        if ($file != '.' && $file != '..' && $file != 'index.php' && !is_dir($dirname . '/' . $file) && $file != 'all_files_list.zip' && $file != '.htaccess' && $file != '.htpasswd' && !check_only($dirname . '/' . $file, $mail) && $fileext != "lock" && $file != 'mail.json' && $file != '.sender' && $file != '.messenger') {
            $filetype = assocExt($fileext);
            $filesize = formatSize(filesize($dirname . '/' . $file));
            ?>
			<tr class="template-download fade in" id="<?php 
            echo $filetype_explode[0];
            ?>
">
				<td>
					<span class="preview">
						<?php 
            //echo sortext($fileext,$dirname,$file);
            ?>
					</span>
				</td>
				<td>
					<p class="name">
						<?php 
Esempio n. 28
0
            break;
        case "multipart/related":
            break;
        case "multipart/alternative":
            break;
        default:
            echo " <tr>\n";
            echo "  <td colspan=2 class=\"detail\">";
            if (property_exists($part, 'd_parameters')) {
                if (isset($part->d_parameters['filename'])) {
                    echo $part->d_parameters['filename'];
                } else {
                    echo 'Attachment without name';
                }
                if (isset($part->d_parameters['size'])) {
                    echo '&nbsp;(size ' . formatSize($part->d_parameters['size']) . ')';
                }
            } else {
                echo 'Attachment without name';
            }
            if ($message->virusinfected == 0 && $message->nameinfected == 0 && $message->otherinfected == 0 || $_SESSION['user_type'] == 'A') {
                echo ' <a href="viewpart.php?id=' . $message_id . '&amp;part=' . $part->mime_id . '">Download</a>';
            }
            echo "  </td>";
            echo " </tr>\n";
            break;
    }
}
echo "</table>\n";
// Add footer
html_end();
Esempio n. 29
0
function create_works($params)
{
    // debugging aid that was removed...
    //error_log(var_export($params,true),0);
    // TODO: throw error if type param does not exist
    $type = $params['type'];
    if (array_key_exists('limit', $params)) {
        $limit = $params['limit'];
    } else {
        $limit = 100000;
        // limitless
    }
    if (array_key_exists('order', $params)) {
        $limit = $params['order'];
    } else {
        $order = 'DESC';
    }
    $res = '';
    // collecting other table data ...
    $honorifics = my_mysql_query_hash('SELECT * FROM TbIdHonorific', 'id');
    $contrib = my_mysql_query_hash('SELECT * FROM TbWkWorkContrib', 'id');
    $types = my_mysql_query_hash('SELECT * FROM TbWkWorkType', 'id');
    $locations = my_mysql_query_hash('SELECT * FROM TbLocation', 'id');
    $devices = my_mysql_query_hash('SELECT * FROM TbDevice', 'id');
    $languages = my_mysql_query_hash('SELECT * FROM TbLanguage', 'id');
    $persons = my_mysql_query_hash('SELECT * FROM TbIdPerson', 'id');
    $personexternal = my_mysql_query_hash('SELECT * FROM TbIdPersonExternal', 'id');
    $organizations = my_mysql_query_hash('SELECT * FROM TbOrganization', 'id');
    $external = my_mysql_query_hash('SELECT * FROM TbExternalType', 'id');
    $workexternal = my_mysql_query_hash('SELECT * FROM TbWkWorkExternal', 'id');
    $contribtype = my_mysql_query_hash('SELECT * FROM TbWkWorkContribType', 'id');
    #$works=my_mysql_query_hash('SELECT * FROM TbWkWork','id');
    # create a hash table of lists of contributors
    $work_contrib = array();
    $role_contrib = array();
    $work_contrib_org = array();
    $role_contrib_org = array();
    foreach ($contrib as $id => $row) {
        $workId = $row['workId'];
        $personId = $row['personId'];
        $organizationId = $row['organizationId'];
        $typeId = $row['typeId'];
        if ($personId != NULL) {
            if (!isset($work_contrib[$workId])) {
                $work_contrib[$workId] = array();
                $role_contrib[$workId] = array();
            }
            $work_contrib[$workId][] = $personId;
            $role_contrib[$workId][] = $typeId;
        }
        if ($organizationId != NULL) {
            if (!isset($work_contrib_org[$workId])) {
                $work_contrib_org[$workId] = array();
                $role_contrib_org[$workId] = array();
            }
            $work_contrib_org[$workId][] = $organizationId;
            $role_contrib_org[$workId][] = $typeId;
        }
    }
    # create a hash table of external ids for works
    $workexternal_externalid = array();
    $workexternal_externalcode = array();
    foreach ($workexternal as $id => $row) {
        $workId = $row['workId'];
        $externalId = $row['externalId'];
        $externalCode = $row['externalCode'];
        $workexternal_externalid[$workId][] = $externalId;
        $workexternal_externalcode[$workId][] = $externalCode;
    }
    # create a hash table of external ids for people
    $personexternal_externalid = array();
    $personexternal_externalcode = array();
    # create an empty entry for every person
    foreach ($persons as $id => $row) {
        $personexternal_externalid[$id] = array();
        $personexternal_externalcode[$id] = array();
    }
    # fill with external ids
    foreach ($personexternal as $id => $row) {
        $personId = $row['personId'];
        $externalId = $row['externalId'];
        $externalCode = $row['externalCode'];
        $personexternal_externalid[$personId][] = $externalId;
        $personexternal_externalcode[$personId][] = $externalCode;
    }
    // sending query
    switch ($type) {
        case 'audio':
            $add = 'TbWkWorkType.isAudio=1';
            break;
        case 'video':
            $add = 'TbWkWorkType.isVideo=1';
            break;
        case 'text':
            $add = 'TbWkWorkType.isText=1';
            break;
        default:
            $add = 'TbWkWorkType.name=\'' . $type . '\'';
            break;
    }
    #$query=sprintf('SELECT TbWkWork.id,TbWkWork.name,TbWkWork.length,TbWkWork.size,TbWkWork.chapters,TbWkWork.typeId,TbWkWork.languageId,TbWkWorkView.startViewDate,TbWkWorkView.endViewDate,TbWkWorkViewPerson.viewerId,TbWkWorkView.locationId,TbWkWorkView.deviceId,TbWkWorkView.langId,TbWkWorkReview.ratingId,TbWkWorkReview.review,TbWkWorkReview.reviewDate FROM TbWkWorkViewPerson,TbWkWork,TbWkWorkType,TbWkWorkReview,TbWkWorkView WHERE TbWkWork.typeId=TbWkWorkType.id AND TbWkWorkViewPerson.viewId=TbWkWorkView.id AND TbWkWorkReview.workId=TbWkWork.id AND TbWkWorkView.workId=TbWkWork.id AND %s ORDER BY TbWkWorkView.endViewDate %s LIMIT %s',$add,$order,$limit);
    $query = sprintf('SELECT TbWkWork.id,TbWkWork.name,TbWkWork.length,TbWkWork.size,TbWkWork.chapters,TbWkWork.typeId,TbWkWork.languageId,TbWkWorkView.startViewDate,TbWkWorkView.endViewDate,TbWkWorkViewPerson.viewerId,TbWkWorkView.locationId,TbWkWorkView.deviceId,TbWkWorkView.langId,TbWkWorkReview.ratingId,TbWkWorkReview.review,TbWkWorkReview.reviewDate FROM TbWkWorkViewPerson,TbWkWorkType,TbWkWork LEFT JOIN TbWkWorkView ON TbWkWorkView.workId=TbWkWork.id LEFT JOIN TbWkWorkReview ON TbWkWorkReview.workId=TbWkWork.id WHERE TbWkWork.typeId=TbWkWorkType.id AND TbWkWorkViewPerson.viewId=TbWkWorkView.id AND %s ORDER BY TbWkWorkView.endViewDate %s LIMIT %s', $add, $order, $limit);
    $result = my_mysql_query($query);
    $res .= multi_accordion_start();
    $body = '';
    // printing table rows
    $currid = NULL;
    while ($row = $result->fetch_assoc()) {
        // finish the previous entry if that is the case
        if ($currid != $row['id']) {
            if ($currid != NULL) {
                $body .= '</ul>';
                $res .= multi_accordion_entry($header, $body);
            }
        }
        if ($row['typeId'] != NULL) {
            $s_type = $types[$row['typeId']]['name'];
        } else {
            $s_type = get_na_string();
        }
        if ($row['languageId'] != NULL) {
            $s_language = $languages[$row['languageId']]['name'];
        } else {
            $s_language = get_na_string();
        }
        if ($row['locationId'] != NULL) {
            $s_location = $locations[$row['locationId']]['name'];
        } else {
            $s_location = get_na_string();
        }
        if ($row['deviceId'] != NULL) {
            $s_device = $devices[$row['deviceId']]['name'];
        } else {
            $s_device = get_na_string();
        }
        if ($row['langId'] != NULL) {
            $s_lang = $languages[$row['langId']]['name'];
        } else {
            $s_lang = get_na_string();
        }
        if ($row['viewerId'] != NULL) {
            $s_viewer = get_full_name($persons[$row['viewerId']], $honorifics);
        } else {
            $s_viewer = get_na_string();
        }
        if ($row['size'] != NULL) {
            $s_size = formatSize($row['size']);
        }
        if ($row['length'] != NULL) {
            $s_length = formatTimeperiod($row['length']);
        }
        if ($row['name'] != NULL) {
            $header = $row['name'];
        } else {
            $header = 'No Name';
        }
        # append contributors to the header...(do not include organizations)
        if (isset($work_contrib[$row['id']])) {
            $cont_array = array();
            foreach ($work_contrib[$row['id']] as $personId) {
                $cont_array[] = get_full_name($persons[$personId], $honorifics);
            }
            if (count($cont_array) > 0) {
                $header .= ' / ' . join($cont_array, ', ');
            }
        }
        if ($currid != $row['id']) {
            $currid = $row['id'];
            $body = '';
            $body .= '<ul>';
            if ($row['id'] != NULL) {
                $body .= '<li>id: ' . $row['id'] . '</li>';
            }
            if ($row['name'] != NULL) {
                $body .= '<li>name: ' . $row['name'] . '</li>';
            }
            if ($row['length'] != NULL) {
                $body .= '<li>length: ' . $s_length . '</li>';
            }
            if ($row['size'] != NULL) {
                $body .= '<li>size: ' . $s_size . '</li>';
            }
            if ($row['chapters'] != NULL) {
                $body .= '<li>chapters: ' . $row['chapters'] . '</li>';
            }
            if ($row['typeId'] != NULL) {
                $body .= '<li>type: ' . $s_type . '</li>';
            }
            if ($row['languageId'] != NULL) {
                $body .= '<li>language: ' . $s_language . '</li>';
            }
            # contributor stuff
            if (isset($work_contrib[$row['id']])) {
                $j = 0;
                foreach ($work_contrib[$row['id']] as $personId) {
                    $name = get_full_name($persons[$personId], $honorifics);
                    $roleid = $role_contrib[$row['id']][$j];
                    $role_name = $contribtype[$roleid]['name'];
                    $body .= '<li>' . $role_name . ': ' . $name;
                    $j++;
                    $e = 0;
                    foreach ($personexternal_externalid[$personId] as $externalid) {
                        $externalcode = $personexternal_externalcode[$personId][$e];
                        $externalname = $external[$externalid]['name'];
                        $externalidname = $external[$externalid]['idname'];
                        $link = get_external_href($externalname, $externalcode);
                        $link = '<a href=\'' . $link . '\'>' . $externalidname . ': ' . $externalcode . '</a>';
                        $body .= ' ' . $link;
                        $e++;
                    }
                    $body .= '</li>';
                }
            }
            if (isset($work_contrib_org[$row['id']])) {
                $j = 0;
                foreach ($work_contrib_org[$row['id']] as $organizationId) {
                    $name = $organizations[$organizationId]['name'];
                    $url = $organizations[$organizationId]['url'];
                    $roleid = $role_contrib_org[$row['id']][$j];
                    $role_name = $contribtype[$roleid]['name'];
                    $body .= '<li>' . $role_name . ': ' . '<a href=\'' . $url . '\'>' . $name . '</a></li>';
                    $j++;
                }
            }
            # external stuff
            $j = 0;
            if (isset($workexternal_externalid[$row['id']])) {
                foreach ($workexternal_externalid[$row['id']] as $externalid) {
                    $externalcode = $workexternal_externalcode[$row['id']][$j];
                    $externalname = $external[$externalid]['name'];
                    $externalidname = $external[$externalid]['idname'];
                    $link = get_external_href($externalname, $externalcode);
                    $link = '<a href=\'' . $link . '\'>' . $externalidname . ': ' . $externalcode . '</a>';
                    $body .= '<li>' . $link . '</li>';
                    $j++;
                }
            }
        }
        # view stuff
        if ($row['startViewDate'] != NULL) {
            $body .= '<li>start view date: ' . $row['startViewDate'] . '</li>';
        }
        if ($row['endViewDate'] != NULL) {
            $body .= '<li>end view date: ' . $row['endViewDate'] . '</li>';
        }
        if ($row['viewerId'] != NULL) {
            $body .= '<li>viewer: ' . $s_viewer . '</li>';
        }
        if ($row['locationId'] != NULL) {
            $body .= '<li>location: ' . $s_location . '</li>';
        }
        if ($row['deviceId'] != NULL) {
            $body .= '<li>device: ' . $s_device . '</li>';
        }
        if ($row['langId'] != NULL) {
            $body .= '<li>lang: ' . $s_lang . '</li>';
        }
        # review stuff
        if ($row['ratingId'] != NULL) {
            $body .= '<li>rating: ' . $row['ratingId'] . '</li>';
        }
        if ($row['review'] != NULL) {
            $body .= '<li>review: ' . $row['review'] . '</li>';
        }
        if ($row['reviewDate'] != NULL) {
            $body .= '<li>review date: ' . $row['reviewDate'] . '</li>';
        }
    }
    if ($currid != NULL) {
        $body .= '</ul>';
        $res .= multi_accordion_entry($header, $body);
    }
    my_mysql_free_result($result);
    $res .= multi_accordion_end();
    return $res;
}
function list_file($cur)
{
    global $PHP_SELF, $order, $asc, $order0;
    if ($dir = opendir($cur)) {
        /* tableaux */
        $tab_dir = array();
        $tab_file = array();
        /* extraction */
        while ($file = readdir($dir)) {
            if (is_dir($cur . "/" . $file)) {
                if (!in_array($file, array(".", ".."))) {
                    $tab_dir[] = addScheme($file, $cur, 'dir');
                }
            } else {
                $tab_file[] = addScheme($file, $cur, 'file');
            }
        }
        /* affichage */
        echo "<table class='table table-hover'>";
        echo "<tr>";
        echo "<th>" . ($order == 'name' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Nom</th>";
        echo "<th>" . ($order == 'size' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Taille</th>";
        echo "<th>" . ($order == 'date' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Date</th>";
        echo "<th>" . ($order == 'time' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Time</th>";
        echo "<th>" . ($order == 'ext' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Type</th>";
        echo "<th>" . ($order == 'name' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Download</th>";
        echo "<th>" . ($order == 'name' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Delete</th>";
        echo "</tr>";
        foreach ($tab_file as $elem) {
            if (assocExt($elem['ext']) != 'inconnu') {
                echo '<tr>';
                echo '<td>';
                echo '<h5><i class="glyphicon glyphicon-saved text-success"></i>';
                echo ' <input type="hidden" value="' . $_SESSION['opensim_select'] . '" name="name_sim">';
                echo '<input type="hidden" value="' . $elem['name'] . '" name="name_file">' . $elem['name'] . '';
                echo '</h5></td>';
                echo '<td><h5>' . formatSize($elem['size']) . '</h5></td>';
                echo '<td><h5><span class="badge">' . date("d-m-Y", $elem['date']) . '</span></h5></td>';
                echo '<td><h5><span class="badge">' . date("H:i:s a", $elem['date']) . '</span></h5></td>';
                echo '<td><h5>' . assocExt($elem['ext']) . '</h5></td>';
                echo '<td>';
                $moteursOK = Securite_Simulateur();
                /* ************************************ */
                //SECURITE MOTEUR
                $btnN1 = "disabled";
                $btnN2 = "disabled";
                $btnN3 = "disabled";
                if ($_SESSION['privilege'] == 4) {
                    $btnN1 = "";
                    $btnN2 = "";
                    $btnN3 = "";
                }
                // Niv 4
                if ($_SESSION['privilege'] == 3) {
                    $btnN1 = "";
                    $btnN2 = "";
                    $btnN3 = "";
                }
                // Niv 3
                if ($_SESSION['privilege'] == 2) {
                    $btnN1 = "";
                    $btnN2 = "";
                }
                // Niv 2
                if ($moteursOK == "OK") {
                    if ($_SESSION['privilege'] == 1) {
                        $btnN1 = "";
                        $btnN2 = "";
                        $btnN3 = "";
                    }
                }
                //SECURITE MOTEUR
                /* ************************************ */
                if ($_SESSION['privilege'] >= 3) {
                    $action = "inc/download.php?file=" . INI_Conf_Moteur($_SESSION['opensim_select'], "address") . $elem['name'];
                    // $btnN3 = "";
                    echo '<form method="post" action="' . $action . '">';
                    echo '<input type="hidden" value="' . $_SESSION['opensim_select'] . '" name="name_sim">';
                    echo '<input type="hidden" value="' . $elem['name'] . '" name="name_file">';
                    echo '<button class="btn btn-success" type="submit" value="download" name="cmd" >';
                    echo '<i class="glyphicon glyphicon-download-alt"></i> Download</button>';
                    echo '</form>';
                    echo '<td>';
                    echo '<form method="post" action="">';
                    echo '<input type="hidden" value="' . $_SESSION['opensim_select'] . '" name="name_sim">';
                    echo '<input type="hidden" value="' . $elem['name'] . '" name="name_file">';
                    echo ' <button class="btn btn-danger" type="submit" value="delete" name="cmd" >';
                    echo '<i class="glyphicon glyphicon-trash"></i> Delete</button>';
                    echo '</td>';
                    echo '</form>';
                } else {
                    if ($moteursOK == "OK") {
                        echo '<form method="post" action="">';
                        echo '<input type="hidden" value="' . $_SESSION['opensim_select'] . '" name="name_sim">';
                        echo '<input type="hidden" value="' . $elem['name'] . '" name="name_file">';
                        echo '<button class="btn btn-success" type="submit" value="download" name="cmd" ' . $btnN2 . '>';
                        echo '<i class="glyphicon glyphicon-download-alt"></i> Download</button>';
                        echo '<td>';
                        echo ' <button class="btn btn-danger" type="submit" value="delete" name="cmd" ' . $btnN2 . '>';
                        echo '<i class="glyphicon glyphicon-trash"></i> Delete</button>';
                        echo '</td>';
                        echo '</form>';
                    } else {
                        echo '<form method="post" action="">';
                        echo '<button class="btn btn-success" type="submit" name="cmd" disabled>';
                        echo '<i class="glyphicon glyphicon-download-alt"></i> Download</button>';
                        echo '<td>';
                        echo ' <button class="btn btn-danger" type="submit" name="cmd" disabled>';
                        echo '<i class="glyphicon glyphicon-trash"></i> Delete</button>';
                        echo '</td>';
                        echo '</form>';
                    }
                }
                echo '</td>';
                echo '</tr>';
            }
        }
        echo '</table>';
        closedir($dir);
    }
}