Example #1
0
 public function albumsDeleteProcess()
 {
     $config = OW::getConfig();
     // check if uninstall is in progress
     if (!$config->getValue('photo', 'uninstall_inprogress')) {
         return;
     }
     // check if cron queue is not busy
     if ($config->getValue('photo', 'uninstall_cron_busy')) {
         return;
     }
     $config->saveConfig('photo', 'uninstall_cron_busy', 1);
     $albumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     try {
         $albumService->deleteAlbums(self::ALBUMS_DELETE_LIMIT);
     } catch (Exception $e) {
         OW::getLogger()->addEntry(json_encode($e));
     }
     $config->saveConfig('photo', 'uninstall_cron_busy', 0);
     if (!$albumService->countAlbums()) {
         BOL_PluginService::getInstance()->uninstall('photo');
         $config->saveConfig('photo', 'uninstall_inprogress', 0);
         PHOTO_BOL_PhotoService::getInstance()->setMaintenanceMode(false);
     }
 }
Example #2
0
 public function notify()
 {
     $log = OW::getLogger('ocsbillingmoneybookers');
     $log->addEntry(print_r($_REQUEST, true), 'notify.data');
     $log->writeLog();
     if (empty($_REQUEST['custom'])) {
         exit;
     }
     $hash = trim($_REQUEST['custom']);
     $transId = !empty($_REQUEST['rec_payment_id']) ? trim($_REQUEST['rec_payment_id']) : trim($_REQUEST['mb_transaction_id']);
     $status = trim($_REQUEST['status']);
     $amount = !empty($_REQUEST['amount']) ? $_REQUEST['amount'] : $_REQUEST['rec_amount'];
     $sig = trim($_REQUEST['md5sig']);
     $billingService = BOL_BillingService::getInstance();
     $gwKey = OCSBILLINGMONEYBOOKERS_CLASS_MoneybookersAdapter::GATEWAY_KEY;
     $merchantId = $billingService->getGatewayConfigValue($gwKey, 'merchantId');
     $secret = $billingService->getGatewayConfigValue($gwKey, 'secret');
     $slug = strtoupper(md5($merchantId . $_REQUEST['transaction_id'] . strtoupper(md5($secret)) . $_REQUEST['mb_amount'] . $_REQUEST['mb_currency'] . $status));
     if ($slug !== $sig) {
         exit("SIG_MISMATCH");
     }
     if ($status == '2') {
         $sale = $billingService->getSaleByHash($hash);
         if (!$sale || !mb_strlen($transId)) {
             exit("NOT_FOUND");
         }
         $adapter = new OCSBILLINGMONEYBOOKERS_CLASS_MoneybookersAdapter();
         if (empty($_REQUEST['rec_payment_id'])) {
             if (!$billingService->saleDelivered($transId, $sale->gatewayId)) {
                 $sale->transactionUid = $transId;
                 if ($billingService->verifySale($adapter, $sale)) {
                     $sale = $billingService->getSaleById($sale->id);
                     $productAdapter = $billingService->getProductAdapter($sale->entityKey);
                     if ($productAdapter) {
                         $billingService->deliverSale($productAdapter, $sale);
                     }
                 }
             }
         } else {
             $rebillTransId = $transId;
             $gateway = $billingService->findGatewayByKey($gwKey);
             if ($billingService->saleDelivered($rebillTransId, $gateway->id)) {
                 exit("DELIVERED");
             }
             $rebillSaleId = $billingService->registerRebillSale($adapter, $sale, $rebillTransId);
             if ($rebillSaleId) {
                 $rebillSale = $billingService->getSaleById($rebillSaleId);
                 $productAdapter = $billingService->getProductAdapter($rebillSale->entityKey);
                 if ($productAdapter) {
                     $billingService->deliverSale($productAdapter, $rebillSale);
                 }
             }
         }
     }
     exit("REGISTERED");
 }
Example #3
0
 public function postback()
 {
     $logger = OW::getLogger('ocsbillingicepay');
     $logger->addEntry(print_r($_REQUEST, true), 'postback.data-array');
     if (empty($_REQUEST['Reference'])) {
         $logger->addEntry("Empty reference", 'postback.reference');
         $logger->writeLog();
         exit;
     }
     require_once OW::getPluginManager()->getPlugin('ocsbillingicepay')->getClassesDir() . 'api' . DS . 'icepay_api_basic.php';
     $gwKey = OCSBILLINGICEPAY_CLASS_IcepayAdapter::GATEWAY_KEY;
     $billingService = BOL_BillingService::getInstance();
     $merchantId = $billingService->getGatewayConfigValue($gwKey, 'merchantId');
     $encryptionCode = $billingService->getGatewayConfigValue($gwKey, 'encryptionCode');
     $icepay = new Icepay_Postback();
     $icepay->setMerchantID($merchantId)->setSecretCode($encryptionCode)->doIPCheck();
     try {
         if ($icepay->validate()) {
             $hash = trim($_REQUEST['Reference']);
             $transId = trim($_REQUEST['TransactionID']);
             $sale = $billingService->getSaleByHash($hash);
             if (!$sale || !mb_strlen($transId)) {
                 $logger->addEntry("Sale not found", 'postback.sale');
                 $logger->writeLog();
                 exit;
             }
             $adapter = new OCSBILLINGICEPAY_CLASS_IcepayAdapter();
             if (!$billingService->saleDelivered($transId, $sale->gatewayId)) {
                 $sale->transactionUid = $transId;
                 if ($billingService->verifySale($adapter, $sale)) {
                     $sale = $billingService->getSaleById($sale->id);
                     $productAdapter = $billingService->getProductAdapter($sale->entityKey);
                     if ($productAdapter) {
                         $billingService->deliverSale($productAdapter, $sale);
                     }
                 }
             }
             $logger->addEntry("Validated!", 'validate-status');
         } else {
             $logger->addEntry("Unable to validate postback data", 'validate-status');
         }
     } catch (Exception $e) {
         $logger->addEntry($e->getMessage(), 'validate-exception');
     }
     $logger->writeLog();
     exit;
 }
