Skip to content

Commit

Permalink
Proxy again, with configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanediondev committed Aug 16, 2015
1 parent addce4c commit 8335915
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 5 deletions.
2 changes: 2 additions & 0 deletions application/database/installation-mysql.sql
Expand Up @@ -172,6 +172,8 @@ CREATE TABLE IF NOT EXISTS `settings` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `settings` (`stg_code`, `stg_type`, `stg_value`, `stg_note`, `stg_is_global`, `stg_is_member`, `stg_is_subscription`, `stg_datecreated`) VALUES
('proxy/enabled', 'boolean', '0', NULL, 1, 0, 0, NOW()),
('proxy/http_only', 'boolean', '0', NULL, 1, 0, 0, NOW()),
('folders', 'boolean', '1', NULL, 1, 0, 0, NOW()),
('gravatar', 'boolean', '1', NULL, 1, 0, 0, NOW()),
('gravatar_default', 'string', 'identicon', 'identicon, mm, monsterid, retro, wavatar', 1, 1, 0, NOW()),
Expand Down
2 changes: 2 additions & 0 deletions application/database/installation-sqlite.sql
Expand Up @@ -144,6 +144,8 @@ CREATE TABLE IF NOT EXISTS `settings` (
CREATE UNIQUE INDEX "settings_stg_code" ON "settings" ("stg_code");

INSERT INTO `settings` (`stg_code`, `stg_type`, `stg_value`, `stg_note`, `stg_is_global`, `stg_is_member`, `stg_is_subscription`, `stg_datecreated`) VALUES
('proxy/enabled', 'boolean', '0', NULL, 1, 0, 0, datetime('now')),
('proxy/http_only', 'boolean', '0', NULL, 1, 0, 0, datetime('now')),
('folders', 'boolean', '1', NULL, 1, 0, 0, datetime('now')),
('gravatar', 'boolean', '1', NULL, 1, 0, 0, datetime('now')),
('gravatar_default', 'string', 'identicon', 'identicon, mm, monsterid, retro, wavatar', 1, 1, 0, datetime('now')),
Expand Down
3 changes: 3 additions & 0 deletions application/database/update-mysql-3.4.0.sql
@@ -0,0 +1,3 @@
REPLACE INTO `settings` (`stg_code`, `stg_type`, `stg_value`, `stg_note`, `stg_is_global`, `stg_is_member`, `stg_is_subscription`, `stg_datecreated`) VALUES
('proxy/enabled', 'boolean', '0', NULL, 1, 0, 0, NOW()),
('proxy/http_only', 'boolean', '0', NULL, 1, 0, 0, NOW());
3 changes: 3 additions & 0 deletions application/database/update-sqlite-3.4.0.sql
@@ -0,0 +1,3 @@
REPLACE INTO `settings` (`stg_code`, `stg_type`, `stg_value`, `stg_note`, `stg_is_global`, `stg_is_member`, `stg_is_subscription`, `stg_datecreated`) VALUES
('proxy/enabled', 'boolean', '0', NULL, 1, 0, 0, datetime('now')),
('proxy/http_only', 'boolean', '0', NULL, 1, 0, 0, datetime('now'));
3 changes: 3 additions & 0 deletions application/language/en/readerself_lang.php
Expand Up @@ -232,3 +232,6 @@
$lang['stg_evernote/sandbox'] = 'Evernote / Sandbox';
$lang['stg_evernote/consumer_key'] = 'Evernote / Consumer Key';
$lang['stg_evernote/consumer_secret'] = 'Evernote / Consumer Secret';

$lang['stg_proxy/enabled'] = 'Proxy enabled';
$lang['stg_proxy/http_only'] = 'Proxy / Http only';
3 changes: 3 additions & 0 deletions application/language/fr/readerself_lang.php
Expand Up @@ -232,3 +232,6 @@
$lang['stg_evernote/sandbox'] = 'Evernote / Sandbox';
$lang['stg_evernote/consumer_key'] = 'Evernote / Consumer Key';
$lang['stg_evernote/consumer_secret'] = 'Evernote / Consumer Secret';

$lang['stg_proxy/enabled'] = 'Proxy actif';
$lang['stg_proxy/http_only'] = 'Proxy / Http uniquement';
3 changes: 3 additions & 0 deletions application/language/zh-CN/readerself_lang.php
Expand Up @@ -232,3 +232,6 @@
$lang['stg_evernote/sandbox'] = 'Evernote / Sandbox';
$lang['stg_evernote/consumer_key'] = 'Evernote / Consumer Key';
$lang['stg_evernote/consumer_secret'] = 'Evernote / Consumer Secret';

$lang['stg_proxy/enabled'] = 'Proxy enabled';
$lang['stg_proxy/http_only'] = 'Proxy / Http only';
22 changes: 22 additions & 0 deletions application/libraries/Readerself_library.php
Expand Up @@ -560,11 +560,33 @@ function prepare_content($content) {

if($attribute_width == 1 || $attribute_height == 1 || stristr($attribute_src, 'feedsportal.com') || stristr($attribute_src, 'feedburner.com')) {
$content = str_replace($flr_img, '', $content);
} else {
$flr_img_new = '<img src="'.$this->add_proxy($attribute_src).'"';
if($attribute_width) {
$flr_img_new .= ' width="'.$attribute_width.'"';
}
if($attribute_height) {
$flr_img_new .= ' height="'.$attribute_height.'"';
}
$flr_img_new .= '>';
$content = str_replace($flr_img, $flr_img_new, $content);
}
}
return $content;
}
function timezone_datetime($datetime, $format = 'Y-m-d H:i:s') {
return date($format, strtotime($datetime) + $this->CI->axipi_session->userdata('timezone') * 3600);
}
function add_proxy($url) {
if($this->CI->config->item('proxy/enabled')) {
if($this->CI->config->item('proxy/http_only') && substr($url, 0, 7) != 'http://') {
return $url;
} else {
//return base_url().'medias/readerself_250x250.png';
return base_url().'proxy/?file='.urlencode($url);
}
} else {
return $url;
}
}
}
10 changes: 5 additions & 5 deletions application/views/item_expand.php
Expand Up @@ -22,14 +22,14 @@
<?php if(stristr($enr->enr_type, 'image/') && $filename != '') { ?>
<div class="enclosure">
<p><a class="mdl-color-text--<?php echo $this->config->item('material-design/colors/text/link'); ?>" target="_blank" href="<?php echo $enr->enr_link; ?>"><i class="material-icons md-18">image</i><?php echo $filename; ?></a></p>
<?php if($enr->enr_length == 0 || $enr->enr_length <= 1048576) { ?><a target="_blank" href="<?php echo $enr->enr_link; ?>"><img src="<?php echo $enr->enr_link; ?>" alt=""></a><?php } ?>
<?php if($enr->enr_length == 0 || $enr->enr_length <= 1048576) { ?><a target="_blank" href="<?php echo $enr->enr_link; ?>"><img src="<?php echo $this->readerself_library->add_proxy($enr->enr_link); ?>" alt=""></a><?php } ?>
</div>

<?php } else if(stristr($enr->enr_type, 'audio/') && $filename != '') { ?>
<div class="enclosure">
<p><a class="mdl-color-text--<?php echo $this->config->item('material-design/colors/text/link'); ?>" target="_blank" href="<?php echo $enr->enr_link; ?>"><i class="material-icons md-18">audiotrack</i><?php echo $filename; ?></a></p>
<audio controls>
<source src="<?php echo $enr->enr_link; ?>" type="<?php echo $enr->enr_type; ?>">
<source src="<?php echo $this->readerself_library->add_proxy($enr->enr_link); ?>" type="<?php echo $enr->enr_type; ?>">
</audio>
</div>

Expand All @@ -55,16 +55,16 @@
<div class="enclosure">
<p><a class="mdl-color-text--<?php echo $this->config->item('material-design/colors/text/link'); ?>" target="_blank" href="<?php echo $enr->enr_link; ?>"><i class="material-icons md-18">videocam</i><?php echo $filename; ?></a></p>
<video width="<?php echo $enr->enr_width; ?>" height="<?php echo $enr->enr_height; ?>" controls>
<source src="<?php echo $enr->enr_link; ?>" type="<?php echo $enr->enr_type; ?>">
<source src="<?php echo $this->readerself_library->add_proxy($enr->enr_link); ?>" type="<?php echo $enr->enr_type; ?>">
</video>
</div>

<?php } else if($enr->enr_type == 'application/x-shockwave-flash' && $filename != '') { ?>
<div class="enclosure">
<p><a class="mdl-color-text--<?php echo $this->config->item('material-design/colors/text/link'); ?>" target="_blank" href="<?php echo $enr->enr_link; ?>"><i class="material-icons md-18">flash_on</i><?php echo $enr->enr_link; ?></a></p>
<?php if($enr->enr_width && $enr->enr_height) { ?>
<object type="application/x-shockwave-flash" data="<?php echo $enr->enr_link; ?>" width="<?php echo $enr->enr_width; ?>" height="<?php echo $enr->enr_height; ?>">
<param name="movie" value="<?php echo $enr->enr_link; ?>">
<object type="application/x-shockwave-flash" data="<?php echo $this->readerself_library->add_proxy($enr->enr_link); ?>" width="<?php echo $enr->enr_width; ?>" height="<?php echo $enr->enr_height; ?>">
<param name="movie" value="<?php echo $this->readerself_library->add_proxy($enr->enr_link); ?>">
<param name="loop" value="false">
</object>
<?php } ?>
Expand Down

0 comments on commit 8335915

Please sign in to comment.