Example #1
0
<?php

/**
 * Convert from the old links schema (string->ID) to the new schema (ID->ID)
 * The wiki should be put into read-only mode while this script executes
 *
 * @file
 * @ingroup Maintenance
 */
/** */
require_once "commandLine.inc";
require_once "convertLinks.inc";
convertLinks();
Example #2
0
$date_url = date('Y/n/j');
$webhook = "https://hooks.slack.com/services/...";
//Slack incoming webhook url
$channel = "#general";
// Slack channel
$language = ['de', 'x'];
$link_wol = 'http://wol.jw.org/' + $language[0] + '/wol/dt/r10/lp-' + $language[1] + '/' . $date_url;
$api_wol = 'http://wol.jw.org/wol/dt/r10/lp-' + $language[1] + '/' . $date_url;
$icon_url = "http://savic.at/jwdevs/dailytextbot/es" . date('Y') . "_X.png";
$obj = json_decode(file_get_contents($api_wol), true, 512, JSON_UNESCAPED_UNICODE);
$dom = str_get_html(mb_convert_encoding($obj['items'][0]['content'], "UTF-8"));
$title = $dom->find('h2', 0)->plaintext;
//get title
$pretext = convertLinks(mb_convert_encoding(removeTags($dom->find('.themeScrp', 0)), 'UTF-8', 'HTML-ENTITIES'), $language[0]);
//get pretext
$bodytext = convertLinks(mb_convert_encoding(removeTags($dom->find('.sb', 0)), 'UTF-8', 'HTML-ENTITIES'), $language[0]);
//get bodytext
//Send Slack message
$data = array('payload' => '{  "icon_url": "' . $icon_url . '", "channel": "' . $channel . '", "username": "******", "attachments": [{ "title": "' . $pretext . '","title_link": "' . $link_wol . '", "text": "' . $bodytext . '" }]}');
$options = array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data)));
$context = stream_context_create($options);
$result = file_get_contents($webhook, false, $context);
echo $result;
function convertLinks($text, $language)
{
    $text = str_replace('<a href="', '<http://wol.jw.org/' + $language, $text);
    $text = str_replace('">', '|', $text);
    $text = str_replace('</a>', '>', $text);
    return $text;
}
function removeTags($data_str)
Example #3
0
            echo $class;
            ?>
" style='height:48px'>
									<span class="tweet_time"><a title="view tweet on twitter" href="http://twitter.com/<?php 
            echo $tweets->results[$i]->user->screen_name;
            ?>
/status/<?php 
            echo $tweets->results[$i]->id_str;
            ?>
"><?php 
            echo $hoursago;
            ?>
</a></span> 
									<span class="tweet_text">
									<?php 
            echo convertLinks($tweets->results[$i]->text);
            ?>
									</li>
									<?php 
        }
        ?>
								</ul>
								</div>
								
							</td>
						</tr>
					<?php 
    }
}
?>
			</table>