/**
  * @param \RainLoop\Model\Account $oHmailAccount
  * @param string $sPrevPassword
  * @param string $sNewPassword
  *
  * @return bool
  */
 public function ChangePassword(\RainLoop\Account $oHmailAccount, $sPrevPassword, $sNewPassword)
 {
     if ($this->oLogger) {
         $this->oLogger->Write('Try to change password for ' . $oHmailAccount->Email());
     }
     $bResult = false;
     try {
         $oHmailApp = new COM("hMailServer.Application");
         $oHmailApp->Connect();
         if ($oHmailApp->Authenticate($this->sLogin, $this->sPassword)) {
             $sEmail = $oHmailAccount->Email();
             $sDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail);
             $oHmailDomain = $oHmailApp->Domains->ItemByName($sDomain);
             if ($oHmailDomain) {
                 $oHmailAccount = $oHmailDomain->Accounts->ItemByAddress($sEmail);
                 if ($oHmailAccount) {
                     $oHmailAccount->Password = $sNewPassword;
                     $oHmailAccount->Save();
                     $bResult = true;
                 } else {
                     $this->oLogger->Write('HMAILSERVER: Unknown account (' . $sEmail . ')', \MailSo\Log\Enumerations\Type::ERROR);
                 }
             } else {
                 $this->oLogger->Write('HMAILSERVER: Unknown domain (' . $sDomain . ')', \MailSo\Log\Enumerations\Type::ERROR);
             }
         } else {
             $this->oLogger->Write('HMAILSERVER: Auth error', \MailSo\Log\Enumerations\Type::ERROR);
         }
     } catch (\Exception $oException) {
         if ($this->oLogger) {
             $this->oLogger->WriteException($oException);
         }
     }
     return $bResult;
 }
 function dbactionDelete()
 {
     $srv = new COM("SQLDMO.SQLServer");
     $srv->LoginSecure = true;
     $DB = new COM("SQLDMO.Database");
     try {
         $srv->Connect("localhost,1433");
         //$srv->Connect(".");
     } catch (Exception $e) {
         throw new lxException('MsSql Server Connection is Failed', '', '');
         exit;
     }
     $strDatabaseDelete = $this->main->dbname;
     $login = $this->main->username;
     $DB = $srv->Databases($strDatabaseDelete);
     if ($DB->IsUser($login)) {
         $DB->Users->Remove($login);
     }
     //print("\nRestored\n");
     //$srv->Logins->Remove($login);
     print "\n" . $login . "\n";
     $srv->DisConnect();
 }
Example #3
0
 function getHmsComServer($user)
 {
     $conf = $this->rc->config->get('hmailserver_server_for_hmsrc');
     $obBaseApp = new COM("hMailServer.Application", NULL, CP_UTF8);
     $obBaseApp->Connect();
     $obBaseApp->Authenticate($conf['Username'], $conf['Password']);
     $obDomain = $obBaseApp->Domains->ItemByName(substr($user, strpos($user, "@") + 1));
     return $obDomain->Accounts->ItemByAddress($user);
 }
Example #4
0
     $ExMessagePort = '110';
 }
 #Get the hmail domain id for the users mailbox
 $hmaildatabase = GetSystemOption('hmailserver_db');
 $sql = "SELECT accountdomainid FROM hm_accounts WHERE accountid='" . $faaccountid . "'";
 $listaccountdomainid = DataExchange("r", $hmaildatabase, $sql);
 $rowaccountdomainid = mysql_fetch_assoc($listaccountdomainid);
 $faadomainid = $rowaccountdomainid['accountdomainid'];
 #we try to connect to the hmailserver
 $obBaseApp = new COM("hMailServer.Application");
 if (!$obBaseApp) {
     header("location: " . GetNormalModuleURL($returnurl) . "&r=hmcomerror");
     exit;
 }
 #connection established, now we authenticate
 $obBaseApp->Connect();
 // Authenticate the user
 $obBaseApp->Authenticate($Usermailbox, $ExMessageAuth);
 if (!$obBaseApp->Authenticate($Usermailbox, $ExMessageAuth)) {
     header("location: " . GetNormalModuleURL($returnurl) . "&r=hmautherror&mb=" . $Usermailbox . "");
     exit;
 }
 #we have authenticated, and all our variables set up so lets move on...
 $domainid = $faadomainid;
 $accountid = $faaccountid;
 $obDomain = $obBaseApp->Domains->ItemByDBID($domainid);
 $obAccount = $obDomain->Accounts->ItemByDBID($accountid);
 $obFetchAccounts = $obAccount->FetchAccounts();
 $obFA = $obFetchAccounts->Add();
 $obFA->Enabled = '1';
 $obFA->Name = $ExMessageAccount;
 function do_backup()
 {
     $sBAKFilePath = "C:/SQL_Backup";
     if (!is_dir($sBAKFilePath)) {
         mkdir($sBAKFilePath, 0777);
     }
     $dir = "{$sBAKFilePath}/mssql";
     $mode = 0700;
     $sBAKFilePath = $dir . mt_rand(0, 9999999);
     //create unique directory everytime.
     mkdir($sBAKFilePath, $mode);
     $srv = new COM("SQLDMO.SQLServer");
     $srv->LoginSecure = true;
     try {
         $srv->Connect("localhost,1433");
     } catch (Exception $e) {
         throw new lxException('MsSql Connection is Failed', '', '');
     }
     $bkp = new COM("SQLDMO.Backup");
     $dbname = $this->main->dbname;
     $bkp->Database = $dbname;
     $docf = $sBAKFilePath . "/" . $dbname . ".bak";
     $bkp->Files = $docf;
     $bkp->Action = 0;
     //FullBackup
     $bkp->SQLBackup($srv);
     $srv->DisConnect();
     print "{$sBAKFilePath}/" . $dbname;
     return array($sBAKFilePath, array(basename($docf)));
 }
