Jump to content

nadeemshafi9

Members
  • Posts

    1,245
  • Joined

  • Last visited

Posts posted by nadeemshafi9

  1. what the onload function does is assign the javascript function to each button, it's the same as putting the onclick='functionstuff("param");' in the htmlcode

    so we wait till every button is loaded, then set the onclick event to every button, and done. a lot less type work, but your way works as well, only my way, it doesn't matter if more buttons are added, they will automatically have the same function assigned to them

     

    ooooooooooooooooooooooooooooh sorry iwas being ignorant and dint read your code thorghly enogh, nice jerb.

  2. window.onload will trigger once the page is fully loaded, so not refresh

     

    it's identical to the <body onload=''> tag

    but your code shows that the function will only happen on window . onload

     

     

    my func

    <script>

    function handleClick(id){

              element= document.getElementById(id);

              if(!element) element= document.getElementsById(id);

              if(element) {

                  if(element.name) alert('You clicked ' + element.name);

                  else if(element.id)  alert('You clicked somthign that dosent have a name but id of ' + element.id);

                  //etc etc etc

              }

              else alert('could not find the element clicked');

    }

    <script>

    <input type='button' id='button1' value='button1' onclick='handleClick('button1')' />

    <input type='button' id='button2' value='button2' onclick='handleClick('button2')' />

    <input type='button' id='button3' value='button3' onclick='handleClick('button3')' />

     

     

    i think parts of your code are good where you reference the buttons as an array of all the buttons, its neat, but my code is more responisve, maybe they can be combined. My code can be used to handle a click of any HTML element, and it will respond straight away at any time without refresh or anything, in the function you can capture what was clicked and what to do with it.

  3. hello guys

     

    my ini_parse function returns an array on one server where i output it using print_r (you know what teh format is)

     

    now i need to read it into a variable on my other server where i fopen this page and read the pages contents in order to get it on my other server.

     

    so basicaly i need to eval the result of a print_r.

     

    or should i be using var_dump i dont know ? or should i be exploding

     

    basicaly i need to evaluate the output from a page into an aray

     

    $handle = fopen("http://*/*/api.php", "rb");
    	$contents = stream_get_contents($handle);
    	fclose($handle);
    
    	echo $contents; // this is a print_r or a var_dump i dont know but i need to eval it now
    
    	exit;
    

     

     

    thanks guys

     

  4. >> nadeemshafi9

     

    It isn't really good practise simply to use @ to hide errors. Better (wherever possible) to prevent the error occurring in the first place by validating inputs (in this case).

     

    most definatly, but i just discovered teh @ thingy and its quite handy

  5. you can just do a function wich checks the time and if teh time is ove rteh limit then just die and echo data

    Why bother?

     

    PHP will cease executing at it's predefined timeout anyway. Why not let PHP terminate as normal, but trap the timeout error and replace it with your own output.

     

    will that be using teh ini set function becaus eyou dont whant to set it for the whole server ??

  6. you could start a process wich chekcs the time and start another process wich does your script, in the process that does your script you can break out of that process and jump into the timmer process which checks the time if the time is ok that process breaks out and jumps back into your script process wich continues from where it jumped out then furtehr down the script yoiu can jump back out into the timer process and check the time again and if the time is too much you can return or pipe throgh a flag from the timer process so that when it jumps back into the script process it has a flag which tells the script process to die.

     

    http://uk3.php.net/manual/en/function.pcntl-fork.php

     

    jajaja im dum

     

     

    you can just do a function wich checks the time and if teh time is ove rteh limit then just die and echo data

  7. Is it a chance there could be a duplicate md5(rand, 10000)) ??

     

    yes so when you havee made the script work, then furtehr develop it to compensate by ckecking if it already exists and makign another one if it does

  8. <?php

    // set up basic connection

    $conn_id = ftp_connect('ftp.example.com');

     

    // login with username and password

    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

     

    // get contents of the current directory

    $contents = ftp_nlist($conn_id, "."); // replace dot with your dir

     

    // output $contents

    print_r($contents);

    ?>

     

  9. you could start a process wich chekcs the time and start another process wich does your script, in the process that does your script you can break out of that process and jump into the timmer process which checks the time if the time is ok that process breaks out and jumps back into your script process wich continues from where it jumped out then furtehr down the script yoiu can jump back out into the timer process and check the time again and if the time is too much you can return or pipe throgh a flag from the timer process so that when it jumps back into the script process it has a flag which tells the script process to die.

     

    http://uk3.php.net/manual/en/function.pcntl-fork.php

  10. OR

    if ((@is_numeric(@$_REQUEST["o"]))&& (@$_REQUEST["o"]!= 0)) {
       @$_SESSION["o"] = @$_REQUEST["o"];
       $o = @$_REQUEST["o"];
    } elseif (@$_SESSION["o"]) {
       $o = @$_SESSION["o"];
    } elseif ($default_module) {
       $o = $default_module;
    } else {
       $o = mysql_result(mysql_query("SELECT module_id from ".$table_prefix."modules where active = 1 order by sequence limit 1"),0,0);
    }

  11. <?php
    // Connect to FTP server
    $conn = ftp_connect('ftp.example.com');
    if (!$conn) die('Unable to connect to ftp.example.com');
    
    // Login as "user" with password "pass"
    if (!ftp_login($conn, 'user', 'pass')) die('Error logging into ftp.example.com');
    
    // Issue: "SITE CHMOD 0600 /home/user/privatefile" command to ftp server
    if (ftp_site($conn, 'CHMOD 0600 /home/user/privatefile')) {
       echo "Command executed successfully.\n";
    } else {
       die('Command failed.');
    }
    ?>
    

     

    http://uk3.php.net/manual/en/function.ftp-fput.php use this to up files

  12. Theoretically you could take any part of MVC and put something else in its place without changing other parts.

     

    It's easiest to imagine when we consider View. You could have one View that generates fancy, colourful, CSS styled HTML Web pages for traditional browsers, and another that generates plain Web pages for mobile devices with low bandwidth. Both would be using same Models and same Controllers. You don't have to introduce any changes into Models or Controllers if you want to switch the view. You can also easily add another view for generating RSS, then another for.. .something else...

     

    On the Model side one could easily imagine the need to switch from MySQL to Oracle to PostgreSQL... With MVC pattern switching a database engine should not require any changes to Controllers or Views.

     

    i like the browser small device example

     

    it woudl pan out like this

     

    http://domain/acontroler-eg-houses/a-method-that-outs-a-view-using-a-controler-method-inside-wich-there-is-model-interactivity-FOR-BROWSER/somvarname/varval

    http://domain/acontroler-eg-houses/a-method-that-outs-a-view-using-a-controler-method-inside-wich-there-is-model-interactivity-FOR-MOB/somvarname/varval

     

    http://domain/acontroler-eg-person/a-method-that-outs-a-view-using-a-controler-method-inside-wich-there-is-model-interactivity-FOR-BROWSER/somvarname/varval

    http://domain/acontroler-eg-person/a-method-that-outs-a-view-using-a-controler-method-inside-wich-there-is-model-interactivity-FOR-MOB/somvarname/varval

     

    http://domain/acontroler-eg-person/another-method-that-outs-a-view-using-a-controler-method-inside-wich-there-is-model-interactivity-FOR-BROWSER/somvarname/varval

    http://domain/acontroler-eg-person/another-method-that-outs-a-view-using-a-controler-method-inside-wich-there-is-model-interactivity-FOR-MOB/somvarname/varval

     

    when you use these its apparent how much better it is, you can move functiuonality about easily everything is encapsulated and ajax becomes much more simple using this format of url pluss its google friendly

     

    extjs

     

    Ext.Ajax.request({

      url: '/person/getname/id/1',

      success: someFn,

      failure: otherFn,

      headers: {

          'my-header': 'foo'

      },

      params: { foo: 'bar' }

    });

     

     

    Ext.Ajax.request({

      url: '/person/getaddress/id/1',

      success: someFn,

      failure: otherFn,

      headers: {

          'my-header': 'foo'

      },

      params: { foo: 'bar' }

    });

     

     

    i use the zend_framework it comes fully strapped with functionaly directory structure classes and a bootstrap file mod rewrite app.ini to controle configuration complete rewrite of all php constructs

     

    http://framework.zend.com/manual/en/

     

  13. <script>

    function handleClick(id){

              element= document.getElementById(id);

              if(!element) element= document.getElementsById(id);

              if(element) {

                  if(element.name) alert('You clicked ' + element.name);

                  else if(element.id)  alert('You clicked somthign that dosent have a name but id of ' + element.id);

                  //etc etc etc

              }

              else alert('could not find the element clicked');

    }

    <script>

    <input type='button' id='button1' value='button1' onclick='handleClick('button1')' />

    <input type='button' id='button2' value='button2' onclick='handleClick('button2')' />

    <input type='button' id='button3' value='button3' onclick='handleClick('button3')' />

     

  14. Both ajax and on page request (basically the same thing) would require at least one player at all times.

    Even worse on page request you'd need to have one person visiting a page every minute.

     

    So yeah, cronjob

     

    i was thinking you could have an admin page that you just leave running on some admins computer with repeated ajax calls to the required script, or he coudl write a demon, cronjob is all good thogh

×
×
  • 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.