Explorar el Código

andres version

andre hace 4 años
padre
commit
50047d47b8
Se han modificado 4 ficheros con 79 adiciones y 606 borrados
  1. 2 6
      api/Sf/Admin.php
  2. 0 433
      clientarea.tpl
  3. 67 146
      seafile.php
  4. 10 21
      seafileAddressAvailable.php

+ 2 - 6
api/Sf/Admin.php

@@ -83,7 +83,6 @@ class Sf_Admin {
                 return array('error_msg' => 'Error: construct failed, something missing');
         }
         $sfClient = curl_init();
-        
         curl_setopt($sfClient, CURLOPT_URL, $this->sfURL . '/api2/auth-token/');
         curl_setopt($sfClient, CURLOPT_CONNECTTIMEOUT, '30');
         curl_setopt($sfClient, CURLOPT_POST, true);
@@ -96,19 +95,16 @@ class Sf_Admin {
         }
         curl_setopt($sfClient, CURLOPT_HEADER, false);
         $authResponse = curl_exec($sfClient);
-        $responseCode = curl_getinfo($sfClient, CURLINFO_RESPONSE_CODE);
-        if($responseCode != 200) {
+        if(curl_getinfo($sfClient, CURLINFO_RESPONSE_CODE) != 200) {
             curl_close($sfClient);
             unset($sfClient);
-            return array('error_msg' => $authResponse, 'response_code' => $responseCode);
+            return array('error_msg' => $authResponse);
         };
         curl_close($sfClient);
         unset($sfClient);
-        
         $authResponseData = json_decode($authResponse, true);
         if (!$authResponseData['token']) {
                 $this->loginSuccess = false;
-                error_log(print_r($authResponseData,true));
                 return array('error_msg' => $authResponse);
         } else {
                 $this->sfToken = $authResponseData['token'];

+ 0 - 433
clientarea.tpl

@@ -1,433 +0,0 @@
-{*
- **********************************************************
- * Developed by: Team Theme Metro
- * Website: http://www.thememetro.com
- * Customized ny thurdata
- **********************************************************
-*}
-{if $modulechangepwresult}
-  {if $modulechangepwresult == "success"}
-    {include file="$template/includes/alert.tpl" type="success" msg=$modulechangepasswordmessage textcenter=true}
-  {elseif $modulechangepwresult == "error"}
-    {include file="$template/includes/alert.tpl" type="error" msg=$modulechangepasswordmessage|strip_tags textcenter=true}
-  {/if}
-{/if}
-
-{if $modulecustombuttonresult}
-  {if $modulecustombuttonresult == "success"}
-    {include file="$template/includes/alert.tpl" type="success" msg=$LANG.moduleactionsuccess textcenter=true idname="alertModuleCustomButtonSuccess"}
-  {else}
-    {include file="$template/includes/alert.tpl" type="error" msg=$LANG.moduleactionfailed|cat:' ':$modulecustombuttonresult textcenter=true idname="alertModuleCustomButtonFailed"}
-  {/if}
-{/if}
-{if $pendingcancellation}
-    {include file="$template/includes/alert.tpl" type="error" msg=$LANG.cancellationrequestedexplanation textcenter=true idname="alertPendingCancellation"}
-{/if}
-{if $unpaidInvoice}
-  <div class="alert alert-{if $unpaidInvoiceOverdue}danger{else}warning{/if}" id="alert{if $unpaidInvoiceOverdue}Overdue{else}Unpaid{/if}Invoice">
-    <div class="pull-right">
-      <a href="viewinvoice.php?id={$unpaidInvoice}" class="btn btn-xs btn-default">
-        {lang key='payInvoice'}
-      </a>
-    </div>
-    {$unpaidInvoiceMessage}
-  </div>
-{/if}
-<div class="tab-content margin-bottom">
-  <div class="tab-pane fade show active" id="tabOverview">
-    {if $tplOverviewTabOutput}
-			{$tplOverviewTabOutput}
-    {else}
-      <div class="section">
-        <div class="product-details">
-          <div class="row row-eq-height row-eq-height-sm">
-            <div class="col-md-6">
-              <div class="product-holder product-status-{$rawstatus|strtolower}" style="min-height: unset; height:210px">
-                <div class="product-content">
-                  <div class="product-image">
-                    <div class="feature-icon">
-                      {if $moduleParams.configoption3 == 'on'}
-                        <img src="/templates/croster/thurdata/productgroups/2.svg" class="img-fluid" style="height:100px;">
-                      {else}
-                        <img src="/templates/croster/thurdata/productgroups/2.svg" class="img-fluid" style="height:100px;">
-                      {/if}
-                    </div>
-                  </div>
-                  <h4><small>SeaFile Account:</small> {$mailaddress}</h4>
-                  <div class="status-sticker-wrapper">
-                    <div class="status-sticker product-status-{$rawstatus|strtolower}">
-                      {$status}
-                    </div>
-                  </div>
-                </div>
-              </div>
-            </div>
-            <div class="col-md-6">
-              <div class="product-info" style="min-height: unset; height:210px;">
-                <table width="100%" border="0">
-            	    <tr>
-            		<td class="list-heading" style="font-size: 85%;">{$LANG.clientareahostingregdate}</td>
-            		<td class="list-text"  style="font-size: 85%;">{$regdate}</td>
-            	    </tr>
-            	    {if $billingcycle != 'Gratis-Account'}
-            		<tr>
-            		    <td class="list-heading" style="font-size: 85%;">{$LANG.firstpaymentamount}</td>
-            		    <td class="list-text"  style="font-size: 85%;">{$firstpaymentamount}</td>
-            		</tr>
-            		<tr>
-            		    <td class="list-heading" style="font-size: 85%;">{$LANG.recurringamount}</td>
-            		    <td class="list-text"  style="font-size: 85%;">{$recurringamount}</td>
-            		</tr>
-            		<tr>
-            		    <td class="list-heading" style="font-size: 85%;">{$LANG.orderbillingcycle}</td>
-            		    <td class="list-text"  style="font-size: 85%;">{$billingcycle}</td>
-            		</tr>
-			<tr>
-			    <td class="list-heading" style="font-size: 85%;">{$LANG.clientareahostingnextduedate}</td>
-			    <td class="list-text"  style="font-size: 85%;">{$nextduedate}</td>
-			</tr>
-			<tr>
-			    <td class="list-heading" style="font-size: 85%;">{$LANG.orderpaymentmethod}</td>
-			    <td class="list-text"  style="font-size: 85%;">{$paymentmethod}</td>
-			</tr>
-                  {else}
-                	<tr>
-                	    <td class="list-heading" style="font-size:85%"><strong>Trial Account</strong></td>
-                            {if $status == "Beendet"}
-                              <td class="list-text" style="font-size:85%;">
-                                Abgelaufen seit {((($smarty.now - ($regdate|@strtotime)) / 86400)|round) - 14} Tagen
-                              </td>
-                            {elseif ($smarty.now - ($regdate|@strtotime)) > 1123200} {* wenn Heute - RegisterDatum > 13 Tage *}
-                              <td class="list-text" style="color:red;font-size:85%;">
-                                <span class="w-hidden">{$normalisedNextDueDate}</span>
-                                Letzter Tag der Trial Periode
-                              </td>
-                            {elseif ($smarty.now - ($regdate|@strtotime)) > 950400} {* wenn Heute - RegisterDatum > 11 Tage *}
-                              <td class="list-text" style="color:orange;font-size:85%;">
-                                <span class="w-hidden">{$normalisedNextDueDate}</span>
-                                Endet in {(14 - (($smarty.now - ($regdate|@strtotime)) / 86400)|round)} Tagen
-                              </td>
-                            {else}
-                              <td class="list-text" style="font-size:85%;">
-                                Endet in {(14 - (($smarty.now - ($regdate|@strtotime)) / 86400)|round)} Tagen
-                              </td>
-                            {/if}
-            		</tr>
-            		<tr>
-                	    <td colspan="2"><br /><br /></td>
-                	</tr>
-            		<tr>
-            		    <td></td>
-            		    <td><a href="/upgrade.php?type=package&id={$id}" class="btn btn-block btn-primary">Jetzt upgraden</a></td>
-            		</tr>
-                  {/if}
-		</table> 
-              </div>
-            </div>
-          </div>
-        </div>
-      </div>
-      {*
-        {if $showcancelbutton || $packagesupgrade}
-          <div class="row">
-            {if $packagesupgrade}
-              <div class="col-xs-{if $showcancelbutton}6{else}12{/if}">
-                <a href="upgrade.php?type=package&amp;id={$id}" class="btn btn-block btn-primary">{$LANG.upgrade}</a>
-              </div>
-            {/if}
-            {if $showcancelbutton}
-              <div class="col-xs-{if $packagesupgrade}6{else}12{/if}">
-                <a href="clientarea.php?action=cancel&amp;id={$id}" class="btn btn-block btn-danger {if $pendingcancellation}disabled{/if}">{if $pendingcancellation}{$LANG.cancellationrequested}{else}{$LANG.clientareacancelrequestbutton}{/if}</a>
-              </div>
-            {/if}
-          </div>
-        {/if}
-      *}
-      {if $systemStatus == 'Active'}
-        {foreach $hookOutput as $output}
-          <div class="section">
-            <div>
-              {$output}
-            </div>
-            <div class=" clearfix"></div>
-          </div>
-        {/foreach}
-        {if $moduleclientarea || $configurableoptions || $customfields || $lastupdate}
-          <div class="section">
-            <div class="card panel panel-tabs">
-              <div class="card-header">
-                <ul class="nav nav-pills card-header-pills flex-column flex-md-row">
-                  {if $moduleclientarea}
-                    <li class="nav-item">
-                      <a href="#manage" data-toggle="tab" class="nav-link active"><i class="fas fa-globe fa-fw"></i> {lang key='manage'}</a>
-                    </li>
-                  {/if}
-                  {if $configurableoptions}
-                    <li class="nav-item">
-                      <a href="#configoptions" data-toggle="tab" class="nav-link{if !$moduleclientarea} active{/if}"><i class="fas fa-cubes fa-fw"></i>Details</a>
-                    </li>
-                  {/if}
-                  {if $metricStats}
-                    <li class="nav-item">
-                      <a href="#metrics" data-toggle="tab" class="nav-link{if !$moduleclientarea && !$configurableoptions} active{/if}"><i class="fas fa-chart-line fa-fw"></i> {lang key='metrics.title'}</a>
-                    </li>
-                  {/if}
-                  {if $customfields}
-                    <li class="nav-item">
-                      <a href="#additionalinfo" data-toggle="tab" class="nav-link{if !$moduleclientarea && !$metricStats && !$configurableoptions} active{/if}"><i class="fas fa-info fa-fw"></i>Zugangsdaten</a>
-                    </li>
-                  {/if}
-                  {if $lastupdate}
-                    <li class="nav-item">
-                      <a href="#resourceusage" data-toggle="tab" class="nav-link{if !$moduleclientarea && !$configurableoptions && !$customfields} active{/if}"><i class="fas fa-inbox fa-fw"></i> {lang key='resourceUsage'}</a>
-                    </li>
-                  {/if}
-                </ul>
-              </div>
-              <div class="card-body">
-                <div class="tab-content">
-                  {if $configurableoptions}
-                    <div class="tab-pane fade{if !$moduleclientarea} show active{/if}" role="tabpanel" id="configoptions">
-                      <table width="100%" cellspacing="0" cellpadding="0" class="frame">
-                        <tr>
-                          <td>
-                            <table width="100%" border="0" cellpadding="10" cellspacing="0" class="table table-striped table-framed">
-                              <tr>
-                                <td align='left'>Benutzername</td>
-                                <td align="left">{$mailaddress}</td>
-                              </tr>
-                              <tr>
-                                <td align='left'>Seafile Speicher inklusive</td>
-                                <td align="left">{$basequota} GB</td>
-                              </tr>
-                              <tr>
-                                <td align='left'>Seafile Speicher zugebucht</td>
-                                <td align="left">{$addonquota} GB</td>
-                              </tr>
-                              <tr>
-                                <td align='left'>Seafile Speicher gesamt</td>
-                                <td align="left">{$userquota} GB</td>
-                              </tr>
-                              {if $moduleParams.configoption3 == 'on'}
-                              <tr>
-                                <td align='left'>Seafile Speicher</td>
-                                <td align="left">{$userquota * 2} GB</a></td>
-                              </tr>
-                              {/if}
-                            </table>
-                          </td>
-                        </tr>
-                      </table>
-                    </div>
-                  {/if}
-                  {if $metricStats}
-                    <div class="tab-pane fade{if !$moduleclientarea && !$configurableoptions} show active{/if}" role="tabpanel" id="metrics">
-                      {include file="$template/clientareaproductusagebilling.tpl"}
-                    </div>
-                  {/if}
-                  {if $customfields}
-                    <div class="tab-pane fade{if !$moduleclientarea && !$configurableoptions && !$metricStats} show active{/if}" role="tabpanel" id="additionalinfo">
-                      <table width="100%" cellspacing="0" cellpadding="0" class="frame">
-                        <tr>
-                          <th width="50%"></th>
-                          <th width="50%"></th>
-                        </tr>
-                        <tr>
-                          <td align='center'>Seafile URL</td>
-                          <td align="center"><a href="{$webmailurl}" target="_blank">{$webmailurl}</a></td>
-                        </tr>
-                        {if $moduleParams.configoption3 == 'on'}
-                        <tr>
-                          <td align='center'>Seafile URL</td>
-                          <td align="center"><a href="{$moduleParams.configoption4}" target="_blank">{$moduleParams.configoption4}</a></td>
-                        </tr>
-                        {/if}
-                        <tr>
-                          <td colspan=2 align='center'>
-                            <br />
-                            <hr>
-                            <br />
-                          </td>
-                        <tr>
-                          <td colspan=2 align='center'>
-                            <h6 class="heading">Integrieren Sie Seafile auf Ihr Mobiltelefon oder Ihren PC</h6>
-                          </td>
-                        </tr>
-                        <tr>
-                          <td colspan=2 align='center'>
-                            <h6 class="heading">Als Benutzernamen verwenden Sie immer Ihren Seafile Account</h6>
-                          </td>
-                        </tr>
-                        <tr>
-                          <td colspan=2 align='center'>
-                            <br />
-                            <hr>
-                            <br />
-                          </td>
-                        </tr>
-                        <tr>
-                          <td align='center'>
-                        	<strong>Windows Drive Client</strong><br />
-                        	Zugriff auf die Daten über ein<br />
-                        	eingebundenes Netzlaufwerk.<br />
-                        	<br />
-                                <a href="https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seadrive-2.0.5-en.msi" target="_blank"><img src="modules/servers/seafile/seadrive-win.png" /><a/>
-                          </td>
-                          <td align="center">
-                        	<strong>Windows Client</strong><br />
-                        	Synchronisierung Ihrer Dateien mit Seafile<br />
-                        	Mehrere Konten auf veschiedenen Servern<br />
-                        	<br />
-                                <a href="https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-7.0.9-en.msi" target="_blank"><img src="modules/servers/seafile/windows.png" /><a/>
-                          </td>
-                        </tr>
-                          <td colspan=2 align='left'>
-                            <br />
-                            <hr>
-                            <br />
-                          </td>
-                        </tr>
-                        <tr>
-                          <td align='center'>
-                        	<strong>Apple Drive Client</strong><br />
-                        	Zugriff auf Ihre Daten über eine im Finder
-                        	direkt eingebundene Freigabe.
-                        	Mehrere Konten auf veschiedenen Servern<br />
-                        	<br />
-                                <a href="https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seadrive-2.0.5.dmg" target="_blank"><img src="modules/servers/seafile/apple.png" /><a/>
-                          </td>
-                          <td align="center">
-                                <strong>Apple Client</strong><br />
-                                Zugriff auf die Dateien via <br />
-                                Desktop Applikation<br />
-                                <br />
-                                <a href="https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-client-7.0.9.dmg" target="_blank"><img src="modules/servers/seafile/apple.png" /><a/>
-                          </td>
-                        </tr>
-                          <td colspan=2 align='left'>
-                            <br />
-                            <hr>
-                            <br />
-                          </td>
-                        </tr>
-                        <tr>
-                          <td align='center'>
-                        	<strong>App für Android</strong><br />
-                        	Mit dem Seafile-Client für Android<br />
-                        	können Sie Ihre Dateien über eine <br />
-                        	verschlüsselte Verbindung völlig <br />
-                        	sicher synchronisieren, bearbeiten und teilen.<br />
-                        	<br />
-                                <a href="https://play.google.com/store/apps/details?id=com.seafile.seadroid2" target="_blank"><img src="modules/servers/seafile/google_play.png" /><a/>
-                          </td>
-                          <td align="center">
-                        	<strong>App für iPhone</strong><br />
-                        	Mit dem Seafile-Client für iPhone<br />
-                        	können Sie Ihre Dateien über eine <br />
-                        	verschlüsselte Verbindung völlig <br />
-                        	sicher synchronisieren, bearbeiten und teilen.<br />
-                        	<br />
-                        	<a href="https://itunes.apple.com/cn/app/seafile-pro/id639202512?l=en&mt=8" target="_blank"><img src="modules/servers/seafile/apple_store.png" /><a/>
-                          </td>
-                        </tr>
-                      </table>
-                    </div>
-                  {/if}
-                  {if $lastupdate}
-                    <div class="tab-pane fade" role="tabpanel" id="resourceusage" align="center">
-                      <div class="col-sm-10">
-                        <div class="col-sm-6">
-                          <h4>{lang key='diskSpace'}</h4>
-                          <input type="text" value="{$diskpercent|substr:0:-1}" class="dial-usage" data-width="100" data-height="100" data-min="0" data-readOnly="true" />
-                          <p>{($diskusage / 1024)|round:1} GB / {($disklimit / 1024)|round:1} GB</p>
-                        </div>
-                      </div>
-                      <div class="clearfix">
-                      </div>
-                      <p class="text-muted">{lang key='clientarealastupdated'}: {$lastupdate}</p>
-                      <script src="{$BASE_PATH_JS}/jquery.knob.js"></script>
-                      <script>
-                        jQuery(function() {
-                          jQuery(".dial-usage").knob({
-                            'format': function(v) {
-                              alert(v);
-                            }
-                          });
-                        });
-                      </script>
-                      <div class="col-xs-{if $showcancelbutton}6{else}12{/if}">
-                        <a href="upgrade.php?type=configoptions&amp;id={$id}" class="btn btn-block btn-primary">Weiteren Speicher hinzubuchen</a>
-                      </div>
-                    </div>
-                  {/if}
-                </div>
-              </div>
-            </div>
-          </div>
-        {/if}
-        {else}
-        <div class="alert-lg no-data">
-          <div class="icon">
-            <i class="fas fa-exclamation-triangle"></i>
-          </div>
-          <div class="text">
-            {if $suspendreason}
-              <strong>{$suspendreason}</strong><br />
-            {/if}
-            {$LANG.cPanel.packageNotActive} {$status}.<br />
-            {if $systemStatus eq "Pending"}
-              {$LANG.cPanel.statusPendingNotice}
-            {elseif $systemStatus eq "Suspended"}
-              {$LANG.cPanel.statusSuspendedNotice}
-            {/if}
-          </div>
-        </div>
-      {/if}
-    {/if}
-  </div>
-  <div class="tab-pane fade in" id="tabChangepw">
-  <div class="section">
-    <div class="section-header">
-      <h3>{$LANG.serverchangepassword}</h3>
-      <p class="desc">Hier können Sie Ihr Passwort für {$mailaddress} ändern</p>
-    </div>
-    <div class="section-body">
-      <div class="row">
-        <div class="col-sm-7">
-          <form class=" using-password-strength" method="post" action="{$smarty.server.PHP_SELF}?action=productdetails&id={$id}" role="form">
-            <input type="hidden" name="id" value="{$id}" />
-            <input type="hidden" name="modulechangepassword" value="true" />
-            <div class="TM-card">
-              <div id="newPassword1" class="form-group has-feedback">
-                <label for="inputNewPassword1" class="control-label">{$LANG.newpassword}</label>
-                <input type="password" class="form-control" id="inputNewPassword1" name="newpw" autocomplete="off" />
-                <span class="form-control-feedback glyphicon"></span>
-                {include file="$template/thurdata/thurpwcheck.tpl"}
-              </div>
-              <div class="alert alert-info">
-                  <div id='hints'>
-                      <strong id='hint2Head'></strong>
-                      <div id='hintLength'></div>
-                      <div id='hintNumeric'></div>
-                      <div id='hintSymbols'></div>
-                      <div id='hintUpperLower'></div>
-                  </div>
-              </div>
-              <div id="newPassword2" class="form-group has-feedback">
-                <label for="inputNewPassword2" class="control-label">{$LANG.confirmnewpassword}</label>
-                <input type="password" class="form-control" id="inputNewPassword2" name="confirmpw" autocomplete="off" />
-                <span class="form-control-feedback glyphicon"></span>
-                <div id="inputNewPassword2Msg">
-                </div>
-              </div>
-            </div>
-            <div class="form-actions">
-              <input class="btn btn-primary" type="submit" value="{$LANG.clientareasavechanges}" />
-            </div>
-          </form>
-        </div>
-      </div>
-    </div>
-  </div>
-  </div>
-</div>

+ 67 - 146
seafile.php

@@ -69,8 +69,6 @@ function seafile_ConfigOptions() {
  */
 function seafile_TestConnection($params) {
 	$seafileURL = $params['serverhttpprefix'] . '://' . $params['serverhostname'] . ':' . $params['serverport'];
-	error_log("Seafile:TestConnection: " . $seafileURL);
-	//error_log("  -> " . $params['serverusername'] . "     " . $params['serverpassword']);
 	$seafileAPI = new Sf_Admin($seafileURL,$params['serverusername'],$params['serverpassword']);
 	$response = $seafileAPI->login();
 	if (isset($response['error_msg'])) {
@@ -123,7 +121,6 @@ function seafile_UsageUpdate($params) {
     foreach((array)$servicesObj as $serviceObj) {
 		$service = get_object_vars($serviceObj[0]);
 		$accountInfo = $seafileAPI->getAccount($service['username']);
-		error_log("Seafile Module: Updating Disk Usage for: " . $accountInfo . " : " . round($accountInfo['quota_usage'] / 1000000,2) . "/" . round($accountInfo['quota_total'] / 1000000,2));
 		if(!isset($accountInfo['error_msg'])) {
 			try {
 				Capsule::table('tblhosting')
@@ -131,7 +128,7 @@ function seafile_UsageUpdate($params) {
 					->update(
 						array(
 							'diskusage' => round($accountInfo['quota_usage'] / 1000000,2),
-							'disklimit' => round($accountInfo['quota_total'] / 1000000,2),
+							'disklimit' => round($accountInfo['quota_total'],2),
 							'lastupdate' => Capsule::raw('now()')
 						)
 					);
@@ -188,26 +185,41 @@ function seafile_ClientArea($params) {
 			$seafileURL = $params['serverhttpprefix'] . '://' . $params['serverhostname'] . ':' . $params['serverport'];
 			break;
 	};
-        $clientInfo['basequota']        = $params['configoption1'] ? $params['configoption1'] : 1;
-        $clientInfo['addonquota']       = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0;
-        $clientInfo['userquota']        = $clientInfo['basequota'] + $clientInfo['addonquota'];
-        $clientInfo['mailaddress']      = $params['username'];
-        $clientInfo['webmailurl']       = $seafileURL;
-        $clientInfo['zimbraserver']     = parse_url($clientInfo['webmailurl'], PHP_URL_HOST);
-        $clientinfo['url']              = $seafileURL;
-        $clientinfo['user']             = $user;
-        $clientinfo['mobile1']          = $app;
-        $clientinfo['mobile2']          = $google;
-        $clientinfo['winclient']        = $winClient;
-        $clientinfo['macclient']        = $macClient;
-        $clientinfo['linClient']        = $linClient;
-        $clientinfo['stitle']           = $params['model']['product']['name'];
+	$user = $params['username'];
 
+	$app = 'https://itunes.apple.com/cn/app/seafile-pro/id639202512?l=en&mt=8';
+	$google = 'https://play.google.com/store/apps/details?id=com.seafile.seadroid2';
+	$driveWin = 'https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seadrive-2.0.5-en.msi';
+	$winClient = 'https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-7.0.9-en.msi';
+	$macClient = 'https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-client-7.0.9.dmg';
+	$driveMac = 'https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seadrive-2.0.5.dmg';
+	$linClient = 'https://download.seafile.com/published/seafile-user-manual/syncing_client/install_linux_client.md';
 
-        return array(
-            'tabOverviewReplacementTemplate' => 'clientarea',
-            'vars' => $clientInfo,
-        );
+    $langObj = Capsule::table('tblconfiguration')
+        ->select('value')
+        ->where('setting', '=', 'Language')
+        ->get();
+	$lla = $_SESSION['Language'] ? trim($_SESSION['Language']) : strtolower($langObj[0]->value);
+	$slang = array();
+	include_once dirname(__FILE__).'/lang/'.$lla.'.php';
+	return array(
+		'templatefile' => 'clientside',
+		'vars' => array_merge(
+			array(
+				'url' => $seafileURL,
+				'user' => $user,
+				'mobile1' => $app,
+				'mobile2' => $google,
+				'drivewin' => $driveWin,
+				'winclient' => $winClient,
+				'macclient' => $macClient,
+				'drivemac' => $driveMac,
+				'linClient' => $linClient,
+			),
+			$slang,
+			$params
+		),
+	);
 }
 
 /**
@@ -286,10 +298,9 @@ function seafile_ChangePassword($params) {
  * @return string 'success' or an error message
  */
 function seafile_ChangePackage($params) { 
-	$quota = $params['configoption1'] ? $params['configoption1'] : 1;
-	$addonQuota = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0;
-    $newAddQuota = $params['configoptions']['newAddQuota'] ? $params['configoptions']['newAddQuota'] : 0;
-	$accountQuota = ($quota + $addonQuota + $newAddQuota);
+	$addonQuota    = $params['configoptions']['addonQuota'];
+	$quota         = $params['configoption1'] ? $params['configoption1'] : 1;
+	$accountQuota = ($quota + $addonQuota) * 1000;
 	$seafileURL = $params['serverhttpprefix'] . '://' . $params['serverhostname'] . ':' . $params['serverport'];
 	$seafileAPI = new Sf_Admin($seafileURL,$params['serverusername'],$params['serverpassword']);
 	$response = $seafileAPI->login();
@@ -314,7 +325,7 @@ function seafile_ChangePackage($params) {
 		);
 		return 'Error: could not find account ' . $params['username'];
 	}
-	$result = $seafileAPI->modifyAccount(array('email' => $userAccount['email'], 'quota_total' => $accountQuota * 1024));
+	$result = $seafileAPI->modifyAccount(array('email' => $userAccount['email'], 'quota_total' => $accountQuota));
 	if(isset($result['error_msg'])) {
 		logModuleCall(
 			'seafile',
@@ -324,7 +335,7 @@ function seafile_ChangePackage($params) {
 			$result
 		);
 		return 'Error: could not update quota for ' . $userAccount['email'];
-	} elseif ($result['quota_total'] != ($accountQuota * 1048576)) {
+	} elseif ($result['quota_total'] != ($accountQuota * 1000000)) {
 		logModuleCall(
 			'seafile',
 			__FUNCTION__,
@@ -339,7 +350,7 @@ function seafile_ChangePackage($params) {
             ->where('id', '=', $params['serviceid'])
             ->update(
                 array(
-                    'disklimit' => $userAccount['quota_total'] / 1024,
+                    'disklimit' => $userAccount['quota_total'],
                 )
             );
     } catch (Exception $e) {
@@ -352,10 +363,7 @@ function seafile_ChangePackage($params) {
         );
         return 'Error: could not update quota in database';
     }
-    if(seafileUpdateQuota($params) != 'success') {
-        return 'Error: could not update addonQuota in database';
-    };
-    return 'success';
+	return 'success';
 }
 
 /**
@@ -378,13 +386,9 @@ function seafile_CreateAccount($params) {
 	$firstName     = $params['customfields']['firstname'];
 	$lastName      = $params['customfields']['lastname'];
 	$loginEMail    = $params['customfields']['login'];
-	$loginPassword = $params['customfields']['password'];
-	$baseQuota     = $params['configoption1'];
-	$addonQuota    = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0;
-	$newAddQuota   = $params['configoptions']['newAddQuota'] ? $params['configoptions']['newAddQuota'] : 0;
-	
-	//error_log( print_r($params,true)  );
-	
+        $loginPassword = $params['customfields']['password'];
+	$addonQuota    = $params['configoptions']['addonQuota'];
+	$quota         = $params['configoption1'] ? $params['configoption1'] : 1;
 	$seafileURL = $params['serverhttpprefix'] . '://' . $params['serverhostname'] . ':' . $params['serverport'];
 	$seafileAPI = new Sf_Admin($seafileURL,$params['serverusername'],$params['serverpassword']);
 	$response = $seafileAPI->login();
@@ -402,7 +406,7 @@ function seafile_CreateAccount($params) {
 	if(!isset($existingAccount['error_msg'])) {
 		return 'Error: account already exists ' . $loginEMail;
 	}
-	$accountQuota = ($baseQuota + $addonQuota + $newAddQuota) * 1024;
+	$accountQuota = ($quota + $addonQuota) * 1000;
 	$newAccount = array();
 	$newAccount['email'] = $loginEMail;
 	$newAccount['name'] = $firstName . ' ' . $lastName;
@@ -411,7 +415,6 @@ function seafile_CreateAccount($params) {
 	$newAccount['password'] = $loginPassword;
 	$newAccount['note'] = 'Account created from WHCMS for client ' . $params['userid'];
 	$newAccount['quota_total'] = $accountQuota;
-	error_log("Seafile:Create Account for " . $loginEMail . " with " . $accountQuota . "MB");
 	$result = $seafileAPI->createAccount($newAccount);
 	if(isset($result['error_msg'])) {
 	    logModuleCall(
@@ -423,31 +426,25 @@ function seafile_CreateAccount($params) {
 		);
 	    return 'Error: could not create account ' . $loginEMail;
 	}
-	try {
-    	    Capsule::table('tblhosting')
-        	->where('id', '=', $params['serviceid'])
-        	->update(
-            	    array(
-                	'username'  => $loginEMail,
-                	'password'  => $params['customfields']['password'],
-                	'disklimit' => $accountQuota,
-					'diskusage' => 0,
-					'domain'	=> $loginEMail,
-            	    )
-        	);
-	} catch (\Exception $e) {
-    	    logModuleCall(
-        	'seafile',
-        	__FUNCTION__,
-        	$params,
-        	'Error: could save username & password in database',
-        	$e->getMessage()
-    	    );
-    	    return 'Error: could save username & password in database';
-	}
-	if(seafileUpdateQuota($params) != 'success') {
-    	    return 'Error: could not update addonQuota in database';
-	};
+    try {
+        Capsule::table('tblhosting')
+            ->where('id', '=', $params['serviceid'])
+            ->update(
+                array(
+                    'username' => $loginEMail,
+                    'password' => $params['customfields']['password'],
+                )
+            );
+    } catch (\Exception $e) {
+        logModuleCall(
+            'seafile',
+            __FUNCTION__,
+            $params,
+            'Error: could save username & password in database',
+            $e->getMessage()
+        );
+        return 'Error: could save username & password in database';
+    }
 	return 'success';
 }
 
@@ -611,9 +608,9 @@ function seafile_TerminateAccount($params) {
 		);
 		return 'Error: could not find account ' . $params['username'];
 	}
-	//if ($existingAccount['is_active'] == 1) {
-	//	return 'Account '. $params['username'] . ' is active, suspend account first!';
-	//}
+	if ($existingAccount['is_active'] == 1) {
+		return 'Account '. $params['username'] . ' is active, suspend account first!';
+	}
 	$result = $seafileAPI->deleteAccount($params['username']);
 	if($result != true) {
 	    logModuleCall(
@@ -660,80 +657,4 @@ function seafileCheckPassword($pwd) {
     }
     return null;
 }
-
-/**
- * Perform an update of customfields to prevent downgrades.
- *
- * Called in changePackage or createAccount functions.
- *
- * @param array $params common module parameters
- *
- * @return *success* or an error
- */
-function seafileUpdateQuota($params) {
-    if(isset($params['configoptions']['addonQuota'])) {
-        $addonQuota = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0 ;
-        $newAddQuota = $params['configoptions']['newAddQuota'] ? $params['configoptions']['newAddQuota'] : 0;
-        $addonQuota = $addonQuota + $newAddQuota;
-        $addonQuotaFieldIDObj = Capsule::table('tblproductconfigoptions')
-            ->join('tblhostingconfigoptions', 'tblproductconfigoptions.id', '=', 'tblhostingconfigoptions.configid')
-            ->where('tblhostingconfigoptions.relid', '=', $params['serviceid'])
-            ->where('tblproductconfigoptions.optionname', 'like', 'addonQuota%')
-            ->select('tblhostingconfigoptions.id', 'tblproductconfigoptions.qtymaximum')
-            ->get();
-        if($addonQuota > $addonQuotaFieldIDObj[0]->qtymaximum) {
-            logModuleCall(
-                'seafile',
-                __FUNCTION__,
-                $params,
-                'Info: someone is trying to exceed the maximum size',
-                ''
-            );
-            $addonQuota = $addonQuotaFieldIDObj[0]->qtymaximum;
-        }
-        try {
-            $updateAddonQuota = Capsule::table('tblhostingconfigoptions')
-                ->where('id', $addonQuotaFieldIDObj[0]->id)
-                ->update(
-                    [
-                        'qty' => $addonQuota,
-                    ]
-                );
-        } catch (\Exception $e) {
-            logModuleCall(
-                'seafile',
-                __FUNCTION__,
-                $updateAddonQuota,
-                'Error: could not save addonOuota in database.',
-                $e->getMessage()
-            );
-            return 'Error: could not save addonOuota in database.';
-        }
-        $newAddQuotaFieldIDObj = Capsule::table('tblproductconfigoptions')
-            ->join('tblhostingconfigoptions', 'tblproductconfigoptions.id', '=', 'tblhostingconfigoptions.configid')
-            ->where('tblhostingconfigoptions.relid', '=', $params['serviceid'])
-            ->where('tblproductconfigoptions.optionname', 'like', 'newAddQuota%')
-            ->select('tblhostingconfigoptions.id')
-            ->get();
-        try {
-            $updateNewAddQuota = Capsule::table('tblhostingconfigoptions')
-                ->where('id', $newAddQuotaFieldIDObj[0]->id)
-                ->update(
-                    [
-                        'qty' => '0',
-                    ]
-                );
-        } catch (\Exception $e) {
-            logModuleCall(
-                'seafile',
-                __FUNCTION__,
-                $updateNewAddQuota,
-                'Error: could not reset newAddOuota in database.',
-                $e->getMessage()
-            );
-            return 'Error: could not reset newAddOuota in database.';
-        }
-    }
-    return 'success';
-}
 ?>

+ 10 - 21
seafileAddressAvailable.php

@@ -1,24 +1,19 @@
 <?php
 /**
- * Helper script to check the availibility of a Seafile Account useable with ajax requests
+ * Helper script to check the availibility of a Zimbra mailbox useable with ajax requests
  * 
- * @see https://www.seafile.com
- * @copyright Copyright (c) Thurdata GmbH 2021
+ * @see https://www.zimbra.com
+ * @copyright Copyright (c) Thurdata GmbH 2020
  * @license GPL
  * 
  */
+
+
 $pos = strpos($_SERVER['HTTP_REFERER'],getenv('HTTP_HOST'));
 if($pos===false) {
     die('Restricted access');
 }
-$productID = $_GET['pid'];
-$accountName = $_GET['username'];
-if(!filter_var($accountName, FILTER_VALIDATE_EMAIL)) {
-    echo "invalid";
-    exit;
-}
 
-error_log("Seafile Address Available: ". $productID . "/" . $accountName);
 /**
  * Requires the whmcs init
  * Requires this PHP api to make soap calls and parse responses
@@ -26,7 +21,10 @@ error_log("Seafile Address Available: ". $productID . "/" . $accountName);
 require_once(__DIR__ . '/../../../init.php');
 require_once(__DIR__ . '/api/Sf/Admin.php');
 use WHMCS\Database\Capsule;
+
 $whmcs = App::self();
+$accountName = $_GET['username'];
+$productID = $_GET['pid'];
 $accessData = array('seafileURL' => '', 'adminUser' => '', 'adminPass' => '');
 $serverGroupIDObj = Capsule::table('tblproducts')
 	->select('servergroup')
@@ -43,7 +41,6 @@ $server = Capsule::table('tblservers')
 	->where('id', '=', $serverID)
 	->where('active', '=', 1)
 	->get();
-
 $accessData['seafileServer'] = $server[0]->hostname;
 $accessData['prefix'] = $server[0]->secure ? 'https://' : 'http://';
 $accessData['port'] = $server[0]->port;
@@ -53,15 +50,9 @@ $adminPassDecrypt = localAPI('DecryptPassword', array('password2' => $adminPassC
 if ($adminPassDecrypt['result'] == 'success') {
         $accessData['adminPass'] = $adminPassDecrypt['password'];
 }
-
-if (empty($accessData['port']) || $accessData['port'] == "") {
-    $seafileURL = $accessData['prefix'] . $accessData['seafileServer'] . ":443";
-} else {
-    $seafileURL = $accessData['prefix'] . $accessData['seafileServer'] . ':' . $accessData['port'];
-}
+$seafileURL = $accessData['prefix'] . $accessData['seafileServer'] . ':' . $accessData['port'];
 $seafileAPI = new Sf_Admin($seafileURL,$accessData['adminUser'],$accessData['adminPass']);
 $response = $seafileAPI->login();
-
 if (isset($response['error_msg'])) {
     logModuleCall(
         'seafile',
@@ -70,9 +61,7 @@ if (isset($response['error_msg'])) {
         'Error: could not login to ' . $seafileURL,
         $response
     );
-    error_log("  --> ERROR " . print_r($response,true));
-    echo "error";
-    exit();
+	exit();
 } else {
     $existingAccount = $seafileAPI->getAccount($accountName);
     if (isset($existingAccount['error_msg'])) {