MyBB Community Forums

Full Version: Call {$lang->change_avatar} from other page.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey all,

I tried to insert a variable at first in the textbox [avatarurl] using java script. But i couldnt get that part to work.
So now i wonder if anybody knows the code for the [change the avatar] on a differnt site page. So not underneath UserCP but a custom page.

I call this custom page from the userCP_avatar template using:

<script type="text/javascript">
function newPopup(url) {
	popupWindow =
<a href="JavaScript:newPopup('(url)');">Armory Avatar</a></td>

That opens this page in a popup window:

if (!isset($_POST['submit'])) { 
<!-- The fill in form -->
<title>Armory Avatar</title>
<form method="post" action="<?php echo $PHP_SELF;?>">
Character Name:<input type="text" size="12" maxlength="50" name="cname"><br />
Realm Name:
<select name="rname">
<optgroup label="English Realms">
<option value="aerie-peak">Aerie-Peak</option>
<option value="agamaggan">Agamaggan</option>
<!-- etc etc etc etc -->
</select><br />
<input type="submit" value="submit" name="submit">
} else {  //If form is submitted execute this

	$charname = $_POST["cname"]; //input character name
	$realmname = $_POST["rname"]; //input realm name

	$charurl = urlencode(utf8_encode($charname)); //prepares character name for url usage
	$realmurl = ''.$realmname.'/';  //combines the basic url link with the realm name
	$toon = $realmurl.$charurl; //adds the charactername behind the realm url
	$data = @file_get_contents($toon); //retrieves the data from the armory api
		if ($data) {
			// if armory data is found execute this 

			$obj = json_decode($data); //converts the data from json to be used in the php code 			
			$image = "".$obj->thumbnail;
			(some button to change avatar)
		else { // if armory data is not found execute this  ?>
			<h3>Unable to retrieve character information:</h3><br />
			<img src=''> </img> <br /><br />
			If you see this message it means you probably misspelled your character name or your character is on a realm that is not include in the realm list.<br />
			<b>Make sure you spell it correctly / select a realm which is supported </b><br/>
			If you keep seeing this error and you are 100% sure you spelled everything correctly <a href='mailto:(mail url)'>contact the forum administrator</a> <?php

Now what i hope to achieve is grab:

$image = "".$obj->thumbnail;

And add a button below this. This changes the avatar using the provide url above (in the variable). Anybody got any good suggestions? Or code how to change the avatar.

Any help would be welcome.