Jump to content

Shadow Wolf

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    Dark+Severance
  • Website URL
    http://www.protoculturex.net
  • Yahoo
    DarkSeverance

Profile Information

  • Gender
    Not Telling

Shadow Wolf's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Using XML grabber with cURL I am able to load information from the XML page and convert it into a variable that I can work with in php. This is great for creating roster page or list based on armory.worldofwarcraft.com without having to manually enter in each members name or remake it every time someone joins. It will automatically update itself. Base Code: <php? 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() { // change the first part of the $url to the armory link that you need if( $this->query === 'roster' ){ $url = 'http://eu.wowarmory.com/guild-info.xml?r=' . urlencode($this->server) . '&n=' . urlencode($this->guild) . '&p=' . $this->page; }elseif( $this->query === 'character' ){ $url = 'http://eu.wowarmory.com/character-sheet.xml?r=' . urlencode($this->server) . '&n=' . $this->guildie; } $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt ($ch, CURLOPT_USERAGENT, self::BROWSER); $url_string = curl_exec($ch); curl_close($ch); return simplexml_load_string($url_string); } // end of pull_xml() } // end class ?> I can then sort the xml data and have it display information in a table format (still work in progress) just be adding this to the code: $armory = new armory('roster', 'Drenden', 'Priests of Discord', NULL, NULL); $xml = $armory->pull_xml(); echo "<table>"; foreach ($xml->guildInfo->guild->members->character as $char) { echo "<tr id=\"".$char['name']."\">"; echo "<td class=\"rightAlign\">".$char['name']."</td>"; echo "<td>".$char['level']."</td>"; echo "<td>".$char['class']."</td>"; echo "<td>".$char['gender']."</td>"; echo "<td>".$char['race']."</td>"; echo "<td>".$char['achPoints']."</td>"; echo "<td>".$char['url']."</td><br />"; echo "</tr>"; } echo "</table>"; I understand that the following: $armory = new armory('roster', 'Drenden', 'Priests of Discord', NULL, NULL); $xml = $armory->pull_xml(); is broken up into variables that let me define where it's pulling the data. There are two different XML pages, one is 'roster' and the other is 'character'. The second field determines what server: 'Drenden'. The third field indicates the guild name: 'Priests of Discord'. The fourth field indicates specific character name: NULL. The last field is page number, when looking at guild information only used during the 'roster' option. The problem is the 'character' xml page. There is a lot more information in that page. I could access it for a single character like 'Anastasia' by using the following code: $armory = new armory('character', 'Drenden', 'Priests of Discord', 'Anastasia', NULL); $xml = $armory->pull_xml(); I want to be able to temporarily load all the XML data for the 'roster' page as well as each 'character' page for only those members on that 'roster' page. I tried to do something like: Load Armory Roster Page $armory = new armory('roster', 'Drenden', 'Priests of Discord', NULL, NULL); $xml = $armory->pull_xml(); Then use access the name variable to create a separate query for each by doing: foreach ($xml->guildInfo->guild->members->character as $char) { $armory = new armory('character', 'Drenden', 'Priests of Discord', $char.['name'], NULL); $xml = $armory->pull_xml(); } Unfortunately that does not seem to work. I'm probably trying to load too much variable information or I have the wrong order of how I can use it. I might be over complicating it too. Step by step I can produce each thing individually, now I'm just trying to combine all the single steps so I can display it all on one page. Full Code: <?php 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() { // change the first part of the $url to the armory link that you need if( $this->query === 'roster' ){ $url = 'http://www.wowarmory.com/guild-info.xml?r=' . urlencode($this->server) . '&n=' . urlencode($this->guild) . '&p=' . $this->page; }elseif( $this->query === 'character' ){ $url = 'http://www.wowarmory.com/character-sheet.xml?r=' . urlencode($this->server) . '&n=' . $this->guildie; } $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt ($ch, CURLOPT_USERAGENT, self::BROWSER); $url_string = curl_exec($ch); curl_close($ch); return simplexml_load_string($url_string); } // end of pull_xml() } // end class $armory = new armory('roster', 'Drenden', 'Priests of Discord', NULL, NULL); $xml = $armory->pull_xml(); foreach ($xml->guildInfo->guild->members->character as $char) { $armory = new armory('character', 'Drenden', 'Priests of Discord', $char['name'], NULL); $xml = $armory->pull_xml(); } foreach ($xml->characterInfo->characterTab->professions->skill as $prof) { echo $prof['name']; } foreach ($xml->guildInfo->guild->members->character as $char) { echo "<tr id=\"".$char['name']."\">"; echo "<td class=\"rightAlign\">".$char['name']."</td>"; echo "<td>".$char['level']."</td>"; echo "<td>".$char['class']."</td>"; echo "<td>".$char['gender']."</td>"; echo "<td>".$char['race']."</td>"; echo "<td>".$char['achPoints']."</td>"; echo "<td>".$char['url']."</td><br />"; echo "</tr>"; } ?>
  2. I am learning to work with XML and have been working to apply a couple tutorials with the xml file that I am attempting to work with. The xml I am working with: http://www.animeregister.com/roster.xml I've figured out how to pull the data out that I want and modify the format with a XSL that I have here: http://www.animeregister.com/roster.xsl Now I'm trying to figure out a way to sort through the data, so a user can choose to sort it. I make manual sort by using: <xsl:sort select="@name/> I can change it to ascending, descending and choose level instead of name if I wanted. But I have to make those changes. Is there a way to add multiple sort options? So if they click on Name, it would then ascending sort by name. Clicking on name again, it is now sorted descending by name. If they click on rating it would sort descending by rating, if they click on that again then it would sort ascending and so forth? From looking at some tutorials it looks like I can use a "xsl:when" and "xsl:otherwise" command to display or create my two different order options descending and ascending. But I still can't figure out how to I translate that into a clickable link on X item to change the sort.
  3. It would be with onload, not as the user is sitting there. Just when they load or refresh the page the background would random. Sort of like randomizing a banner/header but wanting that to remain static while the background changes so the banner/header is always the top layer.
  4. Solved the issue. With the server migration they had some security settings, even though they said it had nothing to do with the upgrade. The file was considered writeable with 644 permissions so I had to set it to 444 permissions then everything worked fine. Thank you.
  5. I tried that and the server security mod won't allow that to work either, even just trying to run the script directly, without having to put in a <src= tag.
  6. My server host just upgraded to PHP5 and mySQL5. Unfortunately this means it broke a few scripts that were working so I need a new method to get the same effect. I was using rid.php (random image script) that was fairly simple. I drop it into a directory with images, then link to it and it will pull the images up in the directory. There was never any need for me to update the script when I added images, I just needed to add the images to the directory. <?php //read folder $folder=opendir("."); while ($file = readdir($folder)) $names[count($names)] = $file; closedir($folder); //sort file names in array sort($names); //remove any non-images from array $tempvar=0; for ($i=0;$names[$i];$i++){ $ext=strtolower(substr($names[$i],-4)); if ($ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png"){$names1[$tempvar]=$names[$i];$tempvar++;} } //random srand ((double) microtime() * 10000000); $rand_keys = array_rand ($names1, 2); //random image from array $slika=$names1[$rand_keys[0]]; //image dimensions $dimensions = GetImageSize($slika); if (isset($pic)){header ("Location: $slika");} else {echo "<img src=\"$slika\" $dimensions[3]>";} ?> I would then use the following code in my html to call upon it and it worked fine with years... except now it will not work anymore: <? function view_logo() { global $mklib; return <<<EOF <!-- begin logostrip --> <tr> <td id="mklogostrip" height="100" width="100%"> <a href="$mklib->siteurl/index.php"><img src="http://www.protoculturex.net/images/header/rid.php?pic=random" border="0" alt="PCX" /></a> </td> </tr> <!-- end logostrip --> EOF; } ?> I used the script in a <img tag because it basically tricked it into thinking it was an image and didn't require me to make any modifications to the script trying to mess with an echo or get it to display the image with the way the .php is setup in the Portal software. I tried to use a random .php script and replace the image tag using the following below. But for some reason it isn't working. It displays all the images, not a random one and it seems the closing tags for the .php part isn't working right. It treats it like regular HTML. <? function view_logo() { global $mklib; return <<<EOF <!-- begin logostrip --> <tr> <td id="mklogostrip" height="100" width="100%"> <? $bannerAd[1] = '<a href="http://www.protoculturex.net/" target="_blank"><img src="/images/header/bleach.jpg" width="903" height="259" border="0"></a>'; $bannerAd[2] = '<a href="http://www.protoculturex.net/" target="_blank"><img src="/images/header/bucktick2.jpg" width="903" height="259" border="0"></a>'; $adCount = count($bannerAd); $randomAdNumber = mt_rand(1, $adCount); echo $bannerAd[$randomAdNumber]; ?> </td> </tr> <!-- end logostrip --> EOF; } ?> So is there an easier way to do this or a method to update the way I was doing it earlier? Any help and suggestions would be appreciated, thank you. Keep in mind I'm pretty much a newbie when it comes to php/mysql, this just seemed like the easiest way to do it at the time.
  7. Is it possible with just CSS to randomize or have the background cycle through a set of pre-selected background images?
  8. Is there a way that I could query the whole mySQL database for a certain wildcard. For example query the whole database to check all the fields to see if a certain URL is somehow in the database somewhere and then output where it is so I can remove it?
  9. So it would look something like this? function database() { //establish a connection mysql_connect("localhost","USER","PASSWD") or die(mysql_error()); mysql_select_db("DATABASE") or die(mysql_error()); //then perform the query operations $sql = "SELECT category_id, directory, masked_file_name FROM ibf_gallery_images WHERE category_id='60' "; $result = mysql_query ($sql); return $result; } So how does that function loop until there are no more results? It seems that would only query and give back 1 result. So I'm not getting the effect of the following when I call on the function: while($row = mysql_fetch_array($result)){ echo "{$row['masked_file_name']}"; echo "<br />"; } And to call the function later on in the code, it would just be the following right? database();
  10. I was thinking I needed to create a seperate function with the query. Then call upon it into this function where the 'return' part is. ... at least that is what I had thought.
  11. Yes the return part is nested in a function, from what I can tell it is part of this function, make_image_tag. function make_image_tag( $i, $tn=0, $med_link=0 ) { //------------------------ // Thumbnail? //------------------------ $tn = $tn ? '&tn=1' : ''; $thumb = $tn ? 'tn_' : ''; //------------------------ // Directory? //------------------------ $dir = $i['directory'] ? "&dir={$i['directory']}/" : ""; $directory = $i['directory'] ? "{$i['directory']}/" : ""; if( !file_exists( $this->ipsclass->vars['gallery_images_path'].'/'.$directory.$thumb.$i['masked_file_name'] ) ) { $tn = ''; $thumb = ''; } if( !file_exists( $this->ipsclass->vars['gallery_images_path'].'/'.$directory.$thumb.$i['medium_file_name'] ) ) { $med_link = 0; } //------------------------ // Update bandwidth, if required //------------------------ if( $this->ipsclass->vars['gallery_detailed_bandwidth'] && $this->ipsclass->input['req'] == 'si' ) { if( ! ( $tn && ! $this->ipsclass->vars['gallery_bandwidth_thumbs'] ) ) { $cut = time() - ( $this->ipsclass->vars['gallery_bandwidth_period'] * 3600 ); if( $this->del_bandwidth != 1 ) { $this->ipsclass->DB->do_delete( 'gallery_bandwidth', "bdate < {$cut}" ); $this->del_bandwidth = 1; } $filename = ( $tn == 0 AND $med_link == 1 ) ? $i['medium_file_name'] : $i['masked_file_name']; $insert = array( 'member_id' => $this->ipsclass->member['id'], 'file_name' => $i['masked_file_name'], 'bdate' => time(), 'size' => intval( @filesize( $this->ipsclass->vars['gallery_images_path'].'/'.$directory.$thumb.$filename ) ) ); $this->ipsclass->DB->do_shutdown_insert( 'gallery_bandwidth', $insert ); } } //------------------------ // Is this media? //------------------------ if( $i['media'] ) { $this->load_media_cache(); $ext = '.' . strtolower( array_pop( $explode_result = explode( ".", $i['masked_file_name'] ) ) ); $media = $this->media_thumb_cache[$ext]; if( $i['media_thumb'] ) { $img_url = "{$this->ipsclass->vars['gallery_images_url']}/{$directory}"; return "<img src='{$img_url}{$i['media_thumb']}' class='galattach' alt='{$i['media_thumb']}' />"; } else { return "<img src='{$this->ipsclass->vars['board_url']}/style_images/<#IMG_DIR#>/{$media['icon']}' />"; } } else { if( $this->ipsclass->vars['gallery_web_accessible'] == 'yes' ) { $img_url = "{$this->ipsclass->vars['gallery_images_url']}/{$directory}{$thumb}"; if( $i['medium_file_name'] && $med_link ) { $img_tag = "<img src='{$img_url}{$i['medium_file_name']}' class='galattach' alt='{$thumb}{$i['masked_file_name']}' />"; return "<a href='{$img_url}{$i['masked_file_name']}' rel='lightbox[{$i['category_id']}]' target='_blank' class='gal'>{$img_tag}</a> <div id='lightbox-hide'> <a href='{$img_url}gallery_60_29440.jpg' rel='lightbox[{$i['category_id']}]'></a> <a href='{$img_url}gallery_60_110410.jpg' rel='lightbox[{$i['category_id']}]'></a> <a href='{$img_url}gallery_60_29896.jpg' rel='lightbox[{$i['category_id']}]'></a> <a href='{$img_url}gallery_60_20234.jpg' rel='lightbox[{$i['category_id']}]'></a> <a href='{$img_url}gallery_60_24532.jpg' rel='lightbox[{$i['category_id']}]'></a> </div>"; } else { return "<img src='{$img_url}{$i['masked_file_name']}' class='galattach' alt='{$thumb}{$i['masked_file_name']}' />"; } } else { $img_url = "{$this->ipsclass->vars['board_url']}/index.php?automodule=gallery&req=viewimage&img={$i['id']}{$tn}"; if( $i['medium_file_name'] && $med_link ) { $img_tag = "<img src='{$img_url}&file=med' class='galattach' title='{$thumb}{$i['masked_file_name']}' />"; return "<a href='{$img_url}' target='_blank' class='gal'>{$img_tag}</a>"; } else { return "<img src='{$img_url}' class='galattach' />"; } } } }
  12. I'm trying to integrate Lightbox into the Gallery system I use. I have integrated it for the initial pop-up image. However it won't advance to the next or previous images. The reason being is because I need the links for the images to be on the webpage. So I created a hidden div tag to hide all the links. To make sure only the images in that particular category display, I need to query the database so that it will only output those category images. I created a test.php page where I duplicated what I wanted with basic .php/html and it works as intended. Now I'm trying to integrate that query into the function that is used to display the image. Then the URL links will be hidden and the previous and next image links will work. Where I'm trying to insert it into is here: Demo URL When you click on the main image it pops up the full size image using lightbox. The highlighted red part is what I have inserted into it to hardcode the lightbox effect, so that it will associate the next/prev images with that main image that popped up. The problem is of course if they go into another Gallery Category those links stay there. It won't change based on the category. So the query I initially created will ouput the file_name so when it enters into that category it will query it, output it to the hidden div field and the lightbox effect will work per category. But I can't figure out how to integrate that query into it so that I can echo it out into the hidden div field.
  13. I need help turning a query into a function. The query and code by itself works fine as a stand-alone .php file. The issue I'm having is trying to integrate it with an existing php script. It looks like the only real way to insert it is as a function, other methods create various syntax errors or the query doesn't produce any results. However the code by itself works fine. So I figured if I turn it into a function place that function in the php file, then call upon it then it would probably work properly. <? mysql_connect("localhost","USER","PASSWD") or die(mysql_error()); mysql_select_db("DATABASE") or die(mysql_error()); $query =" SELECT category_id, directory, masked_file_name FROM ibf_gallery_images WHERE category_id='60' "; $result = mysql_query($query) or die (mysql_error()); echo "<div id='lightbox-hide'>"; while($rowlb = mysql_fetch_array($resultlb)){ echo "<a href='http://www.mydomain.com/{$rowlb['masked_file_name']}' /></a>"; echo "<br />"; } echo "</div>"; ?> If I can put it into a function or maybe it is called an array, then I should be able to call upon it easier. The place where I'd call upon the function looks like this: if( $i['medium_file_name'] && $med_link ) { $img_tag = "<img src='{$img_url}{$i['medium_file_name']}' class='galattach' alt='{$thumb}{$i['masked_file_name']}' />"; return "<a href='{$img_url}{$i['masked_file_name']}' rel='lightbox[{$i['category_id']}]' target='_blank' class='gal'>{$img_tag}</a <div id='lightbox-hide'> [WHERE I WOULD LIKE THE QUERY TO OUTPUT TOO] </div>"; I've spent hours trying to work on this and I can get the initial run to at least work on my test page but integrating it into the other script is where I'm having trouble. That and understanding functions. I've ran through various tutorials online and tried to apply them to this but they are either too basic or I'm missing that little bit of extra knowledge to learn how to better apply it. Any help would be greatly appreciated. Thank you.
  14. Ok... I'm sorry but I'm a bit slow on the uptake. I have read the FAQ but it doesn't explain in terms that I really understand. $this->ipsclass->vars['gallery_images_path'] It is used to call variables from within an object... doesn't explain how the above translates into the example. $this = the object? So $obj->bar(); is actually just doing the falling code: function bar() { echo "Bar initiated"; } $this->ipsclass->vars['gallery_images_path'], since it has multiple -> does that mean it is an object calling upon another object. So the object $this is calling upon ipsclass which is calling upon vars to call upon ['gallery_images_path']? So if I want to find out what the whole thing means, I need to look through the code to find the object ipsclass and vars? Is that correct?
  15. I am not that skilled with php but have a real basic understanding of the syntax. I'm trying to learn it and most of things I get but then I get confused when I encounter things like ->. I don't understand what that means. For example the function below, we have the the variable: $this->ipsclass->vars['gallery_images_path'] . '/' . $dir . $image['masked_file_name'] So from what I see, the variable is $this and I understand $dir is the directory variable and if I echo it, I'll get the directory. $image['masked_file_name'] is the image name variable, echoeing it will show the image name. But the part I don't understand is $this->ipsclass->vars['gallery_images_path'] I don't understand what the -> means. Is it that it is telling me that $this becomes ipsclass which becomes vars['gallery_images_path']? So if I need to call upon that variable is it just vars['gallery_images_path'] or do I have to use the whole string or am I just completely wrong? Can anyone point me someplace to read up on what -> means or help explain it to me in simple terms? Thank you.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.