MyBB Community Forums

Full Version: [Page Manager] Share your custom pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
(2016-01-01, 09:43 PM)leroymcqy Wrote: [ -> ]
(2010-01-24, 07:52 PM)querschlaeger Wrote: [ -> ]Okay, here is a useful page: Usermap (powered by Google Maps)!
It will display all of your users who provide there location in the default MyBB custom profile field in a nice Google Map!

You need a Google Maps API key for your website, get it here:  http://code.google.com/apis/maps/signup.html

Edit the custom page and you will see the point to type in the key (line 3).

First run of the page will take some time to create the location cache. Don't worry about it and don't abort the page loading.

By the way: I developed a plugin called Page Converter, you will find it here: http://mods.mybboard.net/view/page-converter
This plugin allows you to convert custom pages of various page plugins into Page Manager pages. Cool

Seems like this does not work anymore. I have entered what was required to enter.

i am using 1.8 tho.

I am using mybb 1.8.7 and it is working fine for me. You must of did somethign wrong as it DOES work.


You can bypass page manager plugin too and make custom pages without pagemanager plugin. I dont know if this has been told on this thread before, but i am not reading all these pages to find out.


with custom_page.php file in the root directory the content being
<?php
//from here https://community.mybb.com/thread-116225.html
//template in ACP -> templates -> ungrouped tempaltes -> template_name
define('IN_MYBB', 1); require "./global.php";

add_breadcrumb("Title here", "custom_page.php");

eval("\$html = \"".$templates->get("template_name")."\";");

output_page($html);

?>




You have to create the html for the page in the templates. For this specific example it is 
<html>
<head>
<title>Your title here</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="1" cellpadding="4" class="tborder">
<tr>
<td class="thead"><span class="smalltext"><strong>Your title here.</strong></span></td>
</tr>
<tr>
<td class="trow1">

Add here your custom messages.

</td></tr></table>
{$footer}
</body>
</html>
and its located in ACP -> Tempaltes and Style -> Tempaltes -> Default Templates -> Ungrouped Templates 
Create a new templace called
 
template_name
and insert the previous html into it.
Building from what others posted here, I created a little page that displays the user titles along with the number of "stars" or whatever images you use for their rank. 

Example: https://www.linguisten.de/userlevels.php

[attachment=40453]
(2010-03-08, 04:34 PM)EviLito Wrote: [ -> ]Ok this is how I say thanks for this plugin ^^

Everybody may have this nice ban list:

[...] 


I converted that to a complementary page listing warned users: 

[attachment=40498]
(2014-01-17, 01:58 AM)SpongeGod Wrote: [ -> ]Anyone made a showgroups.php because that is something I really need lol.