Example #4
0
 public function postback()
 {
     $logger = OW::getLogger('billingccbill');
     $logger->addEntry(print_r($_POST, true), 'postback.data-array');
     $logger->writeLog();
     $clientAccnum = $_POST['clientAccnum'];
     $clientSubacc = $_POST['clientSubacc'];
     $amount = $_POST['initialPrice'] ? $_POST['initialPrice'] : $_POST['recurringPrice'];
     $saleHash = $_POST['custom'];
     $transId = $_POST['subscription_id'];
     $digest = $_POST['responseDigest'];
     if (!mb_strlen($saleHash) || !mb_strlen($transId)) {
         exit;
     }
     $billingService = BOL_BillingService::getInstance();
     $adapter = new BILLINGCCBILL_CLASS_CcbillAdapter();
     $sale = $billingService->getSaleByHash($saleHash);
     if (!$sale) {
         exit;
     }
     if ($amount != $sale->totalAmount) {
         $logger->addEntry("Wrong amount: " . $amount, 'postback.amount-mismatch');
         $logger->writeLog();
         exit;
     }
     if ($billingService->getGatewayConfigValue(BILLINGCCBILL_CLASS_CcbillAdapter::GATEWAY_KEY, 'clientAccnum') != $clientAccnum) {
         $logger->addEntry("Wrong CCBill account: " . $clientAccnum, 'postback.account-mismatch');
         $logger->writeLog();
         exit;
     }
     if ($adapter->transactionApproved($clientAccnum, $clientSubacc, $transId, $digest)) {
         if ($sale->status != BOL_BillingSaleDao::STATUS_DELIVERED) {
             $sale->transactionUid = $transId;
             if ($billingService->verifySale($adapter, $sale)) {
                 $sale = $billingService->getSaleById($sale->id);
                 $productAdapter = $billingService->getProductAdapter($sale->entityKey);
                 if ($productAdapter) {
                     $billingService->deliverSale($productAdapter, $sale);
                 }
             }
         }
     }
     exit;
 }
Example #5
0
 public function uplaoder()
 {
     OW::getLogger()->addEntry("uploader: started");
     OW::getLogger()->addEntry("uploader ( POST ): " . json_encode($_POST));
     OW::getLogger()->addEntry("uploader ( FILES ): " . json_encode($_FILES));
     OW::getLogger()->addEntry("uploader ( REQUEST ): " . json_encode($_REQUEST));
     OW::getLogger()->addEntry("uploader ( SERVER ): " . json_encode($_SERVER));
     $userFilesDir = OW::getPluginManager()->getPlugin("base")->getUserFilesDir();
     $inputFile = fopen("php://input", "r");
     @unlink($userFilesDir . "api-uploaded.jpg");
     $outputFile = fopen($userFilesDir . "api-uploaded.jpg", "a");
     while (!feof($inputFile)) {
         $data = fread($inputFile, 1024);
         fwrite($outputFile, $data, 1024);
     }
     fclose($inputFile);
     fclose($outputFile);
     $this->assign("uploaded", true);
 }
