about summary refs log tree commit diff stats
path: root/series/core
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2008-09-06 21:14:00 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-09-06 21:14:00 +0000
commitaa716b0b246bb9efa678dae48c1e36a315b5e3e4 (patch)
treeb9683d8039760ba243d2fe92214c43426a06ead8 /series/core
parent73ed91f80e62592d7aa86000ef30e06946be7c68 (diff)
downloadinstadisc-aa716b0b246bb9efa678dae48c1e36a315b5e3e4.tar.gz
instadisc-aa716b0b246bb9efa678dae48c1e36a315b5e3e4.tar.bz2
instadisc-aa716b0b246bb9efa678dae48c1e36a315b5e3e4.zip
Series: Started work on Series Control
Refs #28
Diffstat (limited to 'series/core')
-rw-r--r--series/core/trunk/includes/db.php23
-rw-r--r--series/core/trunk/includes/instadisc.php43
-rw-r--r--series/core/trunk/includes/template.php160
-rw-r--r--series/core/trunk/index.php22
-rw-r--r--series/core/trunk/install.php5
-rw-r--r--series/core/trunk/subscription.php30
-rw-r--r--series/core/trunk/theme/index.tpl7
-rw-r--r--series/core/trunk/xmlrpc.php25
8 files changed, 315 insertions, 0 deletions
diff --git a/series/core/trunk/includes/db.php b/series/core/trunk/includes/db.php new file mode 100644 index 0000000..6c08708 --- /dev/null +++ b/series/core/trunk/includes/db.php
@@ -0,0 +1,23 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5if (!file_exists('includes/config.php'))
6{
7 header('Location: install.php');
8 exit;
9}
10
11if (file_exists('install.php'))
12{
13 die('Excuse me, but you need to delete install.php before you can use this as leaving install.php there is a biiiig security hole.');
14}
15
16session_start();
17
18include('includes/config.php');
19
20mysql_connect($dbhost, $dbuser, $dbpass);
21mysql_select_db($dbname);
22
23?>
diff --git a/series/core/trunk/includes/instadisc.php b/series/core/trunk/includes/instadisc.php new file mode 100644 index 0000000..f67ce44 --- /dev/null +++ b/series/core/trunk/includes/instadisc.php
@@ -0,0 +1,43 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5include('includes/db.php');
6include('includes/template.php');
7
8function instaDisc_subscriptionExists($id)
9{
10 $getsub = "SELECT * FROM subscriptions WHERE identity = \"" . mysql_real_escape_string($id) . "\"";
11 $getsub2 = mysql_query($getsub);
12 $getsub3 = mysql_fetch_array($getsub2);
13 if ($getsub3['identity'] != $id)
14 {
15 return 'false';
16 } else {
17 return 'true';
18 }
19}
20
21function instaDisc_getSubscription($id)
22{
23 $getsub = "SELECT * FROM subscriptions WHERE identity = \"" . mysql_real_escape_string($id) . "\"";
24 $getsub2 = mysql_query($getsub);
25 $getsub3 = mysql_fetch_array($getsub2);
26
27 return $getsub3;
28}
29
30function instaDisc_getAllSubscriptions()
31{
32 $getsubs = "SELECT * FROM subscriptions";
33 $getsubs2 = mysql_query($getsubs);
34 $i=0;
35 while ($getsubs3[$i] = mysql_fetch_array($getsubs2))
36 {
37 $i++;
38 }
39
40 return $getsubs3;
41}
42
43?>
diff --git a/series/core/trunk/includes/template.php b/series/core/trunk/includes/template.php new file mode 100644 index 0000000..b4ec16b --- /dev/null +++ b/series/core/trunk/includes/template.php
@@ -0,0 +1,160 @@
1<?php
2/*
3 444444444
4 4::::::::4
5 4:::::::::4
6 4::::44::::4
7 4::::4 4::::4 Four Island
8 4::::4 4::::4
9 4::::4 4::::4 Written and maintained by Starla Insigna
104::::444444::::444
114::::::::::::::::4 includes/template.php
124444444444:::::444
13 4::::4 Please do not use, reproduce or steal the
14 4::::4 contents of this file without explicit
15 4::::4 permission from Hatkirby.
16 44::::::44
17 4::::::::4
18 4444444444
19*/
20
21class FITemplate
22{
23
24 var $file;
25 var $tags;
26 var $blocks;
27 var $refs;
28
29 function FITemplate($filename)
30 {
31 $tfn = 'theme/' . $filename . '.tpl';
32 if (file_exists($tfn))
33 {
34 $this->file = $tfn;
35 } else {
36 throw new Exception($tfn . ' does not exist');
37 }
38 }
39
40 function add($name, $value)
41 {
42 $this->tags[$name] = $value;
43 }
44
45 function adds($tagarr)
46 {
47 foreach ($tagarr as $name => $value)
48 {
49 $this->add($name,$value);
50 }
51 }
52
53 function adds_block($block, $tagarr)
54 {
55 if (!isset($this->blocks[$block]))
56 {
57 $this->blocks[$block] = array('count' => 1);
58 }
59 foreach ($tagarr as $name => $value)
60 {
61 $this->blocks[$block][$this->blocks[$block]['count']][$name] = $value;
62 }
63 $this->blocks[$block]['count']++;
64 }
65
66 function add_ref($id, $block, $tagarr)
67 {
68 $this->adds_block($block,$tagarr);
69 $this->refs[$id] = &$this->blocks[$block][$this->blocks[$block]['count']-1];//'$this->blocks[\'' . $block . '\'][' . ($this->blocks[$block]['count']-1) . ']';
70 }
71
72 function adds_ref($id, $tagarr)
73 {
74 foreach ($tagarr as $name => $value)
75 {
76 $this->refs[$id][$name] = $value;
77 }
78 }
79
80 function adds_ref_sub($id, $block, $tagarr)
81 {
82 if (!isset($this->refs[$id][$block]))
83 {
84 $this->refs[$id][$block] = array('count' => 1);
85 }
86 foreach ($tagarr as $name => $value)
87 {
88 $this->refs[$id][$block][$this->refs[$id][$block]['count']][$name] = $value;
89 }
90 $this->refs[$id][$block]['count']++;
91 }
92
93 function display()
94 {
95 $template = file_get_contents($this->file);
96 while (preg_match('/<!--INCLUDE ([^>]*)-->/',$template) == 1)
97 {
98 preg_match('/<!--INCLUDE ([^>]*)-->/',$template,$mat);
99 $fname = $mat[1];
100 $itmp = new FITemplate($fname);
101 $template = str_replace('<!--INCLUDE ' . $fname . '-->',file_get_contents($itmp->file),$template);
102 }
103 if (isset($this->tags))
104 {
105 foreach ($this->tags as $name => $value)
106 {
107 $template = str_replace('<!--' . $name . '-->',$value,$template);
108 }
109 }
110 if (isset($this->blocks))
111 {
112 foreach ($this->blocks as $bname => $block)
113 {
114 $this->parseBlock($template, $bname, $block);
115 }
116 }
117 while (preg_match('/<!--BEGIN ([^>]*)-->/',$template) == 1)
118 {
119 preg_match('/<!--BEGIN ([^>]*)-->/',$template,$mat);
120 $bname = $mat[1];
121 $start = strpos($template,'<!--BEGIN ' . $bname . '-->');
122 $end = strpos($template,'<!--END ' . $bname . '-->');
123 $template = str_replace(substr($template,$start,$end-$start+strlen($bname)+11),'',$template);
124 }
125 $template = preg_replace('/<!--([^>]*)-->/','',$template);
126 echo($template);
127 }
128
129 function parseBlock(&$template, $bname, $block)
130 {
131 while (strpos($template,'<!--BEGIN ' . $bname . '-->') !== FALSE)
132 {
133 $start = strpos($template,'<!--BEGIN ' . $bname . '-->');
134 $end = strpos($template,'<!--END ' . $bname . '-->');
135 $gencont = substr($template,$start+strlen($bname)+13,$end-$start-strlen($bname)-13);
136 $blockcont = '';
137 foreach ($block as $lname => $blocktags)
138 {
139 if ($lname != 'count')
140 {
141 $scrcont = $gencont;
142 foreach ($blocktags as $name => $value)
143 {
144 if (!is_array($value))
145 {
146 $scrcont = str_replace('<!--' . $bname . '.' . $name . '-->',$value,$scrcont);
147 } else {
148 $this->parseBlock($scrcont, $bname . '.' . $name, $value);
149 }
150 }
151 $blockcont .= $scrcont;
152 }
153 }
154 $template = str_replace(substr($template,$start,$end-$start+strlen($bname)+11),$blockcont,$template);
155 }
156 }
157
158}
159
160?>
diff --git a/series/core/trunk/index.php b/series/core/trunk/index.php new file mode 100644 index 0000000..7d3916c --- /dev/null +++ b/series/core/trunk/index.php
@@ -0,0 +1,22 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5include('includes/instadisc.php');
6
7$template = new FITemplate('index');
8
9$subs = instaDisc_getAllSubscriptions();
10foreach ($subs as $name => $value)
11{
12 if ($value['personal'] == 'false')
13 {
14 $template->adds_block('SUBSCRIPTION', array( 'IDENTITY' => $name,
15 'TITLE' => $value['title'],
16 'CATEGORY' => $value['category']));
17 }
18}
19
20$template->display();
21
22?>
diff --git a/series/core/trunk/install.php b/series/core/trunk/install.php new file mode 100644 index 0000000..3b3f202 --- /dev/null +++ b/series/core/trunk/install.php
@@ -0,0 +1,5 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5?>
diff --git a/series/core/trunk/subscription.php b/series/core/trunk/subscription.php new file mode 100644 index 0000000..172de32 --- /dev/null +++ b/series/core/trunk/subscription.php
@@ -0,0 +1,30 @@
1<?php
2
3/* InstaDisc Series - A Four Island Project */
4
5include('includes/instadisc.php');
6
7if (!isset($_GET['id']))
8{
9 header('Location: ./index.php');
10 exit;
11}
12
13if (!instaDisc_subscriptionExists($_GET['id']))
14{
15 header('Location: ./index.php');
16 exit;
17}
18
19$sub = instaDisc_getSubscription($_GET['id']);
20
21echo('Subscription: ' . $sub['url'] . "\n");
22echo('Title: ' . $sub['title'] . "\n");
23echo('Category: ' . $sub['category'] . "\n");
24
25if ($sub['password'] != '')
26{
27 echo("Password: On\n");
28}
29
30?>
diff --git a/series/core/trunk/theme/index.tpl b/series/core/trunk/theme/index.tpl new file mode 100644 index 0000000..6c22f3e --- /dev/null +++ b/series/core/trunk/theme/index.tpl
@@ -0,0 +1,7 @@
1<H1>Subscriptions Available</H1>
2
3<UL>
4 <!--BEGIN SUBSCRIPTIONS-->
5 <LI><A HREF="subscription.php?id=<!--SUBSCRIPTIONS.IDENTITY-->"><!--SUBSCRIPTIONS.IDENTITY--></A> - <!--SUBSCRIPTIONS.TITLE--> (<!--SUBSCRIPTIONS.CATEGORY-->)</LI>
6 <!--END SUBSCRIPTIONS-->
7</UL>
diff --git a/series/core/trunk/xmlrpc.php b/series/core/trunk/xmlrpc.php new file mode 100644 index 0000000..60ada6a --- /dev/null +++ b/series/core/trunk/xmlrpc.php
@@ -0,0 +1,25 @@
1<?php
2
3/* InstaDisc Series - A Four Project */
4
5include('includes/instadisc.php');
6
7function subscriptionInfo($id)
8{
9 if (!instaDisc_subscriptionExists($id))
10 {
11 return new xmlrpcresp(new xmlrpcval('false', 'string'));
12 }
13
14 $sub = instaDisc_getSubscription($id);
15 return serialize(array( 'url' => $sub['url'],
16 'category' => $sub['category']
17 ));
18}
19
20$s = new xmlrpc_server(array( "InstaDisc.subscriptionInfo" => array('function' => 'subscriptionInfo')
21 ), 0);
22$s->functions_parameters_type = 'phpvals';
23$s->service();
24
25?>