![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
zq29
-
Posts
2,752 -
Joined
-
Last visited
-
Days Won
1
Posts posted by zq29
-
-
the '$' symbol is a special character when working with Regular Expressions - Escape it and you should be fine.
[code]<?php
$val1 = "{BODY}";
$val2 = '\$453.00';
echo preg_replace('/{BODY}/',$val2,$val1);
?>[/code] -
[quote author=dagnasty link=topic=103226.msg411028#msg411028 date=1154933097]
intimidating at first, but in no time you'll be stripping data and posting forms from a php script.
Need help with it, just give me a PM?
[/quote]
As far as I'm aware our PM system is currently disabled. Even if it wasn't, please keep all technical discussions in the forum - It may help someone else out in the future. -
Sounds a bit dubious... But, you'd be able to do this with the cURL library (documented in the PHP manual).
-
[code=php:0]mysql_query("UPDATE `table` SET `field`='0' WHERE `id`='$id'") or die(mysql_error());[/code]
-
I've never heard that you should not use multidimensional session arrays, there are no downsides that are instantly obvious... I've used them several times with no problems.
-
[quote author=onlyican link=topic=103079.msg410263#msg410263 date=1154795844]
You can find the pixel color from an image, and replace it with your color
I have seen one script which replaces all "Non Internet Safe" colors with "Internet Safe" colors, and let me tell ya, it was a good script, but the images came out really really bad
[/quote]I know how to find a pixels colour, my script above demonstrates that ;)
[quote author=Barand link=topic=103079.msg410301#msg410301 date=1154801369]
imagecolorset() changes the pallete so one change there affects the whole image
[/quote]Yeah, that works fine with gifs and 8-bit pngs, but unfortunately I'm working with true colour jpegs. This is why I am using a threshold so that I am replacing a 'range' of slightly different colours with their counterpart replacement colours.
I'm getting closer to solving my problem I think, but still a long way off - I have been tinkering with this on and off for weeks... -
Hi everyone,
I have found the need to be able to change a specific colour within a photograph automatically with PHP (and GD). My progress so far has enabled me to change the [i]hue[/i] of a specific colour, but I need to be able to change the [i]saturation[/i] and the [i]brightness[/i] as well. This is where I appear to be hitting a wall, and I'm struggling to figure it out - Might have something to do with my poor maths skills ;). Hopefully somone could offer me some usefull pointers on how I might go about this. Here is my function so far...
[code]<?php
function recolor($file,$colortochange,$newcolor) {
$threshold = 30;
$image = imagecreatefromjpeg($file);
$width = imagesx($image);
$height = imagesy($image);
$c1 = sscanf($colortochange,"%2x%2x%2x");
list($huetoreplace,$sattoreplace,$valtoreplace) = rgbtohsv($c1[0],$c1[1],$c1[2]);
$c2 = sscanf($newcolor,"%2x%2x%2x");
list($newhue,$newsat,$newval) = rgbtohsv($c2[0],$c2[1],$c2[2]);
for($y=0; $y<$height; $y++) {
for($x=0; $x<$width; $x++) {
$rgb = imagecolorat($image,$x,$y);
$a = ($rgb >> 24) & 0xFF;
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
list($h,$s,$v) = rgbtohsv($r,$g,$b);
$angle = ($h >= $huetoreplace) ? 360 - ($h - $huetoreplace) : 360 - ($huetoreplace - $h);
$angle = ($angle > 180) ? 360 - $angle : $angle;
if($angle <= $threshold) {
$h = $newhue + ($h - $huetoreplace);
if($h < 0) $h += 360;
if($h > 360) $h -= 360;
/* $s = $newsat + ($s - $sattoreplace);
if($s < 0) $s = 0;
if($s > 100) $s = 100;
$v = $newval + ($v - $valtoreplace);
if($v < 0) $v = 0;
if($v > 100) $v = 100;
*/
list($r,$g,$b) = hsvtorgb($h,$s,$v);
$color = imagecolorallocatealpha($image,$r,$g,$b,$a);
imagesetpixel($image,$x,$y,$color);
}
}
}
header("Content-Type: image/jpeg");
imagejpeg($image);
}
?>[/code]
The above works lovely, replacing the hues where it should. But when I add in the code to alter the saturation and brightness (value), I get some wierd results, such as 'blocks' of colour and random colours here and there. I just can't figure it out.
There are two functions used in the above code that I haven't added, but they are just for converting RGB to HSV and visa-versa. And yes, this function does loop through an image pixel by pixel, if you have any other ideas on how to do this, they would also be appreciated as this method is slow, but it gets the job done (at its current stage).
If anyone needs help understanding my code so far, I can comment it if need be, let me know.
Any help is very much appreciated. :) -
One option could be to create a 'count' field in your table. Every time a user is assigned to a 'job' increment their count, when selecting a user for a 'job', order the results by the 'count' field and select the user with the lowest count.
-
Check out the manual page for the xml_parse_into_struct() function, theres some good examples of how it can be used to parse an xml file into arrays.
-
Sorry, I think I must have misunderstood you. I thought the feed would either be viewed with a browser, or with an RSS aggregator, and the feed would be formatted differently depending on what it was being viewed in. My bad.
-
Please refrain from using vulgar words on the forums, they're not necessary to convey your message. Thanks.
-
You could run your array through strtolower() so everything will be in lowercase...
-
It will save the file to the machine running PHP, your server.
-
You could check the user agent with $_SERVER['HTTP_USER_AGENT']
-
As far as I'm aware, Safari is based on the KHTML engine - The same as Konqueror which is generaly packaged with Linux installs running KDE. It is possible to get Konqueror running on WinXP, but I'm not sure how easy it is - A quick search on Google will show you how.
It might be just easier to burn off a copy of Knoppix.
Do mac users activly use Safari? I use on FireFox on mine... -
Thats quite an interesting way of going about it! Thanks for that AndyB, I might just go ahead with that idea until anyone pops up with a better way / reason why thats not as good of an idea as I first thought!
-
As part of a project, I need the user to be able to place a 'marker' on top of an image, and to do this I need to location of the mouse relative to the top left of the image (contained within a div). My current solution gets the mouse position relative to the page and then offsetting it agains the position of the image div - As you are probably aware, this is not ideal for several reasons. I'd class myself as somewhat of a novice at JavaScript as I don't really use it on a daily basis. Any help with this would be appreciated. My current function:
[code]function getcoords(id,tgt) {
var posX = 0;
var posY = 0;
var exit = 0;
document.getElementById(tgt).onmousemove = getMouseXY;
document.getElementById(tgt).onclick = storeMouseXY;
function getMouseXY(e) {
if(exit == 0) {
if(navigator.appName == "Netscape"){
posX = e.pageX;
posY = e.pageY;
} else {
posX = event.clientX + document.body.scrollLeft;
posY = event.clientY + document.body.scrollTop;
}
if (posX <= 0) {posX = 0;}
if (posY <= 0) {posY = 0;}
var pos = (posX - 494)+","+(posY - 157);
document.getElementById(id).value = pos;
}
}
function storeMouseXY() {
var pos = (posX - 494)+","+(posY - 157);
document.getElementById(id).value = pos;
exit = 1;
}
}[/code] -
No problem what so ever :) Back to the topic at hand...
-
[quote author=AndyB link=topic=102431.msg406423#msg406423 date=1154348956]
If you have the correct versions of everything (or the insecure set-up), then http://www.winguides.com/scripting/ might be a usable solution for you.
[/quote]Thanks AndyB, I'll look into that. -
Bugger. I thought this might be the case as it would be open for some abuse.
It's not even for an internet application either which is the annoying thing, more of an intranet application. Looks like I might have to learn some Java or something... -
Its all in the title ^^
I want to be able to create an array of the contents of a defined local directory - is this possible with JavaScript, and is there a function that does it?
Thanks very much. -
I have just edited out the vulgar words in 6 of the above posts in this thread. Please refrain from using such words in future, they were not necessary to convey your problem. We do have minors browsing the forum, and yes, they probably have heard those words a million times before elsewhere, but thats not the point.
-
Welcome :)
-
Ok, here's my list, a bit of a range of different styles in there I think:
[0] A Tribe Called Quest
[0] Alicia Keys
[0] Basement Jaxx
[0] Blackalicious
[0] Bob Marley
[0] Christina Aguilera
[0] Citizen Cope
[0] De La Soul
[0] Dead Prez
[0] Dillated Peoples
[0] DJ Format
[0] DJ Shadow
[0] DJ Z-Trip
[0] Fatboy Slim
[0] Feeder
[0] Fugees
[0] Gavin DeGraw
[0] Green Day
[0] Hieroglyphics
[0] Jurassic 5
[0] Maroons
[0] Macy Gray
[0] Mos Def
[0] No Doubt
[0] Oasis
[0] Phantom Planet
[0] Prodigy
[0] Ray Charles
[0] Reel Big Fish
[0] Talib Kweli
[0] Tenacious D
[0] The Roots
Delete a file?
in PHP Coding Help
Posted
I tried using
[code=php:0]
chdir ($file_system_path);
exec ("del *.* /s /q");[/code]
And it delted everything in the current directory that I had the file that was running the code. It is a damn good thing that I used a test directory in local host..lol
This is dangerous if you do not know what you are doing.
Thanks,
Tom
[/quote]
Indeed. '*.*' will delete all files with an extension as the * character is used as a wildcard, /s flags all sub-directories for deletion, and /q runs in quiet mode - just deleting without prompting.