Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit b80c040

Browse files
committed
Add PHP Rapid Reseller Example
1 parent 0694c4f commit b80c040

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1805
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ settings_local.py
2323
*node_modules*
2424
apps/java/RapidReseller/war/static/css
2525
apps/java/RapidReseller/war/static/js
26+
apps/php/rapidreseller-php/static/css/app.css
27+
apps/php/rapidreseller-php/static/css/vendor.css
28+
apps/php/rapidreseller-php/static/js/app.compiled.js
29+
apps/php/rapidreseller-php/static/js/app.templates.js
30+
apps/php/rapidreseller-php/static/js/vendor.js
31+
settings_local.php

apps/php/rapidreseller-php/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
google-api-php-client
2+
privatekey.p12
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
module.exports = function(grunt) {
2+
grunt.initConfig({
3+
pkg: grunt.file.readJSON('package.json'),
4+
appDir: 'static',
5+
srcDir: 'src',
6+
bowerDir: 'bower_components',
7+
vendorDir: 'src/js/vendor',
8+
9+
assets: {
10+
css: {
11+
vendor: [
12+
'<%= bowerDir %>/bootstrap/dist/css/bootstrap.css',
13+
'<%= bowerDir %>/bootstrap/dist/css/bootstrap-theme.css'
14+
]
15+
},
16+
js: {
17+
vendor: [
18+
'<%= bowerDir %>/jquery/jquery.js',
19+
'<%= bowerDir %>/angular/angular.js',
20+
'<%= bowerDir %>/angular-route/angular-route.js',
21+
'<%= bowerDir %>/bootstrap/dist/js/bootstrap.js',
22+
'<%= bowerDir %>/angular-bootstrap/ui-bootstrap.js',
23+
'<%= bowerDir %>/angular-bootstrap/ui-bootstrap-tpls.js'
24+
]
25+
}
26+
},
27+
28+
concat: {
29+
vendor: {
30+
files: {
31+
'<%= appDir %>/css/vendor.css': [
32+
'<%= assets.css.vendor %>'
33+
],
34+
'<%= appDir %>/js/vendor.js': [
35+
'<%= assets.js.vendor %>'
36+
]
37+
}
38+
},
39+
app: {
40+
files: {
41+
'<%= appDir %>/js/app.compiled.js': [
42+
'<%= srcDir %>/js/app.js',
43+
'<%= srcDir %>/js/routes.js',
44+
'<%= srcDir %>/js/modules/*.js',
45+
'<%= srcDir %>/js/config/*.js',
46+
'<%= srcDir %>/js/controllers/*.js',
47+
'<%= srcDir %>/js/directives/*.js',
48+
'<%= srcDir %>/js/filters/*.js',
49+
'<%= srcDir %>/js/services/*.js',
50+
'<%= ngtemplates.app.dest %>'
51+
],
52+
'<%= appDir %>/css/app.css': [
53+
'<%= srcDir %>/css/*.css'
54+
]
55+
}
56+
}
57+
},
58+
59+
clean: {
60+
dev: [
61+
'<%= appDir %>/js/app.compiled.js',
62+
'<%= appDir %>/js/app.templates.js'
63+
],
64+
all: [
65+
'<%= appDir %>/js/*',
66+
'<%= appDir %>/css/*'
67+
]
68+
},
69+
70+
karma: {
71+
unit: {
72+
options: {
73+
frameworks: ['jasmine'],
74+
files: [
75+
'<%= appDir %>/js/vendor.js',
76+
'<%= bowerDir %>/angular-mocks/angular-mocks.js',
77+
'<%= appDir %>/js/app.compiled.js',
78+
'<%= appDir %>/js/app.templates.js',
79+
'<%= srcDir %>/js/test/*.js'
80+
],
81+
browsers: ['PhantomJS'],
82+
reporters: ['dots'],
83+
runnerPort: 9999,
84+
autoWatch: true
85+
}
86+
}
87+
},
88+
89+
ngmin: {
90+
app: {
91+
src: '<%= appDir %>/js/app.compiled.js',
92+
dest: '<%= appDir %>/js/app.compiled.js'
93+
},
94+
vendor: {
95+
src: '<%= appDir %>/js/vendor.js',
96+
dest: '<%= appDir %>/js/vendor.js'
97+
}
98+
},
99+
100+
// uglify js for production
101+
uglify: {
102+
default: {
103+
files: {
104+
'<%= appDir %>/js/app.compiled.js': [
105+
'<%= appDir %>/js/app.compiled.js'
106+
],
107+
'<%= appDir %>/js/vendor.js': [
108+
'<%= appDir %>/js/vendor.js'
109+
]
110+
}
111+
}
112+
},
113+
114+
ngtemplates: {
115+
app: {
116+
cwd: '<%= srcDir %>/',
117+
src: 'partials/*.html',
118+
dest: '<%= appDir %>/js/app.templates.js',
119+
options: {
120+
module: '<%= pkg.name %>',
121+
htmlmin: {
122+
collapseWhitespace: true,
123+
collapseBooleanAttributes: true
124+
}
125+
}
126+
}
127+
},
128+
129+
watch: {
130+
scripts: {
131+
files: [
132+
'<%= srcDir %>/js/**',
133+
'<%= srcDir %>/js/*',
134+
'<%= srcDir %>/partials/*'
135+
],
136+
tasks: [
137+
'build:dev'
138+
]
139+
}
140+
},
141+
142+
build: {
143+
dev: {},
144+
prod: {},
145+
all: {}
146+
}
147+
148+
});
149+
150+
// load grunt npm modules
151+
grunt.loadNpmTasks('grunt-contrib-clean');
152+
grunt.loadNpmTasks('grunt-contrib-copy');
153+
grunt.loadNpmTasks('grunt-contrib-concat');
154+
grunt.loadNpmTasks('grunt-contrib-uglify');
155+
grunt.loadNpmTasks('grunt-contrib-watch');
156+
grunt.loadNpmTasks('grunt-ngmin');
157+
grunt.loadNpmTasks('grunt-karma');
158+
grunt.loadNpmTasks('grunt-angular-templates');
159+
160+
grunt.registerTask('dev', [
161+
'build:dev',
162+
'watch'
163+
]);
164+
165+
grunt.registerTask('test', [
166+
'build:dev',
167+
'karma:unit'
168+
]);
169+
170+
// task for building main index page based on environment
171+
grunt.registerMultiTask('build', 'Build the app', function() {
172+
grunt.task.run('clean:dev');
173+
grunt.task.run('ngtemplates');
174+
grunt.task.run('concat:app');
175+
176+
if (this.target == 'all' || this.target == 'prod') {
177+
grunt.task.run('concat:vendor');
178+
grunt.task.run('ngmin');
179+
} else {
180+
grunt.task.run('ngmin:app');
181+
}
182+
183+
if (this.target == 'prod') {
184+
grunt.task.run('uglify');
185+
}
186+
187+
});
188+
189+
};
190+

