Example #1
0
 public function renderHead()
 {
     $page = $this->plugin->getData('page');
     if ($page !== 'photos' && $page !== 'photo-detail' && $page !== 'albums') {
         return;
     }
     $photo = null;
     if ($page === 'photos') {
         $photo = array_shift($this->plugin->getData('photos'));
     } elseif ($page === 'photo-detail') {
         $photo = $this->plugin->getData('photo');
     } elseif ($page === 'albums') {
         $albums = $this->plugin->getData('albums');
         if (count($albums) > 0 && !empty($albums[0]['cover'])) {
             $photo = $albums[0]['cover'];
         }
     }
     if (empty($photo)) {
         return;
     }
     $utility = new Utility();
     $tags = '';
     $title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on Trovebox";
     $tags .= $this->addTag('og:site_name', sprintf('%s Trovebox site', ucwords($utility->posessive($utility->getEmailHandle($this->config->user->email, false), false))));
     $tags .= $this->addTag('og:title', $photo['title']);
     $tags .= $this->addTag('og:url', $photo['url']);
     $tags .= $this->addTag('og:image', $photo['pathBase']);
     return $tags;
 }
Example #2
0
 /**
  * Get an avatar given an email address
  * See http://en.gravatar.com/site/implement/images/ and http://en.gravatar.com/site/implement/hash/
  *
  * @return string
  */
 public function getAvatarFromEmail($size = 50, $email = null)
 {
     if ($email === null) {
         $email = $this->session->get('email');
     }
     // TODO return standard avatar
     if (empty($email)) {
         return;
     }
     $user = $this->getUserByEmail($email);
     if (isset($user['attrprofilePhoto']) && !empty($user['attrprofilePhoto'])) {
         return $user['attrprofilePhoto'];
     }
     $utilityObj = new Utility();
     if (empty($this->config->site->cdnPrefix)) {
         $hostAndProtocol = sprintf('%s://%s', $utilityObj->getProtocol(false), $utilityObj->getHost(false));
     } else {
         $hostAndProtocol = sprintf('%s%s', $utilityObj->getProtocol(false), $this->config->site->cdnPrefix);
     }
     if (!$this->themeObj) {
         $this->themeObj = getTheme();
     }
     $defaultUrl = sprintf('%s%s', $hostAndProtocol, $this->themeObj->asset('image', 'profile-default.png', false));
     $hash = md5(strtolower(trim($email)));
     return sprintf("http://www.gravatar.com/avatar/%s?s=%s&d=%s", $hash, $size, urlencode($defaultUrl));
 }
Example #3
0
 public function testEstimateFee()
 {
     $info = json_decode($this->api->estimateFee(1), true);
     $this->assertArrayHasKey('result', $info);
     $this->assertTrue(is_numeric($info['result']));
     $this->assertNull($info['error']);
 }
Example #4
0
 public function renderHead()
 {
     $page = $this->plugin->getData('page');
     if ($page !== 'photos' && $page !== 'photo-detail' && $page !== 'albums') {
         return;
     }
     $photo = null;
     if ($page === 'photos') {
         $photo = array_shift($this->plugin->getData('photos'));
     } elseif ($page === 'photo-detail') {
         $photo = $this->plugin->getData('photo');
     } elseif ($page === 'albums') {
         $albums = $this->plugin->getData('albums');
         if (count($albums) > 0 && !empty($albums[0]['cover'])) {
             $photo = $albums[0]['cover'];
         }
     }
     if (empty($photo)) {
         return;
     }
     $utility = new Utility();
     $tags = '';
     $title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on Trovebox";
     $tags .= $this->addTag('twitter:card', 'photo');
     $tags .= $this->addTag('twitter:site', '@openphoto');
     $tags .= $this->addTag('twitter:url', sprintf('%s://%s%s', $utility->getProtocol(false), $utility->getHost(), $utility->getPath()));
     $tags .= $this->addTag('twitter:title', $title);
     $tags .= $this->addTag('twitter:description', 'Trovebox lets you keep all your photos from different services and mobile devices safe in one spot.');
     $tags .= $this->addTag('twitter:image', $photo['pathBase']);
     $tags .= $this->addTag('twitter:image:width', '1280');
     return $tags;
 }
