Jump to content

ionik

Members
  • Posts

    187
  • Joined

  • Last visited

Posts posted by ionik

  1. Hello,

     

    I am having a small issue with using a digital ID for server - server communication .... when I try to run the code I get the error message

     

    unable to use client certificate (no key found or wrong pass phrase?)
    

     

    My code is originally written in Python but I have translated it to PHP and CURL works the same across all languages  :shy:

     

    I have the latest Version of cURL installed ( I manually updated it myself 2 days ago ) and the same error happens if I run it in the shell

     

    curl --cert /xxx/digitalID.p12 --key /xxx/digitalId.pem --pass xxx https://xxxxxx.com
    

     

     

    The PHP Code is as follows

     

    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, "https://xxxxxxx.xxx.com");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
    curl_setopt($ch, CURLOPT_SSLCERT, '/home/xxx/xxx/digitalID.p12');
    curl_setopt($ch, CURLOPT_SSLKEY, '/home/xxx/xxx/digitalID.pem');
    curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'xxxxxx');
    curl_setopt($ch, CURLOPT_SSLKEYPASSWD, 'xxxxxx');
    
    curl_exec($ch);
    
    curl_close($ch);
    

     

    and the orginal Python code

    c = pycurl.Curl()
    c.setopt(pycurl.URL, FirstDataAPI_URL)
    c.setopt(pycurl.HTTPHEADER, ["Accept:"])
    c.setopt(pycurl.POST, 1)
    c.setopt(pycurl.POSTFIELDS, urllib.urlencode(FirstDataAPI_PostData))
    import StringIO
    b = StringIO.StringIO()
    c.setopt(pycurl.WRITEFUNCTION, b.write)
    c.setopt(pycurl.FOLLOWLOCATION, 1)
    c.setopt(pycurl.MAXREDIRS, 5)
    c.setopt(pycurl.SSLCERT, '/home/dgiftcard/disney/ssl/digitalID.p12')
    c.setopt(pycurl.SSLCERTPASSWD, 'xxx')
    c.setopt(pycurl.SSLKEY, '/home/dgiftcard/disney/ssl/digitalID.pem')
    c.setopt(pycurl.SSLKEYPASSWD, 'xxx')
    c.perform()
    results = b.getvalue()
    

  2. lol no allen I was not refering to you.

     

    Sorry, Slight mistype on the first sentence....448191

     

    In regards to the Observer issue,

    Yes you would need each the B and C objects,reason is B is the observable object its only purpose is to send state changes to C. C is the registry of Observers that are awaiting to be triggered based on state changes, if you have not guessed D would be the object that is called once C notifies its registry of Observing objects.

     

    You could do it your way and have D perform all aspects ... but this provides 0 support for scalability ...

     

    In the Registry Singleton I am speaking of there will be only minimal "objects" stored on run-time, likely the exact same ones that the Controller will retrieve. I believe you think that the most simple things such as Framework Helpers for example would be loaded from the registry if you do, you are sadly mistaken. Like I said before If the Registry is properly designed it is a very useful Design Pattern.

     

    I will repeat myself for you (since you seem to have a hard time understanding)...

    When it comes to testing, the registry singleton will not be of any issue, as with a good design for any library it should run independently of the application or say a "mini-app" in itself. Thus allowing you to test this "mini-app" out of the registries scope, completely on it own.

     

     

    It also has come to my attention this debate is getting nowhere with the my-way-or-highway attitude you are expressing

     

  3. http://en.wikipedia.org/wiki/Library_(computing)

     

    I must be wrong that a set a classes designed for a specific task would not be considered a library.

     

    I think you are taking things a lot farther out of the scope of what I am discussing or possibility misunderstanding a few things.

    Observer Pattern

    An object that makes itself observable to other objects and sends messages to observing objects when it state changes ... I believe this is the correct definition so I do believe I am not confusing myself with the Chain of Command.

     

    So,

     

    Therefore what I said was in-fact correct. A will send a state change (triggered event) to B (the observable object) -> C (Collection Of objects listening to B) -> D (Object stored in C waiting for state change in B)

     

    Where do u get these assumptions that the Registry will store "all sorts of stuff" I don't see it very wise to make arrogant assumptions based on your own coding standards, knowledge or lack thereof

     

    Take a peak at Magento a highly powerful and flexible e-commerce application, it uses the same registry example I am discussing. I'm sure they know thats its wrong though correct?

     

    Also about testing, if you properly design your libraries (or classes if you like) there would be no issue regarding the registry. The libraries would be exactly what they are called a collection of classes used to perform certain tasks, which would allow you to single them out on their own and test to your hearts desire. Example would be an ACL library in a Framework this collection of classes should be able to be taken directly from the Framework and run completely independent of any other part of the framework.

  4.  

    I have used this argument in the past (I shared this view at one time), but unfortunately it's invalid. If B and C are in between A and D which share a dependency, A and D should have a reference to each other, or at least A should have a reference to D. If this is not the case, your design is at fault.

     

    This is true, but in the example I had given object D will never know object A exists nor will A know D. As with a triggered event (plugin) using the Observer Pattern D will execute from C , C -> B etc etc...

     

    A having no idea that the D object exists it cannot reference it and the same goes for D -> A.

     

    Using a Singleton Registry *everything* is coupled to everything in it. Maybe not right away, but over time it will. You didn't put it in the global space because it looks so pretty, you put it there so *everything* can use it, potentially causing coupling to everything. It really isn't that difficult to understand if you let your guard down for a sec.

     

    And I still do not see how if a "properly designed" Singleton Registry meaning the coupling done within the Singleton Registry is loose coupling, all libraries stored within the Registry are cohesive, using the registry only for abstraction, would cause issues. 

  5. one of the issues that the post mentions is that the data is still available to everyone and one can change variable to anything.

     

    As for getting rid of Singletons, in an MVC application the Controller layer is the obvious choice for providing the other layers with the necessary initialization parameters. During startup it gathers configuration, and can pass it to the Model and View when dispatching. No global data needed.

     

    Using a facade pattern would provide an alternate means to communicate between the layers of the application presented from the Controller in an MVC application, but you will need to reference that object to anything that is used outside of the scope of the Controller that modifies run-time for any layer within the application whether it is the Model, View or Controller which would make things much more complicated than necessary and why not follow KISS.

     

    For example object D (event plugin) needs to use data present in object A (controller) which would mean that either we need to statically access the information or reference it through A -> B -> C -> D, but what happens when object B is modified .. since object C is coupled down to B it now needs modification to continue to pass the needed reference to object D. This is only a small example but you an see the problem that would exist.

     

    I personally don't see a valid reason to remove a Registry Singleton from an application, there are many arguments discussing against this but that is a different discussion, if properly used using a singleton registry for access to common data used in various layers of the application such as the controller accessing the model, the controller will be coupled only to the registry and object D would not need the extra coupling to access data.

  6. Couple of things  ;D  instead of allowing someone to set a registry entry to explicit simply create a list of internal keys that can never be overwritten, deleted or changed only viewed, and let the rest do as they please.

     

    Allowing someone to set a key as explicit could set keys that are needed for other modules/sections/apps and now cannot be overwritten because of this, also you would want a core registry class set to a final class so i cannot be implemented inherited or modified in any way.

     

    What do you mean by "avoid the overuse of singleton patterns when I need an object" if you are creating a registry to store objects only use it for the application critical objects that are used everywhere and need that kind of accessibility otherwise autoloading...

     

    Here is an example of a framework registry that stores all information the framework process has and uses the example i mentioned above

     

    See Here

     

  7. Hello,

     

    I have built a (almost) complete Framework based on Zend, the final feature I will be adding is based from Python's Django Framework the auto-building admin (using the same construction setup)

     

    What I have come up with so far to handle this is currently

     

    Currently the theory I have come up with is to have a the Admin Core Singleton which holds the registry for Models within each Model will be a registry of the fields, the configuration for fields, model configuration, a single method for initializing the Builder which will analyze the Models in the registry, add the routes and build a navigation.

    The admin will be handled through one class(controller) which will feature a method for each action that can be done (view, add, edit, delete) which would be one class with 4 methods. The class would dynamically build the administration view based on a defaults unless otherwise given.

     

    Basically it would be

    Admin_Core -> Load Modules -> Init Admin_Core -> Load Routes & Nav -> Route to Admin -> Determain Model -> Construct View based on default and config given from model configuration

     

    Other tid-bits such as form processing and generation, permission handling, action/error logging I have already built into the framework and would be easy to process given from the config given from a model.

     

    Models would need to be added to the Admin_Core that would allow for the same type simplicity that is used in Django and the first 4 process would have to take place before the page is routed to within the framework ....

     

    Anyone have suggestions?

  8. SOLVED FINAL SQL

    SELECT g.userId, un.groupId, g.userName, pr.videoCount, pr.viewCount
    FROM user g
    LEFT JOIN (
    
    SELECT groupId, userId
    FROM userGroups
    ) AS un
    USING ( userId )
    LEFT JOIN (
    
    SELECT userId, promoId, SUM( vd.videoCount ) AS videoCount, SUM( vd.views ) AS viewCount
    FROM promos
    LEFT JOIN (
    
    SELECT promoId, videoId, COUNT( videoId ) AS videoCount, SUM( vt.viewCount ) AS views
    FROM videos
    LEFT JOIN (
    
    SELECT COUNT( trackId ) AS viewCount, videoId
    FROM videoTracking
    GROUP BY videoId
    ) AS vt
    USING ( videoId )
    GROUP BY videoId
    ) AS vd
    USING ( promoId )
    GROUP BY userId
    ) AS pr
    USING ( userId )
    WHERE groupId = "3"
    LIMIT 0 , 10 
    

  9. Hello,

     

    I am fixing a few bugs with a site and have quite a problem with a SQL query ....

    What we are doing is pulling information for a video sponsors profiles, for the projects that they host for users to upload videos to the information we are getting is views for each video and # of videos for each project.

     

    To do this I need to pull information from 5 Tables in this breakdown

     

    Users
      |- SELECT userId and Username
         | - SELECT users group ID
         | - GET promotions for this user
             | - Count Number of videos for this promotion
             | - GET videos for this promotion
                 | - Count Number of Views for each video
    

     

    Here is the SQL I have

     

    SELECT DISTINCT u.userName, u.userId, v.videoCount, v.viewCount, g.groupId
        FROM user u
            LEFT JOIN (
                SELECT sv.viewCount, sv.videoCount, userId, promoId FROM promos
                    LEFT JOIN (
                        SELECT COUNT(*) AS videoCount, vv.viewCount, videoId, promoId FROM videos
                            LEFT JOIN (
                                SELECT videoId, COUNT(*) AS viewCount FROM videoTracking GROUP BY videoId) AS vv USING (videoId)
                            GROUP BY promoId) AS sv USING(promoId)
            ) AS v USING (userId)
            LEFT JOIN (
                        SELECT userid, groupId FROM userGroups ) AS g USING (userId)
        WHERE g.groupId = "3" ORDER BY u.userId DESC LIMIT 0,10
    

     

    and Here are the table structures

     

    mysql> EXPLAIN videos;
    +-----------+-------------+------+-----+---------+----------------+
    | Field     | Type        | Null | Key | Default | Extra          |
    +-----------+-------------+------+-----+---------+----------------+
    | videoId   | int(11)     | NO   | PRI | NULL    | auto_increment | 
    | date      | varchar(14) | NO   |     | NULL    |                | 
    | promoId   | int(11)     | NO   | MUL | NULL    |                | 
    | channelId | int(11)     | NO   | MUL | NULL    |                | 
    | userId    | int(11)     | NO   | MUL | NULL    |                | 
    | status    | tinyint(1)  | NO   |     | 0       |                | 
    +-----------+-------------+------+-----+---------+----------------+
    6 rows in set (0.00 sec)
    
    mysql> EXPLAIN userGroups;
    +-------------+---------+------+-----+---------+----------------+
    | Field       | Type    | Null | Key | Default | Extra          |
    +-------------+---------+------+-----+---------+----------------+
    | userGroupId | int(11) | NO   | PRI | NULL    | auto_increment | 
    | groupId     | int(11) | NO   |     | NULL    |                | 
    | userId      | int(11) | NO   |     | NULL    |                | 
    +-------------+---------+------+-----+---------+----------------+
    3 rows in set (0.00 sec)
    
    mysql> EXPLAIN user;
    +-----------+-------------+------+-----+---------+----------------+
    | Field     | Type        | Null | Key | Default | Extra          |
    +-----------+-------------+------+-----+---------+----------------+
    | userId    | int(11)     | NO   | PRI | NULL    | auto_increment | 
    | userName  | varchar(20) | NO   |     | NULL    |                | 
    | salt      | varchar(4)  | NO   |     | NULL    |                | 
    | password  | varchar(45) | NO   |     | NULL    |                | 
    | timestamp | varchar(14) | NO   |     | NULL    |                | 
    +-----------+-------------+------+-----+---------+----------------+
    5 rows in set (0.00 sec)
    
    mysql> EXPLAIN videoTracking ;
    +-----------+-------------+------+-----+---------+----------------+
    | Field     | Type        | Null | Key | Default | Extra          |
    +-----------+-------------+------+-----+---------+----------------+
    | trackId   | int(11)     | NO   | PRI | NULL    | auto_increment | 
    | promoId   | varchar(11) | NO   | MUL | NULL    |                | 
    | channelId | int(11)     | NO   | MUL | NULL    |                | 
    | userId    | int(11)     | NO   | MUL | NULL    |                | 
    | viewerId  | int(11)     | NO   |     | NULL    |                | 
    | viewerIp  | varchar(50) | NO   |     | NULL    |                | 
    | videoId   | int(11)     | NO   | MUL | NULL    |                | 
    | timestamp | varchar(14) | NO   |     | NULL    |                | 
    +-----------+-------------+------+-----+---------+----------------+
    8 rows in set (0.00 sec)
    
    mysql> EXPLAIN promos;
    +-----------+-------------+------+-----+---------+----------------+
    | Field     | Type        | Null | Key | Default | Extra          |
    +-----------+-------------+------+-----+---------+----------------+
    | promoId   | int(11)     | NO   | PRI | NULL    | auto_increment | 
    | userId    | int(11)     | NO   | MUL | NULL    |                | 
    | name      | varchar(75) | NO   |     | NULL    |                | 
    | channelId | int(11)     | NO   | MUL | NULL    |                | 
    +-----------+-------------+------+-----+---------+----------------+
    4 rows in set (0.00 sec)
    

  10. Of the 2 pages we tested on the site over the past 90 days, 2 page(s) resulted in malicious software being downloaded and installed without user consent. The last time Google visited this site was on 2009-06-17, and the last time suspicious content was found on this site was on 2009-06-17.

     

    Malicious software includes 5 trojan(s).

  11. Also why the hell would you put this in the footer of your site:

    Opimitized For Gecko & WebKit Browser Rendering Engines

    Trident Rendering Engine (Internet Explorer) may not properly work

     

    Thats like saying if you use IE then tough shit. You should make it work.

     

    Definition of Optimized

    op⋅ti⋅mize

      /ˈɒptəˌmaɪz/ Show Spelled Pronunciation [op-tuh-mahyz]

    –verb (used with object)

    1. to make as effective, perfect, or useful as possible.

    2. to make the best of.

    3. Computers. to write or rewrite (the instructions in a program) so as to maximize efficiency and speed in retrieval, storage, or execution.

    4. Mathematics. to determine the maximum or minimum values of (a specified function that is subject to certain constraints).

     

    Please read the definition above ...

     

    Informing someone that a service is optimized to work using specifics is not in any way telling them "tough shit", it is simply implying that the service you are using will work using other products but may not be 100%

     

    And next time you want to rant please read a post entirely

     

    Havent taken the time to validate or Fix IE, these will be taken care of in the final steps

  12. Are you submitting this to a form?

     

    If so use

     

    $_POST['SesssionID'];
    

     

    If you want the Regex for this here it is

    $str = '<input type="hidden" name="SessionID" value="12433690503231243369050323U[[bR??=96<692">';
    
    preg_match_all('/value="(.*)"/i', $str, $match);
    
    echo '<pre>';
    
    var_dump($match);
    
    echo '</pre>';
    
    
    
    echo $matches[1][0];
    

  13. Developing your own framework will not give you a very knowledgeable understanding or insight on how the MVC Pattern works, if you don't understand it in the first place how would developing a MVC Pattern application help? It would be like saying your going to design and build a Formula 1 Racer with absolutely no knowledge of mechanical engineering and physics to learn how to ... it will turn out very poor-quality and not near capable of being able to perform the task it is intended to do, and you will most likely be in the relatively same place you started 

  14. You can use the id of the PM they are responding in the url and pull the title from the database

     

    // url : <a href='../index.php?page=messages&option=reply&user=" . $sender . "&pmId="'.$pmId.'"'>Reply</a>
    $sql = 'SELECT `title` FROM `private_messages` WHERE `pmId` = "'.(int) $_GET['pmId'].'" LIMIT 1';
    $result = mysql_query($sql);
    $fetch = mysql_fetch_assoc($result);
    $title = 'Re: '.$fetch['title'].';
    

     

  15. Lots of people seem to like rock 8)

     

    I listen to reggae most of the time at work....which my boss cannot understand why also throw in some Anthony Hamilton, Matchbox 20, Journey, Aerosmith and the like.

     

    At home i listen to my wifes pounding loud rap **** which I CANNOT stand...

     

     

    It really depends on what I am doing if I'm going to listen to music, most of the time I get so zoned out when I'm coding I seem to forget there is music and everything else for that matter

  16. Theres not much you can do about TinyMCE producing invalid HTML on its side.... my suggesting is running Html_Tidy on all content your clients input to ensure its validated, and FckEditor is the same.

     

    There is only a handful on WYSIWYG editors that produce valid HTML one I know of is called WymEditor its in Beta and it seems the development has since become frozen

  17. My job I'm the Lead PHP/HTML/CSS/Javascript/jQuery/Ajax Developer............and we are starting to get clients that want to use Python we currently just outsource all of our python work (which isn't much). Now they want to start doing it in-house .... and want me to learn python (django).

     

    I've never really been into Python read about it, used it a bit but would it be worth taken the extra time and learning python?

     

    It is of course my choice completely to do it or not ... if I do I get a bonus of $2k ( only reason I'm considering it ) although nothing else

  18. Hello!

     

    Working with SOAP for a client and they need us to interact with a API using SOAP.

     

    Issue I seem to be having is that when I talk back to their server it doesn't recognize the information I'm giving (I presume as I get a proper response)

     

    I'm not to familiar with SOAP but from my understanding, I need to send the data for the complexType Partner as an Object, for the createWorkOrder function...

     

    They gave us a C snippet for this which works ...... and the parser for this I believe is written in C also, we have contacted the companies support on this to get help but they are outsourced to India and are quite possibly, the most rude sonsa**** we have ever talked to and simply told us they "I dont know PHP im not Program Expert go find elsewhere some help" .....quoted

     

    This is the PHP code being used...

    $client = new SoapClient("http://qasecure.ars.com/leadws/leadws.asmx?WSDL",array("trace" => true));
    
    echo '<pre>';
    
    $Partner = new stdClass();
    
    $Partner->partnerName = "Test";
    
    $Partner->partnerPassword = "Test";
    
    // Dump out our response
    
    var_dump($client->createWorkOrder(array($Partner, null));
    
    // Responds with Invalid ID
    echo '</pre>';
    

     

    And the SOAP XML Data

    <s:element name="createWorkOrder">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="Partner" type="tns:partner" />
                <s:element minOccurs="0" maxOccurs="1" name="WorkOrder" type="tns:workorder" />
              </s:sequence>
    
            </s:complexType>
          </s:element>
          <s:complexType name="partner">
            <s:sequence>
              <s:element minOccurs="0" maxOccurs="1" name="partnerId" type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="partnerName" type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="partnerPassword" type="s:string" />
            </s:sequence>
          </s:complexType>
    
          <s:complexType name="workorder">
            <s:sequence>
              <s:element minOccurs="0" maxOccurs="1" name="dispatchId" type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="branchcode" type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="servicecode" type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="sourcecode" type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="promocode" type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="promodesc" type="s:string" />
              <s:element minOccurs="1" maxOccurs="1" name="serviceDate" type="s:dateTime" />
    
              <s:element minOccurs="0" maxOccurs="1" name="specialInstructions" type="s:string" />
              <s:element minOccurs="0" maxOccurs="1" name="address" type="tns:serviceAddress" />
              <s:element minOccurs="0" maxOccurs="1" name="customer" type="tns:customer" />
              <s:element minOccurs="0" maxOccurs="1" name="work" type="tns:workDetails" />
            </s:sequence>
          </s:complexType>
    

     

  19. Here is a payment calculator I wrote for car payments ...... you need to input the amounts in PHP but it works great

     

    <?php
    
    /*
    * Fixed Rate Interest Loan Calulator
    */
    
    // Do you pay on the amount at time of loan purchase?
    // Or do you pay on the amount of the that you currently owe?
    // Options
    // ---------------------
    // amountOwed | timeofPur
    $loanType = 'amountOwed';
    
    //Interest Rate
    //  1-.00
    $rate = '.23';
    $rateYr = $rate / 365.5;
    // Amount Of Loan
    $amount = 10750;
    
    // Pay Cycle In Days
    $payLength = 14;
    
    $paymentAmounts = 176;
    
    $currentDay = 0;
    $totalDays = 0;
    $totalInterest = 0;
    $totalInterestPayments = array();
    $totalAmountPaid = 0;
    $totalAmountOwed = $amount;
    $lastPayment = 0;
    $totalPayments = 0;
    echo '<span style="font-size: 10px;">';
    // Start calulating the total length
    while ($totalAmountOwed > 0)
    {
        // Are we adding interest?
        if ($currentDay == 365) {
            // Add in loan interest
            $interestAdd = ($loanType == 'amountOwed') ? $rate * $totalAmountOwed : $rate * $amount;
            $totalAmountOwed += $interestAdd;
            $totalInterest += $interestAdd;
            $currentDay = 0;
    echo ' ------------------------------- <br /><br /> INTEREST ADDING <br /><br />';
    echo '<strong>Added Interest : </strong> $'.round($interestAdd, 2).' Loan Balance is now $'.round( $totalAmountOwed, 2).' <br /><br />';
    echo '<br /><br /> ------------------------------- <br /><br />';
        } else {
            $currentDay++;
        }
        
        if ($lastPayment == $payLength)
        {
    if ($totalAmountOwed < $paymentAmounts)
            {
    	$finalPaymentAmount = $totalAmountOwed;
                    $paymentAmounts = $totalAmountOwed;
    }
            // Get the total amount we are paying in interest add to array
            $interestPaid = $payLength * $rateYr * $totalAmountOwed;
            $totalPayments++;
            $totalInterestPayments[] = $interestPaid;
            $totalAmountPaid += $paymentAmounts;
            $totalAmountOwed = $totalAmountOwed - $paymentAmounts;
            $lastPayment = 0;
    if ($finalPaymentAmount)
    {
    	echo '<strong>Making final payment of $'.round($paymentAmounts, 2).' and $'.round($interestPaid, 2).' of it is interest <br /><br /> ------------------------------- <br /><br /> LOAN IS PAID IN FULL <br /><br /> ------------------------------- <br /><br />';
    }
    else
    {
    	echo '<strong>Making a payment of $'.round($paymentAmounts, 2).' and $'.round($interestPaid, 2).' of it is interest loan balance is now $'.round($totalAmountOwed, 2).' <br /><br />';
    }
        }
        else
        {
            $lastPayment++;
        }
        
        $totalDays++;
    }
    
    $interestAddedCount = count($totalInterestPayments);
    foreach ($totalInterestPayments as $k => $v)
    {
        $a++;
        $interestTotal += $v;
    }
    $interestToward = $interestTotal / $interestAddedCount;
    
    $yearDay = 0;
    $year = 0;
    $monthCount = 0;
    while( $totalDays != 0)
    {
        if ($yearDay == 365) {
            $year++;
            $yearDay = 0;
        } else {
            $yearDay++;
        }
    
        if ($totalDays < 365) {
            if ($dayMonth != 30) {
                $dayMonth++;
            } else {
                $monthCount++;
                $dayMonth = 0;
            }
        }
        
        $totalDays--;
    }
    
    $interestPercentage = round(($interestToward / $paymentAmounts) * 100);
    
    // Breakdown some stats!
    echo 'Total Payments : '.$totalPayments.' <br />';
    echo 'Final Payment Amount : $'.round($finalPaymentAmount,2).' <br />';
    echo 'Loan Length : '.$year.' Year(s) '.$monthCount.' Month(s) '.$dayMonth.' Day(s) <br />';
    echo 'Interest Paid : $'.round($totalInterest, 2).' <br />';
    echo 'Total Cost of Loan : $'.round($totalInterest + $amount, 2).' <br />';
    echo 'On Average You will be paying : $'.round($interestToward, 2).' towards interest each payment or '.$interestPercentage.'% of each payment is interest';
    ?>
    </span>
    

  20. This would be a bit better as it would check for a double space and replace it with 'space'  this way you are not limiting yourself to only 'tabbed' spaces

    $variable = str_replace('  ', '   ', $variable);
    

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