Archive > AoC 0.6.x Custom/Unofficial modules

Depot module

(1/6) > >>

Getrix:
Did some modifying on the Depot module.
This module is primary for AoC, but it should work for AO also i think..

Its released as a Beta for now, so feedback is wanted.

http://dump.sjef.biz/aoc/bebot/Depot.phps


INFO:
Download, put in costume/modules
help should be complete, so check it out for commands info.
Biggest change is Request function. This will help ppl to get request item on the Depot list, and remind itemholder that someone wants it.

Changelog:
3.2: Removed old org security check. Using only command check.

xlDanek:
Really nice one!

Unfortunately it doesn't work for me.

I can add items to the list, but if i check the list with "!depot", I only get "No items exist in the org depot.".

A look in the database shows: the new added items haven't been set to "Y" in the "itemActive" column.

I changed the SQL query as below (at row 124)


--- Code: ---$query=("INSERT INTO #___depot (itemDatetime, itemHolder, itemName, itemLowid, itemHighid, itemQl, itemLowcrc, itemHighcrc, itemColour, itemUrl, itemActive) VALUES ('".$DatetimeNow."', '".$items[0]['holder']."', '".$items[0]['name']."', '".$items[0]['lowid']."', '".$items[0]['highid']."', '".$items[0]['ql']."', '".$items[0]['lowcrc']."', '".$items[0]['highcrc']."', '".$items[0]['colour']."', '$fitemname', 'Y')");
--- End code ---

Now it works. Eventually the query in the "else" clause (row 128) has to be changed, too.

But i have two additional mistakes:

If I want to add an item with a german Umlaut "ä", "ü" or "ö" (untestet: "ß"), I get a positive answer, but the entry in the database isn't valid. There are some fields missing, like itemholder, itemName,... And the auto_increment function is sometimes broken after that :D Suddenly I had the ID "12259xxxx" after ID "4" :D
But it doesn't happen everytime (the ID problem, the Umlaut problem is repeatable).

The other mistake is a "permission to delete" problem. With the .php you posted above every member of my guild could delete every item in the list (I don't know why, but in my "whois" table every member has a "org_rank_id" of "0", perhaps because we have set no org). So I comment line 157 out:


--- Code: ---//if($result1[0][0] < 2) $candel = true;
--- End code ---

and it work's fine. Nobody could delete the items except the itemholder himself and the superadmins.

But I've got no solution for the Umlaut problem. :(

Edit:


--- Quote ---And the auto_increment function is sometimes broken after that :D Suddenly I had the ID "12259xxxx" after ID "4" :D
But it doesn't happen everytime (the ID problem, the Umlaut problem is repeatable).
--- End quote ---

Ok, now I found th reason that is responsible for this behavior ;) If the added item is no "item link" but a normal text, the ID is set to the current time


--- Code: ---$depotID = time();
--- End code ---

and


--- Code: ---$query=("INSERT INTO #___depot (id, itemName, itemURL, itemHolder) VALUES ('" . $depotID . "', '" . $fitemname . "', '', '" . $name . "')");
--- End code ---

Afterwards, the auto_increment functions continues with this high ID.
But why is this implemented this way? I don't see why it's useful and necessary? Wouldn't it be better to disable the possibility of adding a normal text instead an item link?

Getrix:
Thanks for the feedback!


--- Quote ---$depotID = time();
--- End quote ---
This is something from the old version, and i must say i never been in the situation where it was triggered...
And yes, its abit stupid that it adds a big number and auto_inc over it.
EDIT: This is removed from Beta 3.0-b



--- Quote ---I changed the SQL query as below (at row 124)
--- End quote ---
This is probly because default value is not set correct, but your suggestion is a nice fix to make sure its being set correct
EDIT: Added this. Thanks for the suggestion!


--- Code: ---//if($result1[0][0] < 2) $candel = true;
--- End code ---
Will check this out.
EDIT: Removed as i cant see the point having it... Got enough security checks.


Going to test some changes out before putting a new file up
EDIT: Working version is uploaded

xlDanek:
It looks really good so far.


--- Quote ---Wouldn't it be better to disable the possibility of adding a normal text instead an item link?
--- End quote ---

I see you changed this in the code, too. You made it exact the same way I did it in my german version ;)

