Example #1
0
function plugin_amazon_convert()
{
    global $script, $vars, $asin, $asin_all;
    $qm = get_qm();
    if (func_num_args() > 3) {
        if (PKWK_READONLY) {
            return '';
        }
        // Show nothing
        return '#amazon([ASIN-number][,left|,right]' . '[,book-title|,image|,delimage|,deltitle|,delete])';
    } else {
        if (func_num_args() == 0) {
            // レビュー作成
            if (PKWK_READONLY) {
                return '';
            }
            // Show nothing
            $s_page = htmlspecialchars($vars['page']);
            if ($s_page == '') {
                $s_page = isset($vars['refer']) ? $vars['refer'] : '';
            }
            $ret = <<<EOD
<form action="{$script}" method="post">
 <div>
  <input type="hidden" name="plugin" value="amazon" />
  <input type="hidden" name="refer" value="{$s_page}" />
  ASIN:
  <input type="text" name="asin" size="30" value="" />
  <input type="submit" value="{$qm->m['plg_amazon']['btn_review']}" /> {$qm->m['plg_amazon']['notice']}
 </div>
</form>
EOD;
            return $ret;
        }
    }
    $aryargs = func_get_args();
    $align = strtolower($aryargs[1]);
    if ($align == 'clear') {
        return '<div style="clear:both"></div>';
    }
    // 改行挿入
    if ($align != 'left') {
        $align = 'right';
    }
    // 配置決定
    $asin_all = htmlspecialchars($aryargs[0]);
    // for XSS
    if (is_asin() == FALSE && $align != 'clear') {
        return FALSE;
    }
    if ($aryargs[2] != '') {
        // タイトル指定
        $title = $alt = htmlspecialchars($aryargs[2]);
        // for XSS
        if ($alt == 'image') {
            $alt = plugin_amazon_get_asin_title();
            if ($alt == '') {
                return FALSE;
            }
            $title = '';
        } else {
            if ($alt == 'delimage') {
                if (unlink(CACHE_DIR . 'ASIN' . $asin . '.jpg')) {
                    return $qm->replace('plg_amazon.img_deleted', $asin);
                } else {
                    return $qm->replace('plg_amazon.err_cannot_delete_img', $asin);
                }
            } elseif ($alt == 'deltitle') {
                if (unlink(CACHE_DIR . 'ASIN' . $asin . '.tit')) {
                    return $qm->replace('plg_amazon.title_deleted', $asin);
                } else {
                    return $qm->replace('plg_amazon.err_cannot_delete_title', $asin);
                }
            } elseif ($alt == 'delete') {
                if (unlink(CACHE_DIR . 'ASIN' . $asin . '.jpg') && unlink(CACHE_DIR . 'ASIN' . $asin . '.tit')) {
                    return $qm->replace('plg_amazon.both_deleted', $asin);
                } else {
                    return $qm->replace('plg_amazon.err_cannot_delete', $asin);
                }
            }
        }
    } else {
        // タイトル自動取得
        $alt = $title = plugin_amazon_get_asin_title();
        if ($alt == '') {
            return FALSE;
        }
    }
    return plugin_amazon_print_object($align, $alt, $title);
}
Example #2
0
function plugin_amazon_convert()
{
    global $script, $vars, $asin, $asin_all;
    if (func_num_args() > 3) {
        if (PKWK_READONLY) {
            return '';
        }
        // Show nothing
        return '#amazon([ASIN-number][,left|,right]' . '[,book-title|,image|,delimage|,deltitle|,delete])';
    } else {
        if (func_num_args() == 0) {
            // レビュー作成
            if (PKWK_READONLY) {
                return '';
            }
            // Show nothing
            $s_page = htmlsc($vars['page']);
            if ($s_page == '') {
                $s_page = isset($vars['refer']) ? $vars['refer'] : '';
            }
            $ret = <<<EOD
<form action="{$script}" method="post">
 <div>
  <input type="hidden" name="plugin" value="amazon" />
  <input type="hidden" name="refer" value="{$s_page}" />
  ASIN:
  <input type="text" name="asin" size="30" value="" />
  <input type="submit" value="レビュー編集" /> (ISBN 10 桁 or ASIN 12 桁)
 </div>
</form>
EOD;
            return $ret;
        }
    }
    $aryargs = func_get_args();
    $align = strtolower($aryargs[1]);
    if ($align == 'clear') {
        return '<div style="clear:both"></div>';
    }
    // 改行挿入
    if ($align != 'left') {
        $align = 'right';
    }
    // 配置決定
    $asin_all = htmlsc($aryargs[0]);
    // for XSS
    if (is_asin() == FALSE && $align != 'clear') {
        return FALSE;
    }
    if ($aryargs[2] != '') {
        // タイトル指定
        $title = $alt = htmlsc($aryargs[2]);
        // for XSS
        if ($alt == 'image') {
            $alt = plugin_amazon_get_asin_title();
            if ($alt == '') {
                return FALSE;
            }
            $title = '';
        } else {
            if ($alt == 'delimage') {
                if (unlink(CACHE_DIR . 'ASIN' . $asin . '.jpg')) {
                    return 'Image of ' . $asin . ' deleted...';
                } else {
                    return 'Image of ' . $asin . ' NOT DELETED...';
                }
            } elseif ($alt == 'deltitle') {
                if (unlink(CACHE_DIR . 'ASIN' . $asin . '.tit')) {
                    return 'Title of ' . $asin . ' deleted...';
                } else {
                    return 'Title of ' . $asin . ' NOT DELETED...';
                }
            } elseif ($alt == 'delete') {
                if (unlink(CACHE_DIR . 'ASIN' . $asin . '.jpg') && unlink(CACHE_DIR . 'ASIN' . $asin . '.tit')) {
                    return 'Title and Image of ' . $asin . ' deleted...';
                } else {
                    return 'Title and Image of ' . $asin . ' NOT DELETED...';
                }
            }
        }
    } else {
        // タイトル自動取得
        $alt = $title = plugin_amazon_get_asin_title();
        if ($alt == '') {
            return FALSE;
        }
    }
    return plugin_amazon_print_object($align, $alt, $title);
}