Example #6
0
 public function verifySale($params)
 {
     if (!SKANDROID_ABOL_Service::getInstance()->isBillingEnabled()) {
         throw new ApiResponseErrorException();
     }
     if (empty($params['purchase'])) {
         throw new ApiResponseErrorException();
     }
     if (empty($params['signature'])) {
         throw new ApiResponseErrorException();
     }
     $logger = OW::getLogger('skadateandroid');
     $logger->addEntry(print_r($params, true), ' purchase data');
     $valid = $this->verifyMarketInApp($params['purchase'], $params['signature'], trim(OW::getConfig()->getValue('skandroid', 'public_key')));
     $purchase = json_decode($params['purchase'], true);
     if (empty($purchase['developerPayload'])) {
         throw new ApiResponseErrorException();
     }
     $developerPayload = json_decode(base64_decode($purchase['developerPayload']), true);
     $userId = !empty($developerPayload['userId']) ? $developerPayload['userId'] : null;
     $purchaseProductId = !empty($purchase['productId']) ? $purchase['productId'] : null;
     $payloadProductId = !empty($developerPayload['productId']) ? $developerPayload['productId'] : null;
     $purchaseHash = $this->generateHash(OW::getUser()->getId(), $purchaseProductId);
     $payloadHash = !empty($developerPayload['hash']) ? $developerPayload['hash'] : null;
     $logger->addEntry(print_r($params['purchase'], true), 'purchase.validation');
     $logger->writeLog();
     $this->assign('error', null);
     if (!isset($userId) || OW::getUser()->getId() != $userId) {
         $this->assign('registered', false);
         $this->assign('error', 'Undefined user id');
         return;
     }
     if (!isset($valid)) {
         $this->assign('registered', false);
         $this->assign('error', 'Purchase validation failed');
         return;
     }
     if (!isset($valid)) {
         $this->assign('registered', false);
         $this->assign('error', 'Purchase validation failed');
         return;
     }
     if (!isset($purchaseProductId) || !isset($payloadProductId) || $payloadProductId != $purchaseProductId) {
         $this->assign('registered', false);
         $this->assign('error', 'Payload validation faild.  Invalid product Id');
         return;
     }
     if (!isset($purchaseHash) || !isset($payloadHash) || $payloadHash != $purchaseHash) {
         $this->assign('registered', false);
         $this->assign('error', 'Payload validation faild.');
         return;
     }
     $billingService = BOL_BillingService::getInstance();
     $service = SKANDROID_ABOL_Service::getInstance();
     $orderId = isset($purchase['orderId']) ? $purchase['orderId'] : null;
     $productId = isset($purchase['productId']) ? $purchase['productId'] : null;
     $purchaseTime = isset($purchase['purchaseTime']) ? $purchase['purchaseTime'] : null;
     $sale = $billingService->getSaleByGatewayTransactionId(SKANDROID_ACLASS_InAppPurchaseAdapter::GATEWAY_KEY, md5($orderId));
     if ($sale) {
         // sale already registered
         $this->assign('registered', false);
         $this->assign('error', 'Sale already registered');
         return;
     }
     $product = $service->findProductByItunesProductId($productId);
     if (!$product) {
         $this->assign('registered', false);
         $this->assign('error', 'Product not found');
     } else {
         // sale object
         $sale = new BOL_BillingSale();
         $sale->pluginKey = $product['pluginKey'];
         $sale->entityDescription = $product['entityDescription'];
         $sale->entityKey = $product['entityKey'];
         $sale->entityId = $product['entityId'];
         $sale->price = $product['price'];
         $sale->period = $product['period'];
         $sale->userId = $userId;
         $sale->recurring = $product['recurring'];
         $saleId = $billingService->initSale($sale, SKANDROID_ACLASS_InAppPurchaseAdapter::GATEWAY_KEY);
         $sale = $billingService->getSaleById($saleId);
         $sale->timeStamp = $purchaseTime / 1000;
         $sale->transactionUid = md5($orderId);
         $sale->extraData = json_encode(array('orderId' => $orderId, 'extra' => $purchase['developerPayload']));
         BOL_BillingSaleDao::getInstance()->save($sale);
         $productAdapter = null;
         switch ($sale->pluginKey) {
             case 'membership':
                 $productAdapter = new MEMBERSHIP_CLASS_MembershipPlanProductAdapter();
                 break;
             case 'usercredits':
                 $productAdapter = new USERCREDITS_CLASS_UserCreditsPackProductAdapter();
                 break;
         }
         $billingService->deliverSale($productAdapter, $sale);
         $this->assign('registered', true);
     }
     return;
 }
Example #7
0
 /**
  * Sends request to DataLink Service
  * 
  * @param array $transactionTypes
  * @param boolean $testMode
  * @return array
  */
 public function getDataLinkServiceResponse(array $transactionTypes, $testMode = false)
 {
     $requestStr = self::DATALINK_URL . '?startTime=' . $this->getDateFormat(time() - 24 * 60 * 60) . '&endTime=' . $this->getDateFormat(time()) . '&transactionTypes=' . implode(',', $transactionTypes) . '&clientAccnum=' . $this->billingService->getGatewayConfigValue(self::GATEWAY_KEY, 'clientAccnum') . '&clientSubacc=' . $this->billingService->getGatewayConfigValue(self::GATEWAY_KEY, 'clientSubacc') . '&username='******'datalinkUsername') . '&password='******'datalinkPassword') . ($testMode ? '&testMode=1' : '');
     $logger = OW::getLogger('billingccbill');
     $logger->addEntry($requestStr, 'datalink.request-string');
     $handle = curl_init($requestStr);
     ob_start();
     curl_exec($handle);
     $string = ob_get_contents();
     ob_end_clean();
     $logger->addEntry($string, 'datalink.response-string');
     $responseArr = array();
     if (!curl_errno($handle)) {
         $responseArr = $this->parseDatalinkResponse($string);
         $logger->addEntry(print_r($responseArr, true), 'datalink.response-array');
     }
     curl_close($handle);
     $logger->writeLog();
     return $responseArr;
 }
Example #8
0
 private function getThemeXmlInfo($themeXmlPath)
 {
     if (!file_exists($themeXmlPath)) {
         OW::getLogger()->addEntry(__CLASS__ . "::" . __FUNCTION__ . " - `" . $themeXmlPath . "` not found");
         return null;
     }
     //$propList = array("key", "developerKey", "name", "description", "license", "author", "build", "copyright", "licenseUrl");
     $propList = array("key", "name", "description");
     $xmlInfo = UTIL_String::xmlToArray(file_get_contents($themeXmlPath));
     //TODO refactor
     if (empty($xmlInfo["developerKey"])) {
         $xmlInfo["developerKey"] = null;
     }
     if (empty($xmlInfo["build"])) {
         $xmlInfo["build"] = 0;
     }
     if (!$xmlInfo) {
         OW::getLogger()->addEntry(__CLASS__ . "::" . __FUNCTION__ . " - invalid `" . $themeXmlPath . "`");
         return null;
     }
     foreach ($propList as $prop) {
         if (empty($xmlInfo[$prop])) {
             OW::getLogger()->addEntry(__CLASS__ . "::" . __FUNCTION__ . " - in `" . $themeXmlPath . "` property `" . $prop . "` not found");
             return null;
         }
     }
     $sidebarPositions = array(BOL_ThemeDao::VALUE_SIDEBAR_POSITION_LEFT, BOL_ThemeDao::VALUE_SIDEBAR_POSITION_RIGHT, BOL_ThemeDao::VALUE_SIDEBAR_POSITION_NONE);
     if (empty($xmlInfo["sidebarPosition"]) || !in_array($xmlInfo["sidebarPosition"], $sidebarPositions)) {
         $xmlInfo["sidebarPosition"] = BOL_ThemeDao::VALUE_SIDEBAR_POSITION_NONE;
     }
     $xmlInfo["build"] = (int) $xmlInfo["build"];
     return $xmlInfo;
 }
