Plugin Directory

Changeset 175817


Ignore:
Timestamp:
11/21/2009 10:38:19 PM (17 years ago)
Author:
erikpbogaerts
Message:

0.1

Location:
zingiri-hoster/trunk
Files:
18 added
13 edited

Legend:

Unmodified
Added
Removed
  • zingiri-hoster/trunk/apps/classes/sub.cartprice.class.php

    r175051 r175817  
    2727        function display(&$field_markup,&$subscript_markup) {
    2828                parent::display(&$field_markup,&$subscript_markup);
    29        
     29
    3030                $e=$this->element;
    3131                $i=$this->subid;
    … …  
    3333
    3434        }
    35        
     35
    3636        function prepare() {
    37                 echo 'here';
    38                 $this->int=123;
    39                 $this->ext=123;
     37                parent::prepare();
     38                $e=$this->element;
     39                $i=$this->subid;
     40
     41                //print_r($this->element->populated_column);
     42                //print_r($this->element->populated_value);
     43                $currency=$e->populated_column['CURRENCY'];
     44                $frequency=$e->populated_column['FREQUENCY'];
     45                $productid=$e->populated_column['PRODUCTID'];
     46                $regtype=$e->populated_column['DOMAIN_REGTYPE'];
     47                $domain=$e->populated_column['DOMAIN_NAME'];
     48                $period=$e->populated_column['DOMAIN_PERIOD'];
     49
     50                $price=$this->calcPackagePrice($productid,$currency,$frequency);
     51                $price+=$this->calcDomainPrice($currency,$period,$regtype,$domain);
     52                $e->populated_value['element_'.$e->id.'_'.$i]=$price;
    4053        }
    41         /*
    42         function verify()
    43         {
    44                 $this->ext=$this->int;
    45                 $status=$this->checkDomain();
    46                 $j=$this->subid+2;
    47                 $regtype=$this->element->input['element_'.$this->element->id.'_'.$j];
    48                 if ($status==1 && ($regtype==2))
    49                         return $this->error("You can't transfer a domain that is not registered!");
    50                 elseif  ($status==2 && ($regtype==1))
    51                         return $this->error("This domain is already registered!");
    52                 elseif  ($status==3)
    53                         return $this->error("This domain name is invalid!");
    54                 return true;   
     54
     55        private function calcPackagePrice($productid,$currency,$frequency) {
     56                if (empty($frequency)) $frequency=1;
     57
     58                if (!empty($productid) && !empty($currency) && !empty($frequency)) {
     59                        $query="select ##pricing.price from ##pricing where ##pricing.productid=".zfqs($productid)." and ##pricing.currency=".zfqs($currency)." and ##pricing.frequency=".zfqs($frequency);
     60                        $sql=new db();
     61                        $sql->select($query);
     62                        if ($row=$sql->next()) {
     63                                $price=$sql->row['price'];
     64                        }
     65
     66                } else {
     67                        $price=false;
     68                }
     69                return $price;
     70        }
     71
     72        private function calcDomainPrice($currency,$period,$regtype,$domain) {
     73                if ($regtype == 3) return 0;
    5574                       
     75                $whois = new SamsWhois();
     76                if (!$whois->ValidDomain($domain)) return false;
     77
     78                //if (empty($period)) $period=1;
     79                $extension=$whois->extension;
     80
     81                if (!empty($extension) && !empty($currency) && !empty($period)) {
     82                        $query="select ##domainpricing.price from ##domainpricing where ##domainpricing.extension=".zfqs($extension)." and ##domainpricing.currency=".zfqs($currency)." and ##domainpricing.period=".zfqs($period);
     83                        $sql=new db();
     84                        $sql->select($query);
     85                        if ($row=$sql->next()) {
     86                                $price=$sql->row['price'];
     87                        }
     88
     89                } else {
     90                        $price=false;
     91                }
     92                return $price;
    5693        }
    57         */
    5894
     95        function verify() {
     96                $success=true;
     97                $e=$this->element;
     98                $i=$this->subid;
     99
     100//              print_r($this->element->populated_column);
     101//              print_r($this->element->populated_value);
     102                $currency=$e->populated_column['CURRENCY'];
     103                $frequency=$e->populated_column['FREQUENCY'];
     104                $productid=$e->populated_column['PRODUCTID'];
     105                $regtype=$e->populated_column['DOMAIN_REGTYPE'];
     106                $domain=$e->populated_column['DOMAIN_NAME'];
     107                $period=$e->populated_column['DOMAIN_PERIOD'];
     108
     109                $price=$this->calcPackagePrice($productid,$currency,$frequency);
     110                $price+=$this->calcDomainPrice($currency,$period,$regtype,$domain);
     111                $this->ext=$this->int=$price;
     112                return $success;
     113        }
    59114}
  • zingiri-hoster/trunk/apps/fields/hosting_billing_choice.xml

    r174990 r175817  
    66                        <name>frequency</name>
    77                        <format>varchar(2)</format>
    8                         <default></default>
     8                        <default>1</default>
    99                        <type>sql</type>
    1010                        <values type="sql">
    11                                 <query>select ##pricing.frequency,concat(##pricing.frequency,' - ',##pricing.price) from ##product,##pricing where ##product.id=##pricing.productid and ##product.id=$productid and ##pricing.currency=$myCurrency order by ##pricing.frequency</query>
     11                                <query>select ##pricing.frequency,##parameter.label from ##pricing,##parameter where ##pricing.productid=$productid and ##pricing.currency=$myCurrency and ##parameter.name='frequency' and ##pricing.frequency=##parameter.value order by ##pricing.frequency</query>
    1212                                <where>productid,myCurrency</where>
    1313                        </values>
  • zingiri-hoster/trunk/apps/fields/hosting_domain.xml

    r174990 r175817  
    22<config type="hosting" version="1.5.0">
    33        <name>Domain</name>
    4         <fields count="3">
     4        <fields count="4">
    55                <field1>
    66                        <name>name</name>
    … …  
    3030                        </values>
    3131                </field3>               
     32                <field4>
     33                        <name>period</name>
     34                        <format>varchar(2)</format>
     35                        <label>registration length</label>
     36                        <default>1</default>
     37                        <type>select</type>
     38                        <values type="multi">
     39                                <option1 value="1">1 Year</option1>
     40                                <option2 value="2">2 Year</option2>
     41                                <option3 value="3">3 Year</option3>
     42                                <option4 value="4">4 Year</option4>
     43                                <option5 value="5">5 Year</option5>
     44                                <option6 value="0">One time</option6>
     45                        </values>
     46                </field4>               
    3247        </fields>
    3348</config>
  • zingiri-hoster/trunk/apps/fields/hosting_price_per_period.xml

    r174990 r175817  
    11<?xml version="1.0" encoding="utf-8"?>
    22<config type="hosting" version="1.5.0">
    3         <name>Price per period</name>
    4         <fields count="2">
     3        <name>Cart price</name>
     4        <fields count="1">
    55                <field1>
    66                        <name>price</name>
    7                         <label>Price</label>
    87                        <format>decimal(12,2)</format>
     8                        <type>cartprice</type>
    99                        <size>10</size>
    1010                </field1>
    11                 <field2>
    12                         <name>allow</name>
    13                         <label>Allow in signup</label>
    14                         <format>int(6)</format>
    15                         <type>checkbox</type>
    16                 </field2>
    1711        </fields>
    1812</config>
  • zingiri-hoster/trunk/fws/admin.php

    r175054 r175817  
    9090                 <td><div style="text-align:center;"><a class="plain" href="?page=customeradmin&action=showcustomers"><img src="<?php echo $gfx_dir; ?>/customers.gif" alt="" /><br /><?php echo $txt['admin3']." (".CountCustomers('CUSTOMER').")"; ?></a><br /><br /></div></td>
    9191                 <td><div style="text-align:center;"><a class="plain" href="?zfaces=list&form=package"><img src="<?php echo $gfx_dir; ?>/package.png" height="32px" alt="package" /><br /><?php echo $txt['admin44']; ?></a><br /><br /></div></td>
    92 
     92                 <td><div style="text-align:center;"><a class="plain" href="?zfaces=list&form=domain"><img src="<?php echo $gfx_dir; ?>/domain.png" height="32px" alt="domain" /><br /><?php echo $txt['admin48']; ?></a><br /><br /></div></td>
    9393              </tr>
    9494              <tr><td colspan="3"><h6><?php echo $txt['admin46']; ?></h6></td></tr>
    … …  
    101101                 <td><div style="text-align:center;"><a class="plain" href="?zfaces=list&form=server"><img src="<?php echo $gfx_dir; ?>/server.png" height="32px" alt="server" /><br /><?php echo $txt['admin40']; ?></a><br /><br /></div></td>
    102102                 <td><div style="text-align:center;"><a class="plain" href="?zfaces=list&form=registrar"><img src="<?php echo $gfx_dir; ?>/registrar.png" height="32px" alt="registrar" /><br /><?php echo $txt['admin42']; ?></a><br /><br /></div></td>                 
    103                  <td><div style="text-align:center;"><a class="plain" href="?zfaces=list&form=domainpricing"><img src="<?php echo $gfx_dir; ?>/domain.png" height="32px" alt="domain" /><br /><?php echo $txt['admin41']; ?></a><br /><br /></div></td>
     103                 <td><div style="text-align:center;"><a class="plain" href="?zfaces=list&form=domainpricing"><img src="<?php echo $gfx_dir; ?>/domainpricing.png" height="32px" alt="domain" /><br /><?php echo $txt['admin41']; ?></a><br /><br /></div></td>
    104104                 <td><div style="text-align:center;"><a class="plain" href="?zfaces=list&form=product"><img src="<?php echo $gfx_dir; ?>/product.png" height="32px" alt="product" /><br /><?php echo $txt['admin5']." (".CountProducts().")"; ?></a><br /><br /></div></td>                 
    105105              </tr>
  • zingiri-hoster/trunk/fws/batch/orders.php

    r175007 r175817  
    77        require (dirname(__FILE__)."/../includes/readsettings.inc.php");    // read shop settigns
    88        require(dirname(__FILE__)."/../includes/setfolders.inc.php");      // set appropriate folders
     9        define("DBTABLESPREFIX",$dbtablesprefix);
     10        define("BR","\n\0");
     11        require(dirname(__FILE__)."/../classes/db.class.php");
     12        require(dirname(__FILE__)."/../classes/order.class.php");
     13        require(dirname(__FILE__)."/../classes/package.class.php");
     14        require(dirname(__FILE__)."/../plugins/controlpanel.class.php");
    915}
    1016
    11 define("DBTABLESPREFIX",$dbtablesprefix);
    12 define("BR","\n\0");
    13 require(dirname(__FILE__)."/../classes/db.class.php");
    14 require(dirname(__FILE__)."/../classes/order.class.php");
    15 require(dirname(__FILE__)."/../classes/package.class.php");
    16 require(dirname(__FILE__)."/../plugins/controlpanel.class.php");
     17echo 'Generate invoices<br />';
    1718
    18 echo 'Processing orders';
    19 
    20 $order=new db();
     19$error=new error();
     20$order=new order();
    2121
    2222//select paid and approved orders
    23 $order->select("select * from ##order where status in ('4')");
     23$order->selectOpenOrders();
    2424while ($order->next()) {
    25         print_r($order->row);
    2625
    2726        $succes=true;
    … …  
    3029        $basket->select("select * from ##basket where orderid=".$order->get('id'));
    3130        while ($basket->next()) {
    32                 echo "basket:";print_r($basket->row);
    33 
    3431                //create the package
    3532                $package=new package();
    … …  
    4138                $package->price=$basket->get('price');
    4239
    43                 $package->create($basket->get('productid'));
     40                if (!$package->create($basket->get('productid'))) {
     41                        $succes=false;
     42                        $error->add("Couldn't create package: ".$package->domain);
     43                }
    4444                       
    4545                //activate the package
    46                 $success=$package->activate();
     46                if ($succes && !$package->activate()) {
     47                        $succes=false;
     48                        $error->add("Couldn't activate package: ".$package->domain);
     49                }
     50                if ($succes && !$package->sendWelcomeEmail()) {
     51                        $succes=false;
     52                        $error->add("Couldn't send welcome email for package: ".$package->domain);
     53                }
    4754        }
    4855        //update order
    49         //$order->setStatusCompleted();
     56        if ($succes) {
     57                $order->setStatusCompleted();
     58        }
    5059
    5160}
    5261
     62$error->dump();
    5363?>
  • zingiri-hoster/trunk/fws/checkout.php

    r175054 r175817  
    257257                                $payment_code = str_replace("%email%", $customer_row['EMAIL'], $payment_code);
    258258                                $payment_code = str_replace("%phone%", $customer_row['PHONE'], $payment_code);
    259                                 $payment_code = str_replace("%ipn%", ZING_URL.'fws/ipn.php', $payment_code);
     259                                $payment_code = str_replace("%ipn%", ZING_URL.'fws/plugins/gateways/paypal/ipn.php', $payment_code);
    260260                                $payment_code = str_replace("%paypal_email%", $sales_mail, $payment_code);
    261261                                $payment_code = str_replace("%return%", $shopurl . '/index.php?page=checkout&paypal=1', $payment_code);
  • zingiri-hoster/trunk/fws/classes/db.class.php

    r175010 r175817  
    77        var $sql="";
    88        var $row;
    9 
    10         function __construct() {
    11                 //echo "hello";
    12         }
    139
    1410        function select($query) {
    … …  
    2218
    2319        function next() {
    24 
    2520                if ($this->row=mysql_fetch_assoc($this->sql)) {
    26                                
    2721                        return $this->row;
    2822                } else { return false; }
    … …  
    3024
    3125        function update($query) {
    32                 $this->sql = mysql_query($query) or die(dbError(1,$query,"",$action));
    33                 return $this->sql;
     26                $query=str_replace("##",DBTABLESPREFIX,$query);
     27                $sql = mysql_query($query) or die($this->dbError(1,$query,"",$action));
     28                return $sql;
    3429        }
    3530
    … …  
    6459
    6560                //      echo $query."<br />";
    66                 $sql = mysql_query($query) or die(dbError(1,$query,"substax.inc.php",$action));
     61                $sql = mysql_query($query) or die($this->dbError(1,$query,"substax.inc.php",$action));
    6762                $numrows=mysql_num_rows($sql);
    6863
    … …  
    105100
    106101                //      echo $query."<br />";
    107                 $sql_update = mysql_query($query) or die(dbError(1,$query,"substax.inc.php",$action));
     102                $sql_update = mysql_query($query) or die($this->dbError(1,$query,"substax.inc.php",$action));
    108103        }
    109104
    … …  
    152147                $query.=")";
    153148                //      echo $query."<br />";
    154                 $sql_insert = mysql_query($query) or die(dbError(1,$query,"substax.inc.php",$action));
     149                $sql_insert = mysql_query($query) or die($this->dbError(1,$query,"substax.inc.php",$action));
    155150                $id = mysql_insert_id();
    156151
    … …  
    172167
    173168                //      echo $query."<br />";
    174                 $sql = mysql_query($query) or die(dbError(1,$query,"",$action));
     169                $sql = mysql_query($query) or die($this->dbError(1,$query,"",$action));
    175170        }
    176171
    … …  
    196191        }
    197192
    198         function txrollback()
     193        private function txrollback()
    199194        {
    200195                Global $txglobal;
    … …  
    208203        }
    209204
    210         function dbError($severity, $query, $page, $action)
     205        private function dbError($severity, $query, $page, $action)
    211206        {
    212207                Global $gfx_dir;
    … …  
    220215                $sql=mysql_error();
    221216
    222                 txrollback();
     217                $this->txrollback();
    223218
    224219                echo "ERROR:".$severity."-".$query."-".$sql;
  • zingiri-hoster/trunk/fws/classes/order.class.php

    r175010 r175817  
    11<?php
    2 class order {
    3         var $numrows;
    4         var $sql="";
    5         var $row;
    6        
    7         function __construct() {
    8                 //echo "hello";
     2class order extends db {
     3
     4
     5        function selectOpenOrders() {
     6                $this->select("select * from ##order where status in ('4')");
    97        }
    108       
    11         function select($query) {
    12                 $action="";
    13                 $query=str_replace("##",DBTABLESPREFIX,$query);
    14                 $this->sql = mysql_query($query) or die($this->error($query));
    15                 $this->numrows=mysql_num_rows($this->sql);
    16                 echo $this->numrows;
    17                 if ($this->numrows == 0) return false; else return $this->numrows;
    18         }
    19        
    20         function next() {
    21                 if ($this->row=mysql_fetch_assoc($this->sql)) {
    22                         return $this->row;
    23                 } else { return false; }
    24         }
    25 
    269        function setStatusCompleted() {
    2710                $status='6';
    2811                $query="update ##order set STATUS=".qs($status);
    29                 $sql = mysql_query($query) or die(dbError(1,$query,"",$action));
    30                 return true;           
     12                return parent::update($query);
    3113        }
    3214       
  • zingiri-hoster/trunk/fws/classes/package.class.php

    r175010 r175817  
    3131                $this->productid=$this->package->get('productid');
    3232                $this->username=$this->package->get('username');
     33                $this->password=$this->package->get('password');
     34                $this->domain=$this->package->get('domain');
    3335        }
    3436
    … …  
    6365                $c['STATUS']='10';
    6466                $c['DOMAIN']=$this->domain;
    65                 $c['REGISTRATION']=$this->registration;
    6667                $c['FREQUENCY']=$this->frequency;
     68                $c['DATE_CREATED']=date("Y-m-d H:i:s");
     69                $c['DUEDATE']=$this->calcNextDueDate();
    6770
    6871                $c['USERNAME']=$this->username=$this->createUsername($this->domain);
    … …  
    7174                $p=new db();
    7275                $this->id=$p->insertRecord("package",null,$c);
     76               
     77                if ($this->id) return true; else return false;
    7378                //not defined yet
    7479                //$c['PERIOD']=$this->period;
    75                 //$c['NEXTDUEDATE']=
    76                 //$c['PRICE']=
    77         }
    78 
     80                //$c['REGISTRATION']=$this->registration;
     81               
     82        }
     83
     84        private function calcNextDueDate() {
     85                $today=date("Y-m-d");
     86                $mth=$this->frequency;
     87                $duedate=add_date($today,$mth);
     88                return $duedate;
     89        }
     90       
    7991        function sendWelcomeEmail() {
    8092                global $webmaster_mail;
    8193                global $shopname;
    8294               
     95                if (!is_object($this->customer)) $this->getCustomer();
     96               
    8397                $template=new template($this->product->get('templateid'));
    8498                $template->replace('FIRSTNAME',$this->customer->get('initials'));
    8599                $template->replace('LASTNAME',$this->customer->get('lastname'));
    86                 $template->replace('DOMAINUSERNAME',$this->package->get('username'));
    87                 $template->replace('DOMAINPASSWORD',$this->package->get('password'));
     100                $template->replace('DOMAINUSERNAME',$this->package->username);
     101                $template->replace('DOMAINPASSWORD',$this->package->password);
     102                $template->replace('DOMAINNAME',$this->package->domain);
    88103                $ns=$this->server->get('NSIP1_NS')." - ".$this->server->get('NSIP1_IP');
    89104                $ns.='<br />';
    90105                $ns.=$this->server->get('NSIP2_NS')." - ".$this->server->get('NSIP2_IP');
    91106                $template->replace('NAMESERVERS',$ns);
    92                 $template->replace('DOMAINNAME',$this->package->get('domain'));
    93107                $template->replace('DOMAINIP',$this->server->get('ip'));
    94108                $template->replace('SUPPORTEMAIL',$this->settings->webmaster_mail);
    95109                $template->replace('COMPANY',$this->settings->shopname);
    96110               
    97                 mymail($this->settings->webmaster_mail, $this->customer->get('email'), $this->product->get('msgtitle'), $template->content, $this->settings->charset);
    98                 echo 'Email sent';
    99                 return true;           
     111                $ret=mymail($this->settings->webmaster_mail, $this->customer->get('email'), $this->product->get('msgtitle'), $template->content, $this->settings->charset);
     112                echo 'Email sent:'.$ret;
     113                return $ret;           
    100114        }
    101115       
    … …  
    140154                $controlpanel=$this->server->get('controlpanel');
    141155                $c=new $controlpanel($this->server->get('hostname'),$this->server->get('login'),$this->server->get('accesshash'),$this->server->get('ssl'),$this->server->get('dnstemplate'));
    142 
    143156                $ret=$c->activate ($this->domain,$this->username,$this->password,$this->product->get('plan'));
    144157                if ($ret) {
    … …  
    146159                        $keys['ID']=$this->id;
    147160                        $row['STATUS']=20;
     161                        $row['STATUSDATE']=date("Y-m-d");
    148162                        $p->updateRecord("package",$keys,$row);
    149163
    … …  
    155169        function cancel() {
    156170                $controlpanel=$this->server->get('controlpanel');
    157                 $c=new $controlpanel($this->server->get('hostname'),$this->server->get('login'),$this->server->get('accesshash'),$this->server->get('ssl'));
    158                 return $c->cancel ($this->username);
     171                $c=new $controlpanel($this->server->get('hostname'),$this->server->get('login'),$this->server->get('accesshash'),$this->server->get('ssl'),$this->server->get('dnstemplate'));
     172                $ret=$c->cancel ($this->username);
     173                if ($ret) {
     174                        $keys['ID']=$this->packageid;
     175                        $row['STATUS']=10;
     176                        $row['STATUSDATE']=date("Y-m-d");
     177                        $this->package->updateRecord('package',$keys,$row);
     178                }
     179                return $ret;
    159180        }
    160181
    … …  
    166187                        $keys['ID']=$this->packageid;
    167188                        $row['STATUS']=30;
     189                        $row['STATUSDATE']=date("Y-m-d");
    168190                        $this->package->updateRecord('package',$keys,$row);
    169191                }
    … …  
    178200                        $keys['ID']=$this->packageid;
    179201                        $row['STATUS']=20;
     202                        $row['STATUSDATE']=date("Y-m-d");
    180203                        $this->package->updateRecord('package',$keys,$row);
    181204                }
  • zingiri-hoster/trunk/fws/includes/subsh.inc.php

    r175766 r175817  
    242242function AllCountries() {
    243243        global $dbtablesprefix;
    244        
     244
    245245        $countries=array();
    246246        $file = file(ZING_DIR.'params/countries.txt');
    … …  
    259259}
    260260
     261function add_date($original_date,$month_interval)
     262{
     263        $current_date = strtotime($original_date);
     264        $resultant_date = date('Y-m-d', mktime(0,0,0,date('m',$current_date)+$month_interval,date('d',$current_date),date('Y',$current_date)));
     265        return $resultant_date;
     266}
     267
    261268?>
  • zingiri-hoster/trunk/fws/iptocountry.php

    r175054 r175817  
    2727}
    2828else {
     29       
     30        ini_set("memory_limit","128M");
    2931
    3032        $handle1 = fopen("compress.zlib://http://software77.net/cgi-bin/ip-country/geo-ip.pl?action=download", "r");
    … …  
    6365//      fclose($handle3);
    6466
    65         $query = "TRUNCATE TABLE `" . $dbtablesprefix . "iptocountry"."`";
    66         $sql=mysql_query($query) or die(mysql_error());
    67 
    6867        PutWindow($gfx_dir, $txt['general13'], $txt['iptocountry1'].$i, "notify.gif", "50");
    6968
  • zingiri-hoster/trunk/fws/langs/en/lang.txt

    r175029 r175817  
    675675$txt['admin46'] = 'Orders';
    676676$txt['admin47'] = 'IP to country DB';
    677 
     677$txt['admin48'] = 'Domains';
    678678
    679679$txt['browse21'] = 'Register';
Note: See TracChangeset for help on using the changeset viewer.