Example #5
0
/**
* Update the groups for this user
* @param none
*/
function update_groups($memberid, $to_add)
{
    $util = new Utility();
    $user = new User($memberid);
    $orig = array_keys($user->groups);
    $groups_to_add = $util->getAddedItems($orig, $to_add);
    $groups_to_remove = $util->getRemovedItems($orig, $to_add);
    $user->add_groups($groups_to_add);
    $user->remove_groups($groups_to_remove);
    close_window();
}
 public function renderHead()
 {
     $utility = new Utility();
     $photo = $this->plugin->getData('photo');
     $tags = '';
     $title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on OpenPhoto";
     $tags .= $this->addTag('og:site_name', sprintf('%s OpenPhoto site', ucwords($utility->posessive($utility->getEmailHandle($this->config->user->email, false), false))));
     $tags .= $this->addTag('og:title', $photo['title']);
     $tags .= $this->addTag('og:url', $photo['url']);
     $tags .= $this->addTag('og:image', $photo['pathBase']);
     return $tags;
 }
Example #7
0
 /**
  * Gets diagnostic information for debugging.
  *
  * @return array
  */
 public function diagnostics()
 {
     $utilityObj = new Utility();
     $diagnostics = array();
     $aclCheck = $this->fs->get_bucket_acl($this->bucket);
     if ((int) $aclCheck->status == 200) {
         $storageSize = $this->fs->get_bucket_filesize($this->bucket, true);
         $diagnostics[] = $utilityObj->diagnosticLine(true, sprintf('Connection to bucket "%s" is okay.', $this->bucket));
         $diagnostics[] = $utilityObj->diagnosticLine(true, sprintf('Total space used in bucket "%s" is %s.', $this->bucket, $storageSize));
     } else {
         $diagnostics[] = $utilityObj->diagnosticLine(false, sprintf('Connection to bucket "%s" is NOT okay.', $this->bucket));
     }
     return $diagnostics;
 }
Example #8
0
 public function hasOpenSession()
 {
     $util = new Utility();
     $config = new Configuration();
     $dbName = $config->settings->authDatabaseName;
     $sessionID = $util->getSessionCookie();
     $query = "SELECT DISTINCT sessionID FROM " . $dbName . ".Session WHERE loginID = '" . $this->loginID . "' AND sessionID='" . $sessionID . "'";
     $result = $this->db->processQuery($query, 'assoc');
     if (isset($result['sessionID'])) {
         return true;
     } else {
         return false;
     }
 }
Example #9
0
 protected function UpdateById($args)
 {
     $object_id = $args[0];
     $metas = $args[1];
     $old_data = Utility::AssColumn($this->GetById(array($object_id)), 'meta_key');
     foreach ($metas as $k => $v) {
         if ($v && $v !== $old_data[$k]['meta_value']) {
             $m = array();
             if ($old_data[$k]) {
                 $m['id'] = $old_data[$k]['id'];
             }
             $m[$this->_fetch_id_name] = $object_id;
             $m['meta_key'] = $k;
             $m['meta_value'] = $v;
             $new_data[] = $m;
         }
     }
     if (!$new_data) {
         return;
     }
     $mm = D($this->_table_name);
     foreach ($new_data as $d) {
         $mm->create($d);
         $mm->saveOrUpdate();
     }
     return;
 }
Example #10
0
 /**
  * [price description]
  * @param  [float or array] $arg [it could be float or an array, if its array you can put
  *         'amount' to display,'discount' that it already has, 'thousandSuffix' if you wanna use that format ]
  *         if you use 'discount' the return is gonna be something like that 'The final value is USD 7.50 (after a 25% discount)'
  *         this function works with config('app.payment_method') then there could be Points or Currency
  * @return [String]      [Formated number or explaint of discount]
  */
 public static function showPrice($arg)
 {
     $options = ['amount' => '', 'discount' => 0, 'thousandSuffix' => 1];
     if (is_array($arg)) {
         $options = $arg + $options;
         if (isset($options['price'])) {
             $options['amount'] = $options['price'];
         }
     } else {
         $options['amount'] = $arg;
     }
     switch (config('app.payment_method')) {
         case 'Points':
             $points = Utility::thousandSuffix($options['amount']);
             if ($options['thousandSuffix']) {
                 $points .= " <small>" . trans('store.points') . "</small>";
             }
             return $points;
         default:
             setlocale(LC_MONETARY, config('app.lc_monetary'));
             $format = '%i';
             if ($options['discount']) {
                 $format = str_replace('##', $options['discount'], trans('product.globals.price_after_discount'));
             }
             return self::money_format($format, $options['amount']);
     }
 }
 public function __construct($data)
 {
     $this->name = isset($data['name']) ? $data['name'] : '';
     $this->tag = isset($data['tag']) ? $data['tag'] : '';
     $this->tag_type = isset($data['tag_type']) ? $data['tag_type'] : '';
     $this->content = isset($data['content']) ? $data['content'] : '';
     $this->before = isset($data['before']) ? $data['before'] : '';
     $this->after = isset($data['after']) ? $data['after'] : '';
     $this->attributes = isset($data['attributes']) ? $data['attributes'] : array();
     $this->hide = isset($data['hide']) ? $data['hide'] : false;
     $this->suppress_filters = isset($data['suppress_filters']) ? $data['suppress_filters'] : true;
     $this->markup = '';
     if (isset($data['post'])) {
         $this->post_object = $data['post'];
     } else {
         $this->post_object = get_post();
     }
     // Ensures that the 'class' attribute is set if it wasn't passed in with attributes.
     if (!isset($this->attributes['class'])) {
         $this->attributes['class'] = array();
     }
     // Add the Atom name as a class
     $this->attributes['class'][] = $this->name;
     if (!empty($data['class'])) {
         $classes_arr = Utility::parse_classes_as_array($data['class']);
         if (!empty($classes_arr)) {
             $this->attributes['class'] = array_merge($this->attributes['class'], $classes_arr);
         }
     }
     unset($this->class);
     // Filter the Atom properties.
     $atom_structure_filter = $this->name . '_properties_filter';
     apply_filters($atom_structure_filter, $this, $data);
     Atom::add_debug_entry('Filter', $atom_structure_filter);
 }
