PDA

View Full Version : Mys 1.3.1 Group sort


StarGirl
05-05-2012, 03:45 AM
This is a group sort mod. Create groups at myadopts.php, move pets in from their management page, navigate through groups through the drop down.

Screenshots: [NOTE: The way that the pets are shown in the screenshots is not how it will look on your site. It is just the way I want them to be displayed on my site.]

Screenshot1 (http://i50.tinypic.com/257lr3t.png)
Screenshot2 (http://i49.tinypic.com/34ninu9.png)


For a preview, check out my site at http://myxiplanet.x10.mx/stable.php (http://myxiplanet.x10.mx/mygroups.php).

1. Create a 'adopts_pet_groups' table
Since I have no idea how to do it with a query, go to PhpMyAdmin then go to your database, select the 'Operations' tab then create a table called adopts_pet_groups with 3 columns, replacing 'adopts_' with your prefix. Then fill in the details like this:
http://i45.tinypic.com/35iqbev.png

2. Create the group row
Go to the {$prefix}owned_adoptables table.. then select the 'structure' tab. Find this and press go:
http://i48.tinypic.com/25qxh5x.png
Then in 'column', put "group", change "type" to "VARCHAR", set "length/values" to 15, set "Default" to "As defined:", "0", and leave all else.

3. Edits
You can close PhpMyAdmin now. Now it's time to edit the files;

In doadopt.php:
At line 60, find:
"imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0));And replace it with
"imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0, "group" => 0));In myadopts.php:
Replace everything with:
<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("css/pagination.css");
include("inc/lang.php");

//***************//
// START SCRIPT //
//***************//

$id = $_GET["id"];
$act = $_GET["act"];
$more = $_GET["more"];
$page = $_GET["page"];
$group = $_GET["group"];
$submit = $_GET["submit"];
$groupname = $_POST["groupname"];

if($isloggedin == "yes"){
if($act == "" and $groupname == ""){
$article_title = "Your Adoptables";
if(!$group == ""){
if(!is_numeric($group)){
$article_title = "No group";
$article_content = "Group does not exist.";
}
else{
$row = $adopts->select("pet_groups", array(), "user='{$loggedinname}' and id='{$group}'")->fetchObject();
if($row->id == $group and $row->user == $loggedinname){
$groupquery = "AND
".constant("PREFIX")."owned_adoptables.group = {$group}";
}
else{
// Invalid group
$article_title = "No group";
$article_content = "Group does not exist.";
}

}
}
else{
$groupquery = "AND
".constant("PREFIX")."owned_adoptables.group = 0";
$selected = "selected";
}

// We need to get all of the user's adoptables from the database and display them...
$query = "SELECT * FROM ".constant("PREFIX")."owned_adoptables,
".constant("PREFIX")."adoptables,
".constant("PREFIX")."levels WHERE ".constant("PREFIX")."owned_adoptables.owner = '{$loggedinname}'
AND ".constant("PREFIX")."adoptables.type = ".constant("PREFIX")."owned_adoptables.type
AND ".constant("PREFIX")."levels.thisislevel = ".constant("PREFIX")."owned_adoptables.currentlevel
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type
{$groupquery}

ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks";
$rowsperpage = 10;
$pagination = new Pagination($adopts, $query, $rowsperpage, "http://".constant("DOMAIN").constant("SCRIPTPATH")."/stable.php?group={$group}");
$pagination->setPage($_GET[page]);
$query = "SELECT * FROM ".constant("PREFIX")."owned_adoptables,
".constant("PREFIX")."adoptables,
".constant("PREFIX")."levels WHERE ".constant("PREFIX")."owned_adoptables.owner = '{$loggedinname}'
AND ".constant("PREFIX")."adoptables.type = ".constant("PREFIX")."owned_adoptables.type
AND ".constant("PREFIX")."levels.thisislevel = ".constant("PREFIX")."owned_adoptables.currentlevel
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type
{$groupquery}
ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks LIMIT {$pagination->getLimit()},{$rowsperpage}";
$stmt = $adopts->query($query);
$groups = ""; // Get groups
$stmt2 = $adopts->select("pet_groups", array(), "user='{$loggedinname}'");
while($row = $stmt2->fetchObject()) {
$id=$row->id;
$name=$row->name;
if($id == $group){
$groups .= "<option value='{$id}' selected>{$name}</option>";
$selected = "";
}
else{
$groups .= "<option value='{$id}'>{$name}</option>";
}
}
$article_content = "
<b>Group:</b><br>
<form method='get' action='myadopts.php'>
<select name='group' id='group'>
<option value='0' {$selected}>Ungrouped</option>
{$groups}
</select><br><input type='submit' value='Go'></form>
<a href='stable.php?act=creategroup'>Create a new group</a>
<br><br><table>
<tr>
<th></th><th>Name and Type</th><th>Image</th><th>Clicks</th>
</tr>";
while($row = $stmt->fetchObject()){
if($row->usealternates == 'yes') $image = $row->alternateimage;
else $image = $row->primaryimage;
if($row->currentlevel == 0) $image = $row->eggimage;
if($image=='') $image = $row->primaryimage;

$article_content .= "<tr>
<td><center><img src='picuploads/{$row->gender}.png'></center></td>
<td><center><em>{$row->name}</em> the {$row->type}</center></td>
<td><center><a href='myadopts.php?act=manage&id={$row->aid}'><img src='{$image}'></a></center></td>
<td><center>{$row->totalclicks}</center></td>
</tr>";
}
$article_content .= "</table><br /><br />{$pagination->showPage()}";
}
elseif($act == "manage"){

// We are managing a specific adoptable
if(!is_numeric($id)){
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
else{
// See if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();

// Check that the adoptable exists for real, or show an error...
if($row->aid == $id){

// The adoptable does exist, so we show the image and junk to the user...
$image = getcurrentimage($id);
$article_title = "Managing {$row->name}";
$article_content = "<img src='{$image}'><br /><br />This page allows you to manage {$row->name}. Click on an option below to change settings.<br /><br />
<b><a href='levelup.php?id={$id}'><img src='templates/icons/add.gif' border=0> Level Up {$row->name}</a><br />
<a href='myadopts.php?act=stats&id={$id}'><img src='templates/icons/stats.gif' border=0> Get Stats for {$row->name}</a><br />
<a href='myadopts.php?act=bbcode&id={$id}'><img src='templates/icons/bbcodes.gif' border=0> Get BBCodes / HTML Codes for {$row->name}</a><br />
<a href='myadopts.php?act=rename&id={$id}'><img src='templates/icons/title.gif' border=0> Rename {$row->name}</a><br />
<a href='myadopts.php?act=trade&id={$id}'><img src='templates/icons/trade.gif' border=0> Change Trade Status {$row->name}</a><br />
<a href='myadopts.php?act=freeze&id={$id}'><img src='templates/icons/freeze.gif' border=0> Freeze or Unfreeze {$row->name}</a><br />
<a href='myadopts.php?act=group&id={$id}'> Group {$row->name}</a><br />
<a href='myadopts.php?act=pound&id={$id}'><img src='templates/icons/delete.gif' border=0> Pound {$row->name}</a></b>";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
} // End the MANAGE action code
elseif($act == "stats"){
// We are getting the stats for the adoptable
// Check that an ID was submitted...
if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
// The adoptable exists, so we show the stats for it...

$image = getcurrentimage($id);
$nextlevelexists = getnextlevelexists($row->type, $row->currentlevel);

// If a higher level exists, get that level's information...

if($nextlevelexists == TRUE){
$nextlevel = $row->currentlevel + 1;

$levels = $adopts->select("levels", array(), "adoptiename='{$row->type}' and thisislevel='{$nextlevel}'")->fetchObject();
$requiredclicks= $levels->requiredclicks; //The adoptable's ID

} // End grab next level info...

// Determine what to show for next level:

if($nextlevelexists == TRUE and $nextlevel != ""){
// See how many more clicks to go
$ctg = $requiredclicks - $row->totalclicks;
$nloutput = "{$nextlevel}<br />Clicks Required for Level Increase: {$ctg}";
}
else $nloutput = "This adoptable is at its maximum level";

$article_title = "{$row->name}'s Statistics:";
$article_content = "<img src='{$image}'><br /><br />
<b>Total Clicks: {$row->totalclicks}<br />
Gender: <img src='picuploads/{$row->gender}.png'><br />
Trade Status: {$row->tradestatus}<br />
Current Level: {$row->currentlevel}<br />
Next Level: {$nloutput}<br /></b>";

// Voters Information...

$article_content .= "<h2>{$row->name}'s Voters:</h2><br />
{$lang_voters_explain}<br /><br />
<table width='450' border='1'>
<tr>
<td width='129'><strong>Username:</strong></td>
<td width='156'><strong>Date Voted: </strong></td>
<td width='82'><strong>Profile:</strong></td>
<td width='55'><strong>PM:</strong></td>
</tr>";

// Select the voters from the DB

$stmt = $adopts->select("vote_voters", array(), "adoptableid='{$id}' ORDER BY date DESC LIMIT 10");
while($row = $stmt->fetchObject()) {
if($row->username == "") $row->username = "Guest";
if($row->username == "Guest"){
$article_content .= "<tr>
<td><div align='left'>Guest</div></td>
<td><div align='left'>{$row->date}</div></td>
<td><div align='center'></div></td>
<td><div align='center'></div></td>
</tr>";
}
else{
$article_content .= "<tr>
<td><div align='left'>{$row->username}</div></td>
<td><div align='left'>{$row->date}</div></td>
<td><div align='center'><a href='profile.php?user={$row->username}' target='_blank'><img src='templates/buttons/profile.gif' border=0></a></div></td>
<td><div align='center'><a href='messages.php?act=newpm&user={$row->username}' target='_blank'><img src='templates/buttons/pm.gif' border=0></a></div></td>
</tr>";
}
}
$article_content .= "</table><br />";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else
{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
} // End the STATS code
elseif($act == "bbcode"){
if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$altbb = grabanysetting("usealtbbcode");

// Adoptable exists, so show the BBCode:
$article_title = "Codes for {$row->name}";
$article_content = "{$lang_bbcode_explain}<br />
<p><u>Forum Codes / BBCode: </u></p>
<p>
<textarea name='textarea' cols='50' rows='4'>
http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/siggy.php?id={$row->aid} (http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid})
</textarea>
</p>";

if($altbb == "yes"){

// Use the seo friendly alternate bbcodes...
$article_content .= "
<p><u>Alternate BBCodes (Use if the above do not work on a forum): </u></p>
<p>
<textarea name='textarea' cols='50' rows='4'>
http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/get/{$row->aid}.gif\" (http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid})
</textarea>
</p>";
}
$article_content .= "<p><u>HTML Code</u>:</p>
<p>
<textarea name='textarea' cols='50' rows='4'>
<a href=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid}\" target=\"_blank\">
<img src=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/siggy.php?id={$row->aid}\" border=0>
</a>
</textarea>
</p>";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
} // End the BBCODE generation for the adoptable...
elseif($act == "rename"){
// We are renaming an adoptable

if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();

if($row->aid == $id){

$image = getcurrentimage($id);
if($row->isfrozen != "yes"){
if($more == ""){
$article_title = "Rename {$row->name}";
$article_content = "<img src='{$image}'><br />{$lang_rename}{$row->name}{$lang_rename2}<br />
<form name='form1' method='get' action='stable.php'>
<p>Adoptable Name:
<input name='more' type='text' id='more'>
<input name='id' type='hidden' id='id' value='{$id}'>
<input name='act' type='hidden' id='act' value='rename'>
</p>
<p>
<input type='submit' name='Submit' value='Rename Adoptable'>
</p>
</form>";
}
else{
// We are renaming the adoptable, lets first check if the user is its original owner.
$row = $adopts->select("pounds", array(), "aid='{$id}'")->fetchObject();
if(!empty($row->firstowner) and $loggedinname != $row->firstowner){
$article_title = "Cannot rename";
$article_content = "The site admin has specified that only original owners can rename their adoptables.";
}
else{
$adopts->update("owned_adoptables", array("name" => $more), "aid='{$id}' and owner='{$loggedinname}'");
$article_title = $lang_rename_success_title;
$article_content = "<img src='{$image}'><br />{$lang_rename_success}{$more}.
You can now manage {$more} in your <a href='myadopts.php?act=manage&id={$id}'>My Adopts</a> page";
}
}
}
else{
// We cannot rename a frozen adoptable...

$article_title = $lang_frozen_title;
$article_content = "{$lang_frozen}<a href='myadopts.php?act=freeze&id={$id}&more=unfreeze'>unfreeze</a> {$lang_frozen2}";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "trade"){
// We are setting the trade status for an adoptable...

if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$image = getcurrentimage($id); // Get the image for the adopt...

if($more == ""){
$article_title = "Setting trade status for {$row->name}";
$article_content = "Are you sure you wish to change the trade status of this adoptable?
<center><b><a href='stable.php?act=trade&id={$id}&more=confirm'>Yes I'd like to change its trade status</a></b><br /><br />
<b><a href='stable.php'>Nope I change my mind! Go back to the previous page.</a></b></center><br />";
}
elseif($more == "confirm"){
$article_title = "Change trade status successfully";
if($row->tradestatus == "fortrade"){
$adopts->update("owned_adoptables", array("tradestatus" => 'notfortrade'), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "The adoptable's trade status is now Not for Trade";
}
elseif($row->tradestatus == "notfortrade"){
$adopts->update("owned_adoptables", array("tradestatus" => 'fortrade'), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "The adoptable's trade status is now For Trade";
}
else{
$article_title = "Something is very very wrong";
$article_content = "Please check phpmyadmin to see if the settings are correct, or report your issue to Mysidia Adoptables support forum";
}
}
else{
$article_title = "Invalid Action";
$article_content = "Invalid Action Specified";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "freeze"){
// We are freezing an adoptable here...

if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){

$image = getcurrentimage($id); // Get the image for the adopt...
if($more == ""){
if($row->isfrozen == "yes"){
$status = "<img src='templates/icons/freeze.gif'> Frozen<br />";
$go = "<a href='stable.php?act=freeze&id={$id}&more=unfreeze'><img src='templates/icons/unfreeze.gif' border=0> Unfreeze This Adoptable</a>";
}
else{
$status = "<img src='templates/icons/unfreeze.gif'> Not Frozen<br />";
$go = "<a href='stable.php?act=freeze&id={$id}&more=freeze'><img src='templates/icons/freeze.gif' border=0> Freeze This Adoptable</a>";
}

$article_title = $lang_freeze_title;
$article_content = "<img src='{$image}'><br /><b>{$row->name}'s Current Status: {$status}</b><br />
{$lang_freeze}<br /><br /><b>{$go}</b><br /><br />
{$lang_freeze_warning}";
}
else{
// We are actually freezing or unfreezing the adopt...

if($more == "freeze"){
$frz = "yes";
$article_title = "{$row->name} Frozen Successfully";
}
elseif($more == "unfreeze"){
$frz = "no";
$article_title = "{$row->name} Unfrozen Successfully";
}

$adopts->update("owned_adoptables", array("isfrozen" => $frz), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "Action Complete. You may now manage {$row->name} on the <a href='myadopts.php?act=manage&id={$id}'>My Adopts</a> page";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else
{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "pound"){
if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$image = getcurrentimage($id); // Get the image for the adopt...
if($more == ""){
$article_title = "Pound {$row->name}";
$article_content = "<img src='{$image}'><br />{$lang_pound}<br /><br />{$lang_pound_warning}<br /><br />
<center><b><a href='stable.php?act=pound&id={$id}&more=confirm'>
<img src='templates/icons/delete.gif' border=0> Pound {$row->name} - I dont want it anymore!
<img src='templates/icons/delete.gif' border=0></a></b><br /><br />
<b><a href='myadopts.php'><img src='templates/icons/yes.gif' border=0>
DO NOT Pound {$row->name}! <img src='templates/icons/yes.gif' border=0></a></b></center><br />";
}
elseif($more == "confirm"){
// Validate the pet can be pounded
$adopt = new Pound($row->aid, "pound");
if($adopt->settings->system->active == "no"){
$article_title = "Invalid Action";
$article_content = "The admin has turned off pound feature, please contact him/her for further explanation.";
}
elseif($adopt->validate() == TRUE){
$adopt->dopound();
$article_title = $lang_pound_title_complete;
$article_content = $adopt->message;
}
else{
$article_title = "An error has occurred";
$article_content = $adopt->message;
}
}
else{
$article_title = "Invalid Action";
$article_content = "Invalid Action Specified";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "group"){
if(is_numeric($id)){
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
$petname = $row->name;
if($row->aid == $id){
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
$article_title = "Group {$row->name}";
if($row->group == 0){
$article_content = "{$row->name} is not in a group. ";
}
else{
$groupname = $row->group;
$row = $adopts->select("pet_groups", array(), "user='{$loggedinname}' and id='{$groupname}'")->fetchObject();
$groupname = $row->name;
$article_content = "{$petname} is in the group '{$groupname}'.";
}
$article_content .= "Select a group to move {$petname} into:<br><br>";
$stmt = $adopts->select("pet_groups", array(), "user='{$loggedinname}'");
while($row = $stmt->fetchObject()) {
$groupid=$row->id;
$name=$row->name;
$groups .= "<option value='{$groupid}'>{$name}</option>";
}

$article_content .= " <form name='form' method='get' action='myadopts.php?'>
<input name='id' type='hidden' id='id' value='{$id}'>
<input name='act' type='hidden' id='act' value='changegroup'>
<select name='group' id='group'>
<option value='none' selected> </option>
{$groups}
</select><br>
<input type='submit' name='submit' value='Move'>
</form>";
}
}
}
elseif($act == "changegroup"){
if($submit == "Move"){
$row = $adopts->select("pet_groups", array(), "user='{$loggedinname}' and id='{$group}'")->fetchObject();
if($row->id == $group and $row->user == $loggedinname){
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$adopts->update("owned_adoptables", array("group" => $group), "aid='{$id}' and owner='{$loggedinname}'");
$article_title = "Moved {$row->name}";
$article_content = "{$row->name} was moved to a new group.<br><br>
<a href='myadopts.php?group={$group}'>Check out the new group</a>";
}
else{
$article_title = "No pet";
$article_content = "This pet doesn't exist.";
}
}
else{
$article_title = "No group";
$article_content = "This group doesn't exist.";
}
}
else{
$article_title = "";
$article_content = "";
}
}
elseif($act == "creategroup"){
if($groupname == ""){
$count = $GLOBALS['adopts']->select("pet_groups", array(), "user='{$loggedinname}'")->fetchAll();
if(count($count) > 4) {
$article_title = "Sorry";
$article_content = "You can only have 5 groups. <br><br>
<a href='myadopts.php'>Go back</a>";
}
else{
$article_title = "Create a new group";
$article_content = "
<form name='form1' method='post' action='myadopts.php?act=creategroup'>
<b>Group Name:</b> <br>
Max length is 15.<br>
<input name='groupname' type='text' id='groupname' maxlength='15' /><br>
<input type='submit' name='submit' value='Create'>
</form>";
}
}
else{
$count = $GLOBALS['adopts']->select("pet_groups", array(), "user='{$loggedinname}'")->fetchAll();
if(count($count) > 4) {
$article_title = "Sorry";
$article_content = "You can only have 5 groups. <br><br>
<a href='stable.php'>Go back to your stable</a>";
}
else{
$adopts->insert("pet_groups", array("id" => NULL, "user" => $loggedinname, "name" => $groupname));
$group = $adopts->select("pet_groups", array(), "name='{$groupname}' and user='{$loggedinname}'")->fetchObject();
$id = $group->id;
$article_title = "Created group '{$groupname}'";
$article_content = "You created a new group called '{$groupname}'.<br><br>
<a href='myadopts.php?group={$id}'>Visit it now</a><br><br>
<a href='myadopts.php'>Go back</a>";
}
}
}
else{
// No valid action specified :: show an error

$article_title = $lang_invalid_action_title;
$article_content = $lang_invalid_action;
}
}
else
{

$article_title = $accden;
$article_content = $reqlogin;

} // End is logged in check else


//***************//
// OUTPUT PAGE //
//***************//

echo showpage($article_title, $article_content, $date);

?> 4. Done
That is it! :) I hope it works for you.

MaximumRide
05-05-2012, 07:36 AM
Well when I make the group in php my admin, it wants me fill out....

Field Type Length/Values1 Collation Attributes Null Default2 Extra --- Comments

StarGirl
05-05-2012, 08:48 AM
Well when I make the group in php my admin, it wants me fill out....

Field Type Length/Values1 Collation Attributes Null Default2 Extra --- Comments

That should be right. (Did you remember to type in 3 columns, not 1?) Then just copy everything from the screenshot.

MaximumRide
05-05-2012, 09:04 AM
Oh ok is "File Type" like "Column?"

Aasixx
05-05-2012, 09:12 AM
Okay, when I'm at the "owned_adoptables" table and I'm trying to click "At End of Table" then go search for id, but when I click the dropdown menu, it for some reason goes back to "After".. plus, id isn't even on the dropdown menu. Did I do something wrong? Also, another thing, id isn't even listed in Structure on my "owned_adoptables" :mii:

And where do I go to edit files? Sorry, this is my first time installing a mod. :T

StarGirl
05-05-2012, 09:56 AM
Okay, when I'm at the "owned_adoptables" table and I'm trying to click "At End of Table" then go search for id, but when I click the dropdown menu, it for some reason goes back to "After".. plus, id isn't even on the dropdown menu. Did I do something wrong? Also, another thing, id isn't even listed in Structure on my "owned_adoptables" :mii:

And where do I go to edit files? Sorry, this is my first time installing a mod. :T

I don't know.. you should be at the "owned_adoptables" table, at the structure tab, and near the bottom should be what you're looking for. And I don't think it matters if you put it at the end of the table or not - I'd prefer it there though. Just simply press the go button, you don't need to change any details until the new window pops up. :3

And you go to file manager to edit files. Then navigate to public_html if not already, and find the files you need to edit. :3

Aasixx
05-05-2012, 10:10 AM
One more question and then I'll leave you alone. :3
Where do I need to put the attached files after downloading them?

StarGirl
05-05-2012, 10:10 AM
Oh ok is "File Type" like "Column?"

I don't know what you mean, but I don't think so :P Here are more detailed instructions. Open PhpMyAdmin, it should look something like:
http://i48.tinypic.com/2igd8ut.png
Now find and click on your database. Mine is called 'myxiplan_database', yours will be something different. It should bring you to a list of your tables..
http://i49.tinypic.com/6zaays.png
My prefix is myxipets_. :P Now open the operations tab, and follow these directions:
http://i50.tinypic.com/35jytm0.png
Now fill in the details with what is shown in the screenshot and press go.
http://i45.tinypic.com/35iqbev.png
There you go. :P Now you go from step 2.

StarGirl
05-05-2012, 10:11 AM
One more question and then I'll leave you alone. :3
Where do I need to put the attached files after downloading them?

Just leave them in public_html, where the rest of the files are. :)

Aasixx
05-05-2012, 10:15 AM
When you say "leave them in public_html" do you mean create a new file for each one? So, like for "creategroup" after I downloaded and opened it, it gave me this code:

<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("inc/lang.php");

//***************//
// START SCRIPT //
//***************//

$name = $_GET["name"];
$submit = $_GET["submit"];

if($isloggedin == "yes"){
if($submit == "Create"){
$count = $GLOBALS['adopts']->select("pet_groups", array(), "user='{$loggedinname}'")->fetchAll();
if(count($count) > 4) {
$article_title = "Sorry";
$article_content = "You have too many groups. <br><br>
<a href='mygroups.php'>Go back to the group center</a>";
}
else{
// Create group!
$adopts->insert("pet_groups", array("id" => NULL, "user" => $loggedinname, "name" => $name));
$group = $adopts->select("pet_groups", array(), "name='{$name}' and user='{$loggedinname}'")->fetchObject();
$id = $group->id;
$article_title = "New Group!";
$article_content = "You have just created a new group - {$name}!<br><br>
<a href='groups.php?id={$id}'>Click here to see it.</a>";
}
}
else{
$article_title = "";
$article_content = "";
}
} // End the log in check IF
else {
$article_title = "Login";
$article_content = "You must login to create a group.";
} // End the log in check ELSE

//***************//
// OUTPUT PAGE //
//***************//

echo showpage($article_title, $article_content, $date);

?>

Would I need to create a new file and put that code in it for creategroup?

StarGirl
05-05-2012, 10:21 AM
When you say "leave them in public_html" do you mean create a new file for each one? So, like for "creategroup" after I downloaded and opened it, it gave me this code:

<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("inc/lang.php");

//***************//
// START SCRIPT //
//***************//

$name = $_GET["name"];
$submit = $_GET["submit"];

if($isloggedin == "yes"){
if($submit == "Create"){
$count = $GLOBALS['adopts']->select("pet_groups", array(), "user='{$loggedinname}'")->fetchAll();
if(count($count) > 4) {
$article_title = "Sorry";
$article_content = "You have too many groups. <br><br>
<a href='mygroups.php'>Go back to the group center</a>";
}
else{
// Create group!
$adopts->insert("pet_groups", array("id" => NULL, "user" => $loggedinname, "name" => $name));
$group = $adopts->select("pet_groups", array(), "name='{$name}' and user='{$loggedinname}'")->fetchObject();
$id = $group->id;
$article_title = "New Group!";
$article_content = "You have just created a new group - {$name}!<br><br>
<a href='groups.php?id={$id}'>Click here to see it.</a>";
}
}
else{
$article_title = "";
$article_content = "";
}
} // End the log in check IF
else {
$article_title = "Login";
$article_content = "You must login to create a group.";
} // End the log in check ELSE

//***************//
// OUTPUT PAGE //
//***************//

echo showpage($article_title, $article_content, $date);

?>

Would I need to create a new file and put that code in it for creategroup?
Well, you could create a creategroup.php in file manager and put that code in it, and repeat for each download. Or, just download each file here, and upload it to public_html.

Aasixx
05-05-2012, 10:35 AM
I'll do the first one. XD Much more easier for my slow-processing brain. Thanks a ton, Star. :)

Um, this is what I get when I'm trying to view a group:
Fatal error: Call to a member function fetchObject() on a non-object in /home/albisian/public_html/adopts/groups.php on line 58

Do you think you might know the problem? :| It also takes me to your site (MyxiPlanet) when I click to view a group..

and now I'm getting this when I'm trying to go to myadopts.php:
Parse error: syntax error, unexpected T_ELSEIF in /home/albisian/public_html/adopts/myadopts.php on line 434

StarGirl
05-05-2012, 10:58 AM
I'll do the first one. XD Much more easier for my slow-processing brain. Thanks a ton, Star. :)

Um, this is what I get when I'm trying to view a group:
Fatal error: Call to a member function fetchObject() on a non-object in /home/albisian/public_html/adopts/groups.php on line 58

Do you think you might know the problem? :| It also takes me to your site (MyxiPlanet) when I click to view a group..

and now I'm getting this when I'm trying to go to myadopts.php:
Parse error: syntax error, unexpected T_ELSEIF in /home/albisian/public_html/adopts/myadopts.php on line 434

Oh, oops.. I forgot to take out the first bit which makes it lead to my site. -.- And can you post your myadopts.php? Maybe some if's got caught up or something. It works fine on my site.. And can you delete mygroups.php and do it again, because I've fixed the leading to my site.

Hall of Famer
05-05-2012, 02:36 PM
Well you can just download the attachment and upload them to your server through ftp, this way there is no need to create empty files and copy/paste the code.

StarGirl
05-05-2012, 03:26 PM
Well you can just download the attachment and upload them to your server through ftp, this way there is no need to create empty files and copy/paste the code.

Ah.. you see my terrible coding.. xP

Aasixx
05-05-2012, 08:10 PM
Alright, here's myadopts.php
<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("css/pagination.css");
include("inc/lang.php");

//***************//
// START SCRIPT //
//***************//

$id = $_GET["id"];
$act = $_GET["act"];
$more = $_GET["more"];
$page = $_GET["page"];

if($isloggedin == "yes"){
if($act == ""){
$article_title = "Your Adoptables";
// We need to get all of the user's adoptables from the database and display them...
$query = "SELECT * FROM ".constant("PREFIX")."owned_adoptables,
".constant("PREFIX")."adoptables,
".constant("PREFIX")."levels WHERE ".constant("PREFIX")."owned_adoptables.owner = '{$loggedinname}'
AND ".constant("PREFIX")."adoptables.type = ".constant("PREFIX")."owned_adoptables.type
AND ".constant("PREFIX")."levels.thisislevel = ".constant("PREFIX")."owned_adoptables.currentlevel
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type
ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks";
$rowsperpage = 10;
$pagination = new Pagination($adopts, $query, $rowsperpage, "http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/myadopts.php");
$pagination->setPage($_GET[page]);
$query = "SELECT * FROM ".constant("PREFIX")."owned_adoptables,
".constant("PREFIX")."adoptables,
".constant("PREFIX")."levels WHERE ".constant("PREFIX")."owned_adoptables.owner = '{$loggedinname}'
AND ".constant("PREFIX")."adoptables.type = ".constant("PREFIX")."owned_adoptables.type
AND ".constant("PREFIX")."levels.thisislevel = ".constant("PREFIX")."owned_adoptables.currentlevel
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type
ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks LIMIT {$pagination->getLimit()},{$rowsperpage}";
$stmt = $adopts->query($query);

$article_content = "<table>
<tr>
<th></th><th>Name and Type</th><th>Image</th><th>Clicks</th>
</tr>";

while($row = $stmt->fetchObject()){
if($row->usealternates == 'yes') $image = $row->alternateimage;
else $image = $row->primaryimage;
if($row->currentlevel == 0) $image = $row->eggimage;
if($image=='') $image = $row->primaryimage;

$article_content .= "<tr>
<td><center><img src='picuploads/{$row->gender}.png'></center></td>
<td><center><em>{$row->name}</em> the {$row->type}</center></td>
<td><center><a href='myadopts.php?act=manage&id={$row->aid}'><img src='{$image}'></a></center></td>
<td><center>{$row->totalclicks}</center></td>
</tr>";
}
$article_content .= "</table><br /><br />{$pagination->showPage()}</div>";
}
elseif($act == "manage"){

// We are managing a specific adoptable
if(!is_numeric($id)){
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
else{
// See if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();

// Check that the adoptable exists for real, or show an error...
if($row->aid == $id){

// The adoptable does exist, so we show the image and junk to the user...
$image = getcurrentimage($id);
$article_title = "Managing {$row->name}";
$article_content = "<img src='{$image}'><br /><br />This page allows you to manage {$row->name}. Click on an option below to change settings.<br /><br />
<b><a href='levelup.php?id={$id}'><img src='templates/icons/add.gif' border=0> Level Up {$row->name}</a><br />
<a href='myadopts.php?act=stats&id={$id}'><img src='templates/icons/stats.gif' border=0> Get Stats for {$row->name}</a><br />
<a href='myadopts.php?act=bbcode&id={$id}'><img src='templates/icons/bbcodes.gif' border=0> Get BBCodes / HTML Codes for {$row->name}</a><br />
<a href='myadopts.php?act=rename&id={$id}'><img src='templates/icons/title.gif' border=0> Rename {$row->name}</a><br />
<a href='myadopts.php?act=trade&id={$id}'><img src='templates/icons/trade.gif' border=0> Change Trade Status {$row->name}</a><br />
<a href='myadopts.php?act=freeze&id={$id}'><img src='templates/icons/freeze.gif' border=0> Freeze or Unfreeze {$row->name}</a><br />

<a href='myadopts.php?act=group&id={$id}'> Group {$row->name}</a><br />
<a href='myadopts.php?act=pound&id={$id}'><img src='templates/icons/delete.gif' border=0> Pound {$row->name}</a></b>";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
} // End the MANAGE action code
elseif($act == "stats"){
// We are getting the stats for the adoptable
// Check that an ID was submitted...
if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
// The adoptable exists, so we show the stats for it...

$image = getcurrentimage($id);
$nextlevelexists = getnextlevelexists($row->type, $row->currentlevel);

// If a higher level exists, get that level's information...

if($nextlevelexists == TRUE){
$nextlevel = $row->currentlevel + 1;

$levels = $adopts->select("levels", array(), "adoptiename='{$row->type}' and thisislevel='{$nextlevel}'")->fetchObject();
$requiredclicks= $levels->requiredclicks; //The adoptable's ID

} // End grab next level info...

// Determine what to show for next level:

if($nextlevelexists == TRUE and $nextlevel != ""){
// See how many more clicks to go
$ctg = $requiredclicks - $row->totalclicks;
$nloutput = "{$nextlevel}<br />Clicks Required for Level Increase: {$ctg}";
}
else $nloutput = "This adoptable is at its maximum level";

$article_title = "{$row->name}'s Statistics:";
$article_content = "<img src='{$image}'><br /><br />
<b>Total Clicks: {$row->totalclicks}<br />
Gender: <img src='picuploads/{$row->gender}.png'><br />
Trade Status: {$row->tradestatus}<br />
Current Level: {$row->currentlevel}<br />
Next Level: {$nloutput}<br /></b>";

// Voters Information...

$article_content .= "<h2>{$row->name}'s Voters:</h2><br />
{$lang_voters_explain}<br /><br />
<table width='450' border='1'>
<tr>
<td width='129'><strong>Username:</strong></td>
<td width='156'><strong>Date Voted: </strong></td>
<td width='82'><strong>Profile:</strong></td>
<td width='55'><strong>PM:</strong></td>
</tr>";

// Select the voters from the DB

$stmt = $adopts->select("vote_voters", array(), "adoptableid='{$id}' ORDER BY date DESC LIMIT 10");
while($row = $stmt->fetchObject()) {
if($row->username == "") $row->username = "Guest";
if($row->username == "Guest"){
$article_content .= "<tr>
<td><div align='left'>Guest</div></td>
<td><div align='left'>{$row->date}</div></td>
<td><div align='center'></div></td>
<td><div align='center'></div></td>
</tr>";
}
else{
$article_content .= "<tr>
<td><div align='left'>{$row->username}</div></td>
<td><div align='left'>{$row->date}</div></td>
<td><div align='center'><a href='profile.php?user={$row->username}' target='_blank'><img src='templates/buttons/profile.gif' border=0></a></div></td>
<td><div align='center'><a href='messages.php?act=newpm&user={$row->username}' target='_blank'><img src='templates/buttons/pm.gif' border=0></a></div></td>
</tr>";
}
}
$article_content .= "</table><br />";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else
{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
} // End the STATS code
elseif($act == "bbcode"){
if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$altbb = grabanysetting("usealtbbcode");

// Adoptable exists, so show the BBCode:
$article_title = "Codes for {$row->name}";
$article_content = "{$lang_bbcode_explain}<br />
<p><u>Forum Codes / BBCode: </u></p>
<p>
<textarea name='textarea' cols='50' rows='4'>
http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/siggy.php?id={$row->aid} (http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid})
</textarea>
</p>";

if($altbb == "yes"){

// Use the seo friendly alternate bbcodes...
$article_content .= "
<p><u>Alternate BBCodes (Use if the above do not work on a forum): </u></p>
<p>
<textarea name='textarea' cols='50' rows='4'>
http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/get/{$row->aid}.gif\" (http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid})
</textarea>
</p>";
}
$article_content .= "<p><u>HTML Code</u>:</p>
<p>
<textarea name='textarea' cols='50' rows='4'>
<a href=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid}\" target=\"_blank\">
<img src=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/siggy.php?id={$row->aid}\" border=0>
</a>
</textarea>
</p>";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
} // End the BBCODE generation for the adoptable...
elseif($act == "rename"){
// We are renaming an adoptable

if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();

if($row->aid == $id){

$image = getcurrentimage($id);
if($row->isfrozen != "yes"){
if($more == ""){
$article_title = "Rename {$row->name}";
$article_content = "<img src='{$image}'><br />{$lang_rename}{$row->name}{$lang_rename2}<br />
<form name='form1' method='get' action='myadopts.php'>
<p>Adoptable Name:
<input name='more' type='text' id='more'>
<input name='id' type='hidden' id='id' value='{$id}'>
<input name='act' type='hidden' id='act' value='rename'>
</p>
<p>
<input type='submit' name='Submit' value='Rename Adoptable'>
</p>
</form>";
}
else{
// We are renaming the adoptable, lets first check if the user is its original owner.
$row = $adopts->select("pounds", array(), "aid='{$id}'")->fetchObject();
if(!empty($row->firstowner) and $loggedinname != $row->firstowner){
$article_title = "Cannot rename";
$article_content = "The site admin has specified that only original owners can rename their adoptables.";
}
else{
$adopts->update("owned_adoptables", array("name" => $more), "aid='{$id}' and owner='{$loggedinname}'");
$article_title = $lang_rename_success_title;
$article_content = "<img src='{$image}'><br />{$lang_rename_success}{$more}.
You can now manage {$more} on the <a href='myadopts.php?act=manage&id={$id}'>My Adopts</a> page";
}
}
}
else{
// We cannot rename a frozen adoptable...

$article_title = $lang_frozen_title;
$article_content = "{$lang_frozen}<a href='manage.php?act=freeze&id={$id}&more=unfreeze'>unfreeze</a> {$lang_frozen2}";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "trade"){
// We are setting the trade status for an adoptable...

if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$image = getcurrentimage($id); // Get the image for the adopt...

if($more == ""){
$article_title = "Setting trade status for {$row->name}";
$article_content = "Are you sure you wish to change the trade status of this adoptable?
<center><b><a href='myadopts.php?act=trade&id={$id}&more=confirm'>Yes I'd like to change its trade status</a></b><br /><br />
<b><a href='myadopts.php'>Nope I change my mind! Go back to the previous page.</a></b></center><br />";
}
elseif($more == "confirm"){
$article_title = "Change trade status successfully";
if($row->tradestatus == "fortrade"){
$adopts->update("owned_adoptables", array("tradestatus" => 'notfortrade'), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "The adoptable's trade status is now Not for Trade";
}
elseif($row->tradestatus == "notfortrade"){
$adopts->update("owned_adoptables", array("tradestatus" => 'fortrade'), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "The adoptable's trade status is now For Trade";
}
else{
$article_title = "Something is very very wrong";
$article_content = "Please check phpmyadmin to see if the settings are correct, or report your issue to Mysidia Adoptables support forum";
}
}
else{
$article_title = "Invalid Action";
$article_content = "Invalid Action Specified";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "freeze"){
// We are freezing an adoptable here...

if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){

$image = getcurrentimage($id); // Get the image for the adopt...
if($more == ""){
if($row->isfrozen == "yes"){
$status = "<img src='templates/icons/freeze.gif'> Frozen<br />";
$go = "<a href='myadopts.php?act=freeze&id={$id}&more=unfreeze'><img src='templates/icons/unfreeze.gif' border=0> Unfreeze This Adoptable</a>";
}
else{
$status = "<img src='templates/icons/unfreeze.gif'> Not Frozen<br />";
$go = "<a href='myadopts.php?act=freeze&id={$id}&more=freeze'><img src='templates/icons/freeze.gif' border=0> Freeze This Adoptable</a>";
}

$article_title = $lang_freeze_title;
$article_content = "<img src='{$image}'><br /><b>{$row->name}'s Current Status: {$status}</b><br />
{$lang_freeze}<br /><br /><b>{$go}</b><br /><br />
{$lang_freeze_warning}";
}
else{
// We are actually freezing or unfreezing the adopt...

if($more == "freeze"){
$frz = "yes";
$article_title = "{$row->name} Frozen Successfully";
}
elseif($more == "unfreeze"){
$frz = "no";
$article_title = "{$row->name} Unfrozen Successfully";
}

$adopts->update("owned_adoptables", array("isfrozen" => $frz), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "Action Complete. You may now manage {$row->name} on the <a href='myadopts.php?act=manage&id={$id}'>My Adopts</a> page";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else
{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "pound"){
if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$image = getcurrentimage($id); // Get the image for the adopt...
if($more == ""){
$article_title = "Pound {$row->name}";
$article_content = "<img src='{$image}'><br />{$lang_pound}<br /><br />{$lang_pound_warning}<br /><br />
<center><b><a href='myadopts.php?act=pound&id={$id}&more=confirm'>
<img src='templates/icons/delete.gif' border=0> Pound {$row->name} - I dont want it anymore!
<img src='templates/icons/delete.gif' border=0></a></b><br /><br />
<b><a href='myadopts.php'><img src='templates/icons/yes.gif' border=0>
DO NOT Pound {$row->name}! <img src='templates/icons/yes.gif' border=0></a></b></center><br />";
}
elseif($more == "confirm"){
// Validate the pet can be pounded
$adopt = new Pound($row->aid, "pound");
if($adopt->settings->system->active == "no"){
$article_title = "Invalid Action";
$article_content = "The admin has turned off pound feature, please contact him/her for further explanation.";
}
elseif($adopt->validate() == TRUE){
$adopt->dopound();
$article_title = $lang_pound_title_complete;
$article_content = $adopt->message;
}
else{
$article_title = "An error has occurred";
$article_content = $adopt->message;
}
}
else{
$article_title = "Invalid Action";
$article_content = "Invalid Action Specified";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
elseif($act == "group"){
if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
$petname = $row->name;
if($row->aid == $id){
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
$article_title = "Group {$row->name}";
if($row->group == 0){
$article_content = "{$row->name} is not in a group. ";
}
else{
$groupname = $row->group;
$row = $adopts->select("pet_groups", array(), "user='{$loggedinname}' and id='{$groupname}'")->fetchObject();
$groupname = $row->name;
$article_content = "{$row->name} is in the group '{$groupname}'.";
}
$article_content .= "Select a group to move {$petname} into:<br><br>";
$stmt = $adopts->select("pet_groups", array(), "user='{$loggedinname}'");
while($row = $stmt->fetchObject()) {
$groupid=$row->id;
$name=$row->name;
$code .= "<option value='{$groupid}'>{$name}</option>";
}

$article_content .= " <form name='form' method='get' action='hatchery.php?'>
<input name='id' type='hidden' id='id' value='{$id}'>
<input name='act' type='hidden' id='act' value='changegroup'>
<select name='group' id='group'>
<option value='none' selected> </option>
{$code}
</select><br>
<input type='submit' name='submit' value='Move'>
</form>";
}
}
}
elseif($act == "changegroup"){
// Check if form was submitted
if($submit == "Move"){
// Check group exists
$row = $adopts->select("pet_groups", array(), "user='{$loggedinname}' and id='{$group}'")->fetchObject();
if($row->id == $group and $row->user == $loggedinname){
// Check if pet exists
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
// Move it
$adopts->update("owned_adoptables", array("group" => $group), "aid='{$id}' and owner='{$loggedinname}'");
$article_title = "Moved {$row->name}";
$article_content = "{$row->name} was moved to a new group.<br><br>
<a href='groups.php?id={$group}'>Check out the new group</a>";
}
else{
$article_title = "Invalid ID";
$article_content = "This pet doesn't exist.";
}
}
else{
$article_title = "Invalid Group";
$article_content = "This group doesn't exist.";
}
}
else{
$article_title = "";
$article_content = "";
}
}
else{
// No valid action specified :: show an error

$article_title = $lang_invalid_action_title;
$article_content = $lang_invalid_action;
}
}
else
{

$article_title = $accden;
$article_content = $reqlogin;

} // End is logged in check else


//***************//
// OUTPUT PAGE //
//***************//

echo showpage($article_title, $article_content, $date);

?>

StarGirl
05-06-2012, 03:22 AM
Alright, here's myadopts.php
<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("css/pagination.css");
include("inc/lang.php");

//***************//
// START SCRIPT //
//***************//

$id = $_GET["id"];
$act = $_GET["act"];
$more = $_GET["more"];
$page = $_GET["page"];

if($isloggedin == "yes"){
if($act == ""){
$article_title = "Your Adoptables";
// We need to get all of the user's adoptables from the database and display them...
$query = "SELECT * FROM ".constant("PREFIX")."owned_adoptables,
".constant("PREFIX")."adoptables,
".constant("PREFIX")."levels WHERE ".constant("PREFIX")."owned_adoptables.owner = '{$loggedinname}'
AND ".constant("PREFIX")."adoptables.type = ".constant("PREFIX")."owned_adoptables.type
AND ".constant("PREFIX")."levels.thisislevel = ".constant("PREFIX")."owned_adoptables.currentlevel
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type
ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks";
$rowsperpage = 10;
$pagination = new Pagination($adopts, $query, $rowsperpage, "http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/myadopts.php");
$pagination->setPage($_GET[page]);
$query = "SELECT * FROM ".constant("PREFIX")."owned_adoptables,
".constant("PREFIX")."adoptables,
".constant("PREFIX")."levels WHERE ".constant("PREFIX")."owned_adoptables.owner = '{$loggedinname}'
AND ".constant("PREFIX")."adoptables.type = ".constant("PREFIX")."owned_adoptables.type
AND ".constant("PREFIX")."levels.thisislevel = ".constant("PREFIX")."owned_adoptables.currentlevel
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type
ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks LIMIT {$pagination->getLimit()},{$rowsperpage}";
$stmt = $adopts->query($query);

$article_content = "<table>
<tr>
<th></th><th>Name and Type</th><th>Image</th><th>Clicks</th>
</tr>";

while($row = $stmt->fetchObject()){
if($row->usealternates == 'yes') $image = $row->alternateimage;
else $image = $row->primaryimage;
if($row->currentlevel == 0) $image = $row->eggimage;
if($image=='') $image = $row->primaryimage;

$article_content .= "<tr>
<td><center><img src='picuploads/{$row->gender}.png'></center></td>
<td><center><em>{$row->name}</em> the {$row->type}</center></td>
<td><center><a href='myadopts.php?act=manage&id={$row->aid}'><img src='{$image}'></a></center></td>
<td><center>{$row->totalclicks}</center></td>
</tr>";
}
$article_content .= "</table><br /><br />{$pagination->showPage()}</div>";
}
elseif($act == "manage"){

// We are managing a specific adoptable
if(!is_numeric($id)){
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
else{
// See if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();

// Check that the adoptable exists for real, or show an error...
if($row->aid == $id){

// The adoptable does exist, so we show the image and junk to the user...
$image = getcurrentimage($id);
$article_title = "Managing {$row->name}";
$article_content = "<img src='{$image}'><br /><br />This page allows you to manage {$row->name}. Click on an option below to change settings.<br /><br />
<b><a href='levelup.php?id={$id}'><img src='templates/icons/add.gif' border=0> Level Up {$row->name}</a><br />
<a href='myadopts.php?act=stats&id={$id}'><img src='templates/icons/stats.gif' border=0> Get Stats for {$row->name}</a><br />
<a href='myadopts.php?act=bbcode&id={$id}'><img src='templates/icons/bbcodes.gif' border=0> Get BBCodes / HTML Codes for {$row->name}</a><br />
<a href='myadopts.php?act=rename&id={$id}'><img src='templates/icons/title.gif' border=0> Rename {$row->name}</a><br />
<a href='myadopts.php?act=trade&id={$id}'><img src='templates/icons/trade.gif' border=0> Change Trade Status {$row->name}</a><br />
<a href='myadopts.php?act=freeze&id={$id}'><img src='templates/icons/freeze.gif' border=0> Freeze or Unfreeze {$row->name}</a><br />

<a href='myadopts.php?act=group&id={$id}'> Group {$row->name}</a><br />
<a href='myadopts.php?act=pound&id={$id}'><img src='templates/icons/delete.gif' border=0> Pound {$row->name}</a></b>";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
} // End the MANAGE action code
elseif($act == "stats"){
// We are getting the stats for the adoptable
// Check that an ID was submitted...
if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
// The adoptable exists, so we show the stats for it...

$image = getcurrentimage($id);
$nextlevelexists = getnextlevelexists($row->type, $row->currentlevel);

// If a higher level exists, get that level's information...

if($nextlevelexists == TRUE){
$nextlevel = $row->currentlevel + 1;

$levels = $adopts->select("levels", array(), "adoptiename='{$row->type}' and thisislevel='{$nextlevel}'")->fetchObject();
$requiredclicks= $levels->requiredclicks; //The adoptable's ID

} // End grab next level info...

// Determine what to show for next level:

if($nextlevelexists == TRUE and $nextlevel != ""){
// See how many more clicks to go
$ctg = $requiredclicks - $row->totalclicks;
$nloutput = "{$nextlevel}<br />Clicks Required for Level Increase: {$ctg}";
}
else $nloutput = "This adoptable is at its maximum level";

$article_title = "{$row->name}'s Statistics:";
$article_content = "<img src='{$image}'><br /><br />
<b>Total Clicks: {$row->totalclicks}<br />
Gender: <img src='picuploads/{$row->gender}.png'><br />
Trade Status: {$row->tradestatus}<br />
Current Level: {$row->currentlevel}<br />
Next Level: {$nloutput}<br /></b>";

// Voters Information...

$article_content .= "<h2>{$row->name}'s Voters:</h2><br />
{$lang_voters_explain}<br /><br />
<table width='450' border='1'>
<tr>
<td width='129'><strong>Username:</strong></td>
<td width='156'><strong>Date Voted: </strong></td>
<td width='82'><strong>Profile:</strong></td>
<td width='55'><strong>PM:</strong></td>
</tr>";

// Select the voters from the DB

$stmt = $adopts->select("vote_voters", array(), "adoptableid='{$id}' ORDER BY date DESC LIMIT 10");
while($row = $stmt->fetchObject()) {
if($row->username == "") $row->username = "Guest";
if($row->username == "Guest"){
$article_content .= "<tr>
<td><div align='left'>Guest</div></td>
<td><div align='left'>{$row->date}</div></td>
<td><div align='center'></div></td>
<td><div align='center'></div></td>
</tr>";
}
else{
$article_content .= "<tr>
<td><div align='left'>{$row->username}</div></td>
<td><div align='left'>{$row->date}</div></td>
<td><div align='center'><a href='profile.php?user={$row->username}' target='_blank'><img src='templates/buttons/profile.gif' border=0></a></div></td>
<td><div align='center'><a href='messages.php?act=newpm&user={$row->username}' target='_blank'><img src='templates/buttons/pm.gif' border=0></a></div></td>
</tr>";
}
}
$article_content .= "</table><br />";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else
{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
} // End the STATS code
elseif($act == "bbcode"){
if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$altbb = grabanysetting("usealtbbcode");

// Adoptable exists, so show the BBCode:
$article_title = "Codes for {$row->name}";
$article_content = "{$lang_bbcode_explain}<br />
<p><u>Forum Codes / BBCode: </u></p>
<p>
<textarea name='textarea' cols='50' rows='4'>
http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/siggy.php?id={$row->aid} (http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid})
</textarea>
</p>";

if($altbb == "yes"){

// Use the seo friendly alternate bbcodes...
$article_content .= "
<p><u>Alternate BBCodes (Use if the above do not work on a forum): </u></p>
<p>
<textarea name='textarea' cols='50' rows='4'>
http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/get/{$row->aid}.gif\" (http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid})
</textarea>
</p>";
}
$article_content .= "<p><u>HTML Code</u>:</p>
<p>
<textarea name='textarea' cols='50' rows='4'>
<a href=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid}\" target=\"_blank\">
<img src=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/siggy.php?id={$row->aid}\" border=0>
</a>
</textarea>
</p>";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
} // End the BBCODE generation for the adoptable...
elseif($act == "rename"){
// We are renaming an adoptable

if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();

if($row->aid == $id){

$image = getcurrentimage($id);
if($row->isfrozen != "yes"){
if($more == ""){
$article_title = "Rename {$row->name}";
$article_content = "<img src='{$image}'><br />{$lang_rename}{$row->name}{$lang_rename2}<br />
<form name='form1' method='get' action='myadopts.php'>
<p>Adoptable Name:
<input name='more' type='text' id='more'>
<input name='id' type='hidden' id='id' value='{$id}'>
<input name='act' type='hidden' id='act' value='rename'>
</p>
<p>
<input type='submit' name='Submit' value='Rename Adoptable'>
</p>
</form>";
}
else{
// We are renaming the adoptable, lets first check if the user is its original owner.
$row = $adopts->select("pounds", array(), "aid='{$id}'")->fetchObject();
if(!empty($row->firstowner) and $loggedinname != $row->firstowner){
$article_title = "Cannot rename";
$article_content = "The site admin has specified that only original owners can rename their adoptables.";
}
else{
$adopts->update("owned_adoptables", array("name" => $more), "aid='{$id}' and owner='{$loggedinname}'");
$article_title = $lang_rename_success_title;
$article_content = "<img src='{$image}'><br />{$lang_rename_success}{$more}.
You can now manage {$more} on the <a href='myadopts.php?act=manage&id={$id}'>My Adopts</a> page";
}
}
}
else{
// We cannot rename a frozen adoptable...

$article_title = $lang_frozen_title;
$article_content = "{$lang_frozen}<a href='manage.php?act=freeze&id={$id}&more=unfreeze'>unfreeze</a> {$lang_frozen2}";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "trade"){
// We are setting the trade status for an adoptable...

if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$image = getcurrentimage($id); // Get the image for the adopt...

if($more == ""){
$article_title = "Setting trade status for {$row->name}";
$article_content = "Are you sure you wish to change the trade status of this adoptable?
<center><b><a href='myadopts.php?act=trade&id={$id}&more=confirm'>Yes I'd like to change its trade status</a></b><br /><br />
<b><a href='myadopts.php'>Nope I change my mind! Go back to the previous page.</a></b></center><br />";
}
elseif($more == "confirm"){
$article_title = "Change trade status successfully";
if($row->tradestatus == "fortrade"){
$adopts->update("owned_adoptables", array("tradestatus" => 'notfortrade'), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "The adoptable's trade status is now Not for Trade";
}
elseif($row->tradestatus == "notfortrade"){
$adopts->update("owned_adoptables", array("tradestatus" => 'fortrade'), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "The adoptable's trade status is now For Trade";
}
else{
$article_title = "Something is very very wrong";
$article_content = "Please check phpmyadmin to see if the settings are correct, or report your issue to Mysidia Adoptables support forum";
}
}
else{
$article_title = "Invalid Action";
$article_content = "Invalid Action Specified";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "freeze"){
// We are freezing an adoptable here...

if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){

$image = getcurrentimage($id); // Get the image for the adopt...
if($more == ""){
if($row->isfrozen == "yes"){
$status = "<img src='templates/icons/freeze.gif'> Frozen<br />";
$go = "<a href='myadopts.php?act=freeze&id={$id}&more=unfreeze'><img src='templates/icons/unfreeze.gif' border=0> Unfreeze This Adoptable</a>";
}
else{
$status = "<img src='templates/icons/unfreeze.gif'> Not Frozen<br />";
$go = "<a href='myadopts.php?act=freeze&id={$id}&more=freeze'><img src='templates/icons/freeze.gif' border=0> Freeze This Adoptable</a>";
}

$article_title = $lang_freeze_title;
$article_content = "<img src='{$image}'><br /><b>{$row->name}'s Current Status: {$status}</b><br />
{$lang_freeze}<br /><br /><b>{$go}</b><br /><br />
{$lang_freeze_warning}";
}
else{
// We are actually freezing or unfreezing the adopt...

if($more == "freeze"){
$frz = "yes";
$article_title = "{$row->name} Frozen Successfully";
}
elseif($more == "unfreeze"){
$frz = "no";
$article_title = "{$row->name} Unfrozen Successfully";
}

$adopts->update("owned_adoptables", array("isfrozen" => $frz), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "Action Complete. You may now manage {$row->name} on the <a href='myadopts.php?act=manage&id={$id}'>My Adopts</a> page";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else
{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "pound"){
if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$image = getcurrentimage($id); // Get the image for the adopt...
if($more == ""){
$article_title = "Pound {$row->name}";
$article_content = "<img src='{$image}'><br />{$lang_pound}<br /><br />{$lang_pound_warning}<br /><br />
<center><b><a href='myadopts.php?act=pound&id={$id}&more=confirm'>
<img src='templates/icons/delete.gif' border=0> Pound {$row->name} - I dont want it anymore!
<img src='templates/icons/delete.gif' border=0></a></b><br /><br />
<b><a href='myadopts.php'><img src='templates/icons/yes.gif' border=0>
DO NOT Pound {$row->name}! <img src='templates/icons/yes.gif' border=0></a></b></center><br />";
}
elseif($more == "confirm"){
// Validate the pet can be pounded
$adopt = new Pound($row->aid, "pound");
if($adopt->settings->system->active == "no"){
$article_title = "Invalid Action";
$article_content = "The admin has turned off pound feature, please contact him/her for further explanation.";
}
elseif($adopt->validate() == TRUE){
$adopt->dopound();
$article_title = $lang_pound_title_complete;
$article_content = $adopt->message;
}
else{
$article_title = "An error has occurred";
$article_content = $adopt->message;
}
}
else{
$article_title = "Invalid Action";
$article_content = "Invalid Action Specified";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
elseif($act == "group"){
if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
$petname = $row->name;
if($row->aid == $id){
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
$article_title = "Group {$row->name}";
if($row->group == 0){
$article_content = "{$row->name} is not in a group. ";
}
else{
$groupname = $row->group;
$row = $adopts->select("pet_groups", array(), "user='{$loggedinname}' and id='{$groupname}'")->fetchObject();
$groupname = $row->name;
$article_content = "{$row->name} is in the group '{$groupname}'.";
}
$article_content .= "Select a group to move {$petname} into:<br><br>";
$stmt = $adopts->select("pet_groups", array(), "user='{$loggedinname}'");
while($row = $stmt->fetchObject()) {
$groupid=$row->id;
$name=$row->name;
$code .= "<option value='{$groupid}'>{$name}</option>";
}

$article_content .= " <form name='form' method='get' action='hatchery.php?'>
<input name='id' type='hidden' id='id' value='{$id}'>
<input name='act' type='hidden' id='act' value='changegroup'>
<select name='group' id='group'>
<option value='none' selected> </option>
{$code}
</select><br>
<input type='submit' name='submit' value='Move'>
</form>";
}
}
}
elseif($act == "changegroup"){
// Check if form was submitted
if($submit == "Move"){
// Check group exists
$row = $adopts->select("pet_groups", array(), "user='{$loggedinname}' and id='{$group}'")->fetchObject();
if($row->id == $group and $row->user == $loggedinname){
// Check if pet exists
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
// Move it
$adopts->update("owned_adoptables", array("group" => $group), "aid='{$id}' and owner='{$loggedinname}'");
$article_title = "Moved {$row->name}";
$article_content = "{$row->name} was moved to a new group.<br><br>
<a href='groups.php?id={$group}'>Check out the new group</a>";
}
else{
$article_title = "Invalid ID";
$article_content = "This pet doesn't exist.";
}
}
else{
$article_title = "Invalid Group";
$article_content = "This group doesn't exist.";
}
}
else{
$article_title = "";
$article_content = "";
}
}
else{
// No valid action specified :: show an error

$article_title = $lang_invalid_action_title;
$article_content = $lang_invalid_action;
}
}
else
{

$article_title = $accden;
$article_content = $reqlogin;

} // End is logged in check else


//***************//
// OUTPUT PAGE //
//***************//

echo showpage($article_title, $article_content, $date);

?>

Yeah, the if's got caught up somewhere. Try replacing it all with:
<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("css/pagination.css");
include("inc/lang.php");

//***************//
// START SCRIPT //
//***************//

$id = $_GET["id"];
$act = $_GET["act"];
$more = $_GET["more"];
$page = $_GET["page"];

if($isloggedin == "yes"){
if($act == ""){
$article_title = "Your Adoptables";
// We need to get all of the user's adoptables from the database and display them...
$query = "SELECT * FROM ".constant("PREFIX")."owned_adoptables,
".constant("PREFIX")."adoptables,
".constant("PREFIX")."levels WHERE ".constant("PREFIX")."owned_adoptables.owner = '{$loggedinname}'
AND ".constant("PREFIX")."adoptables.type = ".constant("PREFIX")."owned_adoptables.type
AND ".constant("PREFIX")."levels.thisislevel = ".constant("PREFIX")."owned_adoptables.currentlevel
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type
ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks";
$rowsperpage = 10;
$pagination = new Pagination($adopts, $query, $rowsperpage, "http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/myadopts.php");
$pagination->setPage($_GET[page]);
$query = "SELECT * FROM ".constant("PREFIX")."owned_adoptables,
".constant("PREFIX")."adoptables,
".constant("PREFIX")."levels WHERE ".constant("PREFIX")."owned_adoptables.owner = '{$loggedinname}'
AND ".constant("PREFIX")."adoptables.type = ".constant("PREFIX")."owned_adoptables.type
AND ".constant("PREFIX")."levels.thisislevel = ".constant("PREFIX")."owned_adoptables.currentlevel
AND ".constant("PREFIX")."levels.adoptiename = ".constant("PREFIX")."adoptables.type
ORDER BY ".constant("PREFIX")."owned_adoptables.totalclicks LIMIT {$pagination->getLimit()},{$rowsperpage}";
$stmt = $adopts->query($query);

$article_content = "<table>
<tr>
<th></th><th>Name and Type</th><th>Image</th><th>Clicks</th>
</tr>";

while($row = $stmt->fetchObject()){
if($row->usealternates == 'yes') $image = $row->alternateimage;
else $image = $row->primaryimage;
if($row->currentlevel == 0) $image = $row->eggimage;
if($image=='') $image = $row->primaryimage;

$article_content .= "<tr>
<td><center><img src='picuploads/{$row->gender}.png'></center></td>
<td><center><em>{$row->name}</em> the {$row->type}</center></td>
<td><center><a href='myadopts.php?act=manage&id={$row->aid}'><img src='{$image}'></a></center></td>
<td><center>{$row->totalclicks}</center></td>
</tr>";
}
$article_content .= "</table><br /><br />{$pagination->showPage()}</div>";
}
elseif($act == "manage"){

// We are managing a specific adoptable
if(!is_numeric($id)){
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
else{
// See if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();

// Check that the adoptable exists for real, or show an error...
if($row->aid == $id){

// The adoptable does exist, so we show the image and junk to the user...
$image = getcurrentimage($id);
$article_title = "Managing {$row->name}";
$article_content = "<img src='{$image}'><br /><br />This page allows you to manage {$row->name}. Click on an option below to change settings.<br /><br />
<b><a href='levelup.php?id={$id}'><img src='templates/icons/add.gif' border=0> Level Up {$row->name}</a><br />
<a href='myadopts.php?act=stats&id={$id}'><img src='templates/icons/stats.gif' border=0> Get Stats for {$row->name}</a><br />
<a href='myadopts.php?act=bbcode&id={$id}'><img src='templates/icons/bbcodes.gif' border=0> Get BBCodes / HTML Codes for {$row->name}</a><br />
<a href='myadopts.php?act=rename&id={$id}'><img src='templates/icons/title.gif' border=0> Rename {$row->name}</a><br />
<a href='myadopts.php?act=trade&id={$id}'><img src='templates/icons/trade.gif' border=0> Change Trade Status {$row->name}</a><br />
<a href='myadopts.php?act=freeze&id={$id}'><img src='templates/icons/freeze.gif' border=0> Freeze or Unfreeze {$row->name}</a><br />

<a href='myadopts.php?act=group&id={$id}'> Group {$row->name}</a><br />
<a href='myadopts.php?act=pound&id={$id}'><img src='templates/icons/delete.gif' border=0> Pound {$row->name}</a></b>";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
} // End the MANAGE action code
elseif($act == "stats"){
// We are getting the stats for the adoptable
// Check that an ID was submitted...
if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
// The adoptable exists, so we show the stats for it...

$image = getcurrentimage($id);
$nextlevelexists = getnextlevelexists($row->type, $row->currentlevel);

// If a higher level exists, get that level's information...

if($nextlevelexists == TRUE){
$nextlevel = $row->currentlevel + 1;

$levels = $adopts->select("levels", array(), "adoptiename='{$row->type}' and thisislevel='{$nextlevel}'")->fetchObject();
$requiredclicks= $levels->requiredclicks; //The adoptable's ID

} // End grab next level info...

// Determine what to show for next level:

if($nextlevelexists == TRUE and $nextlevel != ""){
// See how many more clicks to go
$ctg = $requiredclicks - $row->totalclicks;
$nloutput = "{$nextlevel}<br />Clicks Required for Level Increase: {$ctg}";
}
else $nloutput = "This adoptable is at its maximum level";

$article_title = "{$row->name}'s Statistics:";
$article_content = "<img src='{$image}'><br /><br />
<b>Total Clicks: {$row->totalclicks}<br />
Gender: <img src='picuploads/{$row->gender}.png'><br />
Trade Status: {$row->tradestatus}<br />
Current Level: {$row->currentlevel}<br />
Next Level: {$nloutput}<br /></b>";

// Voters Information...

$article_content .= "<h2>{$row->name}'s Voters:</h2><br />
{$lang_voters_explain}<br /><br />
<table width='450' border='1'>
<tr>
<td width='129'><strong>Username:</strong></td>
<td width='156'><strong>Date Voted: </strong></td>
<td width='82'><strong>Profile:</strong></td>
<td width='55'><strong>PM:</strong></td>
</tr>";

// Select the voters from the DB

$stmt = $adopts->select("vote_voters", array(), "adoptableid='{$id}' ORDER BY date DESC LIMIT 10");
while($row = $stmt->fetchObject()) {
if($row->username == "") $row->username = "Guest";
if($row->username == "Guest"){
$article_content .= "<tr>
<td><div align='left'>Guest</div></td>
<td><div align='left'>{$row->date}</div></td>
<td><div align='center'></div></td>
<td><div align='center'></div></td>
</tr>";
}
else{
$article_content .= "<tr>
<td><div align='left'>{$row->username}</div></td>
<td><div align='left'>{$row->date}</div></td>
<td><div align='center'><a href='profile.php?user={$row->username}' target='_blank'><img src='templates/buttons/profile.gif' border=0></a></div></td>
<td><div align='center'><a href='messages.php?act=newpm&user={$row->username}' target='_blank'><img src='templates/buttons/pm.gif' border=0></a></div></td>
</tr>";
}
}
$article_content .= "</table><br />";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else
{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
} // End the STATS code
elseif($act == "bbcode"){
if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$altbb = grabanysetting("usealtbbcode");

// Adoptable exists, so show the BBCode:
$article_title = "Codes for {$row->name}";
$article_content = "{$lang_bbcode_explain}<br />
<p><u>Forum Codes / BBCode: </u></p>
<p>
<textarea name='textarea' cols='50' rows='4'>

</textarea>
</p>";

if($altbb == "yes"){

// Use the seo friendly alternate bbcodes...
$article_content .= "
<p><u>Alternate BBCodes (Use if the above do not work on a forum): </u></p>
<p>
<textarea name='textarea' cols='50' rows='4'>

</textarea>
</p>";
}
$article_content .= "<p><u>HTML Code</u>:</p>
<p>
<textarea name='textarea' cols='50' rows='4'>
<a href=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/levelup.php?id={$row->aid}\" target=\"_blank\">
<img src=\"http://www.".constant("DOMAIN").constant("SCRIPTPATH")."/siggy.php?id={$row->aid}\" border=0>
</a>
</textarea>
</p>";
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
} // End the BBCODE generation for the adoptable...
elseif($act == "rename"){
// We are renaming an adoptable

if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();

if($row->aid == $id){

$image = getcurrentimage($id);
if($row->isfrozen != "yes"){
if($more == ""){
$article_title = "Rename {$row->name}";
$article_content = "<img src='{$image}'><br />{$lang_rename}{$row->name}{$lang_rename2}<br />
<form name='form1' method='get' action='myadopts.php'>
<p>Adoptable Name:
<input name='more' type='text' id='more'>
<input name='id' type='hidden' id='id' value='{$id}'>
<input name='act' type='hidden' id='act' value='rename'>
</p>
<p>
<input type='submit' name='Submit' value='Rename Adoptable'>
</p>
</form>";
}
else{
// We are renaming the adoptable, lets first check if the user is its original owner.
$row = $adopts->select("pounds", array(), "aid='{$id}'")->fetchObject();
if(!empty($row->firstowner) and $loggedinname != $row->firstowner){
$article_title = "Cannot rename";
$article_content = "The site admin has specified that only original owners can rename their adoptables.";
}
else{
$adopts->update("owned_adoptables", array("name" => $more), "aid='{$id}' and owner='{$loggedinname}'");
$article_title = $lang_rename_success_title;
$article_content = "<img src='{$image}'><br />{$lang_rename_success}{$more}.
You can now manage {$more} on the <a href='myadopts.php?act=manage&id={$id}'>My Adopts</a> page";
}
}
}
else{
// We cannot rename a frozen adoptable...

$article_title = $lang_frozen_title;
$article_content = "{$lang_frozen}<a href='manage.php?act=freeze&id={$id}&more=unfreeze'>unfreeze</a> {$lang_frozen2}";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "trade"){
// We are setting the trade status for an adoptable...

if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$image = getcurrentimage($id); // Get the image for the adopt...

if($more == ""){
$article_title = "Setting trade status for {$row->name}";
$article_content = "Are you sure you wish to change the trade status of this adoptable?
<center><b><a href='myadopts.php?act=trade&id={$id}&more=confirm'>Yes I'd like to change its trade status</a></b><br /><br />
<b><a href='myadopts.php'>Nope I change my mind! Go back to the previous page.</a></b></center><br />";
}
elseif($more == "confirm"){
$article_title = "Change trade status successfully";
if($row->tradestatus == "fortrade"){
$adopts->update("owned_adoptables", array("tradestatus" => 'notfortrade'), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "The adoptable's trade status is now Not for Trade";
}
elseif($row->tradestatus == "notfortrade"){
$adopts->update("owned_adoptables", array("tradestatus" => 'fortrade'), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "The adoptable's trade status is now For Trade";
}
else{
$article_title = "Something is very very wrong";
$article_content = "Please check phpmyadmin to see if the settings are correct, or report your issue to Mysidia Adoptables support forum";
}
}
else{
$article_title = "Invalid Action";
$article_content = "Invalid Action Specified";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "freeze"){
// We are freezing an adoptable here...

if(is_numeric($id)){
// Now we see if the adoptable actually exists...

$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){

$image = getcurrentimage($id); // Get the image for the adopt...
if($more == ""){
if($row->isfrozen == "yes"){
$status = "<img src='templates/icons/freeze.gif'> Frozen<br />";
$go = "<a href='myadopts.php?act=freeze&id={$id}&more=unfreeze'><img src='templates/icons/unfreeze.gif' border=0> Unfreeze This Adoptable</a>";
}
else{
$status = "<img src='templates/icons/unfreeze.gif'> Not Frozen<br />";
$go = "<a href='myadopts.php?act=freeze&id={$id}&more=freeze'><img src='templates/icons/freeze.gif' border=0> Freeze This Adoptable</a>";
}

$article_title = $lang_freeze_title;
$article_content = "<img src='{$image}'><br /><b>{$row->name}'s Current Status: {$status}</b><br />
{$lang_freeze}<br /><br /><b>{$go}</b><br /><br />
{$lang_freeze_warning}";
}
else{
// We are actually freezing or unfreezing the adopt...

if($more == "freeze"){
$frz = "yes";
$article_title = "{$row->name} Frozen Successfully";
}
elseif($more == "unfreeze"){
$frz = "no";
$article_title = "{$row->name} Unfrozen Successfully";
}

$adopts->update("owned_adoptables", array("isfrozen" => $frz), "aid='{$id}' and owner='{$loggedinname}'");
$article_content = "Action Complete. You may now manage {$row->name} on the <a href='myadopts.php?act=manage&id={$id}'>My Adopts</a> page";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else
{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "pound"){
if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
$image = getcurrentimage($id); // Get the image for the adopt...
if($more == ""){
$article_title = "Pound {$row->name}";
$article_content = "<img src='{$image}'><br />{$lang_pound}<br /><br />{$lang_pound_warning}<br /><br />
<center><b><a href='myadopts.php?act=pound&id={$id}&more=confirm'>
<img src='templates/icons/delete.gif' border=0> Pound {$row->name} - I dont want it anymore!
<img src='templates/icons/delete.gif' border=0></a></b><br /><br />
<b><a href='myadopts.php'><img src='templates/icons/yes.gif' border=0>
DO NOT Pound {$row->name}! <img src='templates/icons/yes.gif' border=0></a></b></center><br />";
}
elseif($more == "confirm"){
// Validate the pet can be pounded
$adopt = new Pound($row->aid, "pound");
if($adopt->settings->system->active == "no"){
$article_title = "Invalid Action";
$article_content = "The admin has turned off pound feature, please contact him/her for further explanation.";
}
elseif($adopt->validate() == TRUE){
$adopt->dopound();
$article_title = $lang_pound_title_complete;
$article_content = $adopt->message;
}
else{
$article_title = "An error has occurred";
$article_content = $adopt->message;
}
}
else{
$article_title = "Invalid Action";
$article_content = "Invalid Action Specified";
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
else{
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
}
elseif($act == "group"){
if(is_numeric($id)){

// Now we see if the adoptable actually exists...
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
$petname = $row->name;
if($row->aid == $id){
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
$article_title = "Group {$row->name}";
if($row->group == 0){
$article_content = "{$row->name} is not in a group. ";
}
else{
$groupname = $row->group;
$row = $adopts->select("pet_groups", array(), "user='{$loggedinname}' and id='{$groupname}'")->fetchObject();
$groupname = $row->name;
$article_content = "{$row->name} is in the group '{$groupname}'.";
}
$article_content .= "Select a group to move {$petname} into:<br><br>";
$stmt = $adopts->select("pet_groups", array(), "user='{$loggedinname}'");
while($row = $stmt->fetchObject()) {
$groupid=$row->id;
$name=$row->name;
$code .= "<option value='{$groupid}'>{$name}</option>";
}

$article_content .= " <form name='form' method='get' action='hatchery.php?'>
<input name='id' type='hidden' id='id' value='{$id}'>
<input name='act' type='hidden' id='act' value='changegroup'>
<select name='group' id='group'>
<option value='none' selected> </option>
{$code}
</select><br>
<input type='submit' name='submit' value='Move'>
</form>";
}
}
}
elseif($act == "changegroup"){
// Check if form was submitted
if($submit == "Move"){
// Check group exists
$row = $adopts->select("pet_groups", array(), "user='{$loggedinname}' and id='{$group}'")->fetchObject();
if($row->id == $group and $row->user == $loggedinname){
// Check if pet exists
$row = $adopts->select("owned_adoptables", array(), "owner='{$loggedinname}' and aid='{$id}'")->fetchObject();
if($row->aid == $id){
// Move it
$adopts->update("owned_adoptables", array("group" => $group), "aid='{$id}' and owner='{$loggedinname}'");
$article_title = "Moved {$row->name}";
$article_content = "{$row->name} was moved to a new group.<br><br>
<a href='groups.php?id={$group}'>Check out the new group</a>";
}
else{
$article_title = "Invalid ID";
$article_content = "This pet doesn't exist.";
}
}
else{
$article_title = "Invalid Group";
$article_content = "This group doesn't exist.";
}
}
else{
$article_title = "";
$article_content = "";
}
}
else{
// No valid action specified :: show an error

$article_title = $lang_invalid_action_title;
$article_content = $lang_invalid_action;
}
}
}
else
{

$article_title = $accden;
$article_content = $reqlogin;

} // End is logged in check else


//***************//
// OUTPUT PAGE //
//***************//

echo showpage($article_title, $article_content, $date);

?>
And can you also re-download groups.php, there's something I put in that made it so that only you can see your own groups and nobody else. Sorry ^^

Hall of Famer
05-07-2012, 01:42 AM
Ah.. you see my terrible coding.. xP

Well I wasnt really referring to your script. I was just saying that users may as well download the attachment you provided and it would make things much easier. Of course it wont work for those with highly customized sites.

kristhasirah
05-07-2012, 10:21 PM
Hi, just installed the mod.... but it show me an error page.... and redirects me to a Hatchery page??

Aasixx
05-07-2012, 10:41 PM
Kris: You're probably getting an error because this mod is for Mys 1.3 and your site is currently using Mys 1.2.4. That's my thought, though. :T

kristhasirah
05-07-2012, 11:00 PM
thats other site.... the site im working on is using 1.3.1, is called Pokeponies

MaximumRide
05-09-2012, 12:35 PM
:catfish: I don't get it:displeased:

MaximumRide
05-16-2012, 06:20 PM
Hey well I finally got it to work! :D but now this shows up when I try and create a group :(

Fatal error: Uncaught exception 'Exception' with message 'Database error 1048 - Column 'id' cannot be null' in /home/a2057352/public_html/classes/class_database.php:161 Stack trace: #0 /home/a2057352/public_html/classes/class_database.php(54): Database->_query('pet_groups', Array, 'insert') #1 /home/a2057352/public_html/creategroup.php(25): Database->insert('pet_groups', Array) #2 {main} thrown in /home/a2057352/public_html/classes/class_database.php on line 161

MaximumRide
05-17-2012, 06:27 PM
Can anyone help? :(

Hall of Famer
05-17-2012, 10:38 PM
The OP is not active anymore, so I have no idea if this Mod is still being supported.

MaximumRide
05-17-2012, 11:01 PM
Oh ok, Stargirl do you know what going on [Btw thank HoF :3]

Alaric
05-24-2012, 03:54 AM
When i put my articuno in my group "legendaries" which i created. it shows me this:
http://i50.tinypic.com/wki97l.jpg


When i click on the move button it show me nothing here:
http://i45.tinypic.com/347usf9.png


well as on http://myxiplanet.x10.mx/ it shows this:
http://i48.tinypic.com/nldjc1.png

StarGirl
06-06-2012, 05:54 AM
I updated the mod. Works better now and there are less edits.
@kristhasirah:
Sorry.. that's my site. I probably forgot to edit that..

@Alaric:
Try deleting groups.php, mygroups.php, and creategroup.php that you downloaded and do the new step 3, replace all of myadopts.php with what is shown.

PTGigi
06-07-2012, 03:10 PM
Just a noting a minor issue: you may want to edit the profile page slightly to work a bit better with this. I've noticed on sites that have this installed, if someone has a group with a second page of adoptables, the link to the second page doesn't have the group variable in the link (ie "&tab=GROUPNAME" is not in the url to the second page) so it'll just take you to the default group's second page (if it exists). Just a heads up. Neat script though! :3

StarGirl
06-08-2012, 03:11 PM
Just a noting a minor issue: you may want to edit the profile page slightly to work a bit better with this. I've noticed on sites that have this installed, if someone has a group with a second page of adoptables, the link to the second page doesn't have the group variable in the link (ie "&tab=GROUPNAME" is not in the url to the second page) so it'll just take you to the default group's second page (if it exists). Just a heads up. Neat script though! :3

My script here is different to the ones that the sites you saw that have a group system, I think... I don't use "tab=something", I use "group=something", and I think my script works with 2 pages.. thanks though (:

PTGigi
06-08-2012, 06:59 PM
Ah! Apologies then, I'd seen it on Kristh's site and I'd seen her posting in here for help so I assumed it must be the exact code on the front page. Sorry about that! D:

kristhasirah
06-10-2012, 12:07 PM
I was installing this mod, but din make it work, so silverkitsune was kind to share her tab script with me, I will ask her how can i fix that problem whit the pages

draugluin
11-14-2012, 09:01 AM
Thank you very much, Stargirl...

it works for me. And it's great :meow:

draugluin
11-18-2012, 12:07 PM
But now I have two questions.

1. There's no way to move the adopt back to the "default" Group.
How can I solve this ?

2. I want to make possible, that the users can rename their groups or delete.
Can anyone help ?

Hall of Famer
11-21-2012, 08:43 AM
Sorry to bring this up to you, but the OP's last activity was in June.

draugluin
11-21-2012, 09:15 AM
yes, I know, but I hoped, anyone else used this idea and has the answer to this problems.

Hwona
03-06-2013, 10:43 PM
Thanks for making this! :D Mine is SO close to working, but when I click the create a group link, it brings me to this link:http://hakeoroccave.x10.mx/stable.php?act=creategroup

However, it says that the resource requested was not found on the server. Is this supposed to happen?

Hall of Famer
03-06-2013, 10:48 PM
Well the OP is last activity was in June 2012...

Hwona
03-06-2013, 11:06 PM
Well the OP is last activity was in June 2012...

Oh, I should have noticed that.:p Is there a way for me to add the "resource requested" myself?

Hall of Famer
03-07-2013, 12:31 AM
I dont quite get what you are saying, what do you mean by 'resource requested'?

Hwona
03-07-2013, 07:27 AM
When I click the create group link, it brings me to a page that says resource requested was not found on this server.

I'm wondering if it's an issue with the link. Because Stargirl's site was about ponies and the link had stable.php...

Hall of Famer
03-07-2013, 07:29 AM
Well it seems to me that her site no longer exists. In a word, the user is long gone.

Hwona
03-07-2013, 07:40 AM
Mmm, I'm just wondering if this is the link it's supposed to be. As soon as I get the answer everything will work. Maybe someone else knows...

Hwona
03-07-2013, 04:25 PM
Never mind, I figured it out. :D

NobodysHero
04-03-2016, 03:25 PM
Anyone that can revive this mod or remake it altogether? It would be really great.

Pear
04-03-2016, 03:50 PM
Anyone that can revive this mod or remake it altogether? It would be really great.

Agreed! I would really, really love if someone did this! QwQ

Ittermat
06-06-2016, 01:56 PM
we're going to add something like it to my site in the future- when/if we do I'll see about asking restless to share the code. ^^

Pear
06-06-2016, 06:03 PM
we're going to add something like it to my site in the future- when/if we do I'll see about asking restless to share the code. ^^

That would be amazingly kind QuQ<3

SilverDragonTears
01-16-2017, 09:40 AM
Why is this in 1.3 mods?

Pear
01-16-2017, 11:34 AM
Why is this in 1.3 mods?

These posts were made before there was an addons/mod requests board. :3 It's in 1.3.x, but this thread is just old, so it says 1.3.1.

SilverDragonTears
01-16-2017, 11:38 AM
Ah makes sense :)

parayna
06-11-2017, 05:52 PM
Has anyone made any progress with this..? :3 It's a feature I've been trying to implement but have been failing badly at... XD

Dinocanid
12-16-2017, 08:59 PM
I managed to convert the main part of the script, which involves creating groups and sorting pets on the myadopts index.
http://www.clipular.com/c/5136285479206912.png?k=JRkLXmvXSicr-3wLqmwuS_9ZWD0
That's the table setup for adopts_pet_groups. You need new column in owned_adoptables called "pet_group". (Not "group! "group" is a reserved name in phpMyAdmin.) Also make sure that "default as defined" is set to 0.
I did the entire thing in blank.php/blankview.php for testing purposes, so that's why it looks the way it does.
<?php
class BlankView extends View{


public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle("<center>Sort Testing!</center>");

//pet group variables? I think?
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$group = $_REQUEST["group"];
}
//var end

//convenient vars
$username = $mysidia->user->username;
$uid = $mysidia->user->uid;
//var end


//Pet sorting!
if(!$group == ""){
if(!is_numeric($group)){
$document->setTitle("No group");
$document->add(new Comment("Group does not exist."));
return;
}
else{
$row = $mysidia->db->select("pet_groups", array(), "uid='{$uid}' and id='{$group}'")->fetchObject();
if($row->id == $group and $row->uid == $uid){
$groupquery = "AND pet_group = '{$group}'";
}
else{ // Invalid group
$article_title = "No group";
$article_content = "Group does not exist.";
}
}
}
else{
$groupquery = "AND pet_group = '0'";
}

// We need to get all of the user's adoptables from the database and display them...
$rowsperpage = 10;
//$pagination = new Pagination($adopts, $query, $rowsperpage, "http://".constant("DOMAIN").constant("SCRIPTPATH")."/stable.php?group={$group}");
//$pagination->setPage($_GET[page]);
$pagination = new Pagination($total, 10, "myadopts");
$pagination->setPage($mysidia->input->get("page"));
//$stmt = $mysidia->db->query($query);
$stmt = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' {$groupquery} ORDER BY totalclicks LIMIT {$pagination->getLimit()},{$rowsperpage}");
$groups = ""; // Get groups
$stmt2 = $mysidia->db->select("pet_groups", array(), "uid='{$uid}'");

$document->add(new Comment("
<b>Group:</b><br>
<form method='post' action='blank'>
<select name='group' id='group'>
<option value='0'>Ungrouped</option>"));

while($row = $stmt2->fetchObject()) {
$id = $row->id;
$name = $row->name;
$document->add(new Comment("<option value='{$id}'>{$name}</option>"));
}
$document->add(new Comment("
</select><br>
<input type='submit' value='Go'>
</form>
<a href='blank/creategroup'>Create a new group</a> | <a href='blank/deletegroup'>Delete a group</a>
<br><br>
<table class='table table-bordered table-dark'>
<thead>
<tr>
<th>Image</th>
<th>Info</th>
<th>Action</th>
</tr>
</thead>
<tbody>", FALSE));
while($row = $stmt->fetchObject()){
$adopt = new OwnedAdoptable($row->aid);
$image = $adopt->getImage();
$document->add(new Comment("
<tr>
<td><img src='{$adopt->getImage()}'></td>
<td><b><em>{$adopt->getName()}</b></em><br></br> Level {$adopt->getCurrentLevel()}<br></br> {$Gender}</td>
<td><a href='/myadopts/manage/{$row->aid}' class='btn btn-primary' style='width:200px; height:auto;'>Manage</a></td>
</tr>
", FALSE));
}
$document->add(new Comment("</table><br /><br />{$pagination->showPage()}"));
//Sorting end
}

public function creategroup(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$username = $mysidia->user->username;
$uid = $mysidia->user->uid;
//$document->setTitle("<center>Sort Testing!</center>");
$groupCount = $mysidia->db->select("pet_groups", array("uid"), "uid = '{$mysidia->user->uid}'")->rowCount();
if($groupCount >= 5) {
$document->setTitle("<center>Sorry!</center>");
$document->add(new Comment("You can only have 5 groups. <br><br> <a href='myadopts'>Go back?</a>"));
}
else{
$document->setTitle("<center>Create a new group</center>");
$document->add(new Comment("
<form method='post' action='creategroup'>
<b>Group Name:</b> <br>
Max length is 15.<br>
<input type='text' name='groupname' id='groupname' maxlength='15' /><br>
<input type='submit' name='submit'>
</form>
<a href='/blank'>Go back</a>"));
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$groupCount = $mysidia->db->select("pet_groups", array("uid"), "uid = '{$mysidia->user->uid}'")->rowCount();
if($groupCount >= 5) {
$document->setTitle("<center>Sorry!</center>");
$document->add(new Comment("You can only have 5 groups. <br><br> <a href='myadopts'>Go back?</a>"));
}
else{
$groupname = $_REQUEST["groupname"];
$mysidia->db->insert("pet_groups", array("username" => $username, "uid" => $uid, "name" => $groupname));
$group = $mysidia->db->select("pet_groups", array(), "name='{$groupname}' and uid='{$uid}'")->fetchObject();
$id = $group->id;
$document->setTitle("Created group ''{$groupname}''");
$document->add(new Comment("
You created a new group called '{$groupname}'.<br><br>
<a href='/blank'>Go back</a>"));
}
}
}

public function deletegroup(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$username = $mysidia->user->username;
$uid = $mysidia->user->uid;
$stmt2 = $mysidia->db->select("pet_groups", array(), "uid='{$uid}'");
//$document->setTitle("<center>Sort Testing!</center>");
$groupCount = $mysidia->db->select("pet_groups", array("uid"), "uid = '{$mysidia->user->uid}'")->rowCount();
if($groupCount = 0) {
$document->setTitle("<center>Sorry!</center>");
$document->add(new Comment("You don't have any groups. <br><br> <a href='/blank'>Go back?</a>"));
}
else{
$document->setTitle("<center>Delete a group</center>");
$document->add(new Comment("
<b>Group:</b><br>
<form method='post' action='deletegroup'>
<select name='group' id='group'>
<option value='0' {$selected}>Ungrouped</option>"));

while($row = $stmt2->fetchObject()) {
$id = $row->id;
$name = $row->name;
$document->add(new Comment("<option value='{$id}'>{$name}</option>"));
}
$document->add(new Comment("
</select><br>
<input type='submit' value='Go'>
</form>
<a href='/blank'>Go back</a>"));
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$group = $_REQUEST["group"];
$group_info = $mysidia->db->select("pet_groups", array(), "id='{$group}' and uid='{$uid}'")->fetchObject();
$document->setTitle("Deleted ''{$group_info->name}''");
$document->add(new Comment("
'{$group_info->name}' has been deleted. All pets organized under it are now ''ungrouped''.<br><br>
<a href='/blank'>Go back</a>"));
$mysidia->db->update("owned_adoptables", array("pet_group" => 0), "pet_group = '{$group}'");
$mysidia->db->delete("pet_groups", "uid='{$uid}' AND id = '{$group}'");
}
}

}
?>
<?php

class BlankController extends AppController{


public function index(){
$mysidia = Registry::get("mysidia");

}

public function creategroup(){
$mysidia = Registry::get("mysidia");

}

public function deletegroup(){
$mysidia = Registry::get("mysidia");

}
}
?>

This version doesn't use AJAX, but it basically works the same. It just handles the variables internally instead of passing it to the URL.

Pear
12-17-2017, 02:07 PM
YAAAAS! :D Thanks Dinocanid! :D Makes me want to make a new site now that people can group their pets...I've wanted this kind of feature for sooo long! x'3

parayna
12-17-2017, 02:51 PM
I'll definitely be adding it to my site too! Thank you! It'll make it so much easier to sort pets. I might now replace the faulty sort option with groups because then people can custom group all their pets together! :D

Dinocanid
12-17-2017, 03:51 PM
Yeah, the sort mod didn't work out so well ^^; hopefully a fix is found soon. This one works better imo though. I didn't include a function to actually add pets to those groups yet, but I'm planning to. It's also possible to do it yourself in the meantime with a form that updates the pet's group to whatever the user selected.

draugluin
08-31-2018, 09:38 AM
and here come's the part, which allows you, to assign a group (from the existing groups) to your adopt.

I hope, it works indeed for all :wutno:

in myadopts.php ... after the closing tag ( } ) for the freeze-function


public function changegroup(){
$mysidia = Registry::get("mysidia");
$this->setField("adopt", $this->adopt);
}

and in myadoptsview.php after the closing tag ( } ) for the freeze-function

public function changegroup(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$document->setTitle(" Change group ");
$adopt = $this->getField("adopt");
$username = $mysidia->user->username;
$uid = $mysidia->user->uid;


$stmt20 = $mysidia->db->select("pet_groups", array(), "uid='{$uid}'");

$document->add(new Comment("
<b>Choose a group:</b><br>

<form method='post' action=''>
<select name='groups' id='groups'>
^<option value='0'>choose</option>"));

while($row = $stmt20->fetchObject()) {
$id = $row->id;
$name = $row->name;
$document->add(new Comment("
<option value='{$id}'>{$name}</option>"));
}
$document->add(new Comment("
</select>
<input type='submit' value='go'>
</form>

", FALSE));

if($mysidia->input->post("groups")){
$wahl = $mysidia->input->post("groups");
$new = $mysidia->db->select("pet_groups", array("name"), "id='{$wahl}'")->fetchcolumn();
$mysidia->db->update("owned_adoptables", array("pet_groups" => $new), "aid ='{$adopt->getAdoptID()} ' and owner='{$mysidia->user->username}'");
$document->add(new Comment(" Your adopt is now grouped to :{$new} <br>
<a href='/myadopts/manage/{$adopt->getAdoptID()}'>back to the adopt</a> "));
}



}

and somewhere by the list of name, type etc.

<a href='/myadopts/changegroup/{$aid}'>(changegroup)</a>


have fun :wutno:

Abronsyth
09-04-2018, 03:08 PM
@draugluin, so what I'm getting (from looking at that briefly) is that it allows you to assign your pet to a group via that pet's manage page? That is very handy!

EDIT:
Made some fixes to it so that it works properly, just replace the database update line with;
$mysidia->db->update("owned_adoptables", array("pet_group" => $wahl), "aid ='{$adopt->getAdoptID()} ' and owner='{$mysidia->user->username}'");

draugluin
09-10-2018, 04:01 AM
@ Abronsyth

right... it should be the continuation of Dinocanids script.

but ... $wahl is just the id-number of the pet-groups ... $new is the name.

edit:

http://wolves.16mb.com/w33.jpg

Abronsyth
09-10-2018, 10:03 AM
Aye, the pet-group's ID is what needs to be added to the database for the pet to be "assigned" to it, though, hence replacing with $wahl :)

draugluin
09-17-2018, 04:46 AM
Ah ok ... The main thing is that it works properly :pleased: