PHP - Php Sequance Generator Help Needed
Hello every one i am pretty new to PHP and here is what i am trying to accomplish:
file1.csv has DECIMAL IP ADDRESSES range in the format of "202353920","202353951" "410129408","410129663" "410150912","410151167" "410178372","410178375" "410178560","410178815" I know how to read the numbers and place them in a text file by this code: All i am looking for is a code to generate that range between the first 2 fields for example 202353920 202353921 202353922 till 951 and then we move to the next line and do the same. I want the output to be to a file called range.txt. $row = 1; if (($handle = fopen("LONDON1.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); for ($c=0; $c < $num; $c++) { echo $data[$c]. "<br />\n"; } } this reads the all the fields .. but i dont know how to generate the sequance Part #2 is to get all these numbers and convert them from decimals to x.x.x.x hostnames ( that part i figured out already ) by the this code: function convert1($a){ $b=array(0,0,0,0); $c = 16777216.0; $a += 0.0; for ($i = 0; $i < 4; $i++) { $k = (int) ($a / $c); $a -= $c * $k; $b[$i]= $k; $c /=256.0; }; $d=join('.', $b); return($d); } But part #1 is where i am stuck ( to generate the numbers based on the given range. any help would be really appreciated. Similar TutorialsI need help with creating a page like this:
http://www.flashvort...p?exampleId=219
So that we can offer our clients the opportunity to edit their flash banners.
http://www.degngrafi.../web/Flash.aspx
The generator should be located on our webpage.
Purchase option is not needed as our clients will have this tool offered for free.
Had a crack at making my own generator which makes some jumble 32 characters long with letters and numbers. In logic it seemed fine to me. It practice it just does nothing. function generate(){ $abc = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); $num = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); $result = ""; for ($i = 0; $i < 32; $i++){ $bool = rand(0,1); if ($bool = 1) { $result . $abc[rand(0,25)]; } else { $result . $num[rand(0,9)]; } } echo $result; } Hello I am using a script I found on the internet to create PNG images of text into a font on the server. My problem is that I can't seem to make the font bold. Can someone please let me know how to do this? I would really appreciate the help. Here is a snippet of the code that I believe needs modifying: <?php $background_rgb = hex_to_rgb($background_color) ; $font_rgb = hex_to_rgb($font_color) ; $dip = get_dip($font_file,$font_size) ; $box = @ImageTTFBBox($font_size,0,$font_file,$text) ; $image = @ImageCreate(abs($box[2]-$box[0]),abs($box[5]-$dip)) ; ?> Many thanks. Hello there! I'm looking for a script that generates website screenshots. I want to use a script on my server bcz, i think, it will work faster than use services like webshotspro.com or any other, and have no restriction on size. I need a script that can cache the screenshot and refresh it every 2 weeks for example. Hope that you can help me on this. Thank you in advance! I am having some issues with getting dates for the days of the week based on one date givin Example: User enters date for sunday. (Ending pay period) and I wish to get the dates for that week. Mon - 1-2-2012 Tue - 1-3-2012 Wed - 1-4-2012 Thu - 1-5-2012 Fri - 1-6-2012 Sat - 1-7-2012 Sun - 1-8-2012 User would enter 1/8/2012 and the script would get the rest of the dates to enter into the timecard. I have tried both ways below and cant get it to work no mater if i change the user input date i still get the same output. Function getdatepast($dtp,$cnt) { $undatecon = mktime($dtp); $undatecon2 = strtotime("-".$cnt." day", $undatecon); $ddt1 = date('m-d-Y',($undatecon2)); return $ddt1; } Function getdatepast($dtp,$cnt) { $undatecon = mktime($dtp); $undatecon2 = $undatecon - (86400 * ($cnt)); $ddt1 = date('m-d-Y',($undatecon2)); return $ddt1; } Hello everyone! I'm Abraham and I'm new here. I'm looking for a little help on making a password generator that can make passwords like this s7D9f3 - y2W4j6 - x1N5q8. I made one before but I lost the script can't seem to find it or remember how I did. This works if say I do 192.168.0.1 - 192.168.1.254 it will work. However doing 192.168.0.1 - 192.168.1.10 will only generate up to .10 on both IP schemes. I see why, but I cannot figure out a way around this... Thanks! $start = explode('.', '192.168.10.1'); $end = explode('.', '192.168.11.10'); /** * Final output... */ $a = 0; $b = 0; $c = 0; $d = 0; // First segment for ($a = $start[0]; $a < 1 + $end[0]; $a++) { // Second segment for ($b = $start[1]; $b < 1 + $end[1]; $b++) { // Third segment for ($c = $start[2]; $c < 1 + $end[2]; $c++) { // Fourth segment for ($d = $start[3]; $d < 1 + $end[3]; $d++) { echo "{$a}.{$b}.{$c}.{$d}<br />"; } } } } Hello i am going to try out fpdf generator, but i wanted to know if anyone knows where i can get invoice templates or how would i go to create them. Could i create them with css and html? Hello, I am attempting to develop a simple php script which will generate a 4 letter sequence when a button is pressed. However the sequence has a few rules it has to follow. For example: the letters have to be A B C D E F G H J K L M P Q and R The second letter must be a letter AFTER the first The fourth letter must be a letter AFTER the third There can't be 2 of the same number. I am a bit confused on how I will do this as I am quite new to php, I though about generating the first as $1, then generating the second as $2, then if $1 > $2, then I would regenerate $2 until it wasn't. Then repeating that for $4. However I am not sure on the coding which would be involved in doing this. If someone could give me a few pointers or a link to a website which would help me it would be much appreciated. How can I do the following: 1. Upon successful login, generate a random 8-digit customer number and assign it to that customer and writes that data to mYsQl. 2. Screen then refreshes and reads, "Welcome Mr Smith". The following script causes a segfault during the second $a2->test() pass. I then disabled my debugger (phped) and it works as desired. If I replace the generator with an ArrayIterator, I don't get the errors even with the debugger enabled. Is there something wrong with my script or is there something wrong with the debugger? Thanks <?php ini_set('display_errors', 1); class A { public function test() { $iterator = new \MultipleIterator(\MultipleIterator::MIT_NEED_ALL|\MultipleIterator::MIT_KEYS_ASSOC); $iterator1 = $this->getIterator(1); $iterator2 = $this->getIterator(2); $iterator->attachIterator($iterator1, 'iterator1'); $iterator->attachIterator($iterator2, 'iterator2'); $values = []; foreach($iterator as $v) { $values[] = $v['iterator2'] - $v['iterator1']; } return $values; } public function getIterator($x) { for($index=0; $index < 10; $index++) { yield $x*$index; } } } $a1 = new A(); $o1=$a1->test(); print_r($o1); $a2 = new A(); $o2=$a2->test(); print_r($o2);
hi i want to make a script like http://www.greatdane.ru/eng/site/news/ and i dont have problem too add dogs but i want a auto news update after specific change like the link example : after add new dog or update dog or add image to a dog the link tell exactly what i want but also it has a feature that group added dogs and send a news any one have idea for make it? it is also so similar to facebook profile that after user do something page will auto update like : user change his cover Hi there, I'm learning PHP and decided that I'll try to create a word search generator for my own use. I know there are hundreds of them out there but it's just for learning purposes. I'd like to enter a number of words and then the script should generate a pdf containing a box filled with random letters (among which there will be my words). My question is what keywords/functions should I look at to get started? I'm a php beginner but would like to make my learning more interesting by doing this project. The form with words should be easy, it's the next bit where it's supposed to generate a pdf containing words that I have no idea about. thank you Hi all, I've been working with PHP for the past month to develop a simple web-site. It has two pages that are served dynamically - the events page and the members page. These are public pages. It has 3 other static pages. I've created the database tables in MYSql. The events page has one table. And the teachers page has a few more - particularly - one primary table for member basics, another for member address. These are one to one with the primary driver being the member basic table since it will also include an active/inactive flag. The 2 files that get used are member credentials, and member specialties. These have one to many relationship with basics table. So far I've been using PHPadmin to create dummy data. But my next step is to create an admin page for the events - where the admin can maintain any event. Then I need to create an admin page for the users. (Further down the line each user will be able to maintain their own events and information.) I was actually hoping to find a code generator to help with these. I know it would be a great learning experience to do them on my own. But I would also like to move a little faster than glacial speed. I'm an RPG programmer by day. So I have programming experience - just new to the web. I've looked at MySQl Table Editor from phpguru. But it used Pear - which I'm not using. And it's not clear to me whether/how it will handle the one to many relationships. I also looked at PhpMyEdit - but it looks like overkill and some of the documentation I've seen recommends that the first column in every table be unique(auto incremented) and I haven't done that with the children tables that have a one to many relationship. And I'm not quite sure why I would do that. Can anyone recommend a tool??? And/or a really good tutorial that includes multiple file being updated at the same time? I'd rather not reinvent the wheel. I apologize for the long first post. I've tried to google - but I actually kind of overwhelmed by the amount of material I find on PHP. Thanks. Vic Struggling with creating the following: I'm looking for a random number generator, that chooses a number every hour, and when it does it will be out of 100 (these are player ID's) once the number is chosen, I would like 10 Crystals (special payment) to be given to the number (ID). Is this possible and if so, please help. This is all I have (generator) function createRandomAGTNO() { do { $agt_no = mt_rand(1,100); $valid = true; if (preg_match('/(\d)\1\1/', $agt_no)) $valid = false; // Same digit three times consecutively elseif (preg_match('/(\d).*?\1.*?\1.*?\1/', $agt_no)) $valid = false; // Same digit four times in string } while ($valid === false); return $agt_no; } Please reply ASAP? Hello I've got a php script that generates random number every page refresh Code: [Select] <?php srand ((double) microtime( )*1000000); $random_number = rand(1000,5000); echo "$random_number"; ?> I would like some advanced things... first of all i don't want the random number to be generated every page refresh I would like something like... based on pc hour example: - between 12 AM and 5 AM it will generate a number from 500 to 1000 randomly but the number should change also to a determined time i set such as every 5 minutes and not everytime i refresh the website page - betweem 5 AM - 2 PM will generate a number from 3500 to 8000 and this number will change every 5 minutes too with one that exists between this interval - and so on Would appreciate if someone could help me with that Thanks in advance Since I didn't want to type it out myself I wrote a small Date of Birth drop down menu generator. Now I'm wondering how I can make the code copy-able in a text area? The script should be inserting all the code ready and finished into a textarea so you can copy and go. How is it done? Here's the script: <?php echo "<center>"; ?> <form action='' method='POST'> <input type='submit' name='submit' /> </form> <?php $submit = $_POST['submit']; if ($submit) { echo "<form action='' method='POST'>"; echo "<select name='month'>"; for ($m = 01; $m <= 12; $m++) { echo " <option value='" . $m . "'>" . $m . "</option> "; } echo "</select>"; echo "<select name='day'>"; for ($d = 01; $d <= 31; $d++) { echo " <option value='" . $d . "'>" . $d . "</option> "; } echo "</select>"; echo "<select name='year'>"; for ($y = 1900; $y <= 2010; $y++) { echo " <option value='" . $y . "'>" . $y . "</option> "; } echo "</select>"; echo "</form>"; echo "</center>"; } ?> My images generator comprises
an array of image names extracted form an images table from a database using a select statement
a random number generator,
and a string that builds the correct pathname for the selected file.
To select one of the images for display, i generate a random number between 1 and the length of the array.
Though the generator is working, I noticed one of the random numbers is throwing up this error:
Warning: getimagesize(images/): failed to open stream: No such file or directory in
An inspection of the array reveals 2 array elements (representing my number of images) but one array element is NULL ( the first entry in the banner table
image_generator.php
require_once('connection.inc.php'); $sql = 'SELECT `filename` FROM banner'; $result = $mysqli->query($sql, MYSQLI_STORE_RESULT) or die(mysqli_error()); $row = $result->fetch_array(MYSQLI_ASSOC);//an array of image names $count = $result->num_rows; for ($i = 1; $i <= $count; ++$i) { $row[$i] = $result->fetch_array(MYSQLI_ASSOC); } $i = rand(1, $count); //a random number generator, //The random number is used in the final line to build the correct pathname for the selected file. $selectedImage = "images/{$row[$i]['filename']}"; if (file_exists($selectedImage) && is_readable($selectedImage)) { $imageSize = getimagesize($selectedImage); }var_dump($row) array (size=1) 'filename' => string 'ginsomin2.jpg' (length=13) nullRANDON IMAGE DISPLAY require_once 'image_generator.php'; <div id="banner" class="wrapper clearfix"> <img src="<?php echo $selectedImage; ?>" alt="banner"> </div>Kindly advice how i may proceed from here? Thanks. |