Example #12
0
function sync_event_users()
{
    $current_users = OutboundUsers::GetPartnerUsers(1);
    $current_users_by_mobile = Utility::AssColumn($current_users, 'mobile');
    $users = Users::GetUsers(NULL, 0, 50000);
    global $g_user_type;
    global $g_active_status;
    foreach ($users as $i => $eu) {
        if (!$current_users_by_mobile[$eu['mobile']]) {
            $new_id = OutboundUsers::AddCommonUser(1, $eu);
            $new_ids[] = $new_id;
            //添加默认标签
            if ($eu['user_type'] && $eu['user_type'] !== 'other') {
                $gid = OutboundUserGroups::AddGroup(1, $g_user_type[$eu['user_type']]);
                OutboundUserGroups::AddMap($new_id, $gid);
            }
            if ($eu['active_status']) {
                $gid = OutboundUserGroups::AddGroup(1, $g_active_status[$eu['active_status']]);
                OutboundUserGroups::AddMap($new_id, $gid);
            }
            $current_users_by_mobile[$eu['mobile']] = 1;
        }
    }
    return $new_ids;
}
Example #13
0
 /**
  * Handles a GET request
  *
  * @return none, but populates $this->JSON
  */
 public function handleGET()
 {
     if (!empty($this->JSON)) {
         return;
     }
     $config = $this->Factory->config();
     $useProjects = $config->getSetting("useProjects");
     $useEDC = $config->getSetting("useEDC");
     if ($useEDC === '1' || $useEDC === 'true') {
         $useEDC = true;
     } else {
         $useEDC = false;
     }
     $PSCID = $config->getSetting("PSCID");
     $PSCIDFormat = \Utility::structureToPCRE($PSCID['structure'], "SITE");
     $type = $PSCID['generation'] == 'sequential' ? 'auto' : 'prompt';
     $settings = ["useEDC" => $useEDC, "PSCID" => ["Type" => $type, "Regex" => $PSCIDFormat]];
     if ($useProjects && $useProjects !== "false" && $useProjects !== "0") {
         $projects = \Utility::getProjectList();
         $projArray = [];
         foreach ($projects as $project) {
             $projArray[$project] = $settings;
         }
         $this->JSON = ["Projects" => $projArray];
     } else {
         $this->JSON = ["Projects" => array("loris" => $settings)];
     }
 }
Example #14
0
 /**
  * Send the HTTP request, with optional parameters
  * $params and $header. First parameter $requestURL
  * is also optional, if the URL already been set by
  * the getRequestURL() method.
  *
  * @param   string  The request url.
  * @param   array   Optional. Parameters to post.
  * @param   array   Optional. Http header.
  * @return  array | string
  */
 public function execute($requestURL = NULL, $params = NULL, $header = NULL)
 {
     if ($requestURL === NULL) {
         $requestURL = $this->getRequestURL();
     }
     $curlHandle = curl_init();
     // Default curl options array
     $curlOptions = array(CURLOPT_URL => $requestURL, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_TIMEOUT => 30, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_HEADER => 0, CURLOPT_POST => $this->getHttpMethod() === 'POST');
     curl_setopt_array($curlHandle, $curlOptions);
     // The parameters array must be turned into an URL-encoded query string.
     if ($params !== NULL && $this->getHttpMethod() === 'POST') {
         // The access token should not be included in the post data.
         if (array_key_exists("oauth_token", $params)) {
             unset($params['oauth_token']);
         }
         curl_setopt($curlHandle, CURLOPT_POSTFIELDS, http_build_query($params));
     }
     if ($header !== NULL) {
         curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $header);
     }
     $response = curl_exec($curlHandle);
     // Save the received http code.
     $this->setLastHttpCode(curl_getinfo($curlHandle, CURLINFO_HTTP_CODE));
     curl_close($curlHandle);
     // If the response is in JSON, convert it to an array
     $response = Utility::convertJSON($response);
     return $response;
 }
