Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: forum rangs system

Parašė Black psycho· 2008 Vas. 28 12:02:27
#1

Cia mano forum_ranks :
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2006 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
require_once "../maincore.php";
require_once BASEDIR."subheader.php";
require_once ADMIN."navigation.php";
include LOCALE.LOCALESET."admin/forums.php";

if (!checkrights("F") || !defined("iAUTH") || $aid != iAUTH) fallback("../index.php");
if (!isset($action)) $action = "";

if (isset($status))
{
   if ($status == "savefr")
   {
      $title = $locale['494'];
      $message = "<b>".$locale['495']."</b>";
   }
   elseif ($status == "delfr")
   {
      $title = $locale['494'];
      $message = "<b>".$locale['496']."</b>";
   }
   opentable($title);
   echo "<div align='center'>".$message."</div>\n";
   closetable();
   tablebreak();
}   

if (isset($_POST['save_rank']))
{
   $rank_title = stripinput($_POST['rank_title']);
   $rank_image = stripinput($_POST['rank_image']);
   if($rank_image != "")
   {
      if ( !preg_match("/(\.gif|\.png|\.jpg)$/is", $rank_image))
      {
         $rank_image = "";
      }
   }
   $rank_post = isNum($_POST['rank_post']) ? $_POST['rank_post'] : "0";
   $rank_special = isNum($_POST['rank_special']) ? $_POST['rank_special'] : "0";
   if($action=="radd")
   {
      if($rank_title != "")
      {
         $result = dbquery("INSERT INTO ".$db_prefix."ranks (rank_title,rank_image,rank_post,rank_special) VALUES('$rank_title', '$rank_image', '$rank_post', '$rank_special')");
      }
   }
   else
   {
      $result = dbquery("UPDATE ".$db_prefix."ranks SET rank_title='$rank_title', rank_image='$rank_image', rank_post='$rank_post', rank_special='$rank_special' WHERE rank_id='$rank_id'");
   }
   redirect(FUSION_SELF.$aidlink."&status=savefr");
}
elseif (isset($_POST['save_special']))
{
   $insql="";
   $resultd = dbquery("UPDATE ".$db_prefix."users SET user_rank='0' WHERE user_rank='$rank_id'");
   if (is_array($_POST['special_user']) && count($_POST['special_user']) > 0)
   {
      foreach ($_POST['special_user'] as $thisnum)
      {
         if (isNum($thisnum)) $insql .= ($insql ? "," : "").$thisnum;
      }
      $result = dbquery("UPDATE ".$db_prefix."users SET user_rank='$rank_id' WHERE user_id IN($insql)");
   }
   redirect(FUSION_SELF.$aidlink."&status=savefr");
}
else
{
   if ($action=="redit")
   {
      $result = dbquery("SELECT * FROM ".$db_prefix."ranks WHERE rank_id='$rank_id'");
      $rdata = dbarray($result);
      $rank_title = $rdata['rank_title'];
      $rank_image = $rdata['rank_image'];
      $rank_post = $rdata['rank_post'];
      $rank_special = $rdata['rank_special'];
   }
   else
   {
      $rank_title="";
      $rank_image="";
      $rank_posts="0";
      $rank_special="0";
   }
   
   opentable($locale['494']);
   switch($action)
   {
      case "radd":
      case "redit":
      echo "<form name='ranksform2' method='post' action=''>
      <table align='center' cellpadding='0' cellspacing='1' class='tbl'>
      <tr>
      <td class='tbl'>".$locale['498']."</td>
      <td><input type='text' name='rank_title' value='".$rank_title."' maxlength='50' class='textbox' style='width:200px;'></td>
      </tr>
      <tr>
      <td class='tbl'>".$locale['499']."<br>".$locale['500']."</td>
      <td><input type='text' name='rank_image' value='".$rank_image."' maxlength='255' class='textbox' style='width:200px;'></td>
      </tr>
      <tr>
      <td class='tbl'>".$locale['501']."</td>
      <td><input type='text' name='rank_post' value='".$rank_post."' maxlength='5' class='textbox' style='width:200px;'></td>
      </tr>
      <tr>
      <td class='tbl'>".$locale['502']."</td>
      <td class='tbl'><select name='rank_special' class='textbox'>
      <option value='0'".(!$rank_special ? " selected" : "").">".$locale['505']."</option>
      <option value='1'".($rank_special ? " selected" : "").">".$locale['504']."</option>
      </select></td>
      </tr>
      <tr><td>&nbsp;</td></tr>
      <tr>
      <td class='tbl' align='center' colspan='2'><input type='submit' name='save_rank' value='".$locale['503']."' class='button'></td>
      </tr></table></form>";
      break;

      case "rdelete":
      $result = dbquery("UPDATE ".$db_prefix."users SET user_rank='0' WHERE user_rank='".$rank_id."'");
      $result = dbquery("DELETE FROM ".$db_prefix."ranks WHERE rank_id='".$rank_id."'");
      redirect(FUSION_SELF.$aidlink."&status=delfr");
      break;

      case "rspecial":
      $result = dbquery("SELECT * FROM ".$db_prefix."ranks WHERE rank_id='$rank_id' AND rank_special='1'");
      if(dbrows($result)!=0)
      {
         $user_list="";
         $result2 = dbquery("SELECT user_id,user_name,user_rank FROM ".$db_prefix."users WHERE user_rank='0' OR user_rank='$rank_id' ORDER BY user_name ASC");
         while($data=dbarray($result2))
         {
            $user_list .="<option value='".$data['user_id']."'".($data['user_rank'] == $rank_id ? " selected" : "").">".$data['user_name']."</option>\n";
         }
         echo "<form name='ranksform3' method='post' action=''>
         <table align='center' cellpadding='0' cellspacing='1' width='100%'>
         <tr>
         <td class='tbl' align='center'>".$locale['508']."</td>
         </tr>
         <tr>
         <td class='tbl' align='center'><select multiple size='15' name='special_user[]' class='textbox'>$user_list</select></td>
         </tr>
         <tr>
         <td class='tbl' align='center'><input type='submit' name='save_special' value='".$locale['509']."' class='button'></td>
         </tr>
         </table></form>";
      }
      else
      {
         echo "<center>".$locale['507']."</center>";
      }
      break;

      default:
      echo "<form name='ranksform' method='post' action=''>
      <table align='center' cellpadding='0' cellspacing='1' width='100%'>
      <tr>
      <td class='tbl2' align='center'><b>".$locale['498']."</b></td>
      <td class='tbl2' align='center'><b>".$locale['499']."</b></td>
      <td class='tbl2' align='center'><b>".$locale['501']."</b></td>
      <td class='tbl2' align='center'><b>".$locale['502']."</b></td>
      <td class='tbl2' colspan='3' align='center'><b>".$locale['488']."</b></td>
      </tr>";
      $result = dbquery("SELECT * FROM ".$db_prefix."ranks ORDER BY rank_special DESC, rank_id");
      if(dbrows($result)!=0)
      {
         while($rdata2 = dbarray($result))
         {
            echo "<tr><td class='tbl1' align='center' valign='center' width='33%'>".$rdata2['rank_title']."</td>";
            if($rdata2['rank_image'] != "")
            {
               echo "<td class='tbl1' align='center' width='33%'>".$rdata2['rank_title']."<br><img src='".IMAGES_R.$rdata2['rank_image']."' alt=''></td>";
            }
            else
            {
               echo "<td align='center' valign='center'>---</td>";
            }
            echo "<td class='tbl1' align='center' valign='center' width='10%'>".$rdata2['rank_post']."</td>
            <td class='tbl1' align='center' valign='center' width='10%'>".($rdata2['rank_special'] ? $locale['504'] : $locale['505'])."</td>
            <td class='tbl1' align='center' valign='center' width='7%'><a href='".FUSION_SELF.$aidlink."&amp;action=redit&amp;rank_id=".$rdata2['rank_id']."'>".$locale['481']."</a></td>
            <td class='tbl1' align='center' valign='center' width='7%'><a href='".FUSION_SELF.$aidlink."&amp;action=rdelete&amp;rank_id=".$rdata2['rank_id']."'>".$locale['482']."</a></td>";
            if($rdata2['rank_special'])
            {
               echo "<td class='tbl1' align='center' valign='center' width='7%'><a href='".FUSION_SELF.$aidlink."&amp;action=rspecial&amp;rank_id=".$rdata2['rank_id']."'>".$locale['506']."</a></td>";
            }
            echo "</tr>";
         }
      }
      echo "<tr>
      <td>&nbsp;</td>
      </tr>
      <tr>
      <td colspan='6' align='center'><a href='".FUSION_SELF.$aidlink."&amp;action=radd'>".$locale['497']."</a></td>
      </tr></table></form>";
   }
   closetable();
}

