Example #1
0
function verify_credentials($tmhOAuth)
{
    $tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token'];
    $tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret'];
    $code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials'));
    if ($code == 200) {
        echo $tmhOAuth->response['response'];
    } else {
        outputError($tmhOAuth);
    }
}
Example #2
0
function verify_credentials($tmhOAuth)
{
    $tmhOAuth->config['user_token'] = $_SESSION['access_token']['oauth_token'];
    $tmhOAuth->config['user_secret'] = $_SESSION['access_token']['oauth_token_secret'];
    $code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials'));
    if ($code == 200) {
        $resp = json_decode($tmhOAuth->response['response']);
        echo '<h1>Hello ' . $resp->screen_name . '</h1>';
        echo '<p>The access level of this token is: ' . $tmhOAuth->response['headers']['x_access_level'] . '</p>';
    } else {
        outputError($tmhOAuth);
    }
}
 protected function callApi($url, array $save, array $customFields, array $rename = array())
 {
     $data = file_get_contents($url);
     $issuesData = array();
     if (empty($data)) {
         outputError('No data returned from: ' . $redmineUrl);
         outputError('Full request: ' . $url);
         return $issuesData;
     }
     // save issues data
     $d = new \SimpleXMLElement($data);
     foreach ($d->issue as $issue) {
         $issueCopy = array();
         foreach ($save as $key => $opt) {
             if (is_array($opt)) {
                 if (isset($issue->{$key})) {
                     foreach ($issue->{$key}->attributes() as $attr => $val) {
                         if (in_array($attr, $opt)) {
                             $fieldName = !empty($rename[$key . '_' . $attr]) ? $rename[$key . '_' . $attr] : $key . '_' . $attr;
                             $issueCopy[$fieldName] = (string) $val;
                         }
                     }
                 }
             } else {
                 $fieldName = !empty($rename[$key]) ? $rename[$key] : $key;
                 $issueCopy[$fieldName] = (string) $issue->{$key};
             }
         }
         foreach ($issue->custom_fields->custom_field as $customField) {
             foreach ($customField->attributes() as $attr => $val) {
                 if ('id' === $attr) {
                     $val = (string) $val;
                     if (isset($customFields[$val])) {
                         $issueCopy[$customFields[$val]] = (string) $customField->value;
                     }
                 }
             }
         }
         $issuesData[] = $issueCopy;
     }
     $t = (int) $d['total_count'];
     $o = (int) $d['offset'];
     $l = (int) $d['limit'];
     if ($t > $o + $l) {
         $url .= '&offset=' . ($o + $l);
         $issuesData = array_merge($issuesData, $this->callApi($url, $save, $customFields, $rename));
     }
     return $issuesData;
 }
