template == $templates ) { $found = true; } if ( is_array( $templates ) && in_array( $page->template, $templates ) ) { $found = true; } return $found ? ' class="on" ' : ''; } function display_phone( $str ) { if ( substr( $str, 0, 2 ) == '06' ) { return '06-' . substr( $str, 2 ); } if ( substr( $str, 0, 3 ) == '035' ) { return '035-' . substr( $str, 3 ); } return $str; } function show_banner( $type ) { global $dfp_banners_shown; if ( ! $dfp_banners_shown ) { $dfp_banners_shown = array( '120x60_button' => 0, '200x90_banner' => 0, '300x100_banner' => 0, '300x250_banner' => 0, '300x600_banner' => 0, '728x90_banner' => 0 ); } $dfp_banners_shown[ $type ] ++; echo '
'; echo '
'; return; /* switch($type) { case '120x60_button': echo '
'; break; case '200x90_banner': echo '
'; break; case '300x250_banner': echo '
B02
'; break; case '728x90_banner': echo '
'; break; case '300x100_banner': echo '
B01
'; break; case '300x600_banner': echo '
B03
'; break; } echo '
'; return; */ } function get_twitter_data( $screen_name ) { if ( ! $screen_name ) { return array(); } $data = null; require_once( dirname( __FILE__ ) . '/TwitterAPIExchange.php' ); $settings = array( 'oauth_access_token' => "1683742572-yP0sWvX66s3cICcJnN9IjEpCM3Nm8PV3beSmqzH", 'oauth_access_token_secret' => "pON13LHjtA5jI0BnxZYleqxYLS9yMndgeGSsEl1I", 'consumer_key' => "Vq8b0YvD4cznqwn3kdhxuQ", 'consumer_secret' => "fZxYsJzeHG1sthNuWuEV19kbyvmwTAOJDvURYfkTs" ); // get tweets $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; $getfield = '?screen_name=' . $screen_name; $requestMethod = 'GET'; $twitter = new TwitterAPIExchange( $settings ); $tweets = $twitter->setGetfield( $getfield ) ->buildOauth( $url, $requestMethod ) ->performRequest(); $data->tweets = $tweets ? json_decode( $tweets ) : array(); // Let's create links from hashtags, mentions, urls for ( $c = 0; $c < count( $data->tweets ); $c ++ ) { $tweet_text = $data->tweets[ $c ]->text; $tweet_text = preg_replace( '/(https?:\/\/[^\s"<>]+)/', '$1', $tweet_text ); $tweet_text = preg_replace( '/(^|[\n\s])@([^\s"\t\n\r<:]*)/is', '$1@$2', $tweet_text ); $tweet_text = preg_replace( '/(^|[\n\s])#([^\s"\t\n\r<:]*)/is', '$1#$2', $tweet_text ); $data->tweets[ $c ]->text_html = $tweet_text; } // get user data $url = 'https://api.twitter.com/1.1/users/show.json'; $getfield = '?screen_name=' . $screen_name; $requestMethod = 'GET'; $user_data = $twitter->setGetfield( $getfield ) ->buildOauth( $url, $requestMethod ) ->performRequest(); $data->user = $user_data ? json_decode( $user_data ) : array(); return $data; } function get_dfp_codes_from_items_and_folders( $items, $folders ) { global $db; $dfp_codes = array(); foreach ( $items as $index => $item ) { $item->extend(); if ( $item->folder_ids[0] ) { $codes = $db->getOne( 'SELECT codes FROM folders WHERE id = ' . (int) $item->folder_ids[0] ); } $dfp_codes = array_merge( $dfp_codes, explode( ',', $codes ) ); if ( $index > 10 ) { break; } } foreach ( $folders as $index => $folder ) { $dfp_codes = array_merge( $dfp_codes, explode( ',', $folder->codes ) ); if ( $index > 10 ) { break; } } $dfp_codes = array_unique( $dfp_codes ); // remove empty codes (and keys) $dfp_codes_def = array(); foreach ( $dfp_codes as $code ) { if ( trim( $code ) ) { $dfp_codes_def[] = trim( $code ); } } return $dfp_codes_def; } function get_rss_data( $url ) { $data = array(); $index = 0; try { if ( $rss = @simplexml_load_file( $url ) ) { foreach ( $rss->channel->item as $item ) { $o = null; $o->title = (string) $item->title; $o->link = (string) $item->link; $o->pubDate = (string) $item->pubDate; $o->description = (string) $item->description; $data[] = $o; if ( ++ $index >= 20 ) { break; } } } } catch ( Exception $e ) { } return $data; } ?>'; var_dump($var); echo ''; } function menu_on_check($str, $id_cat=null, $str_not=null) { global $tpl, $id_category; if (stripos($tpl, $str)!==false) { if ($id_cat && $id_cat != $id_category) return; if (stripos($tpl, $str_not)!==false) return; return ' class="active"'; } } function add_message($str, $type=null) { if (!$_SESSION['message']) $_SESSION['message'] = array(); $_SESSION['message'][] = array($str, $type); } function getFileType($filename) { // TO DO: goeie checks bouwen $file_ext = substr($filename, strrpos($filename, '.')); if (strtolower($file_ext)=='.mp3') return 'audio'; if (strtolower($file_ext)=='.jpg') return 'image'; if (strtolower($file_ext)=='.png') return 'image'; if (strtolower($file_ext)=='.gif') return 'image'; if (strtolower($file_ext)=='.flv') return 'video'; return 'unknown'; } function get_request_object($data) { $req = array(); // sort if ($data['order']) $req['order'] = $data['order']; if ($data['dir']) $req['dir'] = $data['dir']; // TODO: pager if ($data['p']) $req['p'] = $data['p']; return $req; } function showTreeOptions($item, $showOnlyFolders=false, $selectedId=-1, $level=0) { //if ($showOnlyFolders && !$item->is_parent) return; echo ''; if ($item->children) foreach($item->children as $child) showTreeOptions($child, $showOnlyFolders, $selectedId, $level+1); } function truncate($string, $length, $append='...') { if (strlen($string)<$length) return $string; $string = substr($string,0,$length); return substr($string,0,strrpos($string,' ')).$append; } function summarize($string, $length, $append='...') { return truncate(trim(strip_tags($string)), $length, $append); } function get_seo_alias($string) { $string = preg_replace("`\[.*\]`U","",$string); $string = str_replace('\'','',$string); $string = str_replace('&','en',$string); $string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string); $string = htmlentities($string, ENT_COMPAT, 'utf-8'); $string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string ); $string = preg_replace( array("`[^a-z0-9\.]`i","`[-]+`") , "-", $string); $string = strtolower(trim($string, '-')); return $string; } function alias_already_exists_old($a, $item) { global $db, $config; $found = false; foreach($config['alias_tables'] as $table) if ($db->getOne('SELECT id FROM '.$table.' WHERE alias = '.$db->escape($a) . (($table==$item->table && $item->id) ? ' AND id !='.$item->id : ''))) return true; return false; } function alias_already_exists($a, $item) { global $db, $config; $muni_sql = $item->id_muni ? ' AND id_muni = '.(int)$item->id_muni : ' '; if ($db->getOne('SELECT id FROM '.$item->table.' WHERE alias = '.$db->escape($a) . $muni_sql . ($item->id ? ' AND id !='.$item->id : ''))) return true; return false; } function get_unique_alias($item,$field='name') { $alias = get_seo_alias($item->$field); if (alias_already_exists($alias, $item)) { $i = 2; while(alias_already_exists($alias.'-'.$i, $item)) $i++; $alias = $alias.'-'.$i; } return $alias; } function get_unique_id() { $id = base64_encode(sha1(uniqid(),true)); $id = str_replace('+','-',$id); $id = str_replace('/','_',$id); $id = substr($id,0,-1); return $id; } function get_youtube_id_from_url($ytURL) { $ytvIDlen = 11; if (strlen($ytURL)==$ytvIDlen) return $ytURL; $idStarts = strpos($ytURL, "?v="); if($idStarts === FALSE) $idStarts = strpos($ytURL, "&v="); if($idStarts === FALSE) return false; $idStarts +=3; $ytvID = substr($ytURL, $idStarts, $ytvIDlen); return $ytvID; } function get_vimeo_id_from_url($url) { sscanf(parse_url($url, PHP_URL_PATH), '/%d', $video_id); return $video_id; } function bytesToSize1024($bytes, $precision = 2) { // human readable format -- powers of 1024 $unit = array('B','KB','MB','GB','TB','PB','EB'); return @round( $bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision ).' '.$unit[$i]; } function rutime($ru, $rus, $index) { return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000)) - ($rus["ru_$index.tv_sec"]*1000 + intval($rus["ru_$index.tv_usec"]/1000)); } function get_pdf_templates() { $templates = array(); foreach(glob(TEMPLATES_PATH."/pdfs/*.*") as $t) $templates[] = basename($t); return $templates; } function generate_pdf($data) { $template = TEMPLATES_PATH.'/pdfs/'.urldecode($data['template']); if (!file_exists($template)) die('invalid pdf template'); if ($data['id_item']) { $item = Item::find((int)$data['id_item']); if ($item) { global $muni; // nodig voor de $item->extend_paths(); $muni = Muni::find($item->id_muni); $item->extend(); $item->extend_paths(); } } ob_start(); include TEMPLATES_PATH.'/pdfs/snippets/header.php'; include($template); include TEMPLATES_PATH.'/pdfs/snippets/footer.php'; $html = ob_get_contents(); ob_end_clean(); // personalize template $ut = UpdateTemplate::find((int)$data['updatetemplate']); foreach(array('verzoek','jaartal','verschijningsdatum','deadline','verzendgegevens') as $field) $html = str_replace('['.$field.']', $ut->$field, $html); // personalize gemeente $html = str_replace('[muni]', $muni->name, $html); ini_set('memory_limit','512M'); require_once(LIBS_PATH.'/dompdf/dompdf_config.inc.php'); $dompdf = new DOMPDF(); $dompdf->load_html($html,'UTF-8'); $dompdf->set_paper('a4', 'portrait'); $dompdf->render(); $dompdf->stream("brief.pdf"); exit; } function generate_pdf_multiple($data) { $item_ids = explode(',', $data['item_ids']); if (!$item_ids) die('invalid item ids'); $template = TEMPLATES_PATH.'/pdfs/'.urldecode($data['pdf_template']); if (!file_exists($template)) die('invalid pdf template'); // personalize template $ut = UpdateTemplate::find((int)$data['id_template']); // header ob_start(); include TEMPLATES_PATH.'/pdfs/snippets/header.php'; $html = ob_get_contents(); ob_end_clean(); foreach($item_ids as $item_id) { $item = Item::find((int)$item_id); if ($item) { global $muni; // nodig voor de $item->extend_paths(); $muni = Muni::find($item->id_muni); $item->extend(); $item->extend_paths(); ob_start(); include($template); echo '
'; $html_item = ob_get_contents(); // personalize fields foreach(array('verzoek','jaartal','verschijningsdatum','deadline','verzendgegevens') as $field) $html_item = str_replace('['.$field.']', $ut->$field, $html_item); // personalize gemeente $html_item = str_replace('[muni]', $muni->name, $html_item); $html .= $html_item; ob_end_clean(); } } // footer ob_start(); include TEMPLATES_PATH.'/pdfs/snippets/footer.php'; $html .= ob_get_contents(); ob_end_clean(); ini_set('memory_limit','512M'); require_once(LIBS_PATH.'/dompdf/dompdf_config.inc.php'); $dompdf = new DOMPDF(); $dompdf->load_html($html,'UTF-8'); $dompdf->set_paper('a4', 'portrait'); $dompdf->render(); $dompdf->stream("brief.pdf"); exit; } function display_url($url) { if (substr($url, 0, 7)=='http://') return substr($url, 7); if (substr($url, 0, 8)=='https://') return substr($url, 8); return $url; } ?>