Example #15
0
 public function updateDetail($arrPost)
 {
     Utility::pushArrAreaID($arrPost);
     //  区域ID
     if (empty($arrPost['endtime'])) {
         $arrPost['endtime'] = '';
     }
     if (!empty($arrPost['photos']) && stristr($arrPost['photos'], '|')) {
         $arrPost['photos'] = Utility::sortImg($arrPost['photos']);
         // 排序
     }
     // 需要 处理的 数字大小
     $arrParam = array('floor', 'floortotal', 'roomnumber', 'livingnumber', 'houseage', 'toiletnumber');
     Utility::checkMaxNum($arrPost, $arrParam);
     $arrPost['aroundpoint'] = empty($arrPost['aroundpoint']) ? '' : implode(',', $arrPost['aroundpoint']);
     $arrPost['livepoint'] = empty($arrPost['livepoint']) ? '' : implode(',', $arrPost['livepoint']);
     $this->strRequestApi = empty($arrPost['id']) ? $this->arrRequestApi['SECOND_HOUSE_ADD'] : $this->arrRequestApi['SECOND_HOUSE__UPDATE'];
     $this->arrRequest = $arrPost;
     $arrResultList = $this->updateParentDetail();
     // D($arrPost);
     // D($arrResultList);
     // exit();
     // 成功跳转
     if ($arrResultList['errorCode'] === 0 || $arrResultList['errorCode'] === 2) {
         Utility::location('secondHouse.php');
     }
     // Utility::UIWindowAlert( '请填写完整。');
     // Utility::location( null , '填写信息有误,请耐心检查下。');
     Utility::location(null, ACTION_ERROR);
 }
Example #16
0
 public static function Create($mobile, $user_id, $secret = null, $enable = false)
 {
     if (!Utility::IsMobile($mobile, true)) {
         return;
     }
     $secret = $secret ? $secret : Utility::VerifyCode();
     $table = new Table('toolsbind', array('user_id' => $user_id, 'tools' => $mobile, 'enable' => $enable ? 'Y' : 'N', 'secret' => $secret));
     $condition = array('user_id' => $user_id, 'tools' => $mobile, 'enable' => 'N');
     $haveone = DB::GetTableRow('toolsbind', $condition);
     if ($haveone) {
         return Table::UpdateCache('toolsbind', $haveone['id'], array('secret' => $secret, 'enable' => 'N'));
     }
     //已经绑定了本号码
     $loginbind = array('user_id' => $user_id, 'tools' => $mobile, 'enable' => 'Y');
     $havebind = DB::GetTableRow('toolsbind', $loginbind);
     if ($havebind) {
         return false;
     }
     //$table->insert(array( 'user_id', 'tools','secret', 'enable'));
     DB::Insert('toolsbind', array('user_id' => $user_id, 'tools' => $mobile, 'secret' => $secret, 'enable' => 'N', 'create_time' => time()));
     $have = Table::Fetch('toolsbind', $mobile, 'tools');
     if ($have && 'Y' == $have['enable']) {
         return true;
     }
 }
