Ejemplo n.º 1
0
 function plugin_ucomedit_action()
 {
     $s_target = htmlspecialchars($this->root->post['target']);
     $mode = $this->root->post['mode'];
     $attachObj = new XpWikiAttachFile($this->xpwiki, $this->root->post['refer'], $this->root->post['target']);
     if (!$attachObj->is_owner()) {
         $mode = 'failed';
     }
     switch ($mode) {
         case 'write':
             $this->config['UCOMED_CHKAUTH'] && $this->func->check_editable($this->root->post['refer']);
             if ($ncom = $this->root->post['usercomm']) {
                 $ncom = mb_convert_encoding($ncom, $this->config['UCOMED_ENCORD'], "auto");
                 $fname = $this->cont['UPLOAD_DIR'] . $this->func->encode($this->root->post['refer']) . "_" . $this->func->encode($this->root->post['target']);
                 $msg = $this->ucomedit_brand($fname, $ncom) ? 'Updated UserComment of $1.' : 'Update UserComment of $1 failed.';
                 $msg = str_replace('$1', $s_target, $msg);
             }
             return array('msg' => $msg);
         case 'failed':
             $msg = 'You can not edit UserComment of $1.';
             $msg = str_replace('$1', $s_target, $msg);
             return array('msg' => $msg);
         case 'edit':
         default:
             return array('msg' => "Edit UserComment of {$s_target}", 'body' => $this->ucomedit_makeform($this->root->post['refer'], $this->root->post['target'], false));
     }
 }
Ejemplo n.º 2
0
 function attach_open()
 {
     //	global $vars,$_attach_messages;
     foreach (array('refer', 'file', 'age') as $var) {
         ${$var} = array_key_exists($var, $this->root->vars) ? $this->root->vars[$var] : '';
     }
     $obj = new XpWikiAttachFile($this->xpwiki, $refer, $file, $age);
     return $obj->getstatus() ? $obj->open() : array('header' => array('HTTP/1.0 404 Not Found', 'Status: 404 Not Found'), 'msg' => 'File Not Found.');
 }
