Jump to content

MrFish

Members
  • Posts

    492
  • Joined

  • Last visited

Everything posted by MrFish

  1. That's the same code I used as posted in OP. I checked an old file I used on this same server which printed correctly. Started stripping it down and found it started nesting incorrectly after I took out text nodes. This now works- $DOM = new DOMDocument(); $div = $DOM->createElement("div"); $div->appendChild($DOM->createTextNode(""));$DOM->appendChild($div); $div = $DOM->createElement("div"); $div->appendChild($DOM->createTextNode(""));$DOM->appendChild($div); $div = $DOM->createElement("div"); $div->appendChild($DOM->createTextNode(""));$DOM->appendChild($div); $div = $DOM->createElement("div"); $div->appendChild($DOM->createTextNode(""));$DOM->appendChild($div);echo $DOM->saveXML(); But it seems like a cheap trick. How does this page look for you? [ URL REMOVED ] Edit: Oh wait you're right. I was viewing the page through Chromes element inspector. In the HTML it's <div/> like you said. This doesn't register as <div></div> though. Any idea how to make that print differently without text nodes?
  2. Strange. I will investigate on that and see what I can find.Could it be a PHP version issue?
  3. Hello W3S, I'm trying to use DOMDocument but when i use appendChild its not appending to the element I expect it to. Here is a simple example- $DOM = new DOMDocument();$DOM->appendChild($DOM->createElement("div"));$DOM->appendChild($DOM->createElement("div"));$DOM->appendChild($DOM->createElement("div"));$DOM->appendChild($DOM->createElement("div"));echo $DOM->saveXML(); What I expect- <body> <div></div> <div></div> <div></div> <div></div></body> What I get- <body> <div> <div> <div> <div> </div> </div> </div> </div></body> I've looked at the PHP documentation and this looks like how they did it but obviously I'm missing something. Can anyone spot my mistake? Edit: Also, i need to use createElement because I want to manipulate the elements before adding them. When you use new DOMElement() its read only for whatever reason
  4. Hello W3, I've got something I'm tossing over in my head looking for different points of view. I mostly work on sites individually site-by-site but I'm working on something that I'm trying to do differently. The idea is- A large-scale network of sites. Each site has a template (choosen from a handful) Each site has it's own database These sites all have the same type of content but have different content that needs to be managed by individuals outside our system. (ex: a car sales site. clients can upload cars and manage content but can't access the files directly) I want to figure out how to do this pretty easily. My two ideas are 1. Have a single center for all content. When a site is accessed it uses a config file for that site and dynamically pulls in all content at each page call. Each site would be a shell essentially. If you access the stylesheet.css file it would actually load like php (using mod_rewrite) and dynamically pull in the correct style. This could have complications since there wouldn't be actually be any php files. If you went to the car_search_results.php file it would send that page url to a parsing page and write the information dynamically before running it. Same with something like an about-us page. This could become complicated and lag the server too much. 2. Each site would hold their own files but any updates would need to be pushed out from the center. So if you updated the stylessheet_redtheme.css file it would push it out to every site that is configured to use that stylesheet. This would be simpler but I don't know if it would loose flexibility. Any thoughts?
  5. http://www.napolitanohomes.com/signup.php Let me know if you have any ideas.
  6. Mobiles site work fine but when I view a sites main desktop version the page locks up (on both iphone and droid). It occasionally allows me to zoom in and out but just locks up again. I cant pan the screen around and I can't fill in forms. I'm just looking for some possible answers. Could it be that the site is too heavy for the phone?I can provide a url if needed.
  7. Figured it out. <a href="sms:000000">Text Now</a> For Iphone only... <a href="sms:000000?body=test">Text Now</a>
  8. I know you can put a phone number on a mobile site and most newer mobile os/browsers automatically open a call prompt when you click it. Is it possible to open a texting window? And is it possible to open the texting window with a pre-typed word inside?
  9. Not required. Figured it out. Results- $likes = array( "'gallery.php?gal=%'" => "Home,Gallery" ); foreach($likes as $key => $value) { $query = "SELECT * FROM aliases WHERE als_url LIKE $key"; $result = mysql_query($query); $newLinks = array(); while($arr = mysql_fetch_assoc($result)) { $newLinks['"' . str_replace("-", " " , $arr[als_slug]) . '"'] = array( "'alias'" => $arr[als_slug], "'link'" => $arr[als_url], "'links'" => array() ); } $arrString = ""; $parts = explode(",", $value); foreach($parts as $part) { $arrString .= "['$part']['links']"; } ob_start(); print_r($newLinks); $arrOutput = ob_get_clean(); $arrOutput = str_replace("Array", "array", $arrOutput); $arrOutput = preg_replace("|( => )([^\[\(]+)( \[)|U", "$1'$2',$3", $arrOutput); $arrOutput = str_replace("[\"", "\"", $arrOutput); $arrOutput = str_replace("\"]", "\"", $arrOutput); $arrOutput = str_replace("['", "'", $arrOutput); $arrOutput = str_replace("']", "'", $arrOutput); $arrOutput = preg_replace('|array[\s]+\([\s]+\)[\s]+\)[\s]+"|U', 'array ( ) ), "', $arrOutput); eval("\$links$arrString = $arrOutput;"); } Wish there was a simpler way but this is what I came up with.
  10. I want to use a csv string to set the value of an index a few layers deep in an array. See my following array- This is for breadcrumbing purposes. $links = array( "Home" => array( "alias" => "home", "link" => "index.php", "links" => array( "Communities" => array( "alias" => "Communities", "link" => "communities.php", "links" => array() ), "Home Plans" => array( "alias" => "Home-Plans", "link" => "plans", "links" => array() ), "Gallery" => array( "alias" => "Photo-Gallery", "link" => "galery.php", "links" => array() ), "About Us" => array( "alias" => "About-Us", "link" => "about.php", "links" => array( "Press" => array( "alias" => "press.php", "link" => "press.php", "links" => array() ), "Testimonials" => array( "alias" => "testimonials.php", "link" => "testimonials.php", "links" => array() ) ) ), "Contact Us" => array( "alias" => "Contact-Us", "link" => "contact.php", "links" => array() ), "Available Homes" => array( "alias" => "Available-Homes", "link" => "homes.php", "links" => array() ), "Homebuyer University" => array( "alias" => "Homebuyer-University", "link" => "homebuyer.php", "links" => array( "Finance Your Home" => array( "alias" => "Finance-Your-Home", "link" => "finance.php", "links" => array() ), "Solution Center" => array( "alias" => "Solution-Center", "link" => "solution.php", "links" => array() ) ) ), "Homeowners Corner" => array( "alias" => "Homeowner-Warranty", "link" => "homeowners.php", "links" => array() ), "Favorites" => array( "alias" => "Online-Favorites-Folder", "link" => "favorites_login.php", "links" => array( "View Favorites" => array( "alias" => "favorites.php", "link" => "favorites.php", "links" => array() ) ) ), ) ) ) The site I'm working on keeps page aliases inside a table called aliases. I want to dynaimcally load those aliases to certain sections of my array but giving it a little info to go off of- $likes = array( "'gallery.php?gal=%'" => "Home,Gallery" ); foreach($likes as $key => $value) { // START OF FOREACH $query = "SELECT * FROM aliases WHERE als_url LIKE $key"; $result = mysql_query($query); $newLinks = array(); while($arr = mysql_fetch_assoc($result)) { $newLinks[str_replace("-", " " , $arr[als_slug])] = array( "alias" => $arr[als_slug], "link" => $arr[als_url], "links" => array() ); } And the string "Home,Gallery" could be of any length and automatically go to that index of the array. To do that I wanted to use eval- $arrString = "\$links"; $parts = explode(",", $value); foreach($parts as $part) { $arrString .= "[$part][links]"; } //Testing... does not work... echo $arrString; print_r(eval($arrString)); } // END OF FOREACH This prints- $links[Home][links][Gallery][links] So I would think if this was evaled it would work. But I get nothing. Anyone know what I'm doing wrong?
  11. A website I'm working on have FB Like buttons on home's pages but when you click them it doesn't pull the right info into facebook. For some pages it doesn't even pull the right page. On the pages that do pull the right content we would like it to pull more accurate information about the page instead of the first image on the page. Page with URL that does not work-http://www.napolitanohomes.com/Home-Details?inv=19 Page with URL that DOES work-http://www.napolitanohomes.com/913B-Vineyard-Place So I've been looking into this and this is what I found. Originally I thought Facebook was accessing the page and dynamically pulling out content and the exact url you were liking. So while trying to figure out why it was pulling the wrong url I setup a script that logged the request url and the user agent of anything that accessed that page. With this I found that when you like a page facebook does not actually access that page but already has some information about it in their databases. Also, Home-Details takes you to a completely different page then Home-Details?inv=19 (Home-Details is a redirect) and Facebook is assuming you're talking about the first URL and when you like the second. So what I need to do is- 1. Get Facebook to "like" the entire correct url instead of the first half.2. Get Facebook to load more accurate information. Once I make these changes will I have to wait for Facebook to revisit these pages and get the correct information out of them? How long should I expect this to take?
  12. This is a long question so bear with me. I've got an ipad webapp I'm working on where you can draw on a canvas and save it. Like a more basic paint program. I need to be able to upload and image to the background and draw on it. Right now that wouldn't be too difficult since I got the drawing functionality and it wouldn't be hard to just print the image to the background and draw on it. The problem I'm having is that it also needs to have manageable layers. This means it needs to support alpha pixels. So what I've done is written a panel class that when paint is called it moves down through it's child panels and paints their buffered images to the temp image. Then I take that and paint it over the parent- continueing until the image is flattened to a temporary image. This works fine- especially on a desktop. But to accomplish this I had to write the putImageData code from scratch which loops through the array of pixels and paints them taking the alpha in account. Like so- var offset = (canvasW*4*y)+x*4; for(var r = 0; r < newHeight; r++) { var lineOffset = (size.width*4 - columns)*r + offset; for(var c = 0; c < columns; c+=4) { var start = (r*columns)+c; var destStart = start+lineOffset; var red = imageData[start]; var green = imageData[start+1]; var blue = imageData[start+2]; var alpha = imageData[start+3]; var destRed = canvasData[destStart]; var destGreen = canvasData[destStart+1]; var destBlue = canvasData[destStart+2]; var destAlpha = canvasData[destStart+3]; var opacity = alpha/255; var destOpacity = destAlpha/255; var invOpacity = 1-opacity; var newRed = Math.abs(red - ((red-destRed)*invOpacity)); var newGreen = Math.abs(green - ((green-destGreen)*invOpacity)); var newBlue = Math.abs(blue - ((blue-destBlue)*invOpacity)); canvasData[start+lineOffset] = newRed; canvasData[start+lineOffset+1] = newGreen; canvasData[start+lineOffset+2] = newBlue; canvasData[start+lineOffset+3] = 255; } } This loop takes about 50 miliseconds per layer. Pretty pathetic already but I would take it if this was for a desktop. Takes a whopping 1200 miliseconds for the ipad! So I tested it with the original putImageData (which doesn't support alpha) and it was still not very impressive but it's the best I got I'm thinking. So here is my problem. I know there is an overal opacity for drawing with canvases but it needs to be able to draw some pixels completely opaque and some completely transparent. Is there an putImageData that includes opacity? If not any recommendations on how I can accomplish this? I saw some people were using css and different <canvas> elements to create layers. Is this the way to go?
  13. I don't generate the image array- chrome does. The pixels to the right of the cup are transparent but they are not part of the same panel. The cup is actually a much larger image but is only displayed inside that view. Instead of drawing one big image then cropping it I'm trying to save processing but only drawing whats in view. I did find the solution though. Only needed to use 4 extra if statements. var w = panel.width; var h = panel.height; if(x < 0) var cutSX = abs(x); else cutSX = 0; if(y < 0) var cutSY = abs(y); else cutSY = 0; if(x+w > size.width) var cutEX = x+w - size.width; else cutEX = w; if(y+h > size.height) var cutEY = y+h - size.height; else cutEY = h; var newWidth = cutEX - cutSX; var newColumns = newWidth*4; var newHeight = cutEY - cutSY; var imageData = panel.getImage(cutSX, cutSY, cutEX, cutEY).data; var columns = newWidth*4; var rows = newHeight;
  14. It appears on the left because since it's one long array as I'm looping through the box image data I'm looping through the cup image data as well starting at a specific offset. After your reach the far right of the cup image the pixels after will start 1px down and all the way to the left. So as I loop it starts drawing to the left of the image. I have to keep track of the width and the height of the canvas. To find the next pixel to draw I do this- var columns = panel.width*4; var rows = panel.height; var offset = (canvasW*4*y)+x*4; for(var r = 0; r < panel.height; r++) { var lineOffset = (size.width*4 - columns)*r + offset; for(var c = 0; c < columns; c+=4) { var start = (r*columns)+c; var destStart = start+lineOffset; var red = imageData[start]; var green = imageData[start+1]; var blue = imageData[start+2]; var alpha = imageData[start+3]; var destRed = canvasData[destStart]; var destGreen = canvasData[destStart+1]; var destBlue = canvasData[destStart+2]; var destAlpha = canvasData[destStart+3];
  15. I'm working on a project where I need to be able to manage frames and panels inside of JS Canvas. They all need to have an independent view but all compile to a flat image when the paint() method is called. It's written so far to be similar to Java's JPanel (in fact I'm calling it MPanel for a lack of creativity). Everything is built around the MPanel class. An MPanel can have an array of other MPanels inside it with different x/y/z properties. When paint() is called the MPanel loops through all it's MPanels and calls paint() on them (which branches out through every MPanel until they have all called paint). The paint() method takes the image data of the panels inside it and draws it to it's own image data (calculating opacities and all). The lousy thing about Canvas is that the image data is not in a 2 dimensional array and is one long array of numbers (every 4 numbers represents the rgba values. So data[0] - data[3] is the first pixel in the top left). This causes a problem when MPanel child is slightly outside the parents view. It turns out looking like this- What do you all think? Any creative solutions without using an if statment on all 640,000 pixels in the ramen noodle cup?
  16. How does a session know which host to point to if all the session information is contained on the server and the ip doesn't look different between hosts on the same network? It's not like it has a steady socket connection.
  17. I'm trying to track login based on IP addresses but not sure if it's possible. I've always used sessions but I want to be able to use IPs for a specific reason. People also should be able to log into the same website on the same network but not on two accounts on the same computer. No one should be able to login to the same user on different computers.Pretty standard I think. But I'm not much of a network person so I never noticed that all the computers connected to the same router have the same IP.I also assumed it was ###.###.###.XXXwhere the X's was the name of your specific machine within your network. But now I got to go back to the bare bones of my site and fix this problem. I still would like to use IP so is there any way I could get the specific host within a network or is the forward facing address of the router the only thing I'm allowed to read? Also. This raises a question for me with Sessions. I thought a session was called based on your IP. And yet I've logged into a session site on one computer and I wasn't logged into the site one a different computer on the same network. I'm confused.
  18. Ah you're right! I found in a sidebar include I was trying to use a class that I didn't load. I didn't notice because it would usually break the page but since it didn't inform me I didn't realize. You saved me another hour of rage!
  19. Any thoughts about what might do it? Another ob_get_clean() ?
  20. I'm trying to include a php file and dynamically write head tags. My short code looks like this. ob_start();include($path);$page = ob_get_contents();ob_end_clean(); But the file is included and displayed anyway. I've put an exit() after ob_end_clean() because I echo the page contents and I still see everything. Any ideas?
  21. Oh nice. I didn't know that was possible. Thanks!
  22. Ok I've got another question that should be easier to answer. I've got an object called Frame that holds an array of objects called Points. I want to use jQuery's $.get method to call a php file to return this information. The $.get is called inside the Frame object. function Frame(){this.JSONReturnData = null;this.pointsJSON = null; this.loadPoints = function(){ $.get("php/getPoints.php", {sessionId:window.sessionId,sequence:this.sequence}, function(d) { this.JSONReturnData = d; this.pointsJSON = $.parseJSON(d); }}} Here is the code cleaned up a bit. I set the values to null in the head of the objects and I want to set their actual values in the method "loadPoints". But I realised before I even tested it that the $.get callback is going to run inside it's own object. And if I return the data then it will just return to the $ (jQuery) object. So using this and return won't work in this situation and I'm not sure how to send the data back to the host object. I know I could use window to set it as a global variable but that's just bad programming. I'm trying to get away from cheap dirty tricks like that. Anyone know how I can solve this problem? EDIT: I have thought about doing this- var jObj = $.get("php/getPoints.php", {sessionId:window.sessionId,sequence:this.sequence}, function(d) { return d; }); this.JSONReturnData = jObj.responseText; this.pointsJSON = $.parseJSON(this.JSONReturnData); But the issue is that the rest of the method will keep running and not wait for the $.get method to finish.
  23. I guess canvases like inline width/height instead of css width/height. This solved the issue.I'm working on a project that uses HTML5 Canvas and I'm having a strange problem with stretching. I noticed it with images and thought my math might have been wrong but then I took everything out and tried drawing a simple 100x100 square and it's completely stretched out at different proportions. The code for this (small class code)- function Canvas(DOMID, F){this.Frame = null;this.width = null;this.height = null;this.zoom = null;this.DOM = null;this.ctx = null;this.offset = null; //Constructor this.init = function(DOMID, F){ this.DOM = document.getElementById(DOMID); this.width = $(this.DOM).width(); this.height = $(this.DOM).height(); this.ctx = this.DOM.getContext("2d"); this.zoom = 1; this.offset = {x:0,y:0}; if(F != null) this.setFrame(F); this.onReady();} //Modifiers this.draw = function(){ //this.ctx.drawImage(image, 0, 0); this.ctx.beginPath(); this.ctx.fillStyle = "#ffffff"; this.ctx.rect(0,0,100,100); this.ctx.closePath(); this.ctx.fill();}this.setFrame = function(F){ this.Frame = F;}//Events this.onReady = function(){} this.init(DOMID, F);} The code calling this function is in an interval- window.goToCanvas = function(){ clearTimeout(playInterval); playInterval = setInterval("drawCurrentCanvas()", window.playSpeed);}window.drawCurrentCanvas = function(){ index = window.canvasIndex; canvases[index].draw();} The page can be found here- http://micahwilliamson.com/analytics/viewer/viewer.php I'm stumped. I hope someone can see my mistake somewhere.
  24. Is it possible to draw html elements inside a canvas? I would like to take an entire page's html and print it inside a canvas like a dynamic screenshot of a webpage. I've looked around an I don't think it's possible but I thought I'd ask.
×
×
  • Create New...