Example #9
0
 public function verifySale($params)
 {
     if (empty($params['receipt'])) {
         throw new ApiResponseErrorException();
     }
     $userId = !empty($params['userId']) ? $params['userId'] : null;
     $receipt = trim($params['receipt']);
     $logger = OW::getLogger('skadateios');
     $logger->addEntry(print_r($params, true), 'receipt.data');
     $configs = OW::getConfig()->getValues("skadateios");
     $validator = new SKADATEIOS_ACLASS_ItunesReceiptValidator($configs["itunes_mode"], $configs["itunes_secret"]);
     $data = $validator->validateReceipt($receipt);
     $logger->addEntry(print_r($data, true), 'receipt.validation');
     $logger->writeLog();
     if (!isset($data['status'])) {
         $this->assign('registered', false);
         $this->assign('error', 'Receipt validation failed');
         return;
     }
     if ($data['status'] == 0) {
         $environment = $data['environment'];
         $bundleId = $data['receipt']['bundle_id'];
         $inAppData = $data['receipt']['in_app'];
         foreach ($inAppData as $inApp) {
             $productId = $inApp['product_id'];
             $transactionId = $inApp['transaction_id'];
             $billingService = BOL_BillingService::getInstance();
             $service = SKADATEIOS_ABOL_Service::getInstance();
             $sale = $billingService->getSaleByGatewayTransactionId(SKADATEIOS_ACLASS_InAppPurchaseAdapter::GATEWAY_KEY, $transactionId);
             if ($sale) {
                 continue;
             }
             $originalTransactionId = isset($inApp['original_transaction_id']) ? $inApp['original_transaction_id'] : null;
             if ($originalTransactionId) {
                 $originalSale = $billingService->getSaleByGatewayTransactionId(SKADATEIOS_ACLASS_InAppPurchaseAdapter::GATEWAY_KEY, $originalTransactionId);
                 if ($originalSale && !$userId) {
                     $userId = $originalSale->userId;
                 }
             }
             $purchaseTime = $inApp['purchase_date_ms'] / 1000;
             $product = $service->findProductByItunesProductId($productId);
             if (!$product) {
                 $this->assign('registered', false);
                 $this->assign('error', 'Product not found');
             } else {
                 // sale object
                 $sale = new BOL_BillingSale();
                 $sale->pluginKey = $product['pluginKey'];
                 $sale->entityDescription = $product['entityDescription'];
                 $sale->entityKey = $product['entityKey'];
                 $sale->entityId = $product['entityId'];
                 $sale->price = $product['price'];
                 $sale->period = $product['period'];
                 $sale->userId = $userId;
                 $sale->recurring = $product['recurring'];
                 $saleId = $billingService->initSale($sale, SKADATEIOS_ACLASS_InAppPurchaseAdapter::GATEWAY_KEY);
                 $sale = $billingService->getSaleById($saleId);
                 $sale->timeStamp = $purchaseTime;
                 $sale->transactionUid = $transactionId;
                 BOL_BillingSaleDao::getInstance()->save($sale);
                 $productAdapter = null;
                 switch ($sale->pluginKey) {
                     case 'membership':
                         $productAdapter = new MEMBERSHIP_CLASS_MembershipPlanProductAdapter();
                         break;
                     case 'usercredits':
                         $productAdapter = new USERCREDITS_CLASS_UserCreditsPackProductAdapter();
                         break;
                 }
                 $billingService->deliverSale($productAdapter, $sale);
                 $this->assign('registered', true);
             }
             return;
         }
     }
     $this->assign('registered', false);
     $this->assign('error', 'Receipt validation failed');
 }