Example #4
0
                outputJSON(array('status' => 'success', 'message' => 'User logged in'));
            }
        } catch (PasswordIncorrectException $e) {
            outputError($e->getMessage(), $e->getCode());
        }
    } catch (UserNotFoundException $e) {
        outputError($e->getMessage(), $e->getCode());
    }
});
$app->get('/auth/current', function () {
    $user = User::getLoggedInUser();
    //    print_r($user);
    if ($user) {
        outputJSON($user);
    } else {
        outputError('Not logged in', 100);
    }
});
$app->get('/auth/logout', function () {
    User::logout();
    outputJSON(array('status' => 'success'));
});
$app->post('/upload/image', function () use($app) {
    // Setup file storage
    $file_storage = new \Upload\Storage\FileSystem("../assets/images");
    $file = new Upload\File("file", $file_storage);
    $file->addValidations(array(new Upload\Validation\Mimetype(array('image/png', 'image/gif', 'image/jpeg', 'video/JPEG', 'video/jpeg2000'))));
    $file->setName(uniqid());
    try {
        // Success!
        $file->upload();
Example #5
0
        $XeroOAuth->config['access_token'] = $_SESSION['oauth']['oauth_token'];
        $XeroOAuth->config['access_token_secret'] = $_SESSION['oauth']['oauth_token_secret'];
        $code = $XeroOAuth->request('GET', $XeroOAuth->url('AccessToken', ''), array('oauth_verifier' => $_REQUEST['oauth_verifier'], 'oauth_token' => $_REQUEST['oauth_token']));
        if ($XeroOAuth->response['code'] == 200) {
            $response = $XeroOAuth->extract_params($XeroOAuth->response['response']);
            $session = persistSession($response);
            unset($_SESSION['oauth']);
            header("Location: {$here}");
        } else {
            outputError($XeroOAuth);
        }
        // start the OAuth dance
    } elseif (isset($_REQUEST['authenticate']) || isset($_REQUEST['authorize'])) {
        $params = array('oauth_callback' => OAUTH_CALLBACK);
        $response = $XeroOAuth->request('GET', $XeroOAuth->url('RequestToken', ''), $params);
        if ($XeroOAuth->response['code'] == 200) {
            $scope = "";
            // $scope = 'payroll.payrollcalendars,payroll.superfunds,payroll.payruns,payroll.payslip,payroll.employees,payroll.TaxDeclaration';
            if ($_REQUEST['authenticate'] > 1) {
                $scope = 'payroll.employees,payroll.payruns';
            }
            print_r($XeroOAuth->extract_params($XeroOAuth->response['response']));
            $_SESSION['oauth'] = $XeroOAuth->extract_params($XeroOAuth->response['response']);
            $authurl = $XeroOAuth->url("Authorize", '') . "?oauth_token={$_SESSION['oauth']['oauth_token']}&scope=" . $scope;
            echo '<p>To complete the OAuth flow follow this URL: <a href="' . $authurl . '">' . $authurl . '</a></p>';
        } else {
            outputError($XeroOAuth);
        }
    }
    testLinks();
}
Example #6
0
    $params = ['oauth_callback' => $callback];
    if (isset($_REQUEST['force_write'])) {
        $params['x_auth_access_type'] = 'write';
    } elseif (isset($_REQUEST['force_read'])) {
        $params['x_auth_access_type'] = 'read';
    }
    $code = $tmhOAuth->request('POST', $tmhOAuth->url('oauth/request_token', ''), $params);
    if ($code == 200) {
        $_SESSION['oauth'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
        $method = isset($_REQUEST['authenticate']) ? 'authenticate' : 'authorize';
        $force = isset($_REQUEST['force']) ? '&force_login=1' : '';
        $authurl = $tmhOAuth->url("oauth/{$method}", '') . "?oauth_token={$_SESSION['oauth']['oauth_token']}{$force}";
        $oPage->Redirect($authurl);
        exit;
    } else {
        outputError($tmhOAuth);
    }
}
$oPage->Redirect('index.php');
/*
  <ul>
  <li><a href="?authenticate=1">Sign in with Twitter</a></li>
  <li><a href="?authenticate=1&amp;force=1">Sign in with Twitter (force login)</a></li>
  <li><a href="?authorize=1">Authorize Application (with callback)</a></li>
  <li><a href="?authorize=1&amp;oob=1">Authorize Application (oob - pincode flow)</a></li>
  <li><a href="?authorize=1&amp;force_read=1">Authorize Application (with callback) (force read-only permissions)</a></li>
  <li><a href="?authorize=1&amp;force_write=1">Authorize Application (with callback) (force read-write permissions)</a></li>
  <li><a href="?authorize=1&amp;force=1">Authorize Application (with callback) (force login)</a></li>
  <li><a href="?wipe=1">Start Over and delete stored tokens</a></li>
  </ul>
*/
Example #7
0
 /**
  * 
  * 返回用户是否收藏商户信息
  * data 0 (string): 没收藏
  * 		1 :收藏
  */
 public function isFavoritedShop_get()
 {
     $uid = $this->get('uid');
     $shopId = $this->get('shopId');
     //
     if (empty($uid) || empty($shopId)) {
         return outputError(-1, '没有用户信息或商户信息');
     }
     $result = $this->isShopFavorited($uid, $shopId);
     if ($result == false) {
         return output_success_response('0');
     } else {
         return output_success_response('1');
     }
 }
Example #8
0
 public function myFavoritedShop_delete()
 {
     $uid = $this->get('uid');
     $shopId = $this->get('shopId');
     $sessionToken = $this->get('sessionToken');
     if (empty($uid) || empty($shopId) || empty($sessionToken)) {
         return outputError(-1, '没有用户信息或商户信息');
     }
     //		$json = $this->kq->removePointerInArrayForUser($uid,$sessionToken,'favoritedShops',avosPointer('Shop',$shopId));
     $result = $this->my_m->remove_my_favorited_shop($uid, $sessionToken, $shopId);
     return $this->output_results($result);
 }
Example #9
0
 function ExecuteOrderCommand($order, $command, $comments, $carrierData, $tracking, $sendEmail)
 {
     try {
         // to change statuses, we need to unhold if necessary
         if ($order->canUnhold()) {
             $order->unhold();
             $order->save();
         }
         switch (strtolower($command)) {
             case "complete":
                 $this->CompleteOrder($order, $comments, $carrierData, $tracking, $sendEmail);
                 break;
             case "cancel":
                 $order->cancel();
                 $order->addStatusToHistory($order->getStatus(), $comments);
                 $order->save();
                 break;
             case "hold":
                 $order->hold();
                 $order->addStatusToHistory($order->getStatus(), $comments);
                 $order->save();
                 break;
             default:
                 outputError(80, "Unknown order command '{$command}'.");
                 break;
         }
         $this->writeStartTag("Debug");
         $this->writeElement("OrderStatus", $order->getStatus());
         $this->writeCloseTag("Debug");
     } catch (Exception $ex) {
         $this->outputError(90, "Error Executing Command. " . $ex->getMessage());
     }
 }
Example #10
0
function verify_credentials($tmhOAuth, $id)
{
    $m = new Mongo();
    $user = $m->circular->users->findOne(array('_id' => new MongoId($id)));
    $tmhOAuth->config['user_token'] = $user['user_token'];
    $tmhOAuth->config['user_secret'] = $user['user_secret'];
    $code = $tmhOAuth->request('GET', $tmhOAuth->url('1/account/verify_credentials'));
    if ($code == 200) {
        $response = json_decode($tmhOAuth->response['response']);
        $_SESSION['account']['users'][$id] = array('user_id' => $response->id, 'user_screen_name' => $response->screen_name, 'profile_image_url' => $response->profile_image_url, 'name' => $response->name, 'id' => $id);
    } else {
        outputError($tmhOAuth);
    }
}
function Action_UpdateStatus()
{
    // get parameters
    $order = isset($_REQUEST['order']) ? $_REQUEST['order'] : '';
    $status = isset($_REQUEST['status']) ? $_REQUEST['status'] : '';
    $comments = isset($_REQUEST['comments']) ? $_REQUEST['comments'] : '';
    // return success
    // writeStartTag('UpdateSuccess');
    // writeCloseTag('UpdateSuccess');
    // return error
    $error_msg = 'This is all your fault! order: ' . $order . ' status: ' . $status . ' comments: ' . $comments;
    outputError('FOO100', $error_msg);
}
Example #12
0
                    imagecopyresampled($newImage, $loadedImage, 0, 0, $start_x, $start_y, $width, $height, $crop_width, $crop_height);
                    break;
            }
            // save to cache folder
            imagejpeg($newImage, $cacheDir . $cacheFile, $imageQuality);
            // display it
            outputImage($cacheDir . $cacheFile);
        } else {
            outputError($maxWidth, $maxHeight, 'Image format not supported.');
        }
    } else {
        // have cached version, display it!
        outputImage($cacheDir . $cacheFile);
    }
} else {
    outputError($maxWidth, $maxHeight, 'No Image Available');
}
##############################################################################
##############################################################################
function outputError($width, $height, $errorMsg)
{
    if (empty($width)) {
        $width = $height;
    }
    if (empty($height)) {
        $height = $width;
    }
    if (empty($width)) {
        $width = 160;
        $height = 53;
    }
Example #13
0
function retune($tracking)
{
    $db = new AutotuneDb();
    if (!$db->validTracking($tracking)) {
        // return error for invalid tracking
        return outputError("1005");
    }
    $newTracking = $db->duplicate($tracking);
    $pos = $db->getQueuePosition($newTracking);
    return outputNewTracking($newTracking, $pos);
}
Example #14
0
    if ($_REQUEST['do'] == 'hide') {
        //hide thank
        $vbulletin->input->clean_array_gpc('r', array('id' => TYPE_UINT));
        $userid = $vbulletin->GPC['id'];
        $records = fetchAwarded($postinfo['postid'], true, false, $userid);
        if (!($userid > 0)) {
            //outputError($vbphrase['kbank_award_mes_noperm']);
            print_no_permission();
        }
        if ($records[$userid]['points'] != 0 and $vbulletin->userinfo['canRemoveAwarded']) {
            //permission is ok
            //trying to hide thank
            $vbulletin->db->query("\n\t\t\t\tUPDATE `" . TABLE_PREFIX . $vbulletin->kbank['donations'] . "`\n\t\t\t\tSET \n\t\t\t\t\t#time = " . TIMENOW . "\n\t\t\t\t\tpostid = 0\n\t\t\t\tWHERE postid = {$postinfo['postid']} AND `from` = {$userid}\n\t\t\t");
            $affected_rows = $vbulletin->db->affected_rows();
            if ($affected_rows > 0) {
                //hide complete
                $vbulletin->db->query("\n\t\t\t\t\tUPDATE `" . TABLE_PREFIX . "user`\n\t\t\t\t\tSET \n\t\t\t\t\t\t{$vbulletin->kbank['award']['thanksenttimes']} = {$vbulletin->kbank['award']['thanksenttimes']} - {$affected_rows}\n\t\t\t\t\t\t, {$vbulletin->kbank['award']['thanksentamount']} = {$vbulletin->kbank['award']['thanksentamount']} - {$records[$userid]['points']}\n\t\t\t\t\tWHERE userid = {$userid}\n\t\t\t\t");
                $vbulletin->db->query("\n\t\t\t\t\tUPDATE `" . TABLE_PREFIX . "user`\n\t\t\t\t\tSET \n\t\t\t\t\t\t{$vbulletin->kbank['award']['thankreceivedtimes']} = {$vbulletin->kbank['award']['thankreceivedtimes']} - {$affected_rows}\n\t\t\t\t\t\t, {$vbulletin->kbank['award']['thankreceivedamount']} = {$vbulletin->kbank['award']['thankreceivedamount']} - {$records[$userid]['points']}\n\t\t\t\t\tWHERE userid = {$postinfo['userid']}\n\t\t\t\t");
                $messages[] = $vbphrase['kbank_award_hide_Done'];
                output($postinfo['postid'], implode('</br>', $messages));
            } else {
                outputError($vbphrase['kbank_award_mes_cantHide']);
            }
        } else {
            //no permission
            //outputError($vbphrase['kbank_award_mes_noperm']);
            print_no_permission();
        }
    }
}
print_no_permission();
Example #15
0
    if ($type == 'coord') {
        $x = $coord[0];
        $y = $coord[1];
        $z = $coord[2];
    }
    for ($i = 0; $i < count($kikaku_all); $i++) {
        //全件の現在地と企画との距離を算出
        $distance = pow($kikaku_all[$i]->coordinate[0] - $x, 2) + pow($kikaku_all[$i]->coordinate[1] - $y, 2) + pow($kikaku_all[$i]->coordinate[2] - $z, 2);
        //二乗して距離取得
        $dist_all[$i] = $distance;
        //連想配列作成
    }
    asort($dist_all);
    //近い順に配列をソート→JSONの順番入れ替え
    $json_output = '[' . "\n";
    foreach ($dist_all as $key => $val) {
        //JSON出力
        $json_output .= json_encode($kikaku_all[$key], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
        if (!(end($dist_all) == $val)) {
            $json_output .= ",\n";
        }
        //最後の行にカンマを挿入しない
    }
    $json_output .= "\n" . ']';
    return $json_output;
}
try {
    echo getKikakuNearBy();
} catch (Exception $e) {
    echo outputError($e->getCode());
}