Example #17
0
 public static function Create($user_row, $uc = true)
 {
     if (function_exists('zuitu_uc_register') && $uc) {
         $pp = $user_row['password'];
         $em = $user_row['email'];
         $un = $user_row['username'];
         $ret = zuitu_uc_register($em, $un, $pp);
         if (!$ret) {
             return false;
         }
     }
     $user_row['password'] = self::GenPassword($user_row['password']);
     $user_row['create_time'] = $user_row['login_time'] = time();
     $user_row['ip'] = Utility::GetRemoteIp();
     $user_row['secret'] = md5(Utility::GenSecret(12));
     $user_row['id'] = DB::Insert('user', $user_row);
     $_rid = abs(intval(cookieget('_rid')));
     if ($_rid) {
         $r_user = Table::Fetch('user', $_rid);
         if ($r_user) {
             ZInvite::Create($r_user, $user_row);
         }
     }
     if ($user_row['id'] == 1) {
         Table::UpdateCache('user', $user_row['id'], array('manager' => 'Y', 'secret' => ''));
     }
     return $user_row['id'];
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndexing()
 {
     ini_set('max_execution_time', 0);
     ob_start();
     $index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
     $criteria = new CDbCriteria();
     $criteria->compare('t.publish', 1);
     $criteria->order = 'album_id DESC';
     //$criteria->limit = 10;
     $model = Albums::model()->findAll($criteria);
     foreach ($model as $key => $item) {
         if ($item->media_id != 0) {
             $images = Yii::app()->request->baseUrl . '/public/album/' . $item->album_id . '/' . $item->cover->media;
         } else {
             $images = '';
         }
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->album_id), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('album/site/view', array('id' => $item->album_id, 't' => Utility::getUrlTitle($item->title)))), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->creation_date, true) . ' WIB'), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
         $index->addDocument($doc);
     }
     echo 'Album Lucene index created';
     $index->commit();
     $this->redirect(Yii::app()->createUrl('article/search/indexing'));
     ob_end_flush();
 }
Example #19
0
 public function getUserGroupId($user_id, $team_id)
 {
     $groups = D("UserGroups")->getTeamGroups($team_id);
     $group_ids = Utility::GetColumn($groups);
     $group = M("UserGroupMapping")->where(array("user_group_id" => array("in", $group_ids), "user_id" => $user_id))->getField("user_group_id");
     return $group;
 }
Example #20
0
 function __construct($username, $password, $tenantID)
 {
     if (strlen($username) == 0 || strlen($password) == 0) {
         throw new Exception("Invalid username or password.");
     }
     $userDetails = User::getUserDetails($username);
     if ($userDetails["active"] == 0) {
         throw new Exception("This user account is inactive. Please check your email for activation instructions.");
     } else {
         $saltedPassword = Utility::saltAndHash($password, $userDetails["password"]);
         //echo 'salted:' . $saltedPassword;
         //echo Utility::saltAndHash($password);
         $query = 'call validateUser(' . Database::queryString($username);
         $query .= ',' . Database::queryString($saltedPassword);
         $query .= ',' . Database::queryNumber($tenantID) . ');';
         $result = Database::executeQuery($query);
         if (!$result) {
             throw new Exception('Unable to validate that username/password combination.');
         } else {
             $userid = 0;
             while ($o = mysqli_fetch_object($result)) {
                 $userid = $o->userid;
                 $name = $o->name;
             }
             if ($userid > 0) {
                 $this->id = $userid;
                 $this->name = $name;
             } else {
                 throw new Exception("Unable to validate that username/password combination.");
             }
         }
     }
 }