Example #10
0
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
OW::getNavigation()->addMenuItem(OW_Navigation::MAIN, 'view_photo_list', 'photo', 'photo', OW_Navigation::VISIBLE_FOR_ALL);
OW::getNavigation()->addMenuItem(OW_Navigation::MOBILE_TOP, 'photo_list_index', 'photo', 'mobile_photo', OW_Navigation::VISIBLE_FOR_ALL);
$widgetService = BOL_ComponentAdminService::getInstance();
try {
    $widget = $widgetService->addWidget('PHOTO_CMP_PhotoListWidget', false);
    $placeWidget = $widgetService->addWidgetToPlace($widget, BOL_ComponentAdminService::PLACE_INDEX);
    $widgetService->addWidgetToPosition($placeWidget, BOL_ComponentService::SECTION_LEFT);
} catch (Exception $e) {
    OW::getLogger()->addEntry(json_encode($e));
}
try {
    $widget = $widgetService->addWidget('PHOTO_CMP_UserPhotoAlbumsWidget', false);
    $placeWidget = $widgetService->addWidgetToPlace($widget, BOL_ComponentAdminService::PLACE_PROFILE);
    $widgetService->addWidgetToPosition($placeWidget, BOL_ComponentService::SECTION_LEFT);
} catch (Exception $e) {
    OW::getLogger()->addEntry(json_encode($e));
}
require_once dirname(__FILE__) . DS . 'classes' . DS . 'credits.php';
$credits = new PHOTO_CLASS_Credits();
$credits->triggerCreditActionsAdd();
Example #11
0
 /**
  * Retrieves update information for all plugins and themes.
  *
  * @return bool
  */
 public function checkUpdates()
 {
     $requestArray = array("platform" => array(self::URI_VAR_BUILD => OW::getConfig()->getValue("base", "soft_build")), "items" => array());
     $plugins = $this->pluginService->findRegularPlugins();
     /* @var $plugin BOL_Plugin */
     foreach ($plugins as $plugin) {
         $requestArray["items"][] = array(self::URI_VAR_KEY => $plugin->getKey(), self::URI_VAR_DEV_KEY => $plugin->getDeveloperKey(), self::URI_VAR_BUILD => $plugin->getBuild(), self::URI_VAR_LICENSE_KEY => $plugin->getLicenseKey(), self::URI_VAR_ITEM_TYPE => self::URI_VAR_ITEM_TYPE_VAL_PLUGIN);
     }
     //check all manual updates before reading builds in DB
     $this->themeService->checkManualUpdates();
     $themes = $this->themeService->findAllThemes();
     /* @var $dto BOL_Theme */
     foreach ($themes as $dto) {
         $requestArray["items"][] = array(self::URI_VAR_KEY => $dto->getKey(), self::URI_VAR_DEV_KEY => $dto->getDeveloperKey(), self::URI_VAR_BUILD => $dto->getBuild(), self::URI_VAR_LICENSE_KEY => $dto->getLicenseKey(), self::URI_VAR_ITEM_TYPE => self::URI_VAR_ITEM_TYPE_VAL_THEME);
     }
     $data = $this->triggerEventBeforeRequest();
     $data["info"] = json_encode($requestArray);
     $params = new UTIL_HttpClientParams();
     $params->addParams($data);
     $response = UTIL_HttpClient::post($this->getStorageUrl(self::URI_CHECK_ITEMS_FOR_UPDATE), $params);
     if (!$response || $response->getStatusCode() != UTIL_HttpClient::HTTP_STATUS_OK) {
         OW::getLogger()->addEntry(__CLASS__ . "::" . __METHOD__ . "#" . __LINE__ . " storage request status is not OK", "core.update");
         return false;
     }
     $resultArray = array();
     if ($response->getBody()) {
         $resultArray = json_decode($response->getBody(), true);
     }
     if (empty($resultArray) || !is_array($resultArray)) {
         OW::getLogger()->addEntry(__CLASS__ . "::" . __METHOD__ . "#" . __LINE__ . " remote request returned empty result", "core.update");
         return false;
     }
     if (!empty($resultArray["update"])) {
         if (!empty($resultArray["update"]["platform"]) && (bool) $resultArray["update"]["platform"]) {
             OW::getConfig()->saveConfig("base", "update_soft", 1);
         }
         if (!empty($resultArray["update"]["items"])) {
             $this->updateItemsUpdateStatus($resultArray["update"]["items"]);
         }
     }
     $items = !empty($resultArray["invalidLicense"]) ? $resultArray["invalidLicense"] : array();
     $this->updateItemsLicenseStatus($items);
     return true;
 }
Example #12
0
 public function notify()
 {
     $logger = OW::getLogger('billingpaypal');
     $logger->addEntry(print_r($_POST, true), 'ipn.data-array');
     $logger->writeLog();
     if (empty($_POST['custom'])) {
         exit;
     }
     $hash = trim($_POST['custom']);
     $amount = !empty($_POST['mc_gross']) ? $_POST['mc_gross'] : $_POST['payment_gross'];
     $transactionId = trim($_POST['txn_id']);
     $status = mb_strtoupper(trim($_POST['payment_status']));
     $currency = trim($_POST['mc_currency']);
     $transactionType = trim($_POST['txn_type']);
     $business = trim($_POST['business']);
     $billingService = BOL_BillingService::getInstance();
     $adapter = new BILLINGPAYPAL_CLASS_PaypalAdapter();
     if ($adapter->isVerified($_POST)) {
         $sale = $billingService->getSaleByHash($hash);
         if (!$sale || !strlen($transactionId)) {
             exit;
         }
         if ($amount != $sale->totalAmount) {
             $logger->addEntry("Wrong amount: " . $amount, 'notify.amount-mismatch');
             $logger->writeLog();
             exit;
         }
         if ($billingService->getGatewayConfigValue(BILLINGPAYPAL_CLASS_PaypalAdapter::GATEWAY_KEY, 'business') != $business) {
             $logger->addEntry("Wrong PayPal account: " . $business, 'notify.account-mismatch');
             $logger->writeLog();
             exit;
         }
         if ($status == 'COMPLETED') {
             switch ($transactionType) {
                 case 'web_accept':
                 case 'subscr_payment':
                     if (!$billingService->saleDelivered($transactionId, $sale->gatewayId)) {
                         $sale->transactionUid = $transactionId;
                         if ($billingService->verifySale($adapter, $sale)) {
                             $sale = $billingService->getSaleById($sale->id);
                             $productAdapter = $billingService->getProductAdapter($sale->entityKey);
                             if ($productAdapter) {
                                 $billingService->deliverSale($productAdapter, $sale);
                             }
                         }
                     }
                     break;
                 case 'recurring_payment':
                     $rebillTransId = $_REQUEST['recurring_payment_id'];
                     $gateway = $billingService->findGatewayByKey(BILLINGPAYPAL_CLASS_PaypalAdapter::GATEWAY_KEY);
                     if ($billingService->saleDelivered($rebillTransId, $gateway->id)) {
                         exit;
                     }
                     $rebillSaleId = $billingService->registerRebillSale($adapter, $sale, $rebillTransId);
                     if ($rebillSaleId) {
                         $rebillSale = $billingService->getSaleById($rebillSaleId);
                         $productAdapter = $billingService->getProductAdapter($rebillSale->entityKey);
                         if ($productAdapter) {
                             $billingService->deliverSale($productAdapter, $rebillSale);
                         }
                     }
                     break;
             }
         }
     } else {
         exit;
     }
 }
