TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-05-2009, 03:18 PM   #1 (permalink)
The Acquainted
 
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 137
Thanks: 3
maeltar is on a distinguished road
Default Pulling my hair out....

Ok, I have an issue that I "think" could be filesystem related, trouble is I'm not using php for all parts, am using some php, some python and glueing them together with a bash script !


Overview..
What I am trying to do it create a system that deals with information from the "World of Warcraft Armory"..
The first php file is run as a script, and exports the characters returned to a text file.

First the PHP, that works fine and does excatly what I want it to do...

PHP Code:
<?
class armory {

 const 
BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";

 public 
$query;
 public 
$server;
 public 
$guild;
 public 
$guildie;
 public 
$page;

public function 
__construct $query$server$guild$guildie$page ) {
        
$this->query $query;
        
$this->server $server;
        
$this->guild $guild;
        
$this->guildie $guildie;
        
$this->page $page;
 } 
// end of __construct()

public function pull_xml() {



        
$url 'http://eu.wowarmory.com/guild-info.xml?r=' urlencode($this->server) . '&n=' urlencode($this->guild) . '&p=' $this->page;
        
$ch curl_init();
        
curl_setopt ($chCURLOPT_URL$url);
        
curl_setopt ($chCURLOPT_RETURNTRANSFER1);
        
curl_setopt ($chCURLOPT_CONNECTTIMEOUT15);
        
curl_setopt ($chCURLOPT_USERAGENT,  self::BROWSER);

        
$url_string curl_exec($ch);
        
curl_close($ch);
        return 
simplexml_load_string($url_string);


 } 
// end of pull_xml()

// end class

$xml_obj simplexml_load_string($xml);


$armory = new armory('roster''Khadgar''Aeturnus Recuso'NULLNULL);

$xml $armory->pull_xml();

foreach (
$xml->guildInfo->guild->members->character as $char)
        {
        if( 
$char['level'] ==  '80' )
                {
                echo 
iconv("UTF-8""ISO-8859-1"$char['name']) . "\n";
                }

        }
?>

Now for a touch of BASH and python, this part reads the roster list (created from the above php code) then drags a line out at a time and throws another query at the Warcraft Armoury to get ALL the Achievements for each character listed in the roster file (one name per line). The output from the python script is redirected to a text file, one per character listing all achievements completed or not..


Ok, now this is where I have the problem...

The roster list displays the character names correctly with their funky characters.

http://maeltar.homelinux.net/sandbox...ist_sorted.txt

The problem lays with the file names created by the BASH script, so that I think is filesystem based...

Code:
for member in $(cat ./cache/roster_list_sorted.txt)
        do
                time_start=`date +%s`
                echo Processing $member
                ./achievement_printer.py --eu -r Khadgar -p $member > ./cache/$member.ach
                time_end=`date +%s`
                time_exec=`expr $(( $time_end - $time_start ))`
                echo "$time_exec seconds"
        done
Ok, now this is where I have the problem...

What i would like to do now, is to process the files and create pretty web pages with the data form each file, not a difficult task in any way, apart from the filenames...

Any ideas ? or should I go back to the drawing board and see if I can write something in PHP that will do the job of the python script (The python script is not my work)

I guess am just looking for pointers really...

The files are stored http://maeltar.homelinux.net/sandbox/wow-scripts/cache/

Have a look and see what I mean about the names...

I have a sneaky feeling am going to have to write someting in PHP to do it...
__________________
Thanks... Simon

Sex, Drugs & Linux Rules
Send a message via MSN to maeltar
maeltar is offline  
Reply With Quote
Old 12-05-2009, 03:19 PM   #2 (permalink)
The Acquainted
 
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 137
Thanks: 3
maeltar is on a distinguished road
Default

Oh, and before anyone says it, yes I know the thing is a mess (the server), is just a junk server I use for basic development and testing..
__________________
Thanks... Simon

Sex, Drugs & Linux Rules
Send a message via MSN to maeltar
maeltar is offline  
Reply With Quote
Old 12-06-2009, 06:45 AM   #3 (permalink)
That guy
 
cachepl0x's Avatar
 
Join Date: Sep 2009
Location: San Antonio, TX
Posts: 24
Thanks: 0
cachepl0x is on a distinguished road
Default

If I am reading this correctly, couldn't you just use a regex to remove any non alphanumeric characters?

http://www.talkphp.com/general/5142-stripping-non-alpha-numeric-characters.html
cachepl0x is offline  
Reply With Quote
Old 12-06-2009, 08:32 AM   #4 (permalink)
The Acquainted
 
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 137
Thanks: 3
maeltar is on a distinguished road
Default

No, thats the problem I need the nonalphanumeric characters as they are the player names..

Maybe I would be better off by creating flat file db with 2 columns...

"player name" | "numeric index"

Then I could use that to grab the correct name when i want to display the actual name of the player, that would get around the issue of the filesystem not able to handle the odd charcters..
In fact am thinking about using mysql to store the data in anyway, so just might plan in that function...
__________________
Thanks... Simon

Sex, Drugs & Linux Rules
Send a message via MSN to maeltar
maeltar is offline  
Reply With Quote
Old 12-06-2009, 09:18 AM   #5 (permalink)
That guy
 
cachepl0x's Avatar
 
Join Date: Sep 2009
Location: San Antonio, TX
Posts: 24
Thanks: 0
cachepl0x is on a distinguished road
Default

Couldn't you use the regex to remove/convert the special characters from the file name, and keep the contents of the file the same? Or is that also not what you're looking for?

Also, you could just use sqlite if it's a small project, and it would also increase portability.
cachepl0x is offline  
Reply With Quote
Old 12-06-2009, 10:35 AM   #6 (permalink)
The Acquainted
 
Join Date: Nov 2009
Location: nr Stratford-Upon-Avon
Posts: 137
Thanks: 3
maeltar is on a distinguished road
Default

Never used sqlite, so may use that, would be nice to learn something else while hacking away at this...

Can't really change the file names like that, as each files contains the achievement (completed/uncompleted) information for that player..
__________________
Thanks... Simon

Sex, Drugs & Linux Rules
Send a message via MSN to maeltar
maeltar is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pulling values from one site as reference 9three Absolute Beginners 4 02-17-2009 02:37 PM
Wishing I had hair to pull out... MattD Absolute Beginners 4 02-14-2009 12:24 AM
[PHP/MySQL] Pulling Multiple Rows *Solved* Andrew General 3 10-19-2007 07:10 PM


All times are GMT. The time now is 05:23 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design