Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. I like the idea, but I think it is retarded that they were "forced" to do it. I mean seriously, they own that operating system. They should have the discretion of what to put on there. You do not see them targeting Mac OS or Linux to force them to allow for Internet Explorer to be chosen as an install. How do they have the right to enforce it? If I made my own operating system I would prefer to use my own browser and not be forced to add 3rd party browsers to my operating system, even if they are better. I think that is such bullshit.
  2. Re-post the question here, as you are much more likely to get help from here than posting on the comments of the tutorials and I am not going to waste my time trying to find your comment on that tutorial.
  3. After looking through google, here is one way to do. Store the users timezone in the database (have them select etc etc). You can then use putenv to change the timezone as follows: ini_set("date.timezone", "US/Mountain"); echo "Original Time(Mountain): ". date("H:i:s")."\n<br />"; ini_set("date.timezone", "US/Eastern"); echo "New Time (Eastern): ". date("H:i:s")."\n"; die(); ?> Using that method, you would just need to put that in one of your includes that goes through all pages, and you can pull that value from session (IE store that value in session when the user logs in). Then just use ini_set as shown above to change the timezone. I hope that makes sense, if not let me know. For a list of valid times: http://www.php.net/manual/en/timezones.php
  4. As long as you are working with PHP5+ : I would suggest using: date_timezone_set
  5. One alternative, have an array of form element names then loop through that assigning the data. $validElements = array("name", "email", "user", "password"); foreach ($validElements as $val) { $$val = isset($_POST[$val]) ? $_POST[$val] : null; } Which way is better is up to you to decide.
  6. Well consider mapping 5 different drives on different servers and the servers being in the following locations: Maryland, Colorado, California, Texas and Montana. Each site has a T1 line (yea T1). Now, imagine that one of these sites is randomly down and you try to open Windows Explorer....5 minutes later you are still trying to disconnect that damn drive to no avail. This happens quite often due to a network outage somewhere or a server upgrade etc. and when it does I basically cannot work in windows till I get that drive disconnected, which this program would make it a lot easier to do, that and I only need them mapped when I need a file from them, so having them mapped all the time is just a waste. But yea, that WNet will probably be a bit cleaner then how I am doing it, but this is more just to learn about files and get a bit more in depth to C++
  7. Interesting, yea using the wnetwork.h might be a better way to go, save me a bit of time. But the main thing I wanted to do was learn to work with files better, so yea. Once I get this done I will probably code the gui using the wnetwork.h. As far as finding a project, yea that was why I never really got into C++, then at work I hate remembering my network servers and always having to map/unmap them all the time and finding that information. So I decided to create this application to manage them for me and give me the option to map / unmap them (unmap them because they slow the computer down if they stay mapped) and at work they disallow the NET command for security reasons, so yea. Either way if I get it going should be great not having to go so slow cause of the network connections and being able to manage them with a click
  8. Yea, reminds me of something my first boss in a programming job said, "Handle errors where they are created." I guess I should have just followed that. Now I can move on to more fun stuff and having people being able to add their own networks / edit and modify them! Then make it a GUI interface. C++ is turning out to be fun now that I remember the little bits that you have to do, as PHP is way more lenient Either way thanks for the information Corbin, it got me on the right track.
  9. Alright, well my solution is basically modifying the VBS file to do a clean error handle and output that, for now it will work just fine. Here is the updated code: #include <cstdlib> #include <iostream> #include <fstream> #include <unistd.h> #include <stdio.h> using namespace std; int main() { string networkPath = "badpath::f"; string letter; int pos = 0; pos = networkPath.find("::"); letter = networkPath.substr(pos + 2); networkPath = networkPath.substr(0, pos); networkPath = "\"\\\\" + networkPath + "\""; ofstream vbFile("test.vbs"); vbFile << "On Error Resume Next" << endl << "Dim objNetwork" << endl; vbFile << "Set objNetwork = CreateObject(\"WScript.Network\")" << endl; vbFile << "objNetwork.MapNetworkDrive \"" << letter << ":\", " << networkPath << endl; // intentional error vbFile << "If Err.number <> 0 Then" << endl << "Wscript.Echo \"Error: \" & Err.Number" << endl << "End If" << endl; vbFile << "WScript.Quit" << endl; vbFile.close(); size_t found; string line; char temp[256]; FILE *fp = popen("cmd.exe /c cscript test.vbs", "r"); while (fgets(temp, 256, fp) != NULL) { line = static_cast<string>(temp); found = line.find("Error:"); if (found != string::npos) { cout << "There was an error mapping the drive." << endl; break; } } pclose(fp); remove("test.vbs"); // always returns succesfull system("PAUSE"); return 0; } The gist of the VBS Error handling came from: http://technet.microsoft.com/en-us/library/ee692852.aspx#EHAA for anyone who is curious about that portion. Questions feel free to ask me as I will do my best to answer
  10. Great info, thanks for that. I read through it all and what I think I am going to do is attempt to implement an error catch in the VB script (I found a hack to do it with class) and see how that goes. If I can figure it out I will post some links on how to do that etc. However, that createprocess may be what I am looking for. I guess the real deal is that it is not possible in C++ to do what I want, I just have to hack the script since VBScript is the one sending the error, I need to find a way to handle the error there. I did not think it was possible because I have been trying this for the past 4 days and doing extensive research with a ton of trial and errors and yea. We will see in the days to come as I am determined to find a way
  11. Hello all, The point of this message is I am learning C++ again by just simply creating a file and executing a script with popen. The issue I am having is when the vb script causes an error, the error is echo'ed to the console and not caught, I need to catch it so I can determine that there was an error and echo it out nicely, I just do not know what the function is to do this. The code I am currently using is as follows: #include <cstdlib> #include <iostream> #include <fstream> #include <unistd.h> using namespace std; int main() { string networkPath = "badpath::f"; string letter; int pos = 0; pos = networkPath.find("::"); letter = networkPath.substr(pos + 2); networkPath = networkPath.substr(0, pos); networkPath = "\"\\\\" + networkPath + "\""; ofstream vbFile("test.vbs"); vbFile << "Option Explicit" << endl << "Dim objNetwork" << endl; vbFile << "Set objNetwork = CreateObject(\"WScript.Network\")" << endl; vbFile << "objNetwork.MapNetworkDrive \"" << letter << "\", " << networkPath << endl; // intentional error vbFile << "WScript.Quit" << endl; vbFile.close(); size_t found; string line; char temp[500]; FILE *fp = popen("cmd.exe /c cscript test.vbs", "r"); pos = 0; while (fgets(temp, 500, fp) != NULL) { line = static_cast<string>(temp); found = line.find("WSHNetwork."); // cout << "Line: " << line << endl << "Found: " << found << endl; if (found != string::npos) { pos = 1; break; } } pclose(fp); remove("test.vbs"); // always returns succesfull if (pos == 1) { cout << "There was an error mapping the drive." << endl; }else { cout << "The drive mapped succesfully." << endl; } system("PAUSE"); return 0; } Which outputs: D:\c_proj\test.vbs(4, 1) WSHNetwork.MapNetworkDrive: The specified device name is invalid. The drive mapped successfully. Press any key to continue . . . Which it obviously did not map, but aside from that if anyone knows or can point me in the right direction that would be awesome. Alternatively, I will continue my searches to find my solution. Thanks.
  12. premiso

    cron job help

    http://www.devarticles.com/c/a/PHP/PHP-CLI-and-Cron/1/ http://en.wikipedia.org/wiki/Cron http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5 Good reads for what you want.
  13. Just glad you got it to work with your script, not many people here could have done that so it was my pleasure.
  14. This way can be dangerous so filter vigoursly and use with caution: <?php $string = '$newArr[0][0][1][3] = "test";'; eval($string); print_r($newArr); ?> That is the only way it is possible to do what you want without a recursive function.
  15. You can simple use a for statement for what you want: $cnt = count($correct); $output = ""; for ($i=0;$i<$cnt;$i++) { $style = ($correct[$i] == $answers[$i]) ? "color: red;" : ""; $output .= '<span style="$style">' . ($i + 1) . ') Chosen Answer: ' . $answers[$i] . ' Correct Answer: ' . $correct[$i] . '<br />'; } echo $output; Incase you do not know the ? and : are the ternary operator (which is an if/else statement) near the $style.
  16. You can try using stripos : if (stripos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { }elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'OPERA')) {
  17. You should probably use the proper escaping function for your database, for instance in MySQL it is mysql_real_escape_string.
  18. You are using backticks (`) when you need to be using single quotes ( ' ) for data. Moved to proper forum (MySQL)
  19. Not really sure what is wrong, worked fine using my database information: <?php mysql_connect("localhost", "Master", "password") or trigger_error("Connection Failed: " . mysql_error()); mysql_select_db("Login") or trigger_error("Database Selection failed: " . mysql_error()); $letter = isset($_GET['search']) ? htmlentities($_GET['search']) : ''; $user = mysql_query("SELECT * FROM Users WHERE username LIKE '{$letter}%' ORDER BY username")or trigger_error ("SQL Failed: " . mysql_error()); while($rowz = mysql_fetch_assoc($user)){ $username = $rowz['username']; echo "<font face='Courier New' font size=2px font color=#FBB917>$username</font>"; } ?> Try that and see if it does any better, not sure if it will because the original way seemed fine on my server, so it could be a server issue.
  20. I think you are looking for a Combo Box.
  21. The text file portion is actually really easy: <?php $proxyArr = file('proxies.txt'); $randProxy = array_rand($proxyArr); $proxy = $proxyArr[$randProxy]; unset($proxyArr[$randProxy]); $fh = fopen('proxies.txt', 'w+'); foreach ($proxyArr as $write) fwrite($fh, $write); fclose($fh); // other code here echo $proxy; ?> If you are using a database it is actually quite a bit easier then that.
  22. <?php global $db; $db = "database"; function sql(){ global $db; return "database name is: ".$db." ta-da!"; } echo sql();// returns: database name is: ta-da! You need to declare it as a DB outside the function as well. You may want to look into defineing the variable as a CONSTANT instead.
  23. I do not think it is possible to do what you want in MySQL, at least in a query. I have tried many combination's, referred to the manual etc and I do not think you can dynamically define which table to pull the data from as shown. However, if you can figure out a WHERE statement in which you can use the case's to filter the data from the tables, you may be able to achieve this.
  24. I stand corrected, I see what you were getting at Sorry about that. @OP, yea you cannot use queries to pull data from arrays. You either need to create a function in PHP to loop through the array to do what you want or pull the data from another query to do the pagination.
  25. premiso

    TGIF

    Yay for Friday!
×
×
  • 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.