Ejemplo n.º 3
0
    function plugin_exifshowcase_body($args, $page)
    {
        //	global $script,$WikiName,$BracketName;
        // 戻り値
        $params = array();
        //パラメータ
        $params = array('left' => FALSE, 'center' => FALSE, 'right' => FALSE, 'wrap' => FALSE, 'nowrap' => FALSE, 'around' => FALSE, 'nolink' => FALSE, 'noimg' => FALSE, 'nomapi' => FALSE, 'nokash' => FALSE, 'noexif' => FALSE, 'reverse' => FALSE, 'ucomedit' => FALSE, 'col' => 1, 'row' => 0, 'pattern' => '', 'sort' => FALSE, '_body' => '', '_args' => array(), '_done' => FALSE, '_error' => '');
        if (count($args) > 0) {
            // compat
            foreach ($args as $key => $val) {
                if (is_numeric($val)) {
                    $args[$key] = 'col:' . $val;
                }
            }
            $this->fetch_options($params, $args, array('pattern'));
        }
        $pattern = trim($params['pattern']);
        $colmn = intval($params['col']);
        $exif_extension = $colmn == 1 && !$params['noexif'] && extension_loaded('exif');
        $file = $title = $url = $url2 = $info = '';
        $width = $height = 0;
        if (!is_dir($this->cont['UPLOAD_DIR'])) {
            $params['_error'] = 'no UPLOAD_DIR.';
            return $params;
        }
        // fetch DB
        $where = $files = $aname = array();
        $where[] = "`pgid` = " . $this->func->get_pgid_by_name($page);
        $where[] = "`type` LIKE 'image%'";
        $where[] = "`age` = 0";
        if ($pattern) {
            $pattern4sql = addslashes($pattern);
            $where[] = "`name` REGEXP '{$pattern4sql}'";
        }
        $where = join(' AND ', $where);
        // 並べ替え
        if ($params['row']) {
            // ランダム表示?
            $show_count = $params['row'] * $colmn;
            $order = " ORDER BY RAND() LIMIT {$show_count}";
        } else {
            if ($params['sort']) {
                // ファイル名順
                $order = " ORDER BY `name` ASC";
            } else {
                // タイムスタンプ順
                $order = " ORDER BY `mtime` ASC";
            }
        }
        $query = "SELECT name FROM `" . $this->db->prefix($this->root->mydirname . "_attach") . "` WHERE {$where}{$order};";
        $result = $this->db->query($query);
        while ($_row = $this->db->fetchRow($result)) {
            $files[$_row[0]] = $this->cont['UPLOAD_DIR'] . $this->func->encode($page) . '_' . $this->func->encode($_row[0]);
        }
        if (!$files) {
            $params['_body'] = $this->msg['err_noimage'] . ($pattern ? '(' . $this->func->htmlspecialchars($pattern) . ')' : '');
            return $params;
        }
        if ($params['reverse']) {
            $files = array_reverse($files);
        }
        $params['_body'] = '<table summary="UnitCell" class="style_table" style="margin:0px;">' . ($exif_extension ? '<tr class="style_th"><th abbr="file">' . $this->msg['cap_file'] . '</th><th abbr="info">' . $this->msg['cap_info'] . '</th><th abbr="desc.">' . $this->msg['cap_comment'] . '</th></tr>' : '');
        $cnt = 0;
        foreach ($files as $aname => $fname) {
            $url = "{$this->root->script}?plugin=attach&amp;openfile={$aname}&amp;refer=" . rawurlencode($page);
            if ($exif_extension) {
                $exif = @exif_read_data($fname, 0, true);
                $eh = @$exif["COMPUTED"]["Height"];
                $ew = @$exif["COMPUTED"]["Width"];
            }
            $info = "";
            if (!$exif_extension) {
                $sz = filesize($fname);
                list($ew, $eh) = getimagesize($fname);
            } else {
                if (!($edate = @$exif["EXIF"]["DateTimeOriginal"])) {
                    if (!($edate = @$exif["EXIF"]["DateTimeDigitized"])) {
                        $edate = @$exif["IFD0"]["DateTime"];
                    }
                }
                $edate = htmlentities(trim($edate), ENT_QUOTES, $this->cont['SOURCE_ENCODING']);
                if ($edate) {
                    $info .= "<tr><td style=\"white-space:nowrap;\">" . $this->msg['cap_time'] . "</td><td>:</td><td>{$edate}</td></tr>";
                }
                if ($edesc = trim(@$exif["IFD0"]["ImageDescription"])) {
                    $edesc = mb_convert_encoding($edesc, $this->cont['SOURCE_ENCODING'], "auto");
                    $edesc = htmlentities($edesc, ENT_QUOTES, $this->cont['SOURCE_ENCODING']);
                    $info .= "<tr style=\"vertical-align:top;\"><td>" . $this->msg['cap_title'] . "</td><td>:</td><td>{$edesc}</td></tr>";
                }
                $cright = rtrim(@$exif["COMPUTED"]["Copyright"]);
                $cphoto = rtrim(@$exif["COMPUTED"]["Copyright.Photographer"]);
                $cedit = rtrim(@$exif["COMPUTED"]["Copyright.Editor"]);
                if ($cphoto) {
                    $cphoto = mb_convert_encoding($cphoto, $this->cont['SOURCE_ENCODING'], "auto");
                    $cphoto = htmlentities($cphoto, ENT_QUOTES, $this->cont['SOURCE_ENCODING']);
                    $info .= "<tr style=\"vertical-align:top;\"><td style=\"white-space:nowrap;\">" . $this->msg['cap_shot_author'] . "</td><td>:</td><td>{$cphoto}</td></tr>";
                }
                if ($cedit) {
                    $cedit = mb_convert_encoding($cedit, $this->cont['SOURCE_ENCODING'], "auto");
                    $cedit = htmlentities($cedit, ENT_QUOTES, $this->cont['SOURCE_ENCODING']);
                    $info .= "<tr style=\"vertical-align:top;\"><td style=\"white-space:nowrap;\">" . $this->msg['cap_edit_author'] . "</td><td>:</td><td>{$cedit}</td></tr>";
                }
                if ($cright && !($cphoto || $cedit)) {
                    $cright = mb_convert_encoding($cright, $this->cont['SOURCE_ENCODING'], "auto");
                    $cright = htmlentities($cright, ENT_QUOTES, $this->cont['SOURCE_ENCODING']);
                    $info .= "<tr style=\"vertical-align:top;\"><td>" . $this->msg['cap_author'] . "</td><td>:</td><td>{$cright}</td></tr>";
                }
                $model = trim(@$exif["IFD0"]["Model"]);
                $make = trim(@$exif["IFD0"]["Make"]);
                if ($model) {
                    $model = htmlentities($model, ENT_QUOTES, $this->cont['SOURCE_ENCODING']);
                    $make = htmlentities($make, ENT_QUOTES, $this->cont['SOURCE_ENCODING']);
                    $info .= "<tr style=\"vertical-align:top;\"><td>" . $this->msg['cap_model'] . "</td><td>:</td><td>{$model}" . ($make ? " ({$make})" : "") . "</td></tr>";
                }
                if (@$exif["GPS"]) {
                    $lar = @$exif["GPS"]["GPSLatitudeRef"];
                    $lad = $this->ratstr2num(@$exif["GPS"]["GPSLatitude"][0]);
                    $lam = $this->ratstr2num(@$exif["GPS"]["GPSLatitude"][1]);
                    $las = $this->ratstr2num(@$exif["GPS"]["GPSLatitude"][2]);
                    list($lad, $lam, $las) = $this->dms2dms($lad, $lam, $las);
                    $lasm = round($las, 2);
                    $lor = @$exif["GPS"]["GPSLongitudeRef"];
                    $lod = $this->ratstr2num(@$exif["GPS"]["GPSLongitude"][0]);
                    $lom = $this->ratstr2num(@$exif["GPS"]["GPSLongitude"][1]);
                    $los = $this->ratstr2num(@$exif["GPS"]["GPSLongitude"][2]);
                    list($lod, $lom, $los) = $this->dms2dms($lod, $lom, $los);
                    $losm = round($los, 2);
                    if ($datum = @$exif["GPS"]["GPSMapDatum"]) {
                        $datum = htmlentities($datum, ENT_QUOTES, $this->cont['SOURCE_ENCODING']);
                        $edatum = "({$datum})";
                    }
                    if (!$params['nokash']) {
                        $lml = "<a href=\"http://lml.kashmir3d.com/getlml?" . $this->MakeLMLURL($lar, $lad, $lam, $las, $lor, $lod, $lom, $los, $datum) . "&amp;icon=915001&amp;name={$aname}&amp;url=http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}" . rawurlencode($url) . "\"><img src=\"" . $this->config['KASH_ICON'] . "\" alt=\"kashmir3d\" /></a>";
                    }
                    if (!$params['nomapi']) {
                        $mpi = $this->MakeMapionURL($lar, $lad, $lam, $las, $lor, $lod, $lom, $los, $datum);
                        if ($mpi) {
                            $mpi = "<a href=\"http://www.mapion.co.jp/c/f?scl=250000&amp;pnf=1&amp;uc=1&amp;grp=all&amp;size=500,500&amp;{$mpi}\"><img width=\"15\" height=\"15\" src=\"" . $this->config['MAPI_ICON'] . "\" alt=\"mapion\" /></a>";
                        }
                    }
                    $info .= <<<EOD
<tr style="vertical-align:top;"><td style="white-space:nowrap;">{$this->msg['cap_location']}</td><td>:</td><td>{$lar}{$lad}'{$lam}'{$lasm}"-{$lor}{$lod}'{$lom}'{$losm}"{$edatum}</td></tr><tr><td></td><td></td><td>{$lml} {$mpi}</td></tr>
EOD;
                }
                if ($ucom = trim(@$exif["COMPUTED"]["UserComment"])) {
                    $ucom = mb_convert_encoding($ucom, $this->cont['SOURCE_ENCODING'], "auto");
                    $ucom = "<p>" . htmlentities("{$ucom}", ENT_QUOTES, $this->cont['SOURCE_ENCODING']) . "</p>";
                    $ucom = str_replace("\r\n", "</p><p>", "{$ucom}");
                    $ucom = str_replace("\r", "</p><p>", "{$ucom}");
                    $ucom = str_replace("\n", "</p><p>", "{$ucom}");
                    $ucom = str_replace("</p><p></p><p>", "</p><p>", "{$ucom}");
                    $ucom = str_replace("</p><p></p><p>", "</p><p>", "{$ucom}");
                }
                if ($params['ucomedit'] && is_array($exif["COMPUTED"]) && array_key_exists('UserComment', $exif["COMPUTED"])) {
                    $attachObj = new XpWikiAttachFile($this->xpwiki, $page, $aname);
                    if ($attachObj->is_owner()) {
                        $script = $this->func->get_script_uri();
                        $ucom .= <<<EOD
<form action="{$script}" method="post">
<div style="text-align:right;margin:0px 4px 4px 0px;"><input type="hidden" name="plugin" value="ucomedit" />
<input type="hidden" name="refer"  value="{$page}" />
<input type="hidden" name="target" value="{$aname}" />
<input type="submit" name="mode" value="edit" /></div>
</form>
EOD;
                    }
                }
                $sz = @$exif['FILE']['FileSize'];
            }
            if ($sz > 1024 * 10) {
                $sz = (int) ($sz / 1024) . "KB";
            } else {
                $sz = $sz . "Bytes";
            }
            $sztype = $eh > $ew ? "height" : "width";
            if ($this->config['THUMB_USE']) {
                $img = $this->func->do_plugin_inline('ref', $page . '/' . $aname . ',mh:' . $this->config['DEFAULT_MH'] . ',mw:' . $this->config['DEFAULT_MW']);
            }
            $img = "<a href=\"{$url}\">" . ($params['noimg'] ? "{$aname}</a>" : ($this->config['THUMB_USE'] ? $img . '</a>' : "<img {$sztype}=\"" . $this->config['THUMB_WSIDE_LEN'] . "\" src=\"{$url}\" /></a>"));
            $params['_body'] .= ($cnt % $colmn == 0 ? "<tr class=\"style_td\">" : '') . "<td align=\"center\">{$img}" . ($params['noimg'] ? '' : "<br />{$aname}") . "<br />{$ew}x{$eh}<br />({$sz})</td>" . ($exif_extension ? "<td>" . ($info ? "<table summary=\"SubInfo\" style=\"border-spacing:0px 0px;\">{$info}</table>" : '') . "</td><td style=\"text-indent:1em;\">{$ucom}</td>" : '') . ($colmn - $cnt % $colmn == 1 ? "</tr>" : '');
            $cnt++;
        }
        $params['_body'] .= ($cnt % $colmn ? "</tr>" : '') . '</table>';
        return $params;
    }