Example #13
0
<?php

/**
 * Copyright (c) 2014, Skalfa LLC
 * All rights reserved.
 * 
 * ATTENTION: This commercial software is intended for exclusive use with SkaDate Dating Software (http://www.skadate.com) and is licensed under SkaDate Exclusive License by Skalfa LLC.
 * 
 * Full text of this license can be found at http://www.skadate.com/sel.pdf
 */
if (OW::getPluginManager()->isPluginActive('skadateios') || OW::getPluginManager()->isPluginActive('skandroid')) {
    $widgetService = BOL_ComponentAdminService::getInstance();
    $widget = $widgetService->addWidget('SKADATE_CMP_MobileExperience', false);
    try {
        $placeWidget = $widgetService->addWidgetToPlace($widget, BOL_ComponentAdminService::PLACE_INDEX);
        $widgetService->addWidgetToPosition($placeWidget, BOL_ComponentService::SECTION_RIGHT);
    } catch (Exception $e) {
        OW::getLogger('skadate.activate.widget_mobile_experience_index')->addEntry(json_encode($e));
    }
    try {
        $placeWidget = $widgetService->addWidgetToPlace($widget, BOL_ComponentAdminService::PLACE_DASHBOARD);
        $widgetService->addWidgetToPosition($placeWidget, BOL_ComponentService::SECTION_RIGHT);
    } catch (Exception $e) {
        OW::getLogger('skadate.activate.widget_mobile_experience_dashboard')->addEntry(json_encode($e));
    }
}
Example #14
0
function skadate_on_plugin_activate(OW_Event $event)
{
    $params = $event->getParams();
    if (in_array($params['pluginKey'], array('skadateios', 'skandroid'))) {
        $widgetService = BOL_ComponentAdminService::getInstance();
        $widget = $widgetService->addWidget('SKADATE_CMP_MobileExperience', false);
        try {
            $placeWidget = $widgetService->addWidgetToPlace($widget, BOL_ComponentAdminService::PLACE_INDEX);
            $widgetService->addWidgetToPosition($placeWidget, BOL_ComponentService::SECTION_RIGHT);
            $placeWidget = $widgetService->addWidgetToPlace($widget, BOL_ComponentAdminService::PLACE_DASHBOARD);
            $widgetService->addWidgetToPosition($placeWidget, BOL_ComponentService::SECTION_RIGHT);
        } catch (Exception $e) {
            OW::getLogger('skadate.activate_widget_mobile_experience')->addEntry(json_encode($e));
        }
    }
}
Example #15
0
 /**
  * Updates user settings configuration
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $config = OW::getConfig();
     $config->saveConfig('base', 'avatar_size', $values['avatarSize']);
     $config->saveConfig('base', 'avatar_big_size', $values['bigAvatarSize']);
     $config->saveConfig('base', 'display_name_question', $values['displayName']);
     $config->saveConfig('base', 'join_display_photo_upload', $values['join_display_photo_upload']);
     $config->saveConfig('base', 'join_display_terms_of_use', $values['join_display_terms_of_use']);
     $config->saveConfig('base', 'avatar_max_upload_size', round((double) $values['avatar_max_upload_size'], 2));
     if (!defined('OW_PLUGIN_XP')) {
         $config->saveConfig('base', 'confirm_email', $values['confirmEmail']);
     }
     $avatarService = BOL_AvatarService::getInstance();
     if (isset($_FILES['avatar']['tmp_name'])) {
         $avatarService->setCustomDefaultAvatar(1, $_FILES['avatar']);
     }
     if (isset($_FILES['bigAvatar']['tmp_name'])) {
         $avatarService->setCustomDefaultAvatar(2, $_FILES['bigAvatar']);
     }
     // privacy
     $config->saveConfig('base', 'who_can_join', (int) $values['who_can_join']);
     $config->saveConfig('base', 'who_can_invite', (int) $values['who_can_invite']);
     $config->saveConfig('base', 'mandatory_user_approve', (bool) $values['user_approve'] ? 1 : 0);
     if ((int) $values['guests_can_view'] == 3) {
         $adminEmail = OW::getUser()->getEmail();
         $senderMail = $config->getValue('base', 'site_email');
         $mail = OW::getMailer()->createMail();
         $mail->addRecipientEmail($adminEmail);
         $mail->setSender($senderMail);
         $mail->setSenderSuffix(false);
         $mail->setSubject(OW::getLanguage()->text('admin', 'site_password_letter_subject', array()));
         $mail->setTextContent(OW::getLanguage()->text('admin', 'site_password_letter_template_text', array('password' => $values['password'])));
         $mail->setHtmlContent(OW::getLanguage()->text('admin', 'site_password_letter_template_html', array('password' => $values['password'])));
         try {
             OW::getMailer()->send($mail);
         } catch (Exception $e) {
             $logger = OW::getLogger('admin.send_password_message');
             $logger->addEntry($e->getMessage());
             $logger->writeLog();
         }
         $values['password'] = crypt($values['password'], OW_PASSWORD_SALT);
         $config->saveConfig('base', 'guests_can_view_password', $values['password']);
     } else {
         $config->saveConfig('base', 'guests_can_view_password', null);
     }
     $config->saveConfig('base', 'guests_can_view', (int) $values['guests_can_view']);
     // profile questions
     isset($_POST['user_view_presentation']) ? $config->saveConfig('base', 'user_view_presentation', 'tabs') : $config->saveConfig('base', 'user_view_presentation', 'table');
     return array('result' => true);
 }
Example #16
0
 public function sendWinkNotification($userId, $partnerId)
 {
     if (empty($userId) || empty($partnerId) || ($user = BOL_UserService::getInstance()->findUserById($userId)) === null || ($partner = BOL_UserService::getInstance()->findUserById($partnerId)) === null) {
         return;
     }
     $avatarUrls = BOL_AvatarService::getInstance()->getAvatarsUrlList(array($userId, $partnerId));
     $displayNames = BOL_UserService::getInstance()->getDisplayNamesForList(array($userId, $partnerId));
     $subjectKey = 'wink_back_email_subject';
     $subjectArr = array('displayname' => $displayNames[$userId]);
     $textContentKey = 'wink_back_email_text_content';
     $htmlContentKey = 'wink_back_email_html_content';
     $contentArr = array('src' => $avatarUrls[$userId], 'displayname' => $displayNames[$userId], 'url' => OW_URL_HOME . 'user/' . $user->getUsername(), 'conversation_url' => OW_URL_HOME . 'messages');
     $language = OW::getLanguage();
     $mail = OW::getMailer()->createMail();
     $mail->addRecipientEmail($partner->getEmail());
     $mail->setSubject($language->text('winks', $subjectKey, $subjectArr));
     $mail->setTextContent($language->text('winks', $textContentKey, $contentArr));
     $mail->setHtmlContent($language->text('winks', $htmlContentKey, $contentArr));
     try {
         OW::getMailer()->send($mail);
     } catch (Exception $e) {
         OW::getLogger('wink.send_notify')->addEntry(json_encode($e));
     }
 }
Example #17
0
 public function index()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $baseConfigs = $config->getValues('base');
     $form = new Form('privacy_settings');
     $userApprove = new CheckboxField('user_approve');
     $userApprove->setLabel($language->text('admin', 'permissions_index_user_approve'));
     $form->addElement($userApprove);
     $whoCanJoin = new RadioField('who_can_join');
     $whoCanJoin->addOptions(array('1' => $language->text('admin', 'permissions_index_anyone_can_join'), '2' => $language->text('admin', 'permissions_index_by_invitation_only_can_join')));
     $whoCanJoin->setLabel($language->text('admin', 'permissions_index_who_can_join'));
     $form->addElement($whoCanJoin);
     $whoCanInvite = new RadioField('who_can_invite');
     $whoCanInvite->addOptions(array('1' => $language->text('admin', 'permissions_index_all_users_can_invate'), '2' => $language->text('admin', 'permissions_index_admin_only_can_invate')));
     $whoCanInvite->setLabel($language->text('admin', 'permissions_index_who_can_invite'));
     $form->addElement($whoCanInvite);
     $guestsCanView = new RadioField('guests_can_view');
     $guestsCanView->addOptions(array('1' => $language->text('admin', 'permissions_index_yes'), '2' => $language->text('admin', 'permissions_index_no'), '3' => $language->text('admin', 'permissions_index_with_password')));
     $guestsCanView->setLabel($language->text('admin', 'permissions_index_guests_can_view_site'));
     $guestsCanView->setDescription($language->text('admin', 'permissions_idex_if_not_yes_will_override_settings'));
     $form->addElement($guestsCanView);
     $password = new TextField('password');
     $password->setHasInvitation(true);
     if ($baseConfigs['guests_can_view'] == 3) {
         $password->setInvitation($language->text('admin', 'change_password'));
     } else {
         $password->setInvitation($language->text('admin', 'add_password'));
     }
     $form->addElement($password);
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'permissions_index_save'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $config->saveConfig('base', 'who_can_join', (int) $data['who_can_join']);
             $config->saveConfig('base', 'who_can_invite', (int) $data['who_can_invite']);
             $config->saveConfig('base', 'mandatory_user_approve', (bool) $data['user_approve'] ? 1 : 0);
             if ((int) $data['guests_can_view'] === 3 && empty($data['password'])) {
                 OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_empty_pass_error_message'));
                 return;
             } else {
                 if ((int) $data['guests_can_view'] === 3 && strlen(trim($data['password'])) < 4) {
                     OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_pass_length_error_message'));
                     return;
                 } else {
                     $adminEmail = OW::getUser()->getEmail();
                     $senderMail = $config->getValue('base', 'site_email');
                     $mail = OW::getMailer()->createMail();
                     $mail->addRecipientEmail($adminEmail);
                     $mail->setSender($senderMail);
                     $mail->setSenderSuffix(false);
                     $mail->setSubject(OW::getLanguage()->text('admin', 'site_password'));
                     $mail->setTextContent(OW::getLanguage()->text('admin', 'admin_password', array('password' => $data['password'])));
                     try {
                         OW::getMailer()->send($mail);
                     } catch (Exception $e) {
                         $logger = OW::getLogger('admin.send_password_message');
                         $logger->addEntry($e->getMessage());
                         $logger->writeLog();
                     }
                     $data['password'] = crypt($data['password'], OW_PASSWORD_SALT);
                     $config->saveConfig('base', 'guests_can_view', (int) $data['guests_can_view']);
                     $config->saveConfig('base', 'guests_can_view_password', $data['password']);
                 }
             }
             OW::getFeedback()->info($language->text('admin', 'permission_global_privacy_settings_success_message'));
             $this->redirect();
         }
     }
     $baseConfigs = $config->getValues('base');
     $form->getElement('who_can_join')->setValue($baseConfigs['who_can_join']);
     $form->getElement('who_can_invite')->setValue($baseConfigs['who_can_invite']);
     $form->getElement('guests_can_view')->setValue($baseConfigs['guests_can_view']);
     $form->getElement('user_approve')->setValue($baseConfigs['mandatory_user_approve']);
 }
Example #18
0
 /**
  * Deletes plugin.
  *
  * @param array $params
  */
 public function uninstall(array $params)
 {
     $language = OW::getLanguage();
     if (empty($params["key"])) {
         OW::getFeedback()->error($language->text('admin', 'manage_plugins_uninstall_error_message'));
         $this->redirect(OW::getRouter()->urlForRoute("admin_plugins_installed"));
     }
     $pluginDto = $this->getPluginDtoByKeyInParamsArray($params);
     if ($pluginDto === null) {
         OW::getFeedback()->error($language->text('admin', 'manage_plugins_uninstall_error_message'));
         $this->redirect(OW::getRouter()->urlForRoute("admin_plugins_installed"));
     }
     if (!$pluginDto->isActive) {
         $this->pluginService->activate($pluginDto->getKey());
     }
     try {
         $this->pluginService->uninstall($pluginDto->getKey());
     } catch (Exception $e) {
         if (OW_DEBUG_MODE) {
             throw $e;
         } else {
             OW::getLogger()->addEntry($e->getTraceAsString());
         }
         OW::getFeedback()->error($language->text("admin", "manage_plugins_uninstall_error_message"));
         $this->redirect(OW::getRouter()->urlForRoute("admin_plugins_installed"));
     }
     OW::getFeedback()->info($language->text("admin", "manage_plugins_uninstall_success_message", array("plugin" => $pluginDto->getTitle())));
     $this->redirect(OW::getRouter()->urlForRoute("admin_plugins_installed"));
 }
