"]); $countDay += $date["day"]; return $countDay; } // ***************************************************************************** // Purpose gets address string // Inputs $date array of item // "day" // "month" // "year" // $date2 must be more later $date1 // Remarks // Returns function _getDayBetweenDate( $date1, $date2 ) { if ( $date1["year"] > $date2["year"] ) return -1; if ( $date1["year"]==$date2["year"] && $date1["month"]>$date2["month"] ) return -1; if ( $date1["year"]==$date2["year"] && $date1["month"]==$date2["month"] && $date1["day"] > $date2["day"] ) return -1; return _getCountDay( $date2 ) - _getCountDay( $date1 ); } // ***************************************************************************** // Purpose // Inputs // Remarks // Returns // -1 access denied // 0 success, access granted and load_counter has been incremented // 1 access granted but count downloading is exceeded eproduct_download_times in PRODUCTS_TABLE // 2 access granted but available days are exhausted to download product // 3 it is not downloadable product // 4 order is not ready function ordAccessToLoadFile( $orderID, $productID, & $pathToProductFile, & $productFileShortName ) { $order = ordGetOrder($orderID); $product = GetProduct( $productID ); if ( strlen($product["eproduct_filename"]) == 0 || !file_exists("core/files/".$product["eproduct_filename"]) || $product["eproduct_filename"] == null ) { return 4; } if ( (int)$order["statusID"] != (int)ostGetCompletedOrderStatus() ) return 3; $orderContent = ordGetOrderContent( $orderID ); foreach( $orderContent as $item ) { if ( GetProductIdByItemId($item["itemID"]) == $productID ) { if ( $item["load_counter"] < $product["eproduct_download_times"] || $product["eproduct_download_times"] == 0 ) { $date1 = dtGetParsedDateTime( $order["order_time_mysql"] ); //$order["order_time"] $date2 = dtGetParsedDateTime( get_current_time() ); $countDay = _getDayBetweenDate( $date1, $date2 ); if ( $countDay>=$product["eproduct_available_days"] ) return 2; if ( $product["eproduct_download_times"] != 0 ) { db_query( "update ".ORDERED_CARTS_TABLE. " set load_counter=load_counter+1 ". " where itemID=".(int)$item["itemID"]." AND orderID=".(int)$orderID ); } $pathToProductFile = "core/files/".$product["eproduct_filename"]; $productFileShortName = $product["eproduct_filename"]; return 0; } else return 1; } } return -1; } ?>