Jump to content

emma57573

Members
  • Posts

    106
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

emma57573's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks for your help, I simplified it a bit as I don't need to check for extensions but it worked a treat. Cleaned up 790 images great was hoping for move though have 219,000 images on site but it seems like most of them are used $row="select url from images_keep where id !=''"; mysql_query($row) or die('Query failed keepimage: ' . mysql_error()); $image[] = $row['url']; // put images to keep in array $folder = "uploadedimages/"; // set folder path to images $files = glob($folder.'*.*'); // open folder and get files foreach ($files as $img) { $ext = strtolower($img); // make it lower case for ease if (!in_array($ext, $image)){ unlink($ext); // remove image } I tested it by inserting it into a table first to inspect the images to delete, too scary to run straight off! But works great thanks
  2. Thanks for that, that makes sen e. I will have a crack at that when I get home and let you know how I get on. Thanks
  3. Hi Im trying to write a script to clean up my image directory which has quite a lot of unused images that have built up over time. In order to do this I am doing the following. First Create a database table called 'image_clean' Then I'm searching through 3 tables and collecting all the image file names and dumping the names in the table 'image_clean' Can do that no problem. So now I have all the images I need in this one table 'image_clean' I now want to go through my directory 'image_uploads' and delete anything thats not in the 'image_clean' table. I know how to delete the files using unlink Im just unsure how to search through the directory file by file and check the file against the database. Im asumming I need to put them in an array. Could anyone give be a clue or two to get me started. I have no problem checking a database against a directory but when its the other way round 'checking a directory against a database I'm lost. What I might do is pop the files to delete in a new database called 'image_delete' so that I can then check the images to delete before I write the unlink script. But I'm just not sure how to pick up each file and compare it to the table. Thanks in advance.
  4. I have a line of code that has been working for over a year, then two days ago it failed in a few areas on my site and I hadnt made any changes. I contacted the host and there was no server updates etc. Its a php/imagemagick issue, basically the "widthxheight^ - Minimum values of width and height given, aspect ratio preserved" command does not work and fails to import the image at all when I add ^ to my code. I need it though and im getting fustrated, for now ive changed my code to: exec("convert $path1 -thumbnail 200x180 -colorspace rgb -gravity center -extent 170x150 $path2"); which works ok but is not spot on like it was before, what I really want is exec("convert $path1 -thumbnail 170x150^ -colorspace rgb -gravity center -extent 170x150 $path2"); What ever I do I cant get ^ to work anymore but oddly all other imagemagick commands are fine.
  5. Ok so Ive fixed that but it still will only allow me to display one widget per page. Any ideas how I can change change my sc ript to allow more than one widget to be shown? Heres an update on how my code is looking: Widgets: <!-- START MY MISI--> <script src="http://www.mydomain.co.uk/jquery.js"></script> <script type="text/javascript"> var user_id = 205; var width = 238; var cid = 0; var text = 1; var ord = 0; var qty = 6; var thumbs = 0; var FRAMEwidth = 245; var FRAMEheight = 720; </script> <script src="http://www.mydomain.co.uk/mini_misi.js"></script> <div id="misi205"></div> <!-- END MY MISI--> <!-- START MY MISI--> <script src="http://www.mydomain.co.uk/jquery.js"></script> <script type="text/javascript"> var user_id = 205; var width = 238; var cid = 0; var text = 1; var ord = 0; var qty = 6; var thumbs = 0; var FRAMEwidth = 245; var FRAMEheight = 720; </script> <script src="http://www.mydomain.co.uk/mini_misi.js"></script> <div id="misi205"></div> <!-- END MY MISI--> /////////JAVASCRIPT FILE mini_misi.js///////////////// // JavaScript Document $(document).ready(function(){ var htmlStr = '<iframe src="http://www.mydomain.co.uk/mini_misi.php?user_id='+user_id+'&width='+width+'&qty='+qty+'&cid='+cid+'&ord='+ord+'&text='+text+'&thumbs='+thumbs+'" scrolling="no" frameborder="0" height="'+FRAMEheight+'" width="'+FRAMEwidth+'"></iframe>'; $('#misi'+user_id+'').html(htmlStr); });
  6. Ok so Ive rewritten this and its working and rendering at a much more acceptable level! yay! HOWEVER although its working great. In some instances I may have users adding more than one widget to their blog/webpage however if I add more than one widget to a page only one will show! I figured it was because the div's are named the same? I have tried to rename the divs so that they are different for each widget but Im not getting the syntax correct: I want to change $("#render").html(htmlStr); To: $("#render'+user_id+'").html(htmlStr); But that does not look or work correctly (sorry Javascript newbie!) Im hoping thats the reason why it will not allow me to paste the widget more than once in the same document?? But im open to suggestions? //HTML Snippit <!-- START MY widget--> <script src="http://www.mydomain.co.uk/jquery.js"></script> <script type="text/javascript"> var user_id = 205; var width = 238; var cid = 0; var text = 1; var ord = 0; var qty = 6; var thumbs = 0; var FRAMEwidth = 245; var FRAMEheight = 720; </script> <script src="http://www.mydomain.co.uk/widget.js"></script> <div id="render"></div> <!-- END MY widget--> // JavaScript Document $(document).ready(function(){ var htmlStr = '<iframe src="http://www.mydomain.co.uk/my_widget.php?user_id='+user_id+'&width='+width+'&qty='+qty+'&cid='+cid+'&ord='+ord+'&text='+text+'&thumbs='+thumbs+'" scrolling="no" frameborder="0" height="'+FRAMEheight+'" width="'+FRAMEwidth+'"></iframe>'; $("#render").html(htmlStr); });
  7. ah ok, Im not confident in Javascript. This is my first attempt at writing anything in Javascript thats not copy and paste! I will give that a go and see if it makes a difference. Im still confused as to why it works for 'user_id' and none of the others when its passed in the same way.
  8. Im having trouble passing variables to PHP from an iframe. The first URL variable is passed with no problem and the remainder are being ignored, any ideas? <!-- Get MINI SHOP--> <script src="http://www.mydomain.com/jquery.js"></script> <span id="205" class="user_id"></span> <span id="900" class="height"></span> <span id="900" class="width"></span> <span id="0" class="cid"></span> <span id="0" class="ord"></span> <script src="http://www.mydomain.com/widget.js"></script> <div id="shop"></div> <!-- END MINI SHOP--> JS Code that opens the iframe // JavaScript Document $(document).ready(function(){ var user_id = $(".user_id").attr("id"); var width = $(".width").attr("id"); var cid = $(".cid").attr("id"); var ord = $(".ord").attr("id"); var qty = $(".qty").attr("id"); var height = $(".height").attr("id"); var htmlStr = '<iframe src=http://www.mydomain.com/mini_shop.php?user_id='+user_id+'&width='+width+'&cid='+cid+'&ord='+ord+'" scrolling="no" frameborder="0" height="'+height+'" width="'+width+'"></iframe>'; $("#shop").html(htmlStr); });
  9. First I should explain that I dont normally write JS, I normally leave and js to code snippits, so this is new to me. So I have a dynamic Iframe and I want to call it for javascript so it can be used as a widget for blogs etc This is what I have: <script src="http://www.mydomain.com/widget_script.js" type="text/javascript"></script><script type="text/javascript">new widget.Promo(205, 188,0,0,3).renderIframe();</script> and the JS: widget = typeof(widget)=="undefined" ? {} : MISImini; widget.Promo = function(user_id, width, cid, order, qty) { this.user_id = user_id; this.width = width; this.cid = cid; this.order = order; this.qty = qty; } getURL: function(){ return 'http://www.mydomain.com/widget.php'+ '?user_id='+this.id+ '&width='+this.getWidth(); '&cid='+this.cid+ '&ord='+this.order+ '&qty='+this.qty+ }, var html = '<iframe id="promo_iframe" name="promo_iframe" allowtransparency=true style="width:100%;height:200px" src="'+this.getURL()+'" scrolling="no" frameborder="0"></iframe>'; document.write(html); } Nothing happens, the iframe does not load :-\
  10. Thank you, the only reason I put the full domain in was because it was looking for a directory ive added ../ and its fine now thanks. However its still showing as a redirect and showing the full domain in the address bar instead of my nice new clean domain :-\
  11. I still havnt had a chance to dig deep into this, anyone have an suggestions?? I thought when I did the mod rewrite it would change the domain and so the domain would stay in the address bar but it seems all it does is send a redirect. I want to use this rule for all my dynamic pages, but I dont want this type of redirection as I dont want to get penalized by google for having redirects everywhere! Maybe Im barking up the wrong tree with .htaccess altogether and theres another way round it altogether. As I said its going to the right page and the link its right every things good apart from the fact the the redirection shows the dynamic page in the menu bar. I just dont want it to look like a redirection (even though it kind of is?? ) :-\
  12. This is what I used for my fake subdomains and it works I had to get my hosting company to set up a wildcard on the server for it to work though. RewriteCond %{HTTP_HOST} ([^/]+).mydomain.co.uk [NC] RewriteCond %1 !www$ [NC] RewriteRule ^(.*)$ http://www.mydomain.co.uk/some_page.php?variable=%1 [L]
  13. The following code works by redirecting, example: www.mydomain.co.uk/gifts/art.html goes to http://www.mydomain.co.uk/handmade-gifts.php?cid=Art Thats all great and works HOWEVER It redirects (which yes is what I wanted) BUT the address bar changes to the long address but what I really want to do is keep the clean address in the address bar to fool SE into thinking they are looking at www.mydomain.co.uk/gifts/art.html as a static page. I know this must be possible as Ive seen lots of sites doing the same thing what am I doing wrong? I should add im new to .htaccess and learning as I go! Options +FollowSymlinks RewriteCond %{HTTP_HOST} ^www.mydomain.co.uk RewriteRule ^gifts\/(.*)\.html http://www.mydomain.co.uk/handmade-gifts.php?cid=$1 [NC]
  14. What the following bit of code does is create a thumbnail of 190x190 then it will crop it to 170x150 in proportion Its working great but some of the file sizes are still coming out quite large and eating on load times/Bandwidth Now I should be able to get a size of about 8 - 12kb for each of these images as they are only small but I cant find any code that will compress the file size to a size that I specify. Ive found loads of resizing commands but I cant find a command to specify a size to compress to. Can anyone help me out? exec("convert -size 190x190 $path1 -thumbnail \"170x150^\" -gravity center -extent 170x150 $path2");
  15. Ive fixed this with the following: $domain=$_REQUEST["domain"]; $patterns = "www."; $replacements = ""; $domain = str_replace($patterns, $replacements, $domain); Sometimes just writing out te question helps you think with a clear head
×
×
  • 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.