Example #19
0
 *
 * If you are not using Composer, you need to require the
 * Slim Framework and register its PSR-0 autoloader.
 *
 * If you are using Composer, you can skip this step.
 */
/**
 * SkadateX intialization
 */
define('_OW_', true);
define('DS', DIRECTORY_SEPARATOR);
define('OW_DIR_ROOT', substr(dirname(__FILE__), 0, -strlen('api')));
require OW_DIR_ROOT . 'ow_includes' . DS . 'init.php';
if (!defined('OW_ERROR_LOG_ENABLE') || (bool) OW_ERROR_LOG_ENABLE) {
    $logFilePath = OW_DIR_LOG . 'error.log';
    $logger = OW::getLogger('ow_core_log');
    $logger->setLogWriter(new BASE_CLASS_FileLogWriter($logFilePath));
    $errorManager->setLogger($logger);
}
@(include OW_DIR_ROOT . 'ow_install' . DS . 'install.php');
OW::getSession()->start();
$application = OW::getApplication();
if (OW_PROFILER_ENABLE || OW_DEV_MODE) {
    UTIL_Profiler::getInstance()->mark('before_app_init');
}
$application->init();
if (OW_PROFILER_ENABLE || OW_DEV_MODE) {
    UTIL_Profiler::getInstance()->mark('after_app_init');
}
$event = new OW_Event(OW_EventManager::ON_APPLICATION_INIT);
OW::getEventManager()->trigger($event);
Example #20
0
 /**
  * @param $groupName
  * @param null $actionName
  * @param array $extra
  * @return string
  */
 public function getActionStatus($groupName, $actionName = null, array $extra = null)
 {
     if (!empty($extra['userId'])) {
         $userId = (int) $extra['userId'];
     } else {
         $userId = OW::getUser()->isAuthenticated() ? OW::getUser()->getId() : 0;
     }
     $isAuthorized = $this->isActionAuthorizedBy($groupName, $actionName, $extra);
     if ($isAuthorized['status']) {
         return array('status' => self::STATUS_AVAILABLE, 'msg' => null, 'authorizedBy' => $isAuthorized['authorizedBy']);
     }
     $lang = OW::getLanguage();
     $error = array('status' => self::STATUS_DISABLED, 'msg' => $lang->text('base', 'authorization_failed_feedback'));
     if (!$userId && !$this->isActionAuthorizedForGuest($groupName, $actionName)) {
         return $error;
     }
     try {
         // layer check
         $eventParams = array('userId' => $userId, 'groupName' => $groupName, 'actionName' => $actionName, 'extra' => $extra);
         $event = new BASE_CLASS_EventCollector('authorization.layer_check_collect_error', $eventParams);
         OW::getEventManager()->trigger($event);
         $data = $event->getData();
     } catch (Exception $ex) {
         OW::getLogger()->addEntry($ex->getMessage() . "\n" . print_r($ex->getTrace(), true));
     }
     if (empty($data)) {
         return $error;
     }
     usort($data, array($this, 'sortLayersByPriorityAsc'));
     $links = array();
     foreach ($data as $option) {
         if (!empty($option['label'])) {
             $label = mb_strtolower($option['label']);
             $links[] = !empty($option['url']) ? '<a href="' . $option['url'] . '">' . $label . '</a>' : $label;
         }
     }
     if (count($links)) {
         $actionLabel = $this->getActionLabel($groupName, $actionName);
         $error = array('status' => self::STATUS_PROMOTED, 'msg' => $lang->text('base', 'authorization_action_promotion', array('alternatives' => implode(' ' . $lang->text('base', 'or') . ' ', $links), 'action' => mb_strtolower($actionLabel))));
     }
     return $error;
 }