Jump to content

samshel

Members
  • Posts

    837
  • Joined

  • Last visited

Posts posted by samshel

  1. Hi,

     

    Does anyone have an idea about a ready made Rule engine available in PHP?

     

    I already took a look at the google project, but it seems it is stuck.

     

    any help is greatly appreciated.

     

    Thanks

    Samshel

     

  2. Hi All,

     

    Ok so here is what i am trying to do and i strongly need advice about what is the best way to do it.

     

    Requirement:

     

    Build an external interface module which will interact with any third party system and if a new system comes up tomorrow i can just add a file with business logic and i dont have to worry about common things which i have already done for other similar systems. So when i need to add a new payment gateway which is a webservice all i need to do is write the business logic.

     

    For this i have divided any system into categories and sub-categories nested upto nth level, Simple Example:

     

    verisign

    - Category : Webservice

    - Sub Category: Payment Gateway

    So Verisign is first a webservice and then a payment gateway.

     

    I have already implemented Paypal webservice and i dont want to write the common code again for Verisign.

     

    I know the first thought that comes to mind is factory method...but still read on :)

     

    I have the following structure

     

    interface

      -- interface.php [Factory Controller for outmost level]

      -- interfacecommon.php [Common functions for outmost level]

     

        webservice

          -- webservice.php [Factory Controller for webservice level]

          -- webservicecommon.php [Common functions for webservice level]

     

          payment

            -- payment.php [Factory Controller for payment level]

            -- paymentcommon.php [Common functions for payment level]

     

            paypal

            -- paypal.php [Actual business logic for Paypal]

            verisign

            -- verisign.php [Actual business logic for Verisign]

     

    Solutions that i can think of:

     

    1) Create object of outermost level (interface.php). Call a function, which will create an object of inner level controller(webservice.php) and assign it to its own member variable. The inner level controller again creates an object of the one more level inner level controller (payment.php), which inturn creates object of lowest level class (verisign.php). All these controllers will inherit a class each present on thier level which will have the common functionality for that level. By this I get one object with many member variables nested.

     

    2) I dont use Factory so i dont need a controller. I start from inner most level (paypal.php) , which inherits upper level common class(payment.php), which inherits 1 more level upper common class (webservice), which inherits one more level upper common class (interface.php) and i use object of this.

     

    3) anything u can suggest..i am all ears.

     

    man this is complicated !! I really hope i am able to explain properly what i need.

     

    anyways i need the system to be extremely scalable but extremely fast too, so i dont want unnecessary includes and object creations.

     

    Thanks for the patience !! :)

     

    your suggestions are highly appreciated..

  3. include("http://www.domain.com/file.php?search=q1");
    include("http://www.domain.com/file.php?search=q2");
    include("http://www.domain.com/file.php?search=q3");
    

     

    when u include a URL, PHP actually gives a hit to that URL as if a user has clicked on it and then includes the HTML output.. check if this is what u need.

     

    It may require some php.ini configurations to allow to read a URL.

  4. so you want to read from an outside website (ex: http://www.google.com/search?hl=en&q=Tvscreens ) parse all specific words like Tvscreens, replace the words in HTML with hyperlink , landing page of which you can specify and put these replacements back on the website? OR do you want to take the HTML, replace words with links and write it to a local file, which you can use in your own website?

     

    Initial case is not possible as u cannot write to pages of a website that does not beling to you, later case is possible, if u need that then it is easy to do

    - read url using any file read command

    - ereg_replace words with links

    - write to a file.

     

    OR may be i completely misunderstood what u r looking for :D

  5. $width = imageSX($imgObj);
    $height = imageSY($imgObj);
    .....
    imagecopyresampled($newImage, $imgObj, 0, 0, 0, 0, $width, $height, imageSX($imgObj), imageSY($imgObj));
    

     

    i think $width is same as imageSX($imgObj) and $height is same as imageSY($imgObj). so ur passing the destination height and width the same as source, so it will give u image of the same size, it crops the image but the size is same so it fills remaining area with black color..

     

    please carefully study each parameter of the function imagecopyresampled and check if you are supplying them correctly.

     

     

     

  6. something like this...

     

    <?php 
    $arrFiles = array(
    					"http://weather.noaa.gov/pub/data/raw/fp/fpus20.kwbn.scs.01.txt",
    					"http://weather.noaa.gov/pub/data/raw/fp/fpus20.kwbn.scs.02.txt",
    					"http://weather.noaa.gov/pub/data/raw/fp/fpus20.kwbn.scs.03.txt",
    					"http://weather.noaa.gov/pub/data/raw/fp/fpus20.kwbn.scs.04.txt"
    					);
    $strHTML = "";
    for($i=0;$i<count($arrFiles)$i++) {
    $arrTemp = file($arrFiles[$i]);
    $strHTML .= implode("", $arrTemp);
    }
    
    $fd = fopen("/path/to/us-scs.html", "w");
    fwrite($fd, $strHTML);
    fclose($fd);
    ?>
    

  7. $row_i = 1;
    foreach($enrolled_array as $enrolled_client){
    echo $cell_1 = "topmostSubform[0].Page1[0].SMART_ID___Row_1[0]";
                 echo "<br/>";
                 echo $cell_1 = "topmostSubform[0].Page1[0].SMART_ID___Row_".$row_i."[0]";
    
    $fields[$cell_1]->setValue($enrolled_client['clientid']);
    $row_i++;
    }
    
    

     

     

    check closely if they are exactly same.

  8. what r u trying to achieve?

     

    you want to show records in 3 columns?

     

    try this..

     

    <?php 
    // Setup and run query
    
    $query = "select * from items where name like '%".$searchterm."%'";
    $result = $db->query($query);
    $num_results = $result->num_rows;
    echo "<p>Number of items found: ".$num_results."</p>";
    
    // Display results
       echo "<table border= 1>";
    
         for ($i=0; $i <$num_results; $i=$i+3) 
          {
            echo "<tr>";
            for ($c=0; $c < 3; $c++)
           {
               if((($i*3) + $c) < $num_results) {
                   $row = $result->fetch_assoc();
                   $Imge = stripslashes($row['imge']);
                      echo "<td>";
                         echo "<p><strong>Number: ";
                         echo stripslashes($row['number']);
                         echo "\t \t";
                         echo htmlspecialchars(stripslashes($row['title']));
                         echo stripslashes($row['name']);
                         echo "</strong><br /></p>";
                         echo "<p align='center'><img border=\"0\" src=\"images/".$Imge."\"><br /></p>";
                         echo stripslashes($row['description']);
                         echo "<br />Price: ";
                         echo stripslashes($row['price']);
                         echo "</p>";
                      echo "</td>";
                  } else {
                   echo "<td> </td>";
                  }
          }                           
       echo "</tr>";         
       }
       echo "</table>";
    
    
    ?>
    
    

    PS: the code is not tested.

     

    EDIT: updated if condition to multiply by 3

     

     

     

  9. it should work !! i tried to do the same thing with sample code and it works..may be there is some problem in function calling or surrounding code.

     

    <?php 
    
    $str = "";
    
    function setString($val){
       global $str;
       $str = $val;
    }
    setString("Test");
    echo $str;
    ?>
    

     

    but yes ! i agree with PFMaBiSmAd :)

  10. <?php
    $filename = 'weather1.txt';
    if (file_exists($filename)) {
    echo "Last Updated: " . date ("F d Y H:i:s.", filemtime($filename) + 60*60);
    }
    ?>
    

     

    i m not sure though if adding 1 hour will solve your problem, it may cause issues when day light savings come into effect.

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