PageRenderTime 42ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/interfaces/index.php

https://gitlab.com/x33n/platform
PHP | 296 lines | 223 code | 38 blank | 35 comment | 26 complexity | b5545653714642ed004b3518b04ca019 MD5 | raw file
  1. <?php
  2. /**
  3. *
  4. * The main page publishing script for a CASH Music instance. Handles the main
  5. * public-facing pages, either the default service page or the user-published
  6. * pages (assumes user id = 1 for single-user instances, looks for a 'username')
  7. * GET parameter for multi-user instances.
  8. *
  9. * @package platform.org.cashmusic
  10. * @author CASH Music
  11. * @link http://cashmusic.org/
  12. *
  13. * Copyright (c) 2014, CASH Music
  14. * Licensed under the Affero General Public License version 3.
  15. * See http://www.gnu.org/licenses/agpl-3.0.html
  16. *
  17. **/
  18. /* SINGLE USER SUPPORT? UNCOMMENT
  19. * $user_id = 1; // we can assume 1 for single-user instances
  20. */
  21. $user_id = false;
  22. // if we've got a username we need to find the id — over-write no matter what. no fallback to user id 1
  23. if (isset($_GET['subdomain']) || isset($_GET['path'])) {
  24. require_once(__DIR__ . '/admin/constants.php');
  25. //error_log($_GET['subdomain'] . "\n" . $_GET['path'] . "\n" . print_r($_GET,true));
  26. if ($_GET['subdomain'] !== 'cashmusic.org' &&
  27. $_GET['subdomain'] !== 'x.cashmusic.org' &&
  28. $_GET['subdomain'] !== 'localhost.cashmusic.org' &&
  29. $_GET['subdomain'] !== 'testing.cashmusic.org' &&
  30. $_GET['subdomain'] !== 'staging.cashmusic.org' &&
  31. $_GET['subdomain'] !== 'air.cashmusic.org' &&
  32. SUBDOMAIN_USERNAMES
  33. ) {
  34. $username = explode('.', $_GET['subdomain']);
  35. $username = $username[0];
  36. } else {
  37. $username = explode('/', trim($_GET['path'],'/'));
  38. $username = $username[0];
  39. }
  40. if ($username) {
  41. // include the necessary bits, define the page directory
  42. // Define constants too
  43. $page_vars = array(); // setting up the array for page variables
  44. $page_vars['www_path'] = ADMIN_WWW_BASE_PATH;
  45. $page_vars['jquery_url'] = (defined('JQUERY_URL')) ? JQUERY_URL : ADMIN_WWW_BASE_PATH . '/ui/default/assets/scripts/jquery-1.8.2.min.js';
  46. $page_vars['cdn_url'] = (defined('CDN_URL')) ? CDN_URL : ADMIN_WWW_BASE_PATH;
  47. // launch CASH Music
  48. require_once($cashmusic_root);
  49. if (stripos($username,'/')) {
  50. $username = explode('/', $username);
  51. $username = $username[0];
  52. }
  53. $user_request = new CASHRequest(
  54. array(
  55. 'cash_request_type' => 'people',
  56. 'cash_action' => 'getuseridforusername',
  57. 'username' => $username
  58. )
  59. );
  60. if ($user_request->response['payload']) {
  61. $user_id = $user_request->response['payload'];
  62. } else {
  63. $user_id = false;
  64. }
  65. }
  66. }
  67. // error_log($user_id);
  68. // if we find a user check for a template and render one if found.
  69. if ($user_id) {
  70. $settings_request = new CASHRequest(
  71. array(
  72. 'cash_request_type' => 'system',
  73. 'cash_action' => 'getsettings',
  74. 'type' => 'public_profile_template',
  75. 'user_id' => $user_id
  76. )
  77. );
  78. if ($settings_request->response['payload']) {
  79. $template_id = $settings_request->response['payload'];
  80. } else {
  81. $template_id = false;
  82. }
  83. $template = false;
  84. if ($template_id) {
  85. $template_request = new CASHRequest(
  86. array(
  87. 'cash_request_type' => 'system',
  88. 'cash_action' => 'gettemplate',
  89. 'template_id' => $template_id,
  90. 'user_id' => $user_id
  91. )
  92. );
  93. $template = $template_request->response['payload'];
  94. }
  95. // with a real user but no template we redirect to the admin
  96. if ($template) {
  97. $element_embeds = false; // i know we don't technically need this, but the immaculate variable in preg_match_all freaks me out
  98. $found_elements = preg_match_all('/{{{element_(.*?)}}}/',$template,$element_embeds, PREG_PATTERN_ORDER);
  99. if ($found_elements) {
  100. foreach ($element_embeds[1] as $element_id) {
  101. ob_start();
  102. CASHSystem::embedElement($element_id);
  103. $page_vars['element_' . $element_id] = ob_get_contents();
  104. ob_end_clean();
  105. }
  106. }
  107. // render out the page itself
  108. echo CASHSystem::renderMustache($template,$page_vars);
  109. exit();
  110. } else {
  111. // redirect to the admin
  112. header('Location: ./admin/');
  113. }
  114. }
  115. /***************************************
  116. *
  117. * ADD PUBLIC PAGE BELOW CLOSING "?>"
  118. *
  119. ***************************************/
  120. ?>
  121. <!DOCTYPE html>
  122. <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
  123. <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
  124. <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
  125. <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
  126. <head>
  127. <meta charset="utf-8">
  128. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  129. <title>CASH Music</title>
  130. <meta name="description" content="The CASH Music platform is a set of digital tools designed to solve real problems for working musicians, based on years of direct collaboration with artists.">
  131. <meta name="viewport" content="width=device-width, initial-scale=1">
  132. <!--<link rel="stylesheet" href="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/css/front.css">-->
  133. <link rel="stylesheet" href="admin/ui/default/assets/css/front.css">
  134. <link href='//fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
  135. <!--facebook metadata-->
  136. <meta property="og:title" content="CASH Music - A nonprofit organization focused on educating and empowering artists and their fans to foster a viable and sustainable future for music."/>
  137. <meta property="og:url" content="http://www.cashmusic.org"/>
  138. <meta property="og:site_name" content="www.cashmusic.org" />
  139. <meta property="fb:admins" content="100001809157387" />
  140. <!--facebook metadata-->
  141. </head>
  142. <body>
  143. <div id="fb-root"></div>
  144. <script>(function(d, s, id) {
  145. var js, fjs = d.getElementsByTagName(s)[0];
  146. if (d.getElementById(id)) return;
  147. js = d.createElement(s); js.id = id;
  148. js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=137611429640196&version=v2.0";
  149. fjs.parentNode.insertBefore(js, fjs);
  150. }(document, 'script', 'facebook-jssdk'));</script>
  151. <!--[if lt IE 7]>
  152. <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  153. <![endif]-->
  154. <div class="menutoggle">Menu</div>
  155. <nav>
  156. <div class="social"><!--<iframe class="git" src="https://ghbtns.com/github-btn.html?user=cashmusic&repo=platform&type=fork"
  157. allowtransparency="true" frameborder="0" scrolling="0" width="62" height="20"></iframe>-->
  158. <a href="https://github.com/cashmusic/platform" target="_blank" class="git">Fork Us On Github</a>
  159. <a href="https://twitter.com/cashmusic" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @cashmusic</a>
  160. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script><div class="fb-like" data-href="https://www.facebook.com/cashmusic.org" data-width="75" data-layout="button" data-action="like" data-show-faces="true" data-share="false"></div></div><!--social-->
  161. <ul>
  162. <!--<li><a href="http://www.cashmusic.org">Home</a></li>-->
  163. <li><a href="http://about.cashmusic.org">About</a></li>
  164. <li><a href="https://medium.com/cash-music" target="_blank">Blog</a></li>
  165. <!--<li><a href="http://tools.cashmusic.org">Tools</a></li>
  166. <li><a href="http://learn.cashmusic.org">Learning</a></li>
  167. <li><a href="http://events.cashmusic.org">Events</a></li>-->
  168. <li><a href="http://donate.cashmusic.org">Donate</a></li>
  169. </ul>
  170. </nav>
  171. <div class="header-container">
  172. <h1 class="logo"><img src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/images/logo.svg" alt="CASH Music" /></h1>
  173. </div>
  174. <div class="main-container">
  175. <div class="main wrapper clearfix">
  176. <div class="panel first">
  177. <div class="inner">
  178. <h1>Get Started With CASH Music.</h1>
  179. <div class="examples">
  180. <!--<img src="images/examples/examples.gif" alt="examples"/> -->
  181. <!-- <iframe width="1280" height="720" src="//www.youtube.com/embed/YLS_WWYUQBg?&amp;vq=hd720&amp;modestbranding=1&amp;showinfo=0&amp;autoplay=1&amp;autohide=1&amp;color=white" autoplay="1" frameborder="0" allowfullscreen></iframe> -->
  182. <video autoplay loop>
  183. <source src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/video/phone.webm" type="video/webm">
  184. Sorry Your browser does not support the video tag.
  185. </video>
  186. </div>
  187. <h2>Manage your mailing list, sell your music, organize your digital world. The CASH Music platform is free to use, now and forever.</h2>
  188. <div class="action">
  189. <a class="singup btn" href="/admin/dosignup/">Sign up</a><!--signup--> <a class="login btn" href="/admin/">Login</a><!--login--></div><!--action-->
  190. </div><!--inner-->
  191. </div><!--panel-->
  192. <div class="panel made">
  193. <div class="inner">
  194. <!--<img src="/admin/admin/ui/default/assets/images/phone.png" alt="phone"/>-->
  195. <h1>Made For Musicians.</h1>
  196. <video class="phonevid" autoplay loop>
  197. <source src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/video/phone.mp4" type="video/mp4">
  198. <source src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/video/phone.webm" type="video/webm">
  199. Sorry Your browser does not support the video tag.
  200. </video>
  201. <h2>The CASH Music platform is a set of digital tools designed to solve real problems for working musicians, based on years of direct collaboration with artists.</h2>
  202. </div><!--inner-->
  203. </div><!--panel-->
  204. <div class="panel free">
  205. <img src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/images/free.jpg" alt="Free"/>
  206. <div class="inner">
  207. <h1>Free Forever.</h1>
  208. <h2>Our goal is to help build a sustainable future for music. Musicians are our partners, not our customers, and our platform will always be free to use.</h2>
  209. </div><!--inner-->
  210. </div><!--panel-->
  211. <div class="panel better">
  212. <img src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/images/blank.gif" alt="Getting Better"/>
  213. <div class="inner">
  214. <h1>Getting Better All the Time.</h1>
  215. <h2>CASH Music is an open source project, with a community of brilliant developers working every day to make it better.</h2>
  216. </div><!--inner-->
  217. </div><!--panel-->
  218. <div class="panel about">
  219. <div class="inner">
  220. <h1>About Us</h1>
  221. <h2>CASH Music is a <a href="https://medium.com/cash-music/the-organization-is-our-protest-song-1c9b01ea3ceb" target="_blank">nonprofit organization</a> focused on educating and empowering artists and their fans to foster a viable and sustainable future for music. We believe the best way to ensure a sustainable future for music is to invest in its creators.</h2>
  222. <script type="text/javascript" src="https://air.cashmusic.org/public/cashmusic.js"></script><script type="text/javascript"> window.cashmusic.embed('https://air.cashmusic.org/public/','12');</script>
  223. <p>Made possible with the support of:</p>
  224. <a class="shuttleworth" href="http://www.shuttleworthfoundation.org/" target="_blank"><img src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/images/shuttleworth.png" alt="Shuttleworth Foundation"/></a>
  225. <a class="mozilla" href="https://www.mozilla.org/" target="_blank"><img src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/images/mozilla.png" alt="Mozilla"/></a>
  226. <a class="mailchimp" href="http://www.mailchimp.com/" target="_blank"><img src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/images/mailchimp.png" alt="Mailchimp"/></a>
  227. <a class="rackspace" href="http://www.rackspace.com/" target="_blank"><img src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/images/rackspace.png" alt="Rackspace"/></a>
  228. <a class="maxcdn" href="http://www.maxcdn.com/" target="_blank"><img src="https://www-cashmusic.netdna-ssl.com/admin/ui/default/assets/images/maxcdn.png" alt="Max CDN"/></a>
  229. </div><!--inner-->
  230. </div><!--panel-->
  231. </div> <!-- #main -->
  232. </div> <!-- #main-container -->
  233. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  234. <script>
  235. $( document ).ready(function() {
  236. $( ".menutoggle" ).click(function() {
  237. if ( !$(".menutoggle").hasClass("show")){
  238. $(".menutoggle").addClass("show");
  239. $(".menutoggle").removeClass("hide");
  240. } else {
  241. if ( $(".menutoggle").hasClass("show")){
  242. $(".menutoggle").removeClass("show");
  243. $(".menutoggle").addClass("hide");
  244. }
  245. }
  246. $("body").toggleClass("show");
  247. });
  248. });
  249. // analytics
  250. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  251. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  252. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  253. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  254. ga('create', 'UA-55083593-1', 'auto');
  255. ga('send', 'pageview');
  256. </script>
  257. </body>
  258. </html>