Example #1
0
 /**
  * App constructor.
  */
 public static function init()
 {
     // we'll reset this after we read our config file
     date_default_timezone_set('UTC');
     self::$config = array('system' => array());
     self::$page = array();
     self::$pager = array();
     self::$query_string = '';
     startup();
     set_include_path('include' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'library/langdet' . PATH_SEPARATOR . '.');
     self::$scheme = 'http';
     if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
         self::$scheme = 'https';
     } elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) {
         self::$scheme = 'https';
     }
     if (x($_SERVER, 'SERVER_NAME')) {
         self::$hostname = $_SERVER['SERVER_NAME'];
         if (x($_SERVER, 'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
             self::$hostname .= ':' . $_SERVER['SERVER_PORT'];
         }
         /**
          * Figure out if we are running at the top of a domain
          * or in a sub-directory and adjust accordingly
          */
         $path = trim(dirname($_SERVER['SCRIPT_NAME']), '/\\');
         if (isset($path) && strlen($path) && $path != self::$path) {
             self::$path = $path;
         }
     }
     set_include_path("include/self::{$hostname}" . PATH_SEPARATOR . get_include_path());
     if (x($_SERVER, 'QUERY_STRING') && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
         self::$query_string = substr($_SERVER['QUERY_STRING'], 2);
         // removing trailing / - maybe a nginx problem
         if (substr(self::$query_string, 0, 1) == "/") {
             self::$query_string = substr(self::$query_string, 1);
         }
     }
     if (x($_GET, 'q')) {
         self::$cmd = trim($_GET['q'], '/\\');
     }
     // unix style "homedir"
     if (substr(self::$cmd, 0, 1) === '~') {
         self::$cmd = 'channel/' . substr(self::$cmd, 1);
     }
     /*
      * Break the URL path into C style argc/argv style arguments for our
      * modules. Given "http://example.com/module/arg1/arg2", self::$argc
      * will be 3 (integer) and self::$argv will contain:
      *   [0] => 'module'
      *   [1] => 'arg1'
      *   [2] => 'arg2'
      *
      * There will always be one argument. If provided a naked domain
      * URL, self::$argv[0] is set to "home".
      */
     self::$argv = explode('/', self::$cmd);
     self::$argc = count(self::$argv);
     if (array_key_exists('0', self::$argv) && strlen(self::$argv[0])) {
         self::$module = str_replace(".", "_", self::$argv[0]);
         self::$module = str_replace("-", "_", self::$module);
         if (strpos(self::$module, '_') === 0) {
             self::$module = substr(self::$module, 1);
         }
     } else {
         self::$argc = 1;
         self::$argv = array('home');
         self::$module = 'home';
     }
     /*
      * See if there is any page number information, and initialise
      * pagination
      */
     self::$pager['page'] = x($_GET, 'page') && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
     self::$pager['itemspage'] = 60;
     self::$pager['start'] = self::$pager['page'] * self::$pager['itemspage'] - self::$pager['itemspage'];
     if (self::$pager['start'] < 0) {
         self::$pager['start'] = 0;
     }
     self::$pager['total'] = 0;
     /*
      * Detect mobile devices
      */
     $mobile_detect = new Mobile_Detect();
     self::$is_mobile = $mobile_detect->isMobile();
     self::$is_tablet = $mobile_detect->isTablet();
     self::head_set_icon('/images/hz-32.png');
     /*
      * register template engines
      */
     spl_autoload_register('ZotlabsAutoloader::loader');
     self::$meta = new Zotlabs\Web\HttpMeta();
     // create an instance of the smarty template engine so we can register it.
     $smarty = new Zotlabs\Render\SmartyTemplate();
     $dc = get_declared_classes();
     foreach ($dc as $k) {
         if (in_array('Zotlabs\\Render\\TemplateEngine', class_implements($k))) {
             self::register_template_engine($k);
         }
     }
 }