Ejemplo n.º 4
0
 function attach_db_init()
 {
     //	global $xoopsDB,$vars,$post,$get;
     if (!$this->func->exist_plugin('attach')) {
         return;
     }
     $attach = $this->func->get_plugin_instance('attach');
     if (!$attach) {
         return;
     }
     if ($dir = @opendir($this->cont['UPLOAD_DIR'])) {
         // 処理済ファイルリストデーター
         $work = $this->cont['CACHE_DIR'] . "dbsync_a.dat";
         $domix = $dones = array();
         $done = 0;
         if (is_file($work)) {
             $dones = unserialize(file_get_contents($work));
             if (!isset($dones[1])) {
                 $dones[1] = array();
             }
             $docnt = count($dones[1]);
             $domix = array_merge($dones[0], $dones[1]);
             $done = count($domix);
         }
         if ($done) {
             echo "<div style=\"font-size:14px;\"><b>DB '" . $this->root->mydirname . "_attach' Already converted {$docnt} pages.</b></div>";
         } else {
             $query = "DELETE FROM " . $this->db->prefix($this->root->mydirname . "_attach");
             if (!($result = $this->db->queryF($query))) {
                 echo 'SQL Error: ' . $query . '<br />';
             }
         }
         echo "<div style=\"font-size:14px;\"><b>DB '" . $this->root->mydirname . "_attach' Now converting... </b>( * = 10 Pages)<hr>";
         $counter = 0;
         $page_pattern = '(?:[0-9A-F]{2})+';
         $age_pattern = '(?:\\.([0-9]+))?';
         $pattern = "/^({$page_pattern})_((?:[0-9A-F]{2})+){$age_pattern}\$/";
         $files = array();
         while ($file = readdir($dir)) {
             $files[] = $file;
         }
         foreach (array_diff($files, $domix) as $file) {
             $matches = array();
             if (!preg_match($pattern, $file, $matches)) {
                 $dones[0][] = $file;
                 continue;
             }
             $page = $this->func->decode($matches[1]);
             $name = $this->func->decode($matches[2]);
             $age = array_key_exists(3, $matches) ? $matches[3] : 0;
             // サムネイルは除外
             if (preg_match("/^\\d\\d?%/", $name)) {
                 $dones[0][] = $file;
                 continue;
             }
             $obj = new XpWikiAttachFile($this->xpwiki, $page, $name, $age);
             $obj->getstatus();
             $obj->status['md5'] = md5_file($obj->filename);
             $obj->putstatus();
             $data['pgid'] = $this->func->get_pgid_by_name($page);
             $data['name'] = $name;
             $data['mtime'] = $obj->time;
             $data['size'] = $obj->size;
             $data['type'] = $obj->type;
             $data['status'] = $obj->status;
             $data['status']['age'] = $age;
             // ページが存在しない
             if (!$data['pgid']) {
                 $dones[0][] = $file;
                 continue;
             }
             if ($this->func->attach_db_write($data, "insert")) {
                 //echo "$page::$name;:$age<br >";
                 $counter++;
                 $dones[1][] = $file;
                 if ($counter / 10 == floor($counter / 10)) {
                     echo "*";
                 }
                 if ($counter / 100 == floor($counter / 100)) {
                     echo " ( Done " . $counter . " Files !)<br />";
                 }
             } else {
                 $dones[0][] = $file;
             }
             if ($this->check_time_limit()) {
                 // 処理済ファイルリスト保存
                 if ($fp = fopen($work, "wb")) {
                     fputs($fp, serialize($dones));
                     fclose($fp);
                 }
                 closedir($dir);
                 $this->plugin_dbsync_next_do();
             }
         }
         closedir($dir);
         echo " ( Done " . $counter . " Files !)<hr />";
         echo "</div>";
         @unlink($work);
     }
     $this->root->post['attach'] = "";
 }
Ejemplo n.º 5
0
 function get_attachstatus($file)
 {
     if (is_array($file)) {
         $page = $file['page'];
         $name = $file['name'];
         $age = $file['age'];
     } else {
         $file = basename($file);
         $pattern = "/^((?:[0-9A-F]{2})+)_((?:[0-9A-F]{2})+)(?:\\.([0-9]+))?\$/";
         if (preg_match($pattern, $file, $matches)) {
             $page = $this->decode($matches[1]);
             $name = $this->decode($matches[2]);
             $age = isset($matches[3]) ? $matches[3] : 0;
         } else {
             return array();
         }
     }
     $obj = new XpWikiAttachFile($this->xpwiki, $page, $name, $age);
     if ($obj->getstatus()) {
         $status = $obj->status;
     } else {
         $status = array();
     }
     $obj = NULL;
     unset($obj);
     return $status;
 }