apps/php/rapidreseller-php/app.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
require_once "controllers.php";
4+
5+
class Application {
6+
/**
7+
This is a very simple attempt to emulate Python's webapp2.
8+
9+
This code should be used as an example,
10+
and should not under any circumstances be used in production.
11+
**/
12+
13+
protected $_ROUTES = array();
14+
15+
function __construct($routes = array()) {
16+
$this->_ROUTES = $routes;
17+
}
18+
19+
function run() {
20+
foreach($this->_ROUTES as $path => $controller) {
21+
if(preg_match($path, $_SERVER['PATH_INFO'])) {
22+
$controller = new $controller;
23+
$controller->_SERVER = $_SERVER;
24+
$controller->_SESSION = $_SESSION;
25+
$controller->_REQUEST = $_REQUEST;
26+
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
27+
$result = call_user_func(array($controller, $request_method));
28+
if(is_array($result)) {
29+
header("Content-type: application/json");
30+
print json_encode($result);
31+
}
32+
exit();
33+
}
34+
}
35+
}
36+
}
37+
38+
class RequestHandler {
39+
public $_SERVER = array();
40+
public $_SESSION = array();
41+
public $_REQUEST = array();
42+
43+
private $_raw_body = "";
44+
protected $json_data = array();
45+
46+
function __construct() {
47+
$this->_raw_body = @file_get_contents("php://input");
48+
$this->json_data = json_decode($this->_raw_body, true);
49+
//print_r($this->json_data);
50+
}
51+
52+
function get() {}
53+
54+
function post() {}
55+
56+
function redirect($loc) {
57+
header("Location: ". $loc);
58+
exit();
59+
}
60+
61+
}
62+
?>