In the meantime I also solved my Umlaut problem. Just for the record because it's only necessary for german bebot users. I only insert some "str_replace" functions in the "depot_add" methode to change the Umlaute in "ä = ae, ö = oe, ü = ue and ß = ss". Afterwards I changed it back to the Umlaute:


--- Code: ---function depot_add($itemname, $name)
    {
 
        $itemname = str_replace('Ä','Ae',$itemname);
        $itemname = str_replace('ä','ae',$itemname);
        $itemname = str_replace('Ö','Oe',$itemname);
        $itemname = str_replace('ö','oe',$itemname);
        $itemname = str_replace('Ü','Ue',$itemname);
        $itemname = str_replace('ü','ue',$itemname);
        $itemname = str_replace('ß','ss',$itemname);

        $sql = "SELECT org_rank_id FROM #___whois WHERE nickname = '$name'";
        $result = $this -> bot -> db -> select($sql);
        if ($this -> bot -> guildbot && $result[0][0] < 6)
        {
           
            if(is_numeric($dimension)) {
              $itemPattern = '(<a href="itemref:\/\/([0-9]*)\/([0-9]*)\/([0-9]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)"><font color=#([0-9a-f]*)>\[([\\-a-zA-Z0-9_\'&\s\-]*)\]<\/font><\/a>)';
              $posPattern = "/<a href=(.+)$/i";
            }         
            else {
              $itemPattern = '(<a style="text-decoration:none" href="itemref:\/\/([0-9]*)\/([0-9]*)\/([0-9]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)"><font color=#([0-9a-f]*)>\[([\\-a-zA-Z0-9_\'&\s\-]*)\]<\/font><\/a>)';
              $posPattern = "/<a (.+) href=(.+)$/i";
            }
           
            $fitemname = addslashes($itemname);
            $pos = preg_match($posPattern, $itemname,$info);
            $DatetimeNow = date('Y-m-d H:i:s');
            //Debug statement, uncomment to see the values are being posted by the user.
            //$this->bot->log("Depot", "Add_Item", "Item string [$itemname] Cutdown[" .str_replace('a','b',$itemname). "] Info [$info]");
            if ($pos)
            {
                $count = preg_match_all('/'.$itemPattern.'/i', $itemname, $matches, PREG_SET_ORDER);
                foreach($matches as $match)
                {
                    $item['holder']                                 = $name;
                    if (is_numeric($match[2])) { $item['lowid']     = $match[2]; }
                    if (is_numeric($match[3])) { $item['highid']    = $match[3]; }
                    if (is_numeric($match[4])) { $item['ql']        = $match[4]; }
                    $item['lowcrc']                                 = $match[5];
                    $item['highcrc']                                = $match[6];
                    $item['colour']                                 = $match[7];
                    $item['name']                                   = addslashes($match[8]);

  $item['name'] = str_replace('Ae','Ä',$item['name']);
  $item['name'] = str_replace('ae','ä',$item['name']);
  $item['name'] = str_replace('Oe','Ö',$item['name']);
  $item['name'] = str_replace('oe','ö',$item['name']);
  $item['name'] = str_replace('Ue','Ü',$item['name']);
  $item['name'] = str_replace('ue','ü',$item['name']);

                    $items[] = $item;
                }
                $query=("INSERT INTO #___depot_eng (itemDatetime, itemHolder, itemName, itemLowid, itemHighid, itemQl, itemLowcrc, itemHighcrc, itemColour, itemUrl, itemActive) VALUES ('".$DatetimeNow."', '".$items[0]['holder']."', '".$items[0]['name']."', '".$items[0]['lowid']."', '".$items[0]['highid']."', '".$items[0]['ql']."', '".$items[0]['lowcrc']."', '".$items[0]['highcrc']."', '".$items[0]['colour']."', '$fitemname', 'Y')");
               
                $this -> bot -> db -> query($query);
                $depotID = mysql_insert_id();
                $strmsg = "Thank you, your item has been added to the database as id #" . $depotID;
            }
            else
            {
                $strmsg= "The link/item you are trying to share is not in a valid format!";
            }
           
        }
        else
            $strmsg = "You must be at least a Unit Member of the org to insert items into the org depot.";

        return $strmsg;
    }

--- End code ---

palm521:
great. however it does not let me add items,

it says , You must be at least a Unit Member of the org to insert items into the org depot

how do you add/remove people from the org (im currently the owner of the bot)

thanks in advance.

Navigation

[0] Message Index

[#] Next page

Go to full version