PHP - Restrict Url Manipulation Vs Using Links
I am trying to find a workaround for people using bookmarks and executing them simultaneously forcing a script to run thousands of times in just a second. Is there a way I can implement a token or a short bit of javascript that would force the user to use the link vs bookmarked URL pages? Sorry if I am being vague here but its really causing me issues having people doing this on my site. Similar TutorialsHey guys i have a script that i made with multiple permissions.. i need to add in the pages restitutions for diffrent levels.. so i got the level $query = "SELECT * FROM users WHERE `username`='$username_from_cookie'"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // get results $result = mysql_query($query) or die("Couldn't execute query"); // now you can display the results returned while ($row10= mysql_fetch_array($result)) { $permissions= $row10["permissions"]; echo '$permissions'; } Now to restick im ok with like to but more then that i get confused.. this shows navigation on levels of permissions.. if ($row10['permissions'] == 2) { print "<a href=\"U.php\"><img src=\"./Icons/Users.png\" title=\"Prof\" /></a>"; } else { print "<img src=\"./Icons/Users_o.png\"/>"; } 2 levels if ($row10['permissions'] == 5) { print "<a href=\"Prof_1.php\"><img src=\"./Icons/sec.png\" title=\"Enseignant(e)\"/></a>"; } elseif ($row10['permissions'] == 2) { print "<a href=\"Prof_1.php\"><img src=\"./Icons/sec.png\" title=\"Enseignant(e)\"/></a>"; } else { print "<img src=\"./Icons/sec_o.png\" title=\"Enseignant(e)\"/>"; } ok so instead of have 10 lines of codes can i $row10['permissions'] == 5&2&3 ??? and can i do if not permissions ==5 redirect to loggin.. thanks What is the best way to force a user to input numeric value into a form, with the following condition: Either the number is an integer (positive or negative or zero), or non integer but limited to the one digit behind the dot (e.g. 1.2 is valid, but 1.21 is not)? I know I can test it in the server side, but I prefer it to be on the form side. Can it be in the HTML level? Hi All, Im new to this forum but think its going to be a regular location for me for quite a while. Im very very new to php and the guy that was doing code for me is not responding to emails, so i thought id have a go myself...lol at the moment im going through the trial and error phase while learning. I have edited some of the code he has put on the site to create a new look. the original page: http://www.ridersguide.co.uk/county_accommodation.php?county=4; the one im trying:http://www.ridersguide.co.uk/county_accommodation2.php?county=4; The new bit is to add a preview of the text for the page. echo $row[ad_text]; the code above brings up all the text but i only want to show the first 4 or 5 lines. Is this possible in php? Any help appreciated Neil Hi, I have been searching everywhere to try to figure out how to restrict the number of chararacters shown when I do a while loop of data. The one I want to restrict is Property_Short_Description here - <?php echo "2.gif vspace=5 border=0><br />"; echo $row['Property_Short_Description'];} ?> Thanks so much Hi. I'm making a file-sharing website but how do I stop users from uploading certain extensions? Here is my script so far: <?php session_start(); $file_name = $HTTP_POST_FILES['ufile']['name'];$random_digit=rand(0000,9999);$new_file_name=$random_digit.$file_name;$path= "upload/".$new_file_name;if($ufile !=none){if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)){echo "Successful<BR/>";}else{echo "Error";}}?>() I have solved this now. hi... I have a site that allows user to download some files. at present if i type http://www.abc.com/files/xyz.zip it allows all the users to access and download files. I want only the login users can access these files....... pls help how to do this. thanks in advance I'm using the restrict content pro plugin to accept website registrations. I would like users to have the ability to click a checkbox on the registration page and it automatically applies a $50 discount. I am using this code to add a checkbox to the registration field, but I'm having trouble applying the "RCP_Discount" class when the box is checked. Any help would be greatly appreciated. Thank you! ~Sarah Hello I have this code: Code: [Select] $data = mysql_query("SELECT * FROM remind WHERE DATE_SUB(CURDATE(), INTERVAL 1 DAY) = event_date ") or die(mysql_error()); Basically what I need, I have a table (remind) with lots of dates of events (event_date). 1 day before the event and on the day of the event, I want to send an e-mail to my customers, automatically. This up mentioned code send e-mails to all the upcoming events, not ONLY to the ones TOMORROW or TODAY. I need something like this: If today is 01-01-2011 AND I have an event on 02-01-2011 I want that the SQL code will find and send the e-mail only for the event tomorrow and on 02-01-2011 send again the reminder of today's event. *I have events every day BUT I want to send a reminder ONLY 1 day before and on the day of the event. Any help ?? Hello, I have a code that adds 1 month to a specific date every month. Code: [Select] $newdate = strtotime ( '+1 month' , strtotime ( $b_date ) ) ; $new_date = date ( 'Y-m-d' , $newdate ); the thing is some month of the year do not contain the SAME amount of days. For example: If the date was 2011-01-31 + 1 month = 03-03-2011 Is there any way to add a month (+1 month) but make it consider the calendar. lets say that I had 2011-01-31 --> +1 month == 2011-28-02 (the last day of the next month if there is NO similar days in month Thanks Right, I have a 2 part question. At the moment, each user has an image stored for them which is linked to via a field in the database. Now I'm showing the image by a simple <img /> tag and just including the result of the filename from a database query, which works perfectly fine but I want to take this a step or two further. 1) Firstly, is it possible to get variables of width, height etc for images that are stored on the server as a file? Much like this information can be accessed when a user uploads an image, is it possible to do it if I'm showing the image once it's uploaded and stored? 2) If I can get dimensions for the image, is it possible to SCALE it properly down to a suitable size? For example, the maximum image can be 50 x 50, but images that are smaller would be scaled up PROPORTIONALLY or if they were bigger they would be scaled down PROPORTIONALLY. For example, if an image is 100 x 200, I don't want it scaled down to 50 x 50, I want it so that it remains to scale and is scaled down to 25 x 50. Hey guys having a problem with the following code which is supposed to change the case of the class name and include the resulting file. function __autoload($class_name) { $class_name = strtolower($class_name); $class_name .= ".php"; include $class_name; } However this throws the following error Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE on $class_name .= ".php"; I cannot figure out why I cannot append the string to the result of strtolower, can anyone tell me what's wrong? I am currently working on a website where users can go and upload images and select different types of filters for the images and then let the user see the result of the filter. This has all gone fine and the image filters are working, the only problem I am having is trying to add a function that allows the user to convert the image so that it looks like a Polaroid. I have seen sites that do similar things but cant work out how its done, wondering if someone could shed some light on the whole area? thanks Hello, I had this case: Text is stored in mysql table in the means of html, i.e. it contains <p> ,<br /> .... I want to display it on a php page, I had 2 questions: I want to display the first 400 characters, then the second 300 each on different <div> , so I need to save them each on different variable? and what about html tags? Thanks I am building an application that creates a label for a manufacturing company... it finds an appropriate font size for given text, and then draws it and displays the image as a bmp(it is required to be a bmp). That is all fine and dandy and working correctly. The problem is that the label must have a depth of 2 bits for it to work correctly on their machine...I am using the following code, but cannot get a bit depth lower than 24. iMagick and GD are both available on the server. Code: [Select] $text = $_GET['text']; if (isset($text)) { $image = new Imagick(); $image->setResolution(71.5, 71.5); $image->newImage(160, 40, new ImagickPixel('black')); $draw = new ImagickDraw(); $draw->setFillColor('white'); $draw->setStrokeColor(new ImagickPixel('black')); $draw->rectangle(0, 0, 159, 39); $font_size = 25; $font_name = 'arial.ttf'; do { $font_size--; $bbox=imagettfbbox($font_size, 0, $font_name, stripcslashes($text)); $right_text = $bbox[2]; $left_text = $bbox[0]; $width_text = $right_text - $left_text; $height_text = abs($bbox[7] - $bbox[1]); } while ($font_size>9 && ($height_text>40 || $width_text>160)); if ($height_text>40 || $width_text>160 || $font_size<10) { echo 'The text given will not fit on the label.<br />'; } else { $draw->setFont($font_name); $draw->setFontSize($font_size); $draw->setFillColor('black'); $draw->setTextAntialias(false); $draw->setGravity (Imagick::GRAVITY_CENTER); $draw->annotation(0, 0, stripcslashes($text)); $image->drawImage($draw); $image->blackthresholdImage( "#999999" ); $image->whitethresholdImage( "#999999" ); $image->setImageType(1); $image->setImageFormat('bmp'); $image->writeImage("flavor_labels/".$text.".bmp"); echo '<img src="flavor_labels/'.$text.'.bmp" /><br /><p>Right click this image and click Save As or Save Image As. <br />Enter in the desired label name and save it to the desired destination.</p>'; } } All, I have a part of code where I get a string or numbers like (234,2345,4536,45,75657...). Can you guys help figure out how I can get the last element of that particular string..i.e., i want to echo 75657 to screen and the likes. The last number is not a fixed size one. It can be a n digit number. I tried using array_pop and end. But it did not work. Suggestion or code snippets please. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=351154.0 This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=357293.0 Hi have an array() in which I would like to manipulate certain elements: Code: [Select] Array ( [TESCO] => Array ( [Veg] => Array ( [Potatoe] => 12 [Cabbage] => 24 [Cucumber] => 56 ) [Meat] => Array ( [Chicken] => 54 [Beef] => 89 ) ) [ASDA] => Array ( [Veg] => Array ( [Potatoe] => 12 [Cabbage] => 24 [Cucumber] => 56 ) [Meat] => Array ( [Chicken] => 23 [Beef] => 90 ) ) ) How would I go about adding the price of my meat section together e.g. Chicken + Beef from ASDA = 113 Also how to add/remove elements from Meat/Veg? Like adding Pork Cheers |