require_once BASEDIR."footer.php";
?>



Kazkas cia negerai nes kai noriu paskirti i specialu ranga nary tai man raso:
Unknown column 'user_rank' in 'field list'Unknown column 'user_rank' in 'field list'



ir buna tuscial laukelis kur reikia nari pasirinkti. Cia modas is modai.webdnd.com

Parašė Black psycho· 2008 Vas. 28 12:02:19
#2

Tai nieks nezinot? :?:?:?:( gal cia kazkas su mysql?

Redagavo Black psycho· 2008 Vas. 28 12:02:12

Parašė Giedrunskis· 2008 Vas. 28 13:02:07
#3

taip, negerai su mysql, tiksliau viskas gerai su ja, tiesiog tau reikia susikurti ta user_rank lentele joje ;)

Parašė Black psycho· 2008 Vas. 28 14:02:45
#4

as sukuriau lentele kaip buvo parasyta bet vistiek nieko

Parašė Black psycho· 2008 Kov. 2 21:03:15
#5

Man atrodo kad sql uzklausoje gali buti kazkas blogai va mano sql uzklausa:
CREATE TABLE IF NOT EXISTS fusion_ranks (
rank_id smallint(5) unsigned NOT NULL auto_increment,
rank_title varchar(50) NOT NULL default '',
rank_image varchar(255) NOT NULL default '',
rank_post smallint(5) unsigned NOT NULL default '0',
rank_special tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (rank_id)
) TYPE=MyISAM;

ALTER TABLE fusion_users ADD user_rank smallint(5) unsigned NOT NULL default '0';



Nes man ismeta:
Klaida

SQL užklausa:

ALTER TABLE fusion_users ADD user_rank smallint( 5 ) unsigned NOT NULL default '0';

MySQL atsakymas: ?
#1146 - Table 'marichuana.fusion_users' doesn't exist



Parašė bruzgis· 2008 Kov. 2 21:03:33
#6

tai ziurek ar vienodi prefixai !!!