Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. Permissions to create a file in the directory specified?
  2. Correct. You are better creating a cURL function / set of functions i.e <?php /* cURL POST request */ function cURLpost($target, $data = false, $cookiePath) { $ch = curl_init(); $queryString = queryString($data); if(isset($queryString)) { curl_setopt($ch, CURLOPT_POSTFIELDS, $queryString); } curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_HTTPGET, FALSE); curl_setopt($ch, CURLOPT_NOBODY, FALSE); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath); curl_setopt($ch, CURLOPT_URL, $target); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); curl_close($ch); return $result; } /* cURL GET request */ function cURLget($target, $data = false, $cookiePath) { $ch = curl_init($target); $queryString = queryString($data); if(isset($queryString)) { $target = $target."?".$queryString; } curl_setopt($ch, CURLOPT_HTTPGET, TRUE); curl_setopt($ch, CURLOPT_POST, FALSE); curl_setopt($ch, CURLOPT_NOBODY, FALSE); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath); curl_setopt($ch, CURLOPT_URL, $target); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); curl_close($ch); return $result; } /* build a query string */ function queryString($dataArray = false) { if(!is_array($dataArray)) { return false; } foreach($dataArray as $key => $value) { if(strlen(trim($value)) > 0) { $value = is_array($value) ? $value : urlencode($value); $tempString[] = $key . "=" . $value; } else { $tempString[] = $key; } } $queryString = join('&', $tempString); return $queryString; } /* usage */ $cookiePath = "/tmp/cookies.txt"; $data['username'] = 'test'; $data['password'] = 'test123'; $data['submit'] = 'login'; // login $result = cURLpost("http://www.foobar.com/login", $data, $cookiePath); // go to my account $result = cURLget("http://www.foobar.com/my-account", false, $cookiePath); print "<xmp>"; print $result; print "</xmp>"; ?>
  3. You need to follow redirects <?php curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); ?>
  4. Not a clue. Could look like anything, depends on what the website is storing in a cookie. What you have posted looks like cookie data. I was referring to your php syntax, not your cookie file. Why don't you just try it and see if you get the expected results returned via a cURL request?
  5. Just change the path to the file that you will read and write cookies from and to. The file you are on about. Your syntax is incorrect. Simple as. <?php $cookiefile = "/path/to/the/file/containing/cookies.txt"; curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); ?>
  6. curl_setopt($ch, CURLOPT_COOKIEFILE, '/path/to/cookie.file'); Look at the options available http://uk3.php.net/manual/en/function.curl-setopt.php
  7. Are you asking how to structure an update query?
  8. Ok, just store the music files in a directory that is outside of your document root i.e /music/ /public_html/ When a member clicks on the file that they want to download use a header to prompt a download i.e $filename = "/music/file.mp3"; header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Content-Length: ".filesize($filename)); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=".$filename); readfile($filename) Have a look at the php manual http://php.net/manual/en/function.header.php
  9. So you are basically creating an e-commerce site where users add music files to their cart and can download them once they have paid for them. Am I correct? If so, have a look at osCommerce. This is an e-commerce script that has file download functionality. http://www.oscommerce.com/ You can study and re-create the parts you need for your own site. This is too big a project to give a simple answer to. You need to break the project into smaller parts before asking for help.
  10. You were on the right lines. <?php $word = str_split('cbad432'); sort($word); $word = implode($word); print $word; ?>
  11. <?php switch($this->item->type) { case "demo": echo "<div class=\"demo\">".$this->renderer->render('item.demo.full', array('view' => $this, 'item' => $this->item))."</div>\n"; break; case "demo1": echo "<div class=\"demo1\">".$this->renderer->render('item.demo1.full', array('view' => $this, 'item' => $this->item))."</div>\n"; break; default: echo "<div class=\"item\">".$this->renderer->render('item.full', array('view' => $this, 'item' => $this->item))."</div>\n"; break; } ?>
  12. Is it definately POST or GET, as the url you have posted contains parameters. Use the correct superglobal $_POST, $_GET. i.e postback.php $query = mysql_query("SELECT * FROM users WHERE ip='".mysql_real_escape_string($_POST['ip'])."'"); if(mysql_num_rows($query)) { $thisUser = mysql_fetch_assoc($query); }
  13. Why not use Google Analytics
  14. JonnoTheDev

    Impossible?

    No. Ask for help on the CSS boards.
  15. No. 'localhost' is a loopback address to 127.0.0.1 which is itself (the server where the script executes). There is no bridge between server & pc. Take for example a website that uses Java. If the Java runtime is not installed on a users pc the website usually displays a message with a link to download the Java runtime. Once installed it is embedded into the web browser so the website is able to obtain information from the users pc such as the version of Java they are running, etc. So, the communication from server to pc application is via the web browser, not directly into the pc filesystem. This is the same with ActiveX components. The issue with this sort of communication over the web is that hackers find holes in ActiveX and web browsers to cause damage to pcs. Any ActiveX components will now display warning messages in modern browsers. It is also likely that any firewall software or antivirus will block the sort of communication that you require. I am not an expert on this subject. Hopefully someone else may pick up where I have left off.
  16. You should NEVER, EVER, EVER store credit card numbers in your database! If you are taking credit card payments on your website then the data is sent through an API call to a payment provider. It is their responsibilty to deal with credit card data. You would use an SSL certificate on your site to make it secure. I haven't used all of the open source carts available but from your requirements I would suggest osCommerce. It has a large community.
  17. Because you are not defining 'request' in the scope of the calling function. Here is the change function updateForm() { var request = createRequest(); var company = document.getElementById("company_name").value; var url = "ajaxformupdate.php?company=" + escape(company); request.onreadystatechange = function () { if (req.readyState==4) { if (req.status==200) { alert('Server is done!'); } } }; request.open("GET", url, true); request.send(null); }
  18. There is no way that this can be achieved using PHP. You would require some kind of ActiveX control or Java Applet with Java installed on the user PC's If websites could access the contents of a users pc can you imagine the consequences.
  19. Even if it does, it only takes 5 minutes to learn. I see it more like learning HTML.
  20. I would hardly call it a language. This debate has gone on and on in numerous posts. I still stick to my guns. Template engines add overhead and are not for everyone. However, Smarty makes my life so much easier working with a team of web designers. Through the Smarty debug mode they can easily see what template a particular page is using and style it up accordingly. If the HTML is embedded in php files & functions they will break the code 9 out of 10 times as they are not programmers. Also when passing a project over for CSS work and the likes of rewritten urls are used then it is difficult for a designer to know what php file to edit and find its location. Smarty has massively reduced the time I have to spend with designers when handing base code over for CSS work. If you work in design & development then a template engine is unneccesary. If you are a developer like myself and work with various designers then they are a benefit.
  21. And use a spell / grammar check wow i wrote that? woops, sorry :/ LOL, you also wrote Sorry for nitpicking
  22. And use a spell / grammar check There's always one, eh. Never mind.
  23. Makes absolutely no difference. I would probably go for the subdomain route and point all at one document root. You can then use the domain as the test for what language to display.
  24. It comes from Jamacia
  25. It is damn near impossible to obfuscate HTML source on the client side for all browsers, as Adam stated if someone wants it they will get it. You could just run a WGET command and I will have a copy of your website if you haven't blocked that program.
×
×
  • 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.