Example #6
0
<?php

$arr = array('один', 'ляляля', "два");
//phpinfo();
$app = new COM("v82.COMConnector") or die("Невозможно создать COM соединение");
print "<br />Loaded 1Cn<br />";
//Путь к базе и имя пользователя. Третьим параметром
//может выступать пароль пользователя (если задан
//в конфигураторе)
$path = "C:\\1c_basesxtra_abz";
$user = "******";
$pass = '';
//Подсоединяемся к нужной базе
echo 'File="' . $path . '";Usr="******";pwd="' . $pass . '"';
try {
    $con = $app->Connect('File="' . $path . '";Usr="******";pwd="' . $pass . '"');
} catch (Exception $e) {
    print_r($e);
}
echo "<br />";
echo $con->test($arr) . "|<br />";
//echo iconv("ASCII", "UTF-8", $con->test($arr));
//В качестве проверки результата получаем глобальную
//переменную glCurrUser определенную в модуле внешенего
//соединения 1С Предприятия v8 и инициализированную
//при начале работы системы
$con = null;
$app = null;
 function doQuery($action)
 {
     // Note that because of the way in which CAFEphp and FileMaker are implemented, CAFEphp must be running on the same
     // machine that is serving as the web server.  (You'll note that PHP creates a COM object which looks for a locally
     // running application.)  For this same reason, the server IP and port are irrelevant.
     $availableActions = array('-delete', '-edit', '-find', '-findall', '-new', '-sqlquery');
     if (!in_array(strtolower($action), $availableActions)) {
         // first off, toss out any requests for actions NOT supported under CAFEphp
         return new FX_Error("The action requested ({$action}) is not supported in CAFEphp.");
     }
     $CAFEphp_res = new COM('CAFEphp.Application');
     // although username and password are optional for this function, FX.php expects them to be set
     if ($CAFEphp_res == false) {
         return new FX_Error('Unable to load to CAFEphp.');
     }
     if (defined("DEBUG") and DEBUG or DEBUG_FUZZY) {
         $currentDebugString = "<p>CAFEphp version: " . $CAFEphp_res->Version() . "</p>\n";
         $this->FX->lastDebugMessage .= $currentDebugString;
         if (defined("DEBUG") and DEBUG) {
             echo $currentDebugString;
         }
     }
     $theResult = $CAFEphp_res->Connect($this->FX->database, $this->FX->DBUser, $this->FX->DBPassword);
     if ($theResult != 0) {
         $CAFEphp_res->EndConnection();
         switch ($theResult) {
             case -1:
                 return new FX_Error('Unable to connect.  Be sure the FileMaker database and CAFEphp are running.');
                 break;
             case -2:
                 return new FX_Error('Certificate not present.  You MUST have a certificate.');
                 break;
             case -3:
                 return new FX_Error('Certificate is corrupt.');
                 break;
             case -4:
                 return new FX_Error('CAFEphp is not running or the demo version has expired.');
                 break;
             case -5:
                 return new FX_Error('The current demo of CAFEphp has expired.');
                 break;
             default:
                 return new FX_Error('An unknown error has occured while attempting to create the COM object.');
                 break;
         }
     }
     switch ($action) {
         case '-delete':
         case '-edit':
         case '-find':
         case '-findall':
         case '-new':
             $this->FX->dataQuery = $this->BuildSQLQuery($action);
             if (FX::isError($this->FX->dataQuery)) {
                 return $this->FX->dataQuery;
             }
         case '-sqlquery':
             // note that there is no preceding break, as we don't want to build a query
             if (substr(trim($this->FX->dataQuery), 0, 6) == 'SELECT') {
                 $currentSelect = true;
                 $theResult = $CAFEphp_res->Query($this->FX->dataQuery, $this->FX->groupSize);
             } else {
                 $currentSelect = false;
                 $theResult = $CAFEphp_res->Execute($this->FX->dataQuery);
             }
             if ($theResult < 0) {
                 $CAFEphp_res->EndConnection();
                 switch ($theResult) {
                     case -1:
                         return new FX_Error('No CAFEphp connection for the query.');
                         break;
                     default:
                         return new FX_Error('An unknown error occured during the query.');
                         break;
                 }
             }
             $this->FX->foundCount = $theResult;
             $theResult = $CAFEphp_res->FieldCount();
             if ($theResult < 0) {
                 $CAFEphp_res->EndConnection();
                 switch ($theResult) {
                     case -1:
                         return new FX_Error('No CAFEphp connection for the field count.');
                         break;
                     case -2:
                         return new FX_Error('No query was performed for a field count.');
                         break;
                     default:
                         return new FX_Error('An unknown error occured during the query.');
                         break;
                 }
             } else {
                 $currentFieldCount = $theResult;
             }
             for ($i = 0; $i < $currentFieldCount; ++$i) {
                 $theResult = $CAFEphp_res->FieldName($i);
                 if ($theResult == '$-CAFEphpNOCONNECTION') {
                     $CAFEphp_res->EndConnection();
                     return new FX_Error("No CAFEphp connection while retieving the name of field {$i}.");
                 } elseif ($theResult == '$-CAFEphpNOQUERY') {
                     $CAFEphp_res->EndConnection();
                     return new FX_Error("CAFEphp returned a \"No Query\" error while retieving the name of field {$i}.");
                 } elseif ($theResult == '$-CAFEphpUNKNOWNERROR') {
                     $CAFEphp_res->EndConnection();
                     return new FX_Error("CAFEphp returned an unknown error while retieving the name of field {$i}.");
                 }
                 $this->FX->fieldInfo[$i]['name'] = $theResult;
                 $this->FX->fieldInfo[$i]['type'] = 'NO DATA';
                 $this->FX->fieldInfo[$i]['emptyok'] = 'NO DATA';
                 $this->FX->fieldInfo[$i]['maxrepeat'] = 'NO DATA';
                 $this->FX->fieldInfo[$i]['extra'] = '';
             }
             if ($currentSelect) {
                 $tempRow = array();
                 for ($i = 0; $i < $this->FX->foundCount; ++$i) {
                     for ($j = 0; $j < $currentFieldCount; ++$j) {
                         $theResult = $CAFEphp_res->FieldValue($j);
                         if ($theResult == '$-CAFEphpNOCONNECTION') {
                             $CAFEphp_res->EndConnection();
                             return new FX_Error("No CAFEphp connection while retieving the value of field {$i} for record {$j}.");
                         } elseif ($theResult == '$-CAFEphpNOQUERY') {
                             $CAFEphp_res->EndConnection();
                             return new FX_Error("CAFEphp returned a \"No Query\" error while retieving the value of field {$i} for record {$j}.");
                         } elseif ($theResult == '$-CAFEphpUNKNOWNERROR') {
                             $CAFEphp_res->EndConnection();
                             return new FX_Error("CAFEphp returned an unknown error while retieving the value of field {$i} for record {$j}.");
                         }
                         if (!$this->FX->useInnerArray) {
                             $tempRow[$this->FX->fieldInfo[$j]['name']] = $theResult;
                         } else {
                             $tempRow[$this->FX->fieldInfo[$j]['name']] = array($theResult);
                         }
                         if ($this->FX->fieldInfo[$j]['name'] == $this->FX->primaryKeyField) {
                             $currentKey = $value;
                         }
                     }
                     if ($this->FX->genericKeys || $this->FX->primaryKeyField == '') {
                         $this->FX->currentData[] = $tempRow;
                     } else {
                         $this->FX->currentData[$currentKey] = $tempRow;
                     }
                     $theResult = $CAFEphp_res->MoveNext();
                     if ($theResult < 0) {
                         $CAFEphp_res->EndConnection();
                         $next = $i + 1;
                         switch ($theResult) {
                             case -1:
                                 return new FX_Error('No CAFEphp connection while moving from record {$i} to {$next}.');
                                 break;
                             case -2:
                                 return new FX_Error('There was no current query while moving from record {$i} to {$next}.');
                                 break;
                             default:
                                 return new FX_Error('An unknown error occured while moving from record {$i} to {$next}.');
                                 break;
                         }
                     }
                 }
             }
             break;
         default:
             return new FX_Error("The action requested ({$action}) is not supported in CAFEphp.");
             break;
     }
     $this->FX->fxError = 0;
     return true;
 }