Exemplo n.º 1
0
function renderQuran()
{
    // html url to the application
    $api_url = 'http://GlobalQuran.com/';
    $api_key = get_option('gq_key');
    ################## DO NOT EDIT BELOW THIS ###################################
    if (!$api_url) {
        die('missing vaules, please fill the configuration values and try again!');
    }
    $_REQUEST['apiKey'] = $api_key;
    $urlstring = NULL;
    build_string($_REQUEST, $urlstring);
    $ch = curl_init($api_url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    curl_close($ch);
    $html = str_ireplace('<!DOCTYPE html>', '', strip_only($data, 'head', true));
    $html = str_ireplace('<html lang="en" dir="lrt">', '', $html);
    $html = str_ireplace('<body class="ltr  ">', '', $html);
    $html = str_ireplace('<body class="ltr ">', '', $html);
    $html = str_ireplace('</body>', '', $html);
    $html = str_ireplace('</html>', '', $html);
    $head = '<link rel="shortcut icon" href="http://GlobalQuran.com/favicon.ico" />
			<link rel="stylesheet" href="' . get_option('gq_css_url') . '" media="screen,print" />
			<link rel="stylesheet" href="' . get_option('gq_css_print_url') . '" media="print" />';
    return $head . $html;
}
Exemplo n.º 2
0
 /**
  * Main workhorse function.
  *
  * @param int $post_ID The numeric ID of the WordPress post to crosspost.
  * @return int $post_ID
  */
 function tumblrize($post_ID)
 {
     // DATA Preparation
     $post = get_post($post_ID);
     // Do not crosspost if not requested for this post.
     if (!$this->isTumblrizeablePost($post_ID)) {
         return $post_ID;
     }
     $post_group = get_post_meta($post_ID, 'tumblrize_post-group', true);
     $post_type = get_post_meta($post_ID, 'tumblrize_post-type', true);
     $post_date = $post->post_date_gmt . ' GMT';
     // use UTC; avoid TZ issues
     $post_title = html_entity_decode($post->post_title);
     $post_body = wpautop(str_replace('\\"', "", html_entity_decode($post->post_content)));
     if (get_option('tumblrize_add_permalink')) {
         $postlink = get_permalink($post_ID);
         $post_body .= "<p class=\"tumblrize-permalink\"><a href=\"{$postlink}\" title=\"Go to original post at " . get_bloginfo('name') . '" rel="bookmark">Original Article</a></p>';
     }
     if (get_option('tumblrize_tags')) {
         $tags = get_option('tumblrize_tags');
         $tags .= ", tumblrize";
     } else {
         $tags = "tumblrize";
     }
     if (get_option('tumblrize_add_post_tags')) {
         query_posts("p={$post_ID}");
         if (have_posts()) {
             while (have_posts()) {
                 the_post();
                 $more_tags = get_the_tags();
             }
         }
         if ($more_tags) {
             foreach ($more_tags as $another_tag) {
                 $tags .= ",{$another_tag->name}";
             }
         }
     }
     // Gather valid data for Tumblr post types.
     if ('photo' === $post_type) {
         $pattern = '/<img.*?src="(.*?)".*?\\/?>/';
         $matches = array();
         preg_match($pattern, $post_body, $matches);
         $photo_source = $matches[1];
         $post_body = strip_only($post_body, '<img>');
     } else {
         if ('link' === $post_type) {
             $pattern = '/<a.*?href="(.*?)".*?>/';
             $matches = array();
             preg_match($pattern, $post_body, $matches);
             $link_url = $matches[1];
         } else {
             if ('audio' === $post_type) {
                 $pattern = '/<a.*?href="(.*?\\.[Mm][Pp]3)".*?>/';
                 $matches = array();
                 preg_match($pattern, $post_body, $matches);
                 $audio_url = $matches[1];
             } else {
                 if ('quote' === $post_type) {
                     // TODO: Buggy. Doesn't always pick up the contents of cite="" attribute.
                     $pattern = '/<blockquote.*?(?:cite="(.*?)")?.*?>(.*?)<\\/blockquote>/';
                     $matches = array();
                     preg_match($pattern, $post_body, $matches);
                     $post_quote = strip_tags($matches[2]);
                     $quote_source = $matches[1] ? "<a href=\"{$matches[1]}\" title=\"Visit quotation source.\">{$matches[1]}</a>" : '';
                 } else {
                     if ('video' === $post_type) {
                         // Currently fetches YouTube's video ID from embedded code and sends the URL to Tumblr
                         $pattern = '/youtube\\.com\\/v\\/([\\w\\-]+)/';
                         $matches = array();
                         preg_match($pattern, $post_body, $matches);
                         $post_video = "http://www.youtube.com/watch?v=" . $matches[1];
                     }
                 }
             }
         }
     }
     // Override default plugin credentials if user supplies their own.
     $cur_user = wp_get_current_user();
     $cur_user_twpemail = get_usermeta($cur_user->ID, 'tumblrize_wpuser_email');
     $this->tusername = $cur_user_twpemail ? $cur_user_twpemail : $this->tusername;
     $cur_user_twppass = get_usermeta($cur_user->ID, 'tumblrize_wpuser_password');
     $this->tpassword = $cur_user_twppass ? $cur_user_twppass : $this->tpassword;
     // SEND Data
     if (!$this->tusername || !$this->tpassword || !$post_body) {
         $this->add_admin_message('error', 'Entry not crossposted! Missing Tumblr post body, or Tumblrize is misconfigured.');
     } else {
         // Prepare DATA
         $request_data = array();
         $request_data['email'] = $this->tusername;
         $request_data['password'] = $this->tpassword;
         $request_data['post-id'] = get_post_meta($post_ID, 'tumblrize_post-id', true);
         if (empty($request_data['post-id'])) {
             unset($request_data['post-id']);
         }
         // no need
         $request_data['group'] = $post_group;
         if (empty($request_data['group'])) {
             unset($request_data['group']);
         }
         $request_data['type'] = $post_type;
         $request_data['date'] = $post_date;
         $request_data['tags'] = $tags;
         $request_data['generator'] = $this->generator;
         switch ($post_type) {
             case 'photo':
                 if (!isset($photo_source) || empty($photo_source)) {
                     $this->add_admin_message('error', 'You indicated a Photo post type, but Tumblrize could not find any images in your post.');
                     return $post_ID;
                     // will forego posting a photo
                 }
                 $request_data['source'] = $photo_source;
                 $request_data['caption'] = $post_body;
                 if ($photo_link = get_post_meta($post_ID, 'tumblrize_photo-click-through', true)) {
                     $request_data['click-through-url'] = $photo_link;
                 }
                 break;
             case 'link':
                 if (!isset($link_url) || empty($link_url)) {
                     $this->add_admin_message('error', 'You indicated a Link post type, but Tumblrize could not find any links in your post.');
                     return $post_ID;
                     // will forego posting a link
                 }
                 $request_data['name'] = $post_title;
                 $request_data['url'] = $link_url;
                 $request_data['description'] = $post_body;
                 break;
             case 'audio':
                 if (!isset($audio_url) || empty($audio_url)) {
                     $this->add_admin_message('error', 'You indicated an Audio post type, but Tumblrize could not find any MP3 links in your post.');
                     return $post_ID;
                     // will forego posting audio
                 }
                 $request_data['externally-hosted-url'] = $audio_url;
                 $request_data['caption'] = $post_body;
                 break;
             case 'video':
                 if (!isset($post_video) || empty($post_video)) {
                     $this->add_admin_message('error', 'You indicated a Video post type, but Tumblrize could not find any videos embedded in your post.');
                     return $post_ID;
                     // will forego posting a video
                 }
                 $request_data['embed'] = $post_video;
                 $request_data['caption'] = $post_title;
                 break;
             case 'quote':
                 if (!isset($post_quote) || empty($post_quote)) {
                     $this->add_admin_message('error', 'You indicated a Quote post type, but Tumblrize could not find any blockquotes embedded in your post.');
                     return $post_ID;
                     // will forego posting a quote; silently fails
                 }
                 $request_data['quote'] = $post_quote;
                 $request_data['source'] = $quote_source;
                 break;
             case 'text':
             case 'regular':
             default:
                 if (empty($post_title) || empty($post_body)) {
                     return $post_ID;
                     // just bail out now
                 }
                 $request_data['title'] = $post_title;
                 $request_data['body'] = $post_body;
                 break;
         }
         // What's notified?
         $tb_services = '';
         if (get_option('tumblrize_shutoff') == "") {
             $tb_services = "Tumblr";
         }
         if (get_option('tumblrize_tumblr_posterous') == "posterous") {
             $tb_services .= " and Posterous";
         }
         if (get_option('tumblrize_shutoff') && get_option('tumblrize_tumblr_posterous') == "posterous") {
             $tb_services = "Posterous";
         }
         // Talk to Tumblr
         $r = $this->tumblrize_to_tumblr('write', $request_data);
         if ($r && $r['status'] === 201) {
             // Success
             add_post_meta($post_ID, 'tumblrize_post-id', $r['result'], true);
         } else {
             if ($r && $r['status'] === 403) {
                 // Authentication failed.
                 $this->add_admin_message('error', 'Tumblrize could not crosspost this entry because Tumblr has rejected your username or password.');
                 $this->add_admin_message('updated', 'Are you sure you entered your Tumblr email and password correctly? Tumblrize is having trouble accessing your account.');
             } else {
                 if ($r && $r['status'] === 400) {
                     // Tumblr errors.
                     $this->add_admin_message('error', 'Tumblr experienced errors trying to save the data we sent it.');
                     // TODO: Show these errors here in subsequent error messages.
                 } else {
                     if ($r && $r['status'] === 0) {
                         // cURL error; no connection
                         $this->add_admin_message('error', 'Tumblrize could access the Internet. Make sure you have a network connection, that Tumblr is online, or try again later.');
                     } else {
                         if ($r && ($r['status'] === 500 || $r['status'] === 503)) {
                             // Tumblr barfed?
                             $this->add_admin_message('error', "Tumblr returned an HTTP Status Code of {$r['status']}. Tumblr might be having problems. Try crossposting again.");
                         } else {
                             // Uncomment to help in debugging.
                             // var_dump($r);
                             // exit();
                             $this->add_admin_message('error', 'Tumblrize could not crosspost this entry. Unfortunately, we also do not know why.');
                         }
                     }
                 }
             }
         }
         // Do additional notifications.
         $this->tumblrize_notify($this->tusername, $post_title, $post_body, $tb_services);
         $this->tumblrize_posterous($this->tusername, $post_title, $post_body, $tags);
     }
     return $post_ID;
 }
Exemplo n.º 3
0
function EditNote($login, $action, $text, $rating = 0)
{
    session_start();
    $objResponse = new xajaxResponse();
    $nuid = get_uid(false);
    //$text = str_replace('&', '&amp;', $text);
    //$text = stripslashes($text);
    $text = strip_only(trim($text), '<script>');
    $text = change_q_x($text, FALSE, TRUE, "", false, false);
    // !! кол-во символов также указано в /scripts/note.js
    if (strlen($text) > 200) {
        $text = substr($text, 0, 200);
    }
    switch ($action) {
        case "add":
            if ($text) {
                $error = notes::Add($nuid, $login, $text, 0, "?");
            }
            break;
        case "update":
            if ($text) {
                $error = notes::Update($nuid, $login, $text, $rating, "?");
            } else {
                $error = notes::DeleteNote($nuid, $login, "?");
                $action = 'delete';
            }
            break;
    }
    if ($error) {
        return false;
    }
    $text_src = input_ref_scr(stripslashes($text));
    $text_src = str_replace('&', '&amp;', $text_src);
    $text = reformat($text, 54, 0, 0, 1, 54);
    //$text = addslashes($text);
    switch ($action) {
        case 'add':
        case 'update':
            if (is_empty_html($text)) {
                $s = "\n                    document.getElement('div.form-templ').setStyle('display', 'none');\n                    document.getElement('div.form-templ input').set('disabled', false);\n                    cancelNote();\n                ";
                break;
            }
            $s = "\n                n = \$('note_{$login}');\n                n.getElement('.uprj-note-cnt>p').set('html', '{$text}');\n                n.setStyle('display', 'block');\n\n                document.getElement('div.form-templ').setStyle('display', 'none');\n                document.getElement('div.form-templ input').set('disabled', false);\n\n                if(\$('team_{$login}')) \$('team_{$login}').getElement('.uprj-st3').setStyle('display', 'none');\n                cancelNote();\n            ";
            break;
        case 'delete':
            $s = "\n                n = \$('note_{$login}');\n                n.getElement('.uprj-note-cnt>p').set('html', '');\n                n.setStyle('display', 'none');\n\n                if(\$('team_{$login}')) \$('team_{$login}').getElement('.uprj-st3').setStyle('display', 'inline-block');\n                document.getElement('div.uprj-note.form-templ').store('action', false);\n                cancelNote();\n            ";
            break;
    }
    $objResponse->script($s);
    return $objResponse;
}
Exemplo n.º 4
0
/**
 * Strips given tags from string
 * 
 * See http://www.php.net/manual/en/function.strip-tags.php#93567
 * @param string $str String to strip
 * @param array $tags Tags to be stripped
 * @return string cleaned up string
 */
function strip_only(&$str, $tags)
{
    if (isset($str) && is_array($str)) {
        return $str;
    }
    if (!is_array($tags)) {
        $tags = strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags);
        if (end($tags) == '') {
            array_pop($tags);
        }
    }
    $size = sizeof($tags);
    $keys = array_keys($tags);
    for ($i = 0; $i < $size; $i++) {
        $tag = $tags[$keys[$i]];
        if (isset($tag) && is_array($tag)) {
            $str = strip_only($str, $tag);
        } else {
            if (stripos($str, $tag) !== false) {
                $str = preg_replace('#</?' . $tag . '[^>]*>#is', '', $str);
            }
        }
    }
    return $str;
}
Exemplo n.º 5
0
function FormSave($login, $text, $action, $rl, $num)
{
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/users.php";
    session_start();
    $objResponse = new xajaxResponse();
    $action = trim($action);
    // Режем тег <script>
    $text = strip_only(trim($text), '<script>');
    //$text = stripslashes($text);
    $text = change_q_x($text, FALSE, TRUE, "", false, false);
    if ($rl == '1') {
        $s_role = "_emp";
    } else {
        $s_role = "_frl";
    }
    if ($text == '') {
        $s_role = "";
    }
    $noassign = 0;
    $nuid = get_uid(false);
    $user = new users();
    $nTargetId = $user->GetUid($sError, $login);
    switch ($action) {
        case "add":
            if ($text) {
                $error = notes::Add($nuid, (int) $nTargetId, $text);
            }
            break;
        case "update":
            if ($text) {
                $error = notes::Update($nuid, (int) $nTargetId, $text);
            } else {
                $error = notes::DeleteNote($nuid, (int) $nTargetId);
            }
            break;
        default:
            $noassign = 1;
    }
    $text = stripslashes($text);
    $text = reformat($text, 24, 0, 0, 1, 24);
    if ($s_role == "") {
        $text = "Вы можете оставить заметку о&nbsp;пользователе. Видеть написанное будете только вы и никто другой.";
    }
    if (!$noassign) {
        $GLOBALS['xajax']->setCharEncoding("windows-1251");
        $objResponse->assign("notetext" . $num, "innerHTML", $text);
        $objResponse->assign("notetd" . $num, "className", "note" . $s_role);
        if (!$s_role == "") {
            $objResponse->script("txt[" . $num . "] = '" . $text . "';");
        }
        $objResponse->script("act[" . $num . "] = '" . ($s_role ? "update" : "add") . "';");
    }
    return $objResponse;
}
Exemplo n.º 6
0
 if ($_POST['subcategory']) {
     $twice = explode('-', $_POST['subcategory']);
     $category = $twice[0];
     $subcategory = $twice[1];
 } elseif ($_POST['category']) {
     $category = $_POST['category'];
     $subcategory = 0;
 }
 $text = $_POST["text"];
 $video = $_POST["video"];
 $small_image = $_POST["small_image"];
 $recept = $_POST["recept"];
 $recept = strip_only($recept, $tags);
 $recept = str_replace("<p>", '<p class="recepts">', $recept);
 $recept = replace_p($recept);
 $text = strip_only($text, $tags);
 $text = str_replace("<p>", '<p class="recepts">', $text);
 $text = replace_p($text);
 $sqlU = mysql_query("UPDATE recepts SET name='{$name}', text='{$text}', video='{$video}', recepts='{$recept}', small_image='{$small_image}', category='{$category}', subcategory='{$subcategory}' WHERE id='{$id}'") or die(mysql_error());
 if ($_FILES['files']) {
     foreach ($_FILES['files']['tmp_name'] as $key => $tmp_name) {
         $file_name = $_FILES['files']['name'][$key];
         $file_size = $_FILES['files']['size'][$key];
         $file_tmp = $_FILES['files']['tmp_name'][$key];
         $file_type = $_FILES['files']['type'][$key];
         $desired_dir = "../images/recepts/" . $id;
         if (empty($errors) == true) {
             if (is_dir($desired_dir) == false) {
                 mkdir("{$desired_dir}", 0755);
                 // Create directory if it does not exist
             }
Exemplo n.º 7
0
        }
    }
    foreach ($tags as $tag) {
        if ($stripContent) {
            $content = '(.+</' . $tag . '[^>]*>|)';
        }
        $str = preg_replace('#</?' . $tag . '[^>]*>' . $content . '#is', '', $str);
    }
    return $str;
}
$tags = array('span', 'font', 'p');
if ($_POST) {
    $keywords = $_POST["keywords"];
    $misho = strip_only($_POST["misho"], $tags);
    $miglena = strip_only($_POST["miglena"], $tags);
    $description = strip_only($_POST["description"], $tags);
    $sql = mysql_query("UPDATE sitedata SET keywords='{$keywords}', misho='{$misho}', miglena='{$miglena}', description='{$description}'") or die(mysql_error());
    if ($sql) {
        echo "Информацията е обновена.";
    }
} else {
    ?>
			<form action="site_config.php" method="post" class="form-horizontal form-bordered form-label-stripped" >
				<div class="form-body">
					<div class="form-group">
						<label class="control-label col-md-2">Ключови думи</label>
						<div class="col-md-9">
							<input type="text" class="form-control" name="keywords" value="<?php 
    echo $keywords;
    ?>
" />