コード例 #1
0
function wppa_kickoff()
{
    global $wppa;
    global $wppa_lang;
    global $wppa_api_version;
    global $wppa_init_js_data;
    global $wppa_dynamic_css_data;
    // init.css failed?
    if ($wppa_dynamic_css_data) {
        echo $wppa_dynamic_css_data;
    }
    // init.js failed?
    if ($wppa_init_js_data) {
        echo $wppa_init_js_data;
    }
    // Patch for chrome?
    if (isset($_SERVER["HTTP_USER_AGENT"]) && isset($_SERVER["HTTP_USER_AGENT"])) {
        echo '
		
<!-- WPPA+ Kickoff -->
<!-- Browser detected = ' . wppa_decode_uri_component(strip_tags($_SERVER["HTTP_USER_AGENT"])) . ' -->';
        if (strstr($_SERVER["HTTP_USER_AGENT"], 'Chrome') && wppa_switch('wppa_ovl_chrome_at_top')) {
            echo '
<style type="text/css">
	#wppa-overlay-ic { padding-top: 5px !important; } 
	#wppa-overlay-qt-txt, #wppa-overlay-qt-img { top: 5px !important; }
</style>';
        }
    }
    // Inline styles?
    if (wppa_switch('wppa_inline_css')) {
        echo '
<!-- WPPA+ Custom styles -->
<style type="text/css" >
' . wppa_opt('wppa_custom_style') . '
</style>';
    }
    // Pinterest js
    if ((wppa_switch('wppa_share_on') || wppa_switch('wppa_share_on_widget')) && wppa_switch('wppa_share_pinterest')) {
        echo '
<!-- Pinterest share -->
<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>';
    }
    if (isset($wppa['debug']) && $wppa['debug']) {
        error_reporting($wppa['debug']);
        add_action('wp_footer', 'wppa_phpinfo');
        add_action('wp_footer', 'wppa_errorlog');
        echo '
<script type="text/javascript" >
	wppaDebug = true;
</script>';
    }
    $wppa['rendering_enabled'] = true;
    echo '
<!-- Rendering enabled -->
<!-- /WPPA Kickoff -->

	';
}
コード例 #2
0
function wppa_get_album_id_by_name($xname, $report_dups = false)
{
    global $wpdb;
    global $allalbums;
    if (wppa_is_int($xname)) {
        return $xname;
        // Already numeric
    }
    if (wppa_is_enum($xname)) {
        return $xname;
        // Is enumeration
    }
    $name = wppa_decode_uri_component($xname);
    $name = str_replace('\'', '%', $name);
    // A trick for single quotes
    $name = str_replace('"', '%', $name);
    // A trick for double quotes
    $name = stripslashes($name);
    $albs = $wpdb->get_results("SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `name` LIKE '%" . $name . "%'", ARRAY_A);
    if ($albs) {
        if (count($albs == 1)) {
            wppa_dbg_msg('Alb ' . $albs[0]['id'], ' found for ' . $xname);
            $aid = $albs[0]['id'];
        } else {
            wppa_dbg_msg('Dups found for ' . $xname);
            if ($report_dups) {
                $aid = false;
            } else {
                $aid = $albs[0]['id'];
            }
        }
    } else {
        $aid = false;
    }
    if ($aid) {
        wppa_dbg_msg('Aid ' . $aid . ' found for ' . $name);
    } else {
        wppa_dbg_msg('No aid found for ' . $name);
    }
    return $aid;
}
コード例 #3
0
function wppa_test_for_search()
{
    global $wppa;
    if (isset($_REQUEST['wppa-searchstring'])) {
        // wppa+ search
        $str = $_REQUEST['wppa-searchstring'];
    } elseif (isset($_REQUEST['searchstring'])) {
        // wppa+ search
        $str = $_REQUEST['searchstring'];
    } elseif (isset($_REQUEST['s'])) {
        // wp search
        $str = $_REQUEST['s'];
    } else {
        // Not search
        $str = '';
    }
    // Sanitize
    $ignore = array('"', "'", '\\', '>', '<', ':', ';', '!', '?', '=', '_', '[', ']', '(', ')', '{', '}');
    $str = wppa_decode_uri_component($str);
    $str = str_replace($ignore, ' ', $str);
    $str = strip_tags($str);
    $str = stripslashes($str);
    $str = trim($str);
    $inter = chr(226) . chr(136) . chr(169);
    $union = chr(226) . chr(136) . chr(170);
    $str = str_replace($inter, ' ', $str);
    $str = str_replace($union, ',', $str);
    while (strpos($str, '  ') !== false) {
        $str = str_replace('  ', ' ', $str);
    }
    // reduce spaces
    while (strpos($str, ',,') !== false) {
        $str = str_replace(',,', ',', $str);
    }
    // reduce commas
    while (strpos($str, ', ') !== false) {
        $str = str_replace(', ', ',', $str);
    }
    // trim commas
    while (strpos($str, ' ,') !== false) {
        $str = str_replace(' ,', ',', $str);
    }
    // trim commas
    // Did we do wppa_initialize_runtime() ?
    if (is_array($wppa)) {
        $wppa['searchstring'] = $str;
        if ($wppa['searchstring'] && $wppa['occur'] == '1' && !$wppa['in_widget']) {
            $wppa['src'] = true;
        } else {
            $wppa['src'] = false;
        }
        $result = $str;
    } else {
        $result = $str;
    }
    if ($wppa['src']) {
        switch (wppa_opt('wppa_search_display_type')) {
            case 'slide':
                $wppa['is_slide'] = '1';
                break;
            case 'slideonly':
                $wppa['is_slide'] = '1';
                $wppa['is_slideonly'] = '1';
                break;
            default:
                break;
        }
    }
    return $result;
}
コード例 #4
0
function wppa_get_album_id_by_name($xname, $report_dups = false)
{
    global $wpdb;
    global $allalbums;
    if (wppa_is_int($xname)) {
        return $xname;
        // Already numeric
    }
    if (wppa_is_enum($xname)) {
        return $xname;
        // Is enumeration
    }
    $name = wppa_decode_uri_component($xname);
    $name = str_replace('\'', '%', $name);
    // A trick for single quotes
    $name = str_replace('"', '%', $name);
    // A trick for double quotes
    $name = stripslashes($name);
    $query = "SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `name` LIKE '%" . $name . "%'";
    $albs = $wpdb->get_results($query, ARRAY_A);
    if ($albs) {
        if (count($albs) == 1) {
            wppa_dbg_msg('Alb ' . $albs[0]['id'], ' found for ' . $xname);
            $aid = $albs[0]['id'];
        } else {
            wppa_dbg_msg('Dups found for ' . $xname);
            if ($report_dups == 'report_dups') {
                $aid = false;
            } elseif ($report_dups == 'return_dups') {
                $aid = '';
                foreach ($albs as $alb) {
                    $aid .= $alb['id'] . '.';
                }
                $aid = rtrim($aid, '.');
            } else {
                // Find the best match
                foreach ($albs as $alb) {
                    $aname = __($alb['name']);
                    // Possibly qTranslate translated
                    $aname = str_replace('\'', '%', $aname);
                    // A trick for single quotes
                    $aname = str_replace('"', '%', $aname);
                    // A trick for double quotes
                    $aname = stripslashes($aname);
                    wppa_dbg_msg('Testing ' . $aname . ' for ' . $name . ' (get_album_id_by_name)');
                    if (strcasecmp($aname, $name) == 0) {
                        $aid = $alb['id'];
                    }
                }
                // No perfect match, take the first 'like' option
                if (!$aid) {
                    $aid = $albs[0]['id'];
                }
            }
        }
    } else {
        $aid = false;
    }
    if ($aid) {
        wppa_dbg_msg('Aid ' . $aid . ' found for ' . $name);
    } else {
        wppa_dbg_msg('No aid found for ' . $name);
    }
    return $aid;
}