예제 #1
0
 public function event_PostAuthentication(&$data)
 {
     global $CONF;
     static $blogid = 0;
     static $blogs = array();
     MediaUtils::$lib_path = preg_replace('#/*$#', '', $this->getDirectory());
     MediaUtils::$prefix = (bool) $CONF['MediaPrefix'];
     MediaUtils::$maxsize = (int) $CONF['MaxUploadSize'];
     $suffixes = explode(',', $CONF['AllowedTypes']);
     foreach ($suffixes as $suffix) {
         $suffix = trim($suffix);
         if (!in_array($suffix, MediaUtils::$suffixes)) {
             MediaUtils::$suffixes[] = strtolower($suffix);
         }
     }
     $result = sql_query('SELECT bnumber, bshortname FROM ' . sql_table('blog') . ';');
     while (FALSE !== ($row = sql_fetch_assoc($result))) {
         $blogs[$row['bnumber']] = $row['bshortname'];
     }
     MediaUtils::$blogs =& $blogs;
     if (array_key_exists('blogid', $_GET)) {
         $blogid = (int) $_GET['blogid'];
     } else {
         if (array_key_exists('blogid', $_POST)) {
             $blogid = (int) $_POST['blogid'];
         } else {
             if (array_key_exists('itemid', $_GET) && function_exists('getBlogIDFromItemID')) {
                 $blogid = (int) getBlogIDFromItemID((int) $_GET['itemid']);
             } else {
                 if (array_key_exists('itemid', $_POST) && function_exists('getBlogIDFromItemID')) {
                     $blogid = (int) getBlogIDFromItemID((int) $_POST['itemid']);
                 } else {
                     if (array_key_exists(MediaUtils::$cookiename, $_COOKIE)) {
                         $blogid = (int) $_COOKIE['blogid'];
                     } else {
                         return;
                     }
                 }
             }
         }
     }
     MediaUtils::$blogid =& $blogid;
     MediaUtils::$bshortname =& MediaUtils::$blogs[MediaUtils::$blogid];
     return;
 }