This is the groups page i made (based on others' work): 
[attachment=41175]

See it in action here: https://www.linguisten.de/misc.php?page=getgroups
Is there anyone who can make usermap working on MyBB 1.8? Thx
(2018-11-02, 07:08 PM)Eldenroot Wrote: [ -> ]Is there anyone who can make usermap working on MyBB 1.8? Thx

[attachment=41636] ?? Wink  * not my area of knowledge truly, but the few minor edits appeared to be working for me for the few free "Map loads quota limit" though my key is limited and I do not want to signup for google $$$ services... even with the offer of "$300 credit for free over 12 months" lol

You need to get an api key visit here and select the start button

https://cloud.google.com/maps-platform/

And add your new api key into the api key on usermap page edit


Also user profile location format must be in this format for example: "Denver, Colorado, United States"

Examples on mybb 1.8.20:

[Image: 3166q82.png]

[Image: 33duwk9.png]

** Note: currently the only issue I get in console with this edit is "You have exceeded your request quota for this API" because my quota limit is "1" if I refuse to pay or agree to the trial...., but for the 1 day quota..., it loaded fine with this edit.

Further note: I primarily just made sure it loads the map and such....,  But, I also did not look at the other functions and any of that may or may not need to still be edited or fixed???? but alas, I don't use this nor have I ever so you most likely will know more about all of this than I.

Anyhoo, since you clearly have more of an interest in this and most likely have said key with higher quota limit perhaps you can continue further with this. Happy editing! Smile

<?php
# MyBB Page Manager Page - Usermap
# vintagedaddyo

$key = '';
$location = 'United States';
$zoom = 4;
$fid = 1;
$datacache = './cache/coords';

global $db, $headerinclude, $header, $theme, $footer, $cache, $templates, $mybb;

if(!$mybb->usergroup['canviewprofiles'])
{
    error_no_permission();
}

require_once MYBB_ROOT.'inc/class_xml.php';
require_once MYBB_ROOT.'inc/functions_image.php';

$contents = fetch_remote_file('https://maps.googleapis.com/maps/api/geocode/xml?address=' . rawurlencode($location).'&key=' . $key . '&sensor=false');
$parser = new XMLParser($contents);
$tree = $parser->get_tree();

if($tree['GeocodeResponse']['result']['geometry']['location'])
{
    $lat = $tree['GeocodeResponse']['result']['geometry']['location']['lat']['value'];
    $lng = $tree['GeocodeResponse']['result']['geometry']['location']['lng']['value'];
       $location = array($lng, $lat);
}
else
{
    $location = array(0, 0);
    $zoom = 2;
}

if(!file_exists($datacache) || time()-filemtime($datacache) > 82800 || ($mybb->usergroup['cancp'] && intval($mybb->input['update']) == 1))
{
    $usergroups_cache = $cache->read('usergroups');
    $query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts', 'order_dir' => 'DESC'));
    while($usertitle = $db->fetch_array($query))
    {
        $usertitles_cache[$usertitle['posts']] = $usertitle;
    }
    $query = $db->query("
        SELECT u.*, f.*
        FROM ".TABLE_PREFIX."users u
        LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
        WHERE f.fid" . $fid . " != ''
        AND u.usergroup NOT IN (5, 7)
    ");

    $usercache = array();

    while($user = $db->fetch_array($query) )
    {
        $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);

        $user['profilelink'] = build_profile_link($user['username'], $user['uid']);

        if(!$user['displaygroup'])
        {
            $user['displaygroup'] = $user['usergroup'];
        }
        $usergroup = $usergroups_cache[$user['displaygroup']];
        
        if(!empty($usergroup['image']))
        {
            if(!empty($mybb->user['language']))
            {
                $language = $mybb->user['language'];
            }
            else
            {
                $language = $mybb->settings['bblanguage'];
            }
            $usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']);
            $usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']);
            $usergroup['groupimage'] = '<img src="' . $usergroup['image'] . '" alt="' . $usergroup['title'] . '" title="' . $usergroup['title'] . '" />';
        }

        $has_custom_title = 0;
        if(trim($user['usertitle']) != "")
        {
            $has_custom_title = 1;
        }

        if($usergroup['usertitle'] != "" && !$has_custom_title)
        {
            $user['usertitle'] = $usergroup['usertitle'];
        }
        elseif(is_array($usertitles_cache) && !$usergroup['usertitle'])
        {
            foreach($usertitles_cache as $posts => $titleinfo)
            {
                if($user['postnum'] >= $posts)
                {
                    if(!$has_custom_title)
                    {
                        $user['usertitle'] = $titleinfo['title'];
                    }
                    $user['stars'] = $titleinfo['stars'];
                    $user['starimage'] = $titleinfo['starimage'];
                    break;
                }
            }
        }

        if($usergroup['stars'])
        {
            $user['stars'] = $usergroup['stars'];
        }

        if(!$user['starimage'])
        {
            $user['starimage'] = $usergroup['starimage'];
        }
        $user['starimage'] = str_replace("{theme}", $theme['imgdir'], $user['starimage']);

        for($i = 0; $i < $user['stars']; ++$i)
        {
            $user['userstars'] .= "<img src=\"".$user['starimage']."\" border=\"0\" alt=\"*\" />";
        }

        if($user['userstars'] && $usergroup['groupimage'])
        {
            $user['userstars'] = "<br />".$user['userstars'];
        }

        if($user['avatar'] != '')
        {
            $user['avatar'] = htmlspecialchars_uni($user['avatar']);
            $avatar_dimensions = explode("|", $user['avatardimensions']);
            
            if($avatar_dimensions[0] && $avatar_dimensions[1])
            {
                list($max_width, $max_height) = explode("x", my_strtolower($mybb->settings['memberlistmaxavatarsize']));
                if($avatar_dimensions[0] > $max_width || $avatar_dimensions[1] > $max_height)
                {
                    $scaled_dimensions = scale_image($avatar_dimensions[0], $avatar_dimensions[1], $max_width, $max_height);
                    $avatar_width_height = "width=\"{$scaled_dimensions['width']}\" height=\"{$scaled_dimensions['height']}\"";
                }
                else
                {
                    $avatar_width_height = "width=\"{$avatar_dimensions[0]}\" height=\"{$avatar_dimensions[1]}\"";    
                }
            }

            $user['avatar'] = '<img src="' . $user['avatar'] . '" alt="" ' . $avatar_width_height . ' />';
        }
        else
        {
            $user['avatar'] = "";
        }

        $html = '<table><tr><td>' . $user['avatar'] . '</td><td>' . $user['profilelink'] . '<br /><span class="smalltext">' . $user['usertitle'] . '<br />' . $usergroup['groupimage'] . $user['userstars'] . '</span></td></tr></table>';

        $home = strtolower($user['fid' . $fid]);
        if(isset($usercache[$home]) )
        {
            $usercache[$home] .= '<hr>'.$html;
        }
        else
        {
            $usercache[$home] = $html;
        }
    }

    $coordscache = array();


    foreach($usercache as $index => $value)
    {
        $contents = fetch_remote_file('https://maps.googleapis.com/maps/api/geocode/xml?address=' . rawurlencode($index).'&key=' . $key . '&sensor=false');
        $parser = new XMLParser($contents);
        $tree = $parser->get_tree();

        sleep(1);
        

        if($tree['GeocodeResponse']['result']['geometry']['location'])
        {
            $lat = $tree['GeocodeResponse']['result']['geometry']['location']['lat']['value'];
            $lng = $tree['GeocodeResponse']['result']['geometry']['location']['lng']['value'];
            $loc = $lng.",".$lat.",0";

            if(isset($coordscache[$loc]))
            {
                $coordscache[$loc] .= '<hr>'.$value;
            }
            else
            {
                $coordscache[$loc] = $value;
            }

        }
    }

    file_put_contents($datacache, serialize($coordscache));
}
else
{
    $coordscache = unserialize(file_get_contents($datacache));
}

$run = 1;

foreach($coordscache as $index => $value)
{
    $point = explode(',', $index);
    $output .= '

        var point' . $run . ' = new google.maps.LatLng(' . $point[1] . ',' . $point[0] . ');

        var marker' . $run . ' = new google.maps.Marker({
                        position: point' . $run . ', 
                        map: map,
                        title: ""
                        });

        var infowindow' . $run . ' = new google.maps.InfoWindow({
                        content: "' . str_replace('"', "'", $value) . '"
                        });

        google.maps.event.addListener(marker' . $run . ', "click", function() {
            infowindow' . $run . '.open(map, marker' . $run . ')
        });

 
    ';
    $run++;
}


$template = '<html>
<head>
<title>' . $pages['name'] . '</title>
{$headerinclude}
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map_canvas { height: 100%; }
    </style>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key=' . $key . '">
    </script>
    <script type="text/javascript">
      function initialize() {
        var myOptions = {
          center: new google.maps.LatLng(' . $location[1] . ',' . $location[0] . '),
          zoom: ' . $zoom . ',
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    {$output}
      }
    </script>
</head>
 <body onload="initialize()">
{$header}
<table border="0" cellspacing="' . $theme['borderwidth'] . '" cellpadding="' . $theme['tablespace'] . '" class="tborder">
<thead>
<tr>
<td class="thead">
<strong>' . $pages['name'] . '</strong>
</td>
</tr>
</thead>
<tbody>
<tr>
<td class="trow1" style="padding: 0;"><div id="map_canvas" style="width:100%; height:500px"></div></td>
</tr>
</tbody>
</table>
<br />
{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>



Update: And since this is a localhost and I have devel generated users there were no user locations set in profiles so I manually added a few more in such a format for example: "Denver, Colorado, United States" since earlier and then simply updated the cache like so misc.php?page=usermap&update=1 just to show you that it is still working...

[Image: vgpkid.png]


Another note: not sure what version or variant of pagemanager you are using but the particular version I quickly tried was not showing the information correctly in "who's online" and was marking usermap as "Unknown Location" though the page link was accurate, that bugged me to no avail and I simply did not feel like digging into the page manager plugin  for something I don't plan on using myself so a simple plugin solved it for me and my ocd instead, lol.

[attachment=41637]

[Image: 34f1t6s.png]

Page manager I used for this:

https://github.com/vintagedaddyo/MyBB_Pl...agemanager

* but you could ignore version compat on install if not using 1.5.2 or most  likely just edit the provided xml file for whatever page manager version you are using if it is not 1.5.2 and say for example something like 2.1.3 or any other such variant
(2019-03-07, 07:47 AM)linguist Wrote: [ -> ]Is there any way one can use the "last modified" date of Page Manager pages (preferably even in pages using "template") and display it inside the pages? I'd love to have that update automatically and not edit the Date manually any more.

any ideas ?!
(2019-03-15, 09:03 AM)linguist Wrote: [ -> ]
(2019-03-07, 07:47 AM)linguist Wrote: [ -> ]Is there any way one can use the "last modified" date of Page Manager pages (preferably even in pages using "template") and display it inside the pages? I'd love to have that update automatically and not edit the Date manually any more.

any ideas ?!

Not my area of knowledge nor am I very familar with pagemanager but {$pages[dateline]} might be an area to start looking at perhaps?
Looks good, thanks! :-)
... but doesn't work in pages that are "templates" enabled. Sad
Any suggestions?
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49