$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)
function changeTags($uid, $pid, $add, $remove) { mysql_query('START TRANSACTION'); addTags($uid, $pid, $add); removeTags($uid, $pid, $remove); mysql_query('COMMIT'); }
function createToolTipText($text, $len) { global $chapStart; //echo '<br> TTTEXT: '.$text; $tttext = removeTags($text); //echo '<br> TTTEXT: '.$tttext; $i = $len; if (strpos($text, $chapStart) > -1) { $i = min(strpos($text, $chapStart), $len); } $tttext = substr($tttext, 0, $i); $tttext = cleanText($tttext); $tttext = trim($tttext); //echo '<br> TTTEXT: '.$tttext; //echo $tttext; return $tttext . ' [...]'; }
<tr><td><pre><?php echo removeTags(highlight_string('<?php $criterion->getBelongsToAdGroupId(); ?>', true)); ?> </pre></td><td><?php echo $criterion->getBelongsToAdGroupId(); ?> </td></tr> <tr><td><pre><?php echo removeTags(highlight_string('<?php $criterion->getStatus(); ?>', true)); ?> </pre></td><td><?php echo $criterion->getStatus(); ?> </td></tr> <tr><td><pre><?php echo removeTags(highlight_string('<?php $criterion->getIsNegative(); ?>', true)); ?> </pre></td><td><?php echo $criterion->getIsNegative(); ?> </td></tr> </table> <br /> <?php } ?> <?php // view some quota details echo "<br /><b>Overall Consumed Units:</b> " . $apilityUser->getOverallConsumedUnits() . "<br />"; echo "<br /><b>Overall Performed Operations: </b>" . $apilityUser->getOverallPerformedOperations() . "<br />";