/** * Log the transaction details into the flux_paypal_transactions table. * * @param Flux_LoginAthenaGroup $servGroup * @param string $accountID * @param string $serverName * @access private */ private function logToPayPalTable(Flux_LoginAthenaGroup $servGroup, $accountID, $serverName, $trusted, $credits = 0) { if ($this->txnIsValid) { $holdUntil = null; if (!$trusted) { $email = $this->ipnVariables->get('payer_email'); $sql = "SELECT hold_until FROM {$servGroup->loginDatabase}.{$this->txnLogTable} "; $sql .= "WHERE account_id = ? AND payer_email = ? AND hold_until > NOW() AND payment_status = 'Completed' LIMIT 1"; $sth = $sth = $servGroup->connection->getStatement($sql); $sth->execute(array($accountID, $email)); $row = $sth->fetch(); if ($row && $row->hold_until) { $holdUntil = $row->hold_until; } else { $hours = +(int) Flux::config('HoldUntrustedAccount'); $holdUntil = date('Y-m-d H:i:s', time() + $hours * 60 * 60); } } $this->logPayPal('Saving transaction details to PayPal transactions table...'); $sql = "\n\t\t\t\tINSERT INTO {$servGroup->loginDatabase}.{$this->txnLogTable} (\n\t\t\t\t\taccount_id,\n\t\t\t\t\tserver_name,\n\t\t\t\t\tcredits,\n\t\t\t\t\treceiver_email,\n\t\t\t\t\titem_name,\n\t\t\t\t\titem_number,\n\t\t\t\t\tquantity,\n\t\t\t\t\tpayment_status,\n\t\t\t\t\tpending_reason,\n\t\t\t\t\tpayment_date,\n\t\t\t\t\tmc_gross,\n\t\t\t\t\tmc_fee,\n\t\t\t\t\ttax,\n\t\t\t\t\tmc_currency,\n\t\t\t\t\tparent_txn_id,\n\t\t\t\t\ttxn_id,\n\t\t\t\t\ttxn_type,\n\t\t\t\t\tfirst_name,\n\t\t\t\t\tlast_name,\n\t\t\t\t\taddress_street,\n\t\t\t\t\taddress_city,\n\t\t\t\t\taddress_state,\n\t\t\t\t\taddress_zip,\n\t\t\t\t\taddress_country,\n\t\t\t\t\taddress_status,\n\t\t\t\t\tpayer_email,\n\t\t\t\t\tpayer_status,\n\t\t\t\t\tpayment_type,\n\t\t\t\t\tnotify_version,\n\t\t\t\t\tverify_sign,\n\t\t\t\t\treferrer_id,\n\t\t\t\t\tprocess_date,\n\t\t\t\t\thold_until\n\t\t\t\t) VALUES (\n\t\t\t\t\t?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,\n\t\t\t\t\t?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(),\n\t\t\t\t\t?\n\t\t\t\t)\n\t\t\t"; $var = $this->ipnVariables; $sth = $servGroup->connection->getStatement($sql); $ret = $sth->execute(array($accountID, $serverName, $credits, $var->get('receiver_email'), $var->get('item_name'), $var->get('item_number'), $var->get('quantity'), $var->get('payment_status'), $var->get('pending_reason'), $var->get('payment_date'), $var->get('mc_gross'), $var->get('mc_fee'), $var->get('tax'), $var->get('mc_currency'), $var->get('parent_txn_id'), $var->get('txn_id'), $var->get('txn_type'), $var->get('first_name'), $var->get('last_name'), $var->get('address_street'), $var->get('address_city'), $var->get('address_state'), $var->get('address_zip'), $var->get('address_country'), $var->get('address_status'), $var->get('payer_email'), $var->get('payer_status'), $var->get('payment_type'), $var->get('notify_version'), $var->get('verify_sign'), $var->get('receiver_id'), $holdUntil)); if ($ret) { if (!trim($serverName)) { $serverName = '(unknown)'; } $this->logPayPal('Stored information in PayPal transactions table for server %s.', $serverName); } else { $errorInfo = implode('/', $sth->errorInfo()); $this->logPayPal('Failed to save information in PayPal transactions table. (%s)', $errorInfo); } } }
/** * Wrapper method for setting and getting values from the access config. * * @param string $key * @param mixed $value * @param arary $options * @access public */ public function config($key, $value = null, $options = array()) { if (!is_null($value)) { return $this->config->set($key, $value, $options); } else { return $this->config->get($key); } }
/** * Wrapper method for setting and getting values from the messagesConfig. * * @param string $key * @param mixed $value * @param arary $options * @access public */ public static function message($key, $value = null, $options = array()) { if (!is_null($value)) { return self::$messagesConfig->set($key, $value, $options); } else { return self::$messagesConfig->get($key); } }
/** * Create a series of select fields matching a MySQL DATE format. * * @param string $name * @param string $value DATE formatted string. * @param int $fowardYears * @param int $backwardYears * @return string */ public function dateField($name, $value = null, $fowardYears = null, $backwardYears = null) { if (!isset($fowardYears)) { $fowardYears = (int) Flux::config('ForwardYears'); } if (!isset($backwardYears)) { $backwardYears = (int) Flux::config('BackwardYears'); } $ts = $value && !preg_match('/^0000-00-00(?: 00:00:00)?$/', $value) ? strtotime($value) : time(); $year = ($year = $this->params->get("{$name}_year")) ? $year : date('Y', $ts); $month = ($month = $this->params->get("{$name}_month")) ? $month : date('m', $ts); $day = ($day = $this->params->get("{$name}_day")) ? $day : date('d', $ts); $fw = $year + $fowardYears; $bw = $year - $backwardYears; // Get years. $years = sprintf('<select name="%s_year">', $name); for ($i = $fw; $i >= $bw; --$i) { if ($year == $i) { $years .= sprintf('<option value="%04d" selected="selected">%04d</option>', $i, $i); } else { $years .= sprintf('<option value="%04d">%04d</option>', $i, $i); } } $years .= '</select>'; // Get months. $months = sprintf('<select name="%s_month">', $name); for ($i = 1; $i <= 12; ++$i) { if ($month == $i) { $months .= sprintf('<option value="%02d" selected="selected">%02d</option>', $i, $i); } else { $months .= sprintf('<option value="%02d">%02d</option>', $i, $i); } } $months .= '</select>'; // Get days. $days = sprintf('<select name="%s_day">', $name); for ($i = 1; $i <= 31; ++$i) { if ($day == $i) { $days .= sprintf('<option value="%02d" selected="selected">%02d</option>', $i, $i); } else { $days .= sprintf('<option value="%02d">%02d</option>', $i, $i); } } $days .= '</select>'; return sprintf('<span class="date-field">%s-%s-%s</span>', $years, $months, $days); }
/** * Dispatch current request to the correct action and render the view. * * @param array $options Options for the dispatcher. * @access public */ public function dispatch($options = array()) { $config = new Flux_Config($options); $basePath = $config->get('basePath'); $paramsArr = $config->get('params'); $modulePath = $config->get('modulePath'); $themePath = $config->get('themePath'); $themeName = $config->get('themeName'); $defaultModule = $config->get('defaultModule'); $defaultAction = $config->get('defaultAction'); $missingActionModuleAction = $config->get('missingActionModuleAction'); $missingViewModuleAction = $config->get('missingViewModuleAction'); $useCleanUrls = $config->get('useCleanUrls'); if (!$defaultModule && $this->defaultModule) { $defaultModule = $this->defaultModule; } if (!$defaultAction && $this->defaultAction) { $defaultAction = $this->defaultAction; } if (!$defaultModule) { throw new Flux_Error('Please set the default module with $dispatcher->setDefaultModule()'); } elseif (!$defaultAction) { throw new Flux_Error('Please set the default action with $dispatcher->setDefaultAction()'); } if (!$paramsArr) { $paramsArr =& $_REQUEST; } // Provide easier access to parameters. $params = new Flux_Config($paramsArr); $baseURI = Flux::config('BaseURI'); if ($params->get('module')) { $safetyArr = array('..', '/', '\\'); $moduleName = str_replace($safetyArr, '', $params->get('module')); if ($params->get('action')) { $actionName = str_replace($safetyArr, '', $params->get('action')); } else { $actionName = $defaultAction; } } elseif (Flux::config('UseCleanUrls')) { $baseURI = preg_replace('&/+&', '/', rtrim($baseURI, '/')) . '/'; $requestURI = preg_replace('&/+&', '/', rtrim($_SERVER['REQUEST_URI'], '/')) . '/'; $requestURI = preg_replace('&\\?.*?$&', '', $requestURI); $components = explode('/', trim((string) substr($requestURI, strlen($baseURI)), '/')); $moduleName = empty($components[0]) ? $defaultModule : $components[0]; $actionName = empty($components[1]) ? $defaultAction : $components[1]; } elseif (!$params->get('module') && !$params->get('action')) { $moduleName = $defaultModule; $actionName = $defaultAction; } // Authorization handling. $auth = Flux_Authorization::getInstance(); if ($auth->actionAllowed($moduleName, $actionName) === false) { if (!Flux::$sessionData->isLoggedIn()) { Flux::$sessionData->setMessageData('Please log-in to continue.'); $this->loginRequired($baseURI); } else { $moduleName = 'unauthorized'; $actionName = $this->defaultAction; } } $params->set('module', $moduleName); $params->set('action', $actionName); $templateArray = array('params' => $params, 'basePath' => $basePath, 'modulePath' => $modulePath, 'moduleName' => $moduleName, 'themePath' => $themePath, 'themeName' => $themeName, 'actionName' => $actionName, 'viewName' => $actionName, 'headerName' => 'header', 'footerName' => 'footer', 'missingActionModuleAction' => $missingActionModuleAction, 'missingViewModuleAction' => $missingViewModuleAction, 'useCleanUrls' => $useCleanUrls); $templateConfig = new Flux_Config($templateArray); $template = new Flux_Template($templateConfig); // Default data available to all actions and views. $data = array('auth' => Flux_Authorization::getInstance(), 'session' => Flux::$sessionData, 'params' => $params); $template->setDefaultData($data); // Render template! :D $template->render(); }
/** * */ public function uploadShopItemImage($shopItemID, Flux_Config $file) { if ($file->get('error')) { return false; } $validexts = array_map('strtolower', Flux::config('ShopImageExtensions')->toArray()); $extension = strtolower(pathinfo($file->get('name'), PATHINFO_EXTENSION)); if (!in_array($extension, $validexts)) { return false; } $serverName = $this->server->loginAthenaGroup->serverName; $athenaServerName = $this->server->serverName; $dir = FLUX_DATA_DIR . "/itemshop/{$serverName}/{$athenaServerName}"; if (!is_dir(FLUX_DATA_DIR . "/itemshop/{$serverName}")) { mkdir(FLUX_DATA_DIR . "/itemshop/{$serverName}"); } if (!is_dir($dir)) { mkdir($dir); } $this->deleteShopItemImage($shopItemID); if (move_uploaded_file($file->get('tmp_name'), "{$dir}/{$shopItemID}.{$extension}")) { return true; } else { return false; } }