Example #21
0
 /**
  * Create new user
  * @access  public
  * @param   user_group_id: user group ID (1 [admin] or 2 [user])
  *          login: login name
  *          pwd: password
  *          email: email
  *          first_name: first name
  *          last_name: last name
  * @return  user id, if successful
  *          false and add error into global var $msg, if unsuccessful
  * @author  Cindy Qi Li
  */
 public function Create($user_group_id, $login, $pwd, $email, $first_name, $last_name, $is_author, $organization, $phone, $address, $city, $province, $country, $postal_code, $status)
 {
     global $addslashes;
     /* email check */
     $login = $addslashes(strtolower(trim($login)));
     $email = $addslashes(trim($email));
     $first_name = $addslashes(str_replace('<', '', trim($first_name)));
     $last_name = $addslashes(str_replace('<', '', trim($last_name)));
     $organization = $addslashes(trim($organization));
     $phone = $addslashes(trim($phone));
     $address = $addslashes(trim($address));
     $city = $addslashes(trim($city));
     $province = $addslashes(trim($province));
     $country = $addslashes(trim($country));
     $postal_code = $addslashes(trim($postal_code));
     if ($this->isFieldsValid('new', $user_group_id, $login, $email, $first_name, $last_name, $is_author, $organization, $phone, $address, $city, $province, $country, $postal_code)) {
         if ($status == "") {
             if (defined('TR_EMAIL_CONFIRMATION') && TR_EMAIL_CONFIRMATION) {
                 $status = TR_STATUS_UNCONFIRMED;
             } else {
                 $status = TR_STATUS_ENABLED;
             }
         }
         /* insert into the db */
         $sql = "INSERT INTO " . TABLE_PREFIX . "users\n\t\t\t              (login,\n\t\t\t               password,\n\t\t\t               user_group_id,\n\t\t\t               first_name,\n\t\t\t               last_name,\n\t\t\t               email,\n\t\t\t               is_author,\n\t\t\t               organization,\n\t\t\t               phone,\n\t\t\t               address,\n\t\t\t               city,\n\t\t\t               province,\n\t\t\t               country,\n\t\t\t               postal_code,\n\t\t\t               web_service_id,\n\t\t\t               status,\n\t\t\t               create_date\n\t\t\t               )\n\t\t\t       VALUES ('" . $login . "',\n\t\t\t               '" . $pwd . "',\n\t\t\t               " . $user_group_id . ",\n\t\t\t               '" . $first_name . "',\n\t\t\t               '" . $last_name . "', \n\t\t\t               '" . $email . "',\n\t\t\t               " . $is_author . ",\n\t\t\t               '" . $organization . "',\n\t\t\t               '" . $phone . "',\n\t\t\t               '" . $address . "',\n\t\t\t               '" . $city . "',\n\t\t\t               '" . $province . "',\n\t\t\t               '" . $country . "',\n\t\t\t               '" . $postal_code . "',\n\t\t\t               '" . Utility::getRandomStr(32) . "',\n\t\t\t               " . $status . ", \n\t\t\t               now())";
         if (!$this->execute($sql)) {
             $msg->addError('DB_NOT_UPDATED');
             return false;
         } else {
             return mysql_insert_id();
         }
     } else {
         return false;
     }
 }
 /**
  * Initialize public template
  */
 public function init()
 {
     $arrThemes = Utility::getCurrentTemplate('public');
     Yii::app()->theme = $arrThemes['folder'];
     $this->layout = $arrThemes['layout'];
     //$this->pageGuest = true;
 }
Example #23
0
 public static function parse_params($input)
 {
     if (!isset($input) || !$input) {
         return array();
     }
     $pairs = explode('&', $input);
     $parsed_params = array();
     foreach ($pairs as $pair) {
         $split = explode('=', $pair, 2);
         $parameter = Utility::urldecode_rfc3986($split[0]);
         $value = isset($split[1]) ? Utility::urldecode_rfc3986($split[1]) : '';
         if (isset($parsed_params[$parameter])) {
             // We have already recieved parameter(s) with this name, so add to the list
             // of params with this name
             if (is_scalar($parsed_params[$parameter])) {
                 // This is the first duplicate, so transform scalar (string) into an array
                 // so we can add the duplicates
                 $parsed_params[$parameter] = array($parsed_params[$parameter]);
             }
             $parsed_params[$parameter][] = $value;
         } else {
             $parsed_params[$parameter] = $value;
         }
     }
     return $parsed_params;
 }
 public function get_base_info()
 {
     $query_data = array('api_id' => $this->appid, 'api_secret' => $this->appsecret);
     $sendurl = $this->api_url . http_build_query($query_data);
     $result = Utility::HttpRequest($sendurl);
     die(dump($result));
 }
Example #25
0
function sms_coupon($coupon, $mobile = null)
{
    global $INI;
    if ($coupon['consume'] == 'Y' || $coupon['expire_time'] < strtotime(date('Y-m-d'))) {
        return $INI['system']['couponname'] . '已失效';
    }
    $user = Table::Fetch('user', $coupon['user_id']);
    $order = Table::Fetch('order', $coupon['order_id']);
    if (!Utility::IsMobile($mobile)) {
        $mobile = $order['mobile'];
        if (!Utility::IsMobile($mobile)) {
            $mobile = $user['mobile'];
        }
    }
    if (!Utility::IsMobile($mobile)) {
        return '请设置合法的手机号码,以便接受短信';
    }
    $team = Table::Fetch('team', $coupon['team_id']);
    $partner = Table::Fetch('partner', $coupon['partner_id']);
    $coupon['end'] = date('Y-n-j', $coupon['expire_time']);
    $coupon['name'] = $team['product'];
    $content = render('manage_tpl_smscoupon', array('partner' => $partner, 'coupon' => $coupon, 'user' => $user));
    if (true === ($code = sms_send($mobile, $content))) {
        Table::UpdateCache('coupon', $coupon['id'], array('sms' => array('`sms` + 1'), 'sms_time' => time()));
        return true;
    }
    return $code;
}
 /**
  * private
  * main process
  */
 function CSSValidator($type, $content, $return_array = false)
 {
     $this->validate_type = $type;
     $this->validate_content = $content;
     if ($this->validate_type == "uri") {
         if (Utility::getValidURI($this->validate_content) === false) {
             $this->contain_errors = true;
             $this->msg = _AC('AC_ERROR_CANT_CONNECT', $uri);
             //"Error: Cannot connect to <strong>".$uri. "</strong>";
             return false;
         }
         $result = $this->validate_uri($this->validate_content);
     } else {
         return false;
         // css validator is only available for url checking, not for file upload and paste
     }
     if (!$result) {
         return false;
     } else {
         $this->full_return = $result;
         $this->result = $this->stripOutResult($result);
         if ($return_array == true) {
             $this->stripOutResultArray();
         }
         $this->num_of_errors = $this->stripOutNumOfErrors($result);
         return true;
     }
 }
Example #27
0
 /**
  * @author Bui Dang <*****@*****.**>
  * action create and edit group
  * @return array
  */
 public function create_group($data = array())
 {
     if ($data['group_id'] and !\Model_Mgroups::find_by_pk($data['group_id'])) {
         Session::set_flash('error', '取引先グループは存在しません');
         return array('status' => \Constants::$_status_save['id_not_exist']);
     }
     if (isset($data['group_id'])) {
         $group = Model_Mgroups::find_by_pk($data['group_id']);
         $data['updated_at'] = date('Y-m-d H:i:s');
     } else {
         $group = new Model_Mgroups();
         $data['created_at'] = date('Y-m-d H:i:s');
         $data['updated_at'] = date('Y-m-d H:i:s');
     }
     $data['name'] = Utility::strip_tag_string($data['group_name']);
     $group->set($data);
     //Set data
     $is_name = self::check_name($data['group_id'], $data['group_name']);
     if ($is_name != 0) {
         return array('status' => \Constants::$_status_save['value_exist']);
     }
     if ($group and $group->save() >= 0) {
         Session::set_flash('success', '保存しました ');
         return array('group_id' => $group->m_group_id, 'status' => \Constants::$_status_save['save_success']);
     }
 }
 function processTable()
 {
     $this->srcBase->createAndExecuteQuery($this->selectQuery);
     while ($result = $this->srcBase->getQueryResult($this->selectQuery)) {
         $utvMedl = new UtvMedl();
         $utvMedl->UM_PNID = $result['PNID'];
         $utvMedl->UM_UTVID = $result['UTVID'];
         $utvMedl->UM_FRADATO = Utility::fixDateFormat($result['FUNKFRA']);
         if (isset($result['FUNKTIL']) == false) {
             $this->logger->log($this->XMLfilename, "UM_PNID (" . $result['PNID'] . ") is mising UM_TILDATO. This is fine accodring to DTD but arkn4 seems to require it. Setting UM_TILDATO to " . Utility::fixDateFormat(Constants::DATE_AUTO_END), Constants::LOG_WARNING);
             $this->warningIssued = true;
             $utvMedl->UM_TILDATO = Utility::fixDateFormat(Constants::DATE_AUTO_END);
         } else {
             $utvMedl->UM_TILDATO = Utility::fixDateFormat($result['FUNKTIL']);
         }
         $utvMedl->UM_FUNK = $result['FUNKSJON'];
         $utvMedl->UM_RANGERING = '0';
         $this->logger->log($this->XMLfilename, "UM.RANGERING has no value, setting to 0 for UM_PNID (" . $utvMedl->UM_PNID . ")", Constants::LOG_WARNING);
         $this->warningIssued = true;
         $utvMedl->UM_SORT = $result['NR'];
         $this->logger->log($this->XMLfilename, "Non mandatory field UM.REPRES is not linked on ADRID for UTVID( " . $utvMedl->UM_UTVID . "), PNID (" . $utvMedl->UM_PNID . "). Value from ESA is " . $result['REPPARTI'], Constants::LOG_WARNING);
         $utvMedl->UM_MERKNAD = $result['MERKNAD'];
         $utvMedl->UM_VARAFOR = $result['VARAPERSON'];
         if (is_null($result['VARAPERSON']) == true) {
             $queryGetPNID = "select PNID from dgjhutvmedlem where adrid = '" . $result['ADRID'] . "' AND utvid = '" . $utvMedl->UM_UTVID . "'";
             $this->srcBase->createAndExecuteQuery($queryGetPNID);
             $pnidResult = $this->srcBase->getQueryResult($queryGetPNID);
             $utvMedl->UM_VARAFOR = $pnidResult['PNID'];
             $this->srcBase->endQuery($queryGetPNID);
         }
         $this->writeToDestination($utvMedl);
     }
     $this->srcBase->endQuery($this->selectQuery);
 }
 function processTable()
 {
     $this->srcBase->createAndExecuteQuery($this->selectQuery);
     while ($result = $this->srcBase->getQueryResult($this->selectQuery)) {
         $tggrp = new Tggrp();
         $tggrp->TG_GRUPPNAVN = $result['FULLTNAVN'];
         $tggrp->TG_GRUPPEID = $result['GRUPPEID'];
         if (is_null($result['OPPRAVID'])) {
             $tggrp->TG_OPPRAV = Constants::INGENBRUKER_ID;
             $this->logger->log($this->XMLfilename, "TG_OPPRAV is null for TG_GRUPPNAVN (" . $tggrp->TG_GRUPPNAVN . ") setting it to unkown user " . Constants::INGENBRUKER_ID, Constants::LOG_WARNING);
         } else {
             $tggrp->TG_OPPRAV = $result['OPPRAVID'];
         }
         if (strcmp($result['CTYPE'], "T") == 0) {
             $tggrp->TG_GENERELL = '1';
         } else {
             $tggrp->TG_GENERELL = '0';
         }
         $this->logger->log($this->XMLfilename, "TG_GENERELL is missing for TG_GRUPPNAVN (" . $tggrp->TG_GRUPPNAVN . ") assumed a value from CTYPE field (" . $result['CTYPE'] . ") setting TG_GENERELL  to " . $tggrp->TG_GENERELL, Constants::LOG_WARNING);
         if (is_null($result['FRADATO'])) {
             $this->logger->log($this->XMLfilename, "TG_FRADATO is null for TG_GRUPPNAVN (" . $tggrp->TG_GRUPPNAVN . ") setting it to unkown date " . Constants::DATE_AUTO_START, Constants::LOG_WARNING);
             $tggrp->TG_FRADATO = Utility::fixDateFormat(Constants::DATE_AUTO_START);
         } else {
             $tggrp->TG_FRADATO = Utility::fixDateFormat($result['FRADATO']);
         }
         if (is_null($result['TILDATO'])) {
             $this->logger->log($this->XMLfilename, "TG_TILDATO is null for TG_GRUPPNAVN (" . $tggrp->TG_GRUPPNAVN . ") setting it to unkown date " . Constants::DATE_AUTO_END, Constants::LOG_WARNING);
             $tggrp->TG_TILDATO = Utility::fixDateFormat(Constants::DATE_AUTO_END);
         } else {
             $tggrp->TG_TILDATO = Utility::fixDateFormat($result['TILDATO']);
         }
         $this->writeToDestination($tggrp);
     }
     $this->srcBase->endQuery($this->selectQuery);
 }
 function processTable()
 {
     $this->srcBase->createAndExecuteQuery($this->selectQuery);
     // This utvalg is created to handle the cases where UTVID is null in DGMAMO
     $utvalg = new Utvalg();
     $utvalg->UT_ID = '0';
     $utvalg->UT_KODE = 'UKT';
     $utvalg->UT_NAVN = 'UKJENT UTVALG';
     $utvalg->UT_ADMID = '0';
     $utvalg->UT_MONUMSER = "0";
     $this->logger->log($this->XMLfilename, "UT.ID with value 0 added to handle UTVMOTE where UTVID is null", Constants::LOG_WARNING);
     $this->warningIssued = true;
     $this->writeToDestination($utvalg);
     while ($result = $this->srcBase->getQueryResult($this->selectQuery)) {
         $utvalg = new Utvalg();
         $utvalg->UT_ID = $result['ID'];
         $utvalg->UT_KODE = $result['UTV'];
         $utvalg->UT_NAVN = $result['UTVALG'];
         $utvalg->UT_ADMID = '0';
         $this->logger->log($this->XMLfilename, "For UT.ID (" . $result['ID'] . "), UT_ADMID has no value, not in table. Setting to 0", Constants::LOG_WARNING);
         $this->warningIssued = true;
         $utvalg->UT_ARKDEL = $result['FYSARK'];
         if ($result['FUNKTIL'] != null) {
             $utvalg->UT_NEDLAGT = Utility::fixDateFormat($result['FUNKTIL']);
         }
         $utvalg->UT_MONUMSER = "0";
         $this->logger->log($this->XMLfilename, "NUMSER foreign key relationship missing. MONUMSER required value. Added  MONUMSER  value  = 0", Constants::LOG_ERROR);
         $this->errorIssued = true;
         $this->writeToDestination($utvalg);
     }
     $this->srcBase->endQuery($this->selectQuery);
 }