| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | $config = array(); |
|---|
| 20 | $thumbnail_config = array(); |
|---|
| 21 | |
|---|
| 22 | require_once(dirname(__FILE__)."/plog-globals.php"); |
|---|
| 23 | if (is_file(PLOGGER_DIR."plog-config.php")){ |
|---|
| 24 | require_once(PLOGGER_DIR."plog-config.php"); |
|---|
| 25 | } else if (is_file(PLOGGER_DIR."plog-config-sample.php")) { |
|---|
| 26 | require_once(PLOGGER_DIR."plog-config-sample.php"); |
|---|
| 27 | } else { |
|---|
| 28 | die("Could not find any config file!"); |
|---|
| 29 | } |
|---|
| 30 | require_once(PLOGGER_DIR."plog-includes/plog-functions.php"); |
|---|
| 31 | |
|---|
| 32 | if (defined('PLOGGER_DEBUG') && PLOGGER_DEBUG == '1') { |
|---|
| 33 | $GLOBALS['query_count'] = 0; |
|---|
| 34 | $GLOBALS['queries'] = array(); |
|---|
| 35 | $plog_start_time = plog_timer(); |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | connect_db(); |
|---|
| 39 | |
|---|
| 40 | $query = "SELECT * FROM `".TABLE_PREFIX."config`"; |
|---|
| 41 | $result = run_query($query); |
|---|
| 42 | |
|---|
| 43 | if (mysql_num_rows($result) == 0){ |
|---|
| 44 | die("No config information in the database."); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | $config = mysql_fetch_assoc($result); |
|---|
| 48 | |
|---|
| 49 | $config['basedir'] = PLOGGER_DIR; |
|---|
| 50 | |
|---|
| 51 | $url_parts = parse_url($_SERVER['REQUEST_URI']); |
|---|
| 52 | $config['baseurl'] = "http://".$_SERVER['HTTP_HOST'].$url_parts['path']; |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | if (!defined('PLOGGER_EMBEDDED') || PLOGGER_EMBEDDED=='') { |
|---|
| 58 | if (dirname(__FILE__) != dirname(realpath($_SERVER['SCRIPT_FILENAME'])) && strpos($_SERVER['SCRIPT_FILENAME'],"plog-admin") === false) { |
|---|
| 59 | $config['embedded'] = 1; |
|---|
| 60 | |
|---|
| 61 | $config['use_mod_rewrite'] = 0; |
|---|
| 62 | trace('Plogger is embedded'); |
|---|
| 63 | trace('dirname: ' . dirname(__FILE__)); |
|---|
| 64 | trace('$_SERVER[\'SCRIPT_FILENAME\']' .': '. $_SERVER['SCRIPT_FILENAME']); |
|---|
| 65 | trace('realpath($_SERVER[\'SCRIPT_FILENAME\'])' .': '. realpath($_SERVER['SCRIPT_FILENAME'])); |
|---|
| 66 | } else { |
|---|
| 67 | $config['embedded'] = 0; |
|---|
| 68 | |
|---|
| 69 | if ($config['use_mod_rewrite'] == 1) { |
|---|
| 70 | $config['baseurl'] = "http://".$_SERVER['HTTP_HOST']. substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],"/")) . "/"; |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | } else{ |
|---|
| 74 | |
|---|
| 75 | if (PLOGGER_EMBEDDED == '1') { |
|---|
| 76 | $config['embedded'] = 1; |
|---|
| 77 | $config['use_mod_rewrite'] = 0; |
|---|
| 78 | trace('Plogger is embedded'); |
|---|
| 79 | |
|---|
| 80 | } else { |
|---|
| 81 | $config['embedded'] = 0; |
|---|
| 82 | |
|---|
| 83 | if ($config['use_mod_rewrite'] == 1) { |
|---|
| 84 | $config['baseurl'] = "http://".$_SERVER['HTTP_HOST']. substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],"/")) . "/"; |
|---|
| 85 | } |
|---|
| 86 | } |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | if (strpos($config['baseurl'], 'plog-admin/')) { |
|---|
| 92 | $config['baseurl'] = substr($config['baseurl'], 0, strpos($config['baseurl'], 'plog-admin/')); |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | $config['theme_url'] = $config['gallery_url']."plog-content/themes/".basename($config['theme_dir'])."/"; |
|---|
| 96 | $config['charset'] = 'utf-8'; |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | $revision = '$LastChangedRevision$'; |
|---|
| 100 | $revision = substr($revision, strpos($revision, ' ')+1, strrpos($revision, ' ')-strpos($revision, ' ')-1); |
|---|
| 101 | |
|---|
| 102 | $config['version'] = 'Version 1.0Beta3, Rev ' . $revision; |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | if (!headers_sent()){ |
|---|
| 109 | header('Content-Type: text/html; charset=' . $config['charset']); |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | $query = "SELECT * FROM `".TABLE_PREFIX."thumbnail_config`"; |
|---|
| 113 | $result = run_query($query); |
|---|
| 114 | |
|---|
| 115 | if (mysql_num_rows($result) == 0){ |
|---|
| 116 | die("No thumbnail config information in the database."); |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | $prefix_arr = array(1 => '', 2 => 'lrg-', 3 => 'rss-', 4 => 'tn-'); |
|---|
| 120 | |
|---|
| 121 | while($row = mysql_fetch_assoc($result)) { |
|---|
| 122 | $thumbnail_config[$row['id']] = array( |
|---|
| 123 | 'filename_prefix' => $prefix_arr[$row['id']], |
|---|
| 124 | 'size' => $row['max_size'], |
|---|
| 125 | 'timestamp' => $row['update_timestamp'], |
|---|
| 126 | 'disabled' => $row['disabled']); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | $thumbnail_config[5] = array( |
|---|
| 131 | 'filename_prefix' => 'theme-', |
|---|
| 132 | 'size' => 150, |
|---|
| 133 | 'timestamp' => 0, |
|---|
| 134 | 'disabled' => 0); |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | function display_uservariables() { |
|---|
| 138 | foreach ($config as $keys => $values) { |
|---|
| 139 | echo "$keys = $values<br />"; |
|---|
| 140 | } |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | function trace($output, $echo = true) { |
|---|
| 144 | if (defined('PLOGGER_DEBUG')) { |
|---|
| 145 | if (PLOGGER_DEBUG == '1') { |
|---|
| 146 | |
|---|
| 147 | if ($echo === false) { |
|---|
| 148 | return '*'.$output.'*<br />'; |
|---|
| 149 | } else { |
|---|
| 150 | echo '*'.$output.'*<br />'; |
|---|
| 151 | } |
|---|
| 152 | } |
|---|
| 153 | } |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | function vname(&$var, $scope=false, $prefix='unique', $suffix='value') { |
|---|
| 157 | if ($scope) $vals = $scope; |
|---|
| 158 | else $vals = $GLOBALS; |
|---|
| 159 | $old = $var; |
|---|
| 160 | $var = $new = $prefix.rand().$suffix; |
|---|
| 161 | $vname = FALSE; |
|---|
| 162 | foreach($vals as $key => $val) { |
|---|
| 163 | if($val === $new) $vname = $key; |
|---|
| 164 | } |
|---|
| 165 | $var = $old; |
|---|
| 166 | return $vname; |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | if (!isset($_SESSION['plogger_sortby'])){ |
|---|
| 170 | $_SESSION['plogger_sortby'] = $config['default_sortby']; |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | if (!isset($_SESSION['plogger_sortdir'])){ |
|---|
| 174 | $_SESSION['plogger_sortdir'] = $config['default_sortdir']; |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | if (!isset($_SESSION['plogger_details'])){ |
|---|
| 178 | $_SESSION['plogger_details'] = 0; |
|---|
| 179 | |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | ?> |
|---|