Example #2
0
    $iId = 'app_new_status_' . $aRow->id . '';
    echo '$App.addItem(\'status\', \'' . $iId . '\', \'' . App::cleanJs($sItem) . '\');';
    exit;
}
if (!App::isAjax()) {
    ?>
<div class="app_form">
	<form method="post" action="#">
		<div><input type="hidden" name="do" value="index" id="app_form_action" /></div>
		<textarea cols="60" rows="10" name="status" id="app_form_status" placeholder="What's going on?"></textarea>
		<div class="app_submit">
			<input type="submit" value="Post" class="app_button" id="app_form_button" />
			<div class="app_form_process"></div>
		</div>
	</form>
</div>
<div id="app_new_status_updates"></div>
<?php 
}
$aRows = (array) App::api('user.status');
foreach ($aRows as $aRow) {
    App::item(array('id' => $aRow->id, 'module' => 'user_status', 'display_name' => $aRow->profile_full_name, 'profile_image' => $aRow->profile_image, 'content' => $aRow->update, 'likes' => $aRow->likes, 'is_liked' => $aRow->is_liked, 'comments' => $aRow->comments, 'time' => $aRow->convert_time_stamp));
}
if (empty($aRows)) {
    if (App::isAjax()) {
        echo '<div class="app_item_done">No more updates to view at this time.</div>';
    } else {
    }
} else {
    App::pager('');
}
Example #3
0
    echo App::link('photos');
    ?>
" enctype="multipart/form-data" target="app_iframe_src">
		<div id="app_form_photo_upload_holder">
			<div class="app_form_input">
				Share a Photo
			</div>		
			<input type="file" name="photo" id="app_form_photo_upload" />
		</div>		
		<div class="app_form_hidden">
			<textarea cols="60" rows="10" name="status" id="app_form_status" placeholder="Say something about this photo..."></textarea>
			<div class="app_submit">
				<input type="submit" value="Share" class="app_button" onclick="$('.app_form_process').show();" />
				<div class="app_form_process"></div>
			</div>
		</div>
	</form>
	<iframe id="app_iframe_src" name="app_iframe_src" style="display:none;"></iframe>
</div>
<div id="app_new_status_updates"></div>
<?php 
}
$aPhotos = (array) App::api('photo.get');
foreach ($aPhotos as $oPhoto) {
    App::item(array('module' => 'photo', 'id' => $oPhoto->id, 'display_name' => $oPhoto->uploaded_by, 'profile_image' => $oPhoto->uploaded_by_image, 'content' => $oPhoto->description . '<div class="app_item_break"><a href="' . $oPhoto->photo_1024px . '" class="app_view_photo"><img src="' . $oPhoto->photo_500px . '" alt="" class="app_item_img" /></a></div>', 'likes' => $oPhoto->likes, 'is_liked' => $oPhoto->is_liked, 'comments' => $oPhoto->comments, 'time' => $oPhoto->convert_time_stamp));
}
if (empty($aPhotos)) {
    echo '<div class="app_item_done">No more photos to view at this time.</div>';
} else {
    App::pager('photos');
}
Example #4
0
        echo '$App.addItem(\'status\', \'' . $iId . '\', \'' . App::cleanJs($sItem) . '\');';
    }
    exit;
}
if (!App::isAjax()) {
    ?>
<div class="app_form">
	<form method="post" action="#">
		<div><input type="hidden" name="do" value="videos" id="app_form_action" /></div>
		<div class="app_form_input">
			Share a Video
		</div>		
		<input type="text" name="status" value="" id="app_form_status" placeholder="http://" />
		<div class="app_submit">
			<input type="submit" value="Post" class="app_button" id="app_form_button" />
			<div class="app_form_process"></div>
		</div>
	</form>
</div>
<div id="app_new_status_updates"></div>
<?php 
}
$aRows = (array) App::api('video.get');
foreach ($aRows as $aRow) {
    App::item(array('id' => $aRow->id, 'module' => 'video', 'display_name' => $aRow->uploaded_by, 'profile_image' => $aRow->uploaded_by_image, 'content' => buildVideoContent($aRow), 'likes' => $aRow->likes, 'is_liked' => $aRow->is_liked, 'comments' => $aRow->comments, 'time' => $aRow->convert_time_stamp));
}
if (empty($aRows)) {
    echo '<div class="app_item_done">No more videos to view at this time.</div>';
} else {
    App::pager('videos');
}