phpBMS

Changeset 693 for trunk/phpbms/include

Show
Ignore:
Timestamp:
12/31/09 13:36:45 (2 years ago)
Author:
brieb
Message:
  • Introduced administratively changeable settings to indvidual reports
  • Modified all reports to work with new settings system
  • Altered invoice and line item total reports to accept parameters from reportsettings: You can now bypass the grouping/column dialog by providing the infrmation administratively
  • Altered all sales order PDF reports to accept parameters from reportsettings: You can now administratively change certain aspects of the print outs, including what parts of the top of the report to show, and what to title the report
  • Altered label reports to accept parameters from reportsettings: printed data as well

as label measurements and layout are now defined by administratively

  • Altered export and tableprint reports to accept parameters from reportsettings: You can specify individual columns and from table instead of just the defaults (all fields, main table only)
  • Added var_dump-esque 'debug' function for development purposes to common functions
  • Integrated FPDI functionality with sales order PDF reports: It is now possible to use a PDF saved in the files table as a background template for your invoices (e.g. watermarks)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/include/common_functions.php

    r675 r693  
    549549/** 
    550550  *  function makeDelimeterString 
    551   *   
     551  * 
    552552  *  Creates a string with the same length as $string, with a delimeter where 
    553553  *  the corresponding part of the string is on or within that delimeter, and 
     
    565565  */ 
    566566function makeDelimeterString($string, $delimeters, $escapeCharacter = "\\"){ 
    567          
     567 
    568568        if(!$escapeCharacter) 
    569569                $escapeCharacter = NULL; 
    570          
     570 
    571571        if(strlen($escapeCharacter) > 1) 
    572572                return false; 
    573          
     573 
    574574        $returnString = ""; 
    575575        $stringArray = str_split($string); 
     
    577577        $prevChar = ""; 
    578578        foreach($stringArray as $char){ 
    579                  
     579 
    580580                if(!$inside){ 
    581581                        if(in_array($char, $delimeters) && $prevChar != $escapeCharacter){ 
     
    586586                                $returnString .= "0"; 
    587587                }else{ 
    588                          
     588 
    589589                        if($char == $delimeter && $prevChar != $escapeCharacter){ 
    590590                                $inside = false; 
     
    592592                        }else 
    593593                                $returnString .= $delimeter; 
    594                          
     594 
    595595                }//end if 
    596                  
     596 
    597597                $prevChar = $char; 
    598                  
     598 
    599599        }//end foreach 
    600          
     600 
    601601        return $returnString; 
    602602 
    603603}//end function 
     604 
    604605 
    605606/* 
     
    607608 * Returns the part of $querystatement from the general FROM to its ORDER BY or 
    608609 * the end of the querystatement if no ORDER BY exists. 
    609  *  
     610 * 
    610611 * @param $querystatement 
    611612 * @return string The part of $querystatement from the general FROM to its 
    612613 * ORDER BY. 
    613614 */ 
    614  
    615615function getSearchFrom($querystatement) { 
    616          
     616 
    617617        $modstatement = $querystatement; 
    618618        $insideString = makeDelimeterString($querystatement, array("'", "\"", "`")); 
    619619        $insideArray = str_split($insideString); 
    620          
    621          
     620 
     621 
    622622        /** 
    623623          *  Check for SELECTs that are not inside quotes or tics. 
     
    628628        $offset = 0; 
    629629        do{ 
    630                  
     630 
    631631                $pos = stripos($querystatement, "select", $offset); 
    632                  
     632 
    633633                if($pos !== false) 
    634634                        if(!$insideArray[$pos]) 
    635635                                $selectArray[] = $pos; 
    636636                $offset = $pos+1; 
    637          
     637 
    638638        }while($pos !== false); 
    639          
     639 
    640640        /** 
    641641          *  Check for FROMSs that are not inside quotes or tics. 
     
    646646        $offset = 0; 
    647647        do{ 
    648                  
     648 
    649649                $pos = stripos($querystatement, "from", $offset); 
    650                  
     650 
    651651                if($pos !== false) 
    652652                        if(!$insideArray[$pos]) 
    653653                                $fromArray[] = $pos; 
    654654                $offset = $pos+1; 
    655          
     655 
    656656        }while($pos !== false); 
    657          
     657 
    658658        /** 
    659659          *  Check for ORDER BYs that are not inside quotes or tics. 
     
    664664        $offset = 0; 
    665665        do{ 
    666                  
     666 
    667667                $pos = stripos($querystatement, "order by", $offset); 
    668                  
     668 
    669669                if($pos !== false) 
    670670                        if(!$insideArray[$pos]) 
    671671                                $orderArray[] = $pos; 
    672672                $offset = $pos+1; 
    673          
     673 
    674674        }while($pos !== false); 
    675          
    676          
     675 
     676 
    677677        /** 
    678           *  Pair the SELECTs with their appropriate FROMs  
     678          *  Pair the SELECTs with their appropriate FROMs 
    679679          */ 
    680680        $godArray = array(); 
     
    682682        $j = 0; 
    683683        foreach($fromArray as $fromPos){ 
    684                  
     684 
    685685                $closest = 0; 
    686686                $index = 0; 
     
    690690                                $index = $i; 
    691691                        }//end if 
    692                          
     692 
    693693                unset($tempSelectArray[$index]); 
    694694                $godArray[$j]["select"] = $closest; 
    695695                $godArray[$j]["from"] = $fromPos; 
    696696                $j++; 
    697                  
     697 
    698698        }//end foreach 
    699          
    700          
     699 
     700 
    701701        /** 
    702702          *  Pair the ORDER BYs with their approriate FROMs (and thus their 
     
    706706        $j = 0; 
    707707        foreach($orderArray as $orderPos){ 
    708                  
     708 
    709709                $closest = 0; 
    710710                $index = 0; 
     
    714714                                $index = $i; 
    715715                        }//end if 
    716                          
     716 
    717717                unset($tempFromArray[$index]); 
    718718                for($k=0; $k < count($godArray); $k++) 
    719719                        if($godArray[$k]["from"] == $closest) 
    720720                                $godArray[$k]["order"] = $orderPos; 
    721                  
     721 
    722722                $j++; 
    723                  
     723 
    724724        }//end foreach 
    725          
    726          
     725 
     726 
    727727        /** 
    728728          *  The last entry in the $godArray should be the outermost / first 
     
    732732        if(!isset($godArray[$l]["order"])) 
    733733                $godArray[$l]["order"] = strlen($querystatement); 
    734          
     734 
    735735        if(!($godArray[$l]["order"])) 
    736736                $godArray[$l]["order"] = strlen($querystatement); 
    737          
     737 
    738738        return substr($querystatement, $godArray[$l]["from"], $godArray[$l]["order"] - $godArray[$l]["from"]); 
    739          
     739 
    740740}//end function 
    741741 
     
    11251125 
    11261126/* 
    1127  * function cleanFilename        
     1127 * function cleanFilename 
    11281128 * @param $string 
    11291129 * @return string $string with only alpha-numeric characters, periods (.), 
     
    11321132 
    11331133function cleanFilename($string) { 
    1134          
     1134 
    11351135        $pattern = "/[^\w\d\.\-\_]/"; 
    11361136        $string = preg_replace($pattern, "", $string); 
    1137          
     1137 
    11381138        return $string; 
    1139          
     1139 
    11401140}//end function --cleanFilename-- 
    11411141 
     
    12461246 
    12471247 
     1248/** 
     1249 * function debug 
     1250 * 
     1251 * essentially provides a formatted var_dump with extra info for development purposes 
     1252 */ 
     1253function debug($variable, $exit = false){ 
     1254 
     1255        echo "<pre>"; 
     1256        var_dump($variable); 
     1257        echo "</pre>"; 
     1258 
     1259        $backtrace = debug_backtrace(); 
     1260 
     1261        if(count($backtrace) > 1) 
     1262            array_shift($backtrace); 
     1263 
     1264        foreach($backtrace as $trace){ 
     1265 
     1266                echo "* "; 
     1267 
     1268                if(isset($trace["class"])) 
     1269                    echo $trace["class"]."-&gt; "; 
     1270 
     1271                if(isset($trace["function"])) 
     1272                    echo $trace["function"]." "; 
     1273 
     1274                echo "in ".$trace["file"]." "; 
     1275                echo "on line ".$trace["line"]."<br />"; 
     1276 
     1277        }//endforeach 
     1278 
     1279        if($exit) 
     1280                exit(); 
     1281 
     1282}//endif 
     1283 
    12481284//for windows servers, we have no define time constants and nl_langinfo function 
    12491285//in a limited fashion; some windows servers still show that the function 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.