Jump to content

s0c0

Members
  • Posts

    422
  • Joined

  • Last visited

    Never

Everything posted by s0c0

  1. I had to move to some InnoDB tables to a different server today and it didn't work cause of all the foreign key constraints. We tried using mysqldump and copying the actual files over to the new server all of which failed. I were rather afraid to copy the ibdate file which was suggested by the MySQL site http://dev.mysql.com/doc/refman/5.0/en/innodb-backup.html. What I instead did was copy the table structures over as MyISAM. Then add all the data over. Then finally I did all the alter statements to add my foriegn key constraints, indexing etc... This worked, but dear god there has to be an easier way next time.
  2. I would like to be able to read firefox preferences using javascript. Is there any way to do this. By preferences I mean the settings when you type into your firefox address bar and hit enter. I would like to create a custom preference so I can tell which machine the user is on from my application. I know this is a long shot. If this is not possible is there any other way I can do this? Yes I know we can just define static IP addresses, I was looking for something a bit more elegant though. I should note that when I say access these preferences with javascript I don't mean via an extension, I mean by regular old javascript.
  3. Yeah fix your form: <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>"> They way you are doing this will make it difficult. What you will need to do for the text fields name is name it something like phone-36 where 36 is the primary key of that particular row in the database. Now once the data has been posted explode on the hyphen and update the phone field with what ever $_POST['phone-36'] is equal to where the user equals 36. Does that make sense?
  4. Or store it in the session or even in a cookie if its small enough. There is a class out there that stores arrays in cookies by serializing them. Just look in PHPs documentation on cookies, it was posted there by a user a while back.
  5. Then create a single dimensional array called data, add the values in and then throw it in with the rest of the suff. That cleans up the code.
  6. Build your array like this: $tableArr[]=array('data'=>array(0=>'cell 1',1=>'cell 2'),'opts'=>'center','color'=>'#FFF');
  7. This most likely means you keep overwriting the array. You should just be able to do something like: $array[]=$new_value; This will keep incrementing the index by one each time you add something to the array.
  8. This would then have to be initiated by the client then right? That could be difficult. Another idea is running a login script once the client logs in to update the database. You could write something this in VBScript, Python, or maybe even if you're luck in a batch file. Not sure that it would work with a session, unless you maybe had the login script create a cookie. You would have to create the cookie in multiple browsers or limit support to a single browser.
  9. Definitely strange, just for kicks can you try creating a cookie using javascript? Also post the code your using to create the cookie using PHP please.
  10. Have you heard of cURL. If not, just take a look at this shameless self promotion of my blog: http://blog.cnizz.com/2007/05/02/phplinux-performing-an-http-post-the-easy-way/ Basically you have a page that accepts POST data, then the client (some other web server) has another page used to handle the data returned which is just another page that accepts POST data. Its simple really, your other options is building a web service, but the cURL post method is much easier.
  11. Well this is very hard if not impossible since PHP as you know is a server side language and therefor has great difficultly accessing client side information. Off the top of my head though here are two options. If you have a windows 200x domain server you might be able to get this information through some LDAP calls. I did some stuff with LDAP back in my network admin days: http://blog.cnizz.com/?s=ldap Your other option is to install apache and php on the local machine, store the username is a text file, access the text file via php, and create an iframe in your webapp that accesses the local machine, passes the information to your app (such as ip and username) to your app and try something like that. Honestly if you can get something working it will be a hack. Something like this is better suited for java or c# etc... Rather than writing this yourself, have you thought about looking for some open source software that does this already. Or better yet if you run exchange and outlook use that, or whatever your mail solution is see if there is integration there. Good luck.
  12. I would start by echoing out that query you are building. I much rather look that then stepping through rather convoluted code. I bet if you look at the actual query you can figure it out on your own, but if not post it here.
  13. It might be easier to just rebuild the XML file every single time. I have an application I wrote that has a simple little xml file that stores file paths for users. Everytime the user adds, edits, or deletes the XML file I just completely rebuild the XML file. So I guess maybe creating arrays of the data that will go into the xml, unsetting the piece of information that has been removed, and then rebuilding the XML file could work. The same would be for saving content. The difficult portion is what if they add an element in the middle of your XML file. That gets trickier, you basically have to take your base array, build a new array and stick that piece of information in it, and then loop through writing to the XML. Or perhaps I am just misinterpreting what you are looking for.
  14. Yeah you can just send data over regular HTTP. Unfortunately the vpn won't work so i can't snag an example of using cURL, but see how far you will get with whats available on php.net. It took me a while to get it down. But basically it works just like a regular php form post, but instead you are doing the form submission programatically. For instance if you're application was sending stock quotes you would post the data to http://yourserver.com/receive.php or whatever. That receiving script would look something like this: if($_SERVER['REMOTE_ADDR']=='10.10.10.10' && $_POST['token']='adhggcgh6786acacaadf') { $sql="INSERT INTO yourtable SET quote='60 a share'"; mysql_query($sql); $key = mysql_insert_id(); $sql="SELECT date_time FROM yourtable WHERE primary_key='$key'"; $result = mysql_query($sql); $array = mysql_fetch_assoc($result); // here is where you would post back to the other server with cURL sending it $array['date_time'] or whatever you want } The $_SERVER['REMOTE_ADDR'] will verify its coming from a permitted server (though this information can be spoofed) and the $_POST['token'] will contain the password for added security. There are ways to make this even more secure such as sending HTTPS through an IPSEC tunnel etc... but if this isn't a huge project you are probably okay with that, but i warned you. You could also send everything via SSH using PHP, all different things I would look at depending on how paranoid I was....or how much coffee I had before the meeting. Or using the token method you could even half a set of alternating tokens. Ok I am done.
  15. Look at www.php.net/simplexml also considering reading up on XSLT www.w3schools.com/xsl/ basically XSLT takes your XML data and puts it into a user friendly format such as an HTML Table or whatever.
  16. There are a whole bunch of functions the developers of PHP have made available to you. Please review the following: www.php.net/date www.php.net/mktime Then have a look at this helpful snippet I am giving to you freshly ripped out of same report I wasted all day on. It will give you an idead of using those two functions in conjunction with eachother. $startWeek = date('Y-m-d', mktime(12,0,0,date('m'),date('d')-date('w'),date('Y'))); $endWeek = date('Y-m-d', mktime(12,0,0,date('m'),date('d')-date('w')+6,date('Y'))); Happy learning...
  17. Two ways. The more difficult of your options is to use a SOAP. The easier one is to use cURL over HTTPS. A script on the receiving server would that handle the posted data, insert into a table, the insert function returns a dateTime stamp which is then posted back to the other server. Pretty simple. For security if the server you are sending data too will always have the same ip address due a check on the receiving server for that IP, additional security can be done by passing a funky string looking hashed string (a token of sorts) over as POST variable and only accepting the posted data if the token matches. That makes it pretty secure.
  18. mktime wrapped inside of the date function with use of explode is you're friend for instance. $currentDate=date('Y-m-d'); // you probably want to store the date the user is viewing as a GET variable $dateArr=explode($currentDate,'-'); $nextDate=date('Y-m-d',mktime('12','0','0','0',$dateArr[2],$dateArr[1]-1,$dateArr[0])); The syntax in that is probably wrong, but you look up those functions and you should be able to figure the exact syntax out based on what I gave you. I'd do it, but my hash browns are almost done. Good luck.
  19. You should be able to set a target. You do this in either the iframe tag or form tag. Just do a google search on it and you'll figure it out.
  20. Does this exist? I have a class that outputs lots of HTML and I would like to make it pretty under the hood by properly indenting my HTML. Why you ask? Because I am seriously that anal. Is there something easy that will do this for me? I was thinking there would be something like \n or \r except like \t or \i that does a tab/indent. Seriously nothing pisses me off more than when a developer outputs an assload of HTML via PHP you view source and its one long unreadable line. Thanks.
  21. Damn, really no on is going to try this out? 26 views and not one of you....
  22. I know this doesn't exactly answer your question, but why not create a cronjob to do this?
  23. There is always a brute force script. But your easiest option as stated by others in this thread is to beg your host.
  24. I really like this. Are you open sourcing the code?
  25. I didn't think any of the existing datagrids out there where simplistic enough so I created my own. I'm still developing but I feel its at a point to get some feedback on it. Download it here http://blog.cnizz.com/ezgrid.zip The zip archive contains the class (C_EZGrid.php), the css file (ezgrid.css), 2 images, and the view page (ezgrid.php). Here are the steps to using it: 1. download the file to your web server. 2. the zip archive contains everything you will need to test it out. 3. use this example: <? include_once('/php/global/C_EZGrid.php'); $db = 'database connection' // this your database connection link which is needed by mysqli $gridObj = new C_EZGrid('users',$db); // construct the object $gridObj->set_sql('SELECT id,username,city,state,country,joined,lastLogin FROM users'); // set the sql (replace with your own) $gridObj->opt_left_arrow='arrow-left.gif'; // set image $gridObj->opt_right_arrow='arrow-right.gif'; // set image $gridObj->set_column_names(array('ID','User','City','State','Country','Joined','Last Login')); // replace with your own custom column names //$gridObj->debug(); # uncomment this line to get debugging info ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>EZ Grid Demo</title> <link rel="stylesheet" href="ezgrid.css" type="text/css" /> </head> <body> <?=$gridObj->display_grid(); ?> </body> </html> 4. In the above example you include the C_EZGrid class. 5. I pass the table name (users) and the database connection link to C_EZGrid's constructor. 6. Next I set my sql statement (optionally you can pass in an array instead using $gridObj->set_dataArr($array_name) ). 7. I can then set my right and left arrow images (these were included in the zip archive). 8. Now I set the column names for my html table header by passing them in as an array. If you don't specify these it will use the actuall column names defined in your mysql table. 9. Now I can call $gridObj->display_grid() which will return text and when you echo the text you get a pretty table! If you run into problems you can try $gridObj->debug() and see if the debug info helps. There are more options you can set but I didn't feel like writing them all out, the code is pretty well commented, basically if its a public data member you can set it to your liking. The opt_detailsArr is pretty cool as it lets you make all values in a column linkable for administration of that row. For instance I could do this: $gridObj->opt_detailsArr=array('id'=>array('details','id')); This would make all the ID fields link to the current page with the url parameter of details= [whatever the id is]. So it would look like this <a href="ezgrid.php?details=5">5</a> and so on... Anywho let me know what you think and if you have any suggestions.
×
×
  • 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.