1
+ <?php
2
+
3
+ /*
4
+ * Copyright (C) zdsr.com
5
+ */
6
+
7
+ !defined ('FRAMEWORK_PATH ' ) && exit ('FRAMEWORK_PATH not defined. ' );
8
+
9
+ include BBS_PATH .'control/common_control.class.php ' ;
10
+
11
+ class open_control extends common_control {
12
+
13
+ function __construct (&$ conf ) {
14
+ parent ::__construct ($ conf );
15
+ $ this ->_title [] = ($ this ->conf ['seo_title ' ] ? $ this ->conf ['seo_title ' ] : $ this ->conf ['app_name ' ]) . '开放平台 ' ;
16
+ //$this->_seo_keywords = $this->conf['seo_keywords'];
17
+ //$this->_seo_description = $this->conf['seo_description'];
18
+ }
19
+
20
+ public function on_index () {
21
+ $ applist = $ this ->open_app ->get_applist ();
22
+ foreach ($ applist as &$ app ) {
23
+ $ this ->open_app ->format ($ app );
24
+ }
25
+ $ this ->format == "json " && $ this ->json ($ applist );
26
+ $ this ->view ->assign ("applist " ,$ applist );
27
+ $ this ->view ->display ("open_index.htm " );
28
+ }
29
+
30
+ public function on_view () {
31
+ $ aid = core::gpc ("aid " );
32
+ $ app = $ this ->open_app ->read ($ aid );
33
+ $ this ->format == "json " && $ this ->json ($ app );
34
+ $ this ->view ->assign ("app " ,$ app );
35
+ $ this ->view ->display ("open_view.htm " );
36
+ }
37
+
38
+ public function on_create () {
39
+ $ this ->check_login ();
40
+ if ($ this ->form_submit ()) {
41
+ $ error = array ();
42
+ $ name = core::gpc ("name " ,"P " );
43
+ $ screenname = core::gpc ("screenname " ,"P " );
44
+ $ error ['name ' ] = $ this ->open_app ->check_name_exists ($ name );
45
+ $ error ['screenname ' ] = $ this ->open_app ->check_screenname_exists ($ screenname );
46
+ if (array_filter ($ error )) $ this ->message ($ error );
47
+ $ description = core::gpc ("description " ,"P " );
48
+ $ type = core::gpc ("type " ,"P " );
49
+ $ created = time ();
50
+ $ modified = time ();
51
+ $ appkey = $ this ->open_app ->generate_appkey ();
52
+ $ seckey = $ this ->open_app ->generate_seckey ();
53
+ $ arr = array (
54
+ 'uid ' =>$ this ->_user ['uid ' ],
55
+ 'username ' =>$ this ->_user ['username ' ],
56
+ 'created ' =>$ created ,
57
+ 'modified ' =>$ modified ,
58
+ 'name ' =>$ name ,
59
+ 'screenname ' =>$ screenname ,
60
+ 'type ' =>$ type ,
61
+ 'description ' =>$ description ,
62
+ 'appkey ' =>$ appkey ,
63
+ 'seckey ' =>$ seckey ,
64
+ 'verify ' =>0
65
+ );
66
+ $ aid = $ this ->open_app ->create ($ arr );
67
+ $ this ->message ("应用创建完成。 " ,1 ,"?open-index.htm " );
68
+ }
69
+ array_unshift ($ this ->_title ,'创建新应用 ' );
70
+ $ this ->view ->display ("open_create.htm " );
71
+ }
72
+ //end class
73
+ }
74
+ ?>
0 commit comments