apps/php/rapidreseller-php/app.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
application: rapidreseller-php
2+
version: 1
3+
runtime: php
4+
api_version: 1
5+
threadsafe: yes
6+
7+
handlers:
8+
- url: /static
9+
static_dir: static
10+
secure: always
11+
12+
- url: /favicon\.ico
13+
static_files: favicon.ico
14+
upload: favicon\.ico
15+
16+
- url: /transfer
17+
script: transfer.php
18+
19+
- url: .*
20+
script: main.php
21+

apps/php/rapidreseller-php/bower.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "Rapid Reseller",
3+
"description": "Rapid Reseller",
4+
"version": "1.0.0",
5+
"dependencies": {
6+
"angular": "~1.2.8",
7+
"angular-route": "~1.2.8",
8+
"angular-mocks": "~1.2.10",
9+
"bootstrap": "~3.0.3",
10+
"angular-bootstrap": "~0.10.0",
11+
"jquery": "~2.1.0"
12+
}
13+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
class ResellerProduct {
4+
const GoogleApps = "Google-Apps";
5+
const GoogleDrive = "Google-Drive-storage";
6+
const GoogleVault = "Google-Vault";
7+
}
8+
9+
class ResellerSKU {
10+
const GoogleApps = "Google-Apps-For-Business";
11+
const GoogleDriveStorage20GB = "Google-Drive-storage-20GB";
12+
const GoogleDriveStorage50GB = "Google-Drive-storage-50GB";
13+
const GoogleDriveStorage200GB = "Google-Drive-storage-200GB";
14+
const GoogleDriveStorage400GB = "Google-Drive-storage-400GB";
15+
const GoogleDriveStorage1TB = "Google-Drive-storage-1TB";
16+
const GoogleDriveStorage2TB = "Google-Drive-storage-2TB";
17+
const GoogleDriveStorage4TB = "Google-Drive-storage-4TB";
18+
const GoogleDriveStorage8TB = "Google-Drive-storage-8TB";
19+
const GoogleDriveStorage16TB = "Google-Drive-storage-16TB";
20+
const GoogleVault = "Google-Vault";
21+
}
22+
23+
class ResellerPlanName {
24+
// Annual plan
25+
const ANNUAL = "ANNUAL";
26+
27+
// Month-to-month plan
28+
const FLEXIBLE = "FLEXIBLE";
29+
30+
// Trial plan.
31+
const TRIAL = "TRIAL";
32+
}
33+
34+
class ResellerDeletionType {
35+
const Cancel = "cancel";
36+
const Downgrade = "downgrade";
37+
const Suspend = "suspend";
38+
}
39+
40+
class ResellerRenewalType {
41+
// automatically renew for the same license count purchased.
42+
const AUTO_RENEW_MONTHLY = "AUTO_RENEW_MONTHLY_PAY";
43+
const AUTO_RENEW_YEARLY = "AUTO_RENEW_YEARLY_PAY";
44+
45+
// automatically renew for the current user count (for better or worse)
46+
const RENEW_CURRENT_USERS_MONTHLY = "RENEW_CURRENT_USERS_MONTHLY_PAY";
47+
const RENEW_CURRENT_USERS_YEARLY = "RENEW_CURRENT_USERS_YEARLY_PAY";
48+
49+
// at the renewal date, switch to a "FLEXIBLE" plan type,
50+
// which is billed on a monthly basis.
51+
// This is only relevant when adjusting an annual plan.
52+
const PAY_AS_YOU_GO = "SWITCH_TO_PAY_AS_YOU_GO";
53+
54+
// at the renewal date, cancel the subscription
55+
const CANCEL = "CANCEL";
56+
}
57+
58+
?>

0 commit comments

Comments
 (0)