#i', "\n\n", $new_text); // $new_text = preg_replace("/[\r\n]+/", "\n", $new_text); // Cleanup noise // $new_text = preg_replace("/\([^)]+\)/", "", $new_text); // $new_text = preg_replace('/More\s*:\s*(news|Trending|Sport|Entertainment|Lifestyle).*$/i', '', $new_text); // $new_text = preg_replace('/[a-z0-9._%+-]+@metro\.co\.uk/i', 'email', $new_text); // $new_text = preg_replace('/Metro\.co\.uk/i', 'The Agency', $new_text); // $new_text = preg_replace('/To\s+view\s+this\s+video.*HTML5\s+video/i', '', $new_text); // return trim($new_text); //} function restore_html($text) { $text = nl2br($text); // $text = preg_replace('/(#\[BR_TAG#\])/', '

', $text); // $text = preg_replace('/(#\[IMG_TAG)(.*?)(IMG_TAG_OVR#\])/', '', $text); // $text = preg_replace('/(\[BR_TAG\])/', '

', $text); // $text = preg_replace('/(\[IMG_TAG)(.*?)(IMG_TAG_OVR\])/', '', $text); // $text = preg_replace('/(\] IMG_TAG_OVR)/', '>', $text); // $text = preg_replace('/(\[IMG_TAG)/', ' $text, 'error' => '', 'success' => 0, 'api_response' => '', 'payload' => ''); $curl = curl_init(); // $prompt = $no_img ? "Briefly paraphrase text under 255 characters \n$text\n\n" : "paraphrase all sentences in this text without removing word 'IMAGETAGGOESHERE' and continue till end\n\n$text\n\n"; $prompt = $no_img ? "Briefly paraphrase text under 150 characters \n$text\n\n" : "Rewrite the following text in a human-like manner while maintaining the original context, tone, and meaning. It should have multiple paragraphs. Ensure the output text sounds natural and coherent.\nOriginal Text:\n\n$text\n\n"; $payload = array( 'model' => 'gpt-3.5-turbo-instruct', //old - text-davinci-003 // highest, max_tokens 4000 // 'model' => 'text-curie-001', // 2nd highest, max_tokens 2048 // 'model' => 'text-babbage-001', // 3rd highest, max_tokens 2048 // 'model' => 'text-ada-001', // lowest, max_tokens 2048 'prompt' => $prompt, 'temperature' => 0.7, 'max_tokens' => 2000, 'top_p' => 1, 'frequency_penalty' => 0, 'presence_penalty' => 0, 'stop' => null, ); $config['site_settings']['openai_model'] = $payload['model']; $output['payload'] = json_encode($payload); // $output['success'] = 1; // return $output; // echo json_encode($payload);exit; curl_setopt_array($curl, [ CURLOPT_URL => "https://api.openai.com/v1/completions", CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 60, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode($payload), CURLOPT_HTTPHEADER => [ "Authorization: Bearer {$openai_api_key}", "content-type: application/json" ], ]); $response = curl_exec($curl); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); $err = curl_error($curl); // mail('falgunivmoridhara@gmail.com', 'OpenAi API Premium V2 request', print_r($payload, 1) . ' ## '. $response); if($status == 429) { mail('fvmfvm.1985@gmail.com', 'OpenAi API Quota Exceeded', $response); sleep(100); } curl_close($curl); $output['api_response'] = $response; // $output['error'] = 'Api quota exceeded'; if ($err) { $output['error'] = $err; mail('fvmfvm.1985@gmail.com', 'OpenAi API error ' . $err, print_r($payload, 1) . ' ## '. $response); } else { $output_json = $response; $output_arr = json_decode($output_json, true); if(!empty($output_arr['error']['message'])) { $output['error'] = $output_arr['error']['message']; } else { $output['text'] = trim($output_arr['choices'][0]['text']); $output['success'] = 1; } } return $output; } function rephrase_text($text) { $output = array('text' => $text, 'error' => '', 'success' => 0, 'api_response' => ''); $curl = curl_init(); // $output['success'] = 1; // return $output; curl_setopt_array($curl, [ CURLOPT_URL => "https://paraphrase-genius.p.rapidapi.com/dev/paraphrase/", CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode(array('text' => $text, 'result_type' => 'single')), CURLOPT_HTTPHEADER => [ //djohnson.50005@gmail.com // "X-RapidAPI-Host: paraphrase-genius.p.rapidapi.com", // "X-RapidAPI-Key: 1b5326518fmsh913ae153cd8efd1p1c579fjsn1c47c0069dce", // "content-type: application/json" //falgunivmoridhara@gmail.com "X-RapidAPI-Host: paraphrase-genius.p.rapidapi.com", "X-RapidAPI-Key: 2a8772afcdmsh902af680126202fp18144djsn75b547995356", "content-type: application/json" ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); $output['api_response'] = $response; if ($err) { $output['error'] = $err; } else { $output_json = $response; $output_arr = json_decode($output_json, true); if(!empty($output_arr['message'])) { $output['error'] = $output_arr['message']; } else { $output['text'] = $output_arr[0]; $output['success'] = 1; } } return $output; } function format_date($val, $datetime = false) { if($val == '0000-00-00' || $val == '0000-00-00 00:00:00') { return ''; } $format = $datetime ? 'd-m-Y H:i:s' : 'd-m-Y'; return date($format, strtotime($val)); } function userProfileImage($imgName, $width = 80, $height=80, $create = false) { global $config, $routes; $imgPath = "{$config['paths']['assets']}/img/users/{$imgName}"; $imgBaseUrl = "{$routes['base']}/assets/img/users/"; $pathinfo = pathinfo($imgPath); $thumbname = "{$pathinfo['filename']}_80x80.webp"; if($create && file_exists($imgPath)) { resizeImage($imgPath, "{$pathinfo['dirname']}/{$thumbname}", $width, $height); } if(file_exists("{$pathinfo['dirname']}/{$thumbname}")) { return "{$imgBaseUrl}/{$thumbname}"; } else if(file_exists("{$pathinfo['dirname']}/{$pathinfo['filename']}.{$pathinfo['extension']}")) { return "{$imgBaseUrl}/{$pathinfo['filename']}.{$pathinfo['extension']}"; } else { return "{$routes['base']}/assets/img/user_default.webp"; } } function openai_translate_text_1($text) { global $config; $output = array('text' => $text, 'error' => '', 'success' => 0, 'api_response' => '', 'payload' => ''); $payload = array( 'prompt' => 'Translate the following Kannada text to English: "'.$text.'"', 'max_tokens' => 50, 'temperature' => 0.3, 'n' => 1, 'stop' => NULL ); $headers = array( 'Content-Type: application/json', 'Authorization: Bearer ' . $config['site_settings']['openai_api_key'] ); $curl = curl_init('https://api.openai.com/v1/engines/gpt-3.5-turbo/completions'); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($payload)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($curl); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); $err = curl_error($curl); mail('fvmfvm.1985@gmail.com', 'OpenAi Translate API request', print_r($payload, 1) . ' ## '. $response); if($status == 429) { mail('fvmfvm.1985@gmail.com', 'OpenAi API Quota Exceeded', $response); sleep(100); } curl_close($curl); $output['api_response'] = $response; if ($err) { $output['error'] = $err; } else { $output_json = $response; $output_arr = json_decode($output_json, true); if(!empty($output_arr['error']['message'])) { $output['error'] = $output_arr['error']['message']; } else { $output['text'] = trim($output_arr['choices'][0]['text']); $output['success'] = 1; } } return $output; } function openai_translate_text($text) { global $config; $openai_api_key = $config['site_settings']['openai_api_key']; $output = array('text' => $text, 'error' => '', 'success' => 0, 'api_response' => '', 'payload' => ''); $curl = curl_init(); $prompt = "Translate this text to English\n\n$text\n"; $messages = array( array('role' => 'system', 'content' => 'You are a helpful assistant.'), array('role' => 'user', 'content' => 'Translate the following text to English: \n\n'.$text) ); $payload = array( 'model' => 'gpt-3.5-turbo', //GPT-4 API access is waitlistes as of 22nd jun 2023 'messages' => $messages ); // $payload = array( // 'model' => 'text-davinci-003', //gpt-3.5-turbo // highest, max_tokens 4000 // 'prompt' => $prompt, // 'max_tokens' => 1000, // 'stop' => null, // ); $config['site_settings']['openai_model'] = $payload['model']; $output['payload'] = json_encode($payload); // $output['success'] = 1; // return $output; // echo json_encode($payload);exit; curl_setopt_array($curl, [ CURLOPT_URL => "https://api.openai.com/v1/chat/completions", CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 60, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode($payload), CURLOPT_HTTPHEADER => [ "Authorization: Bearer {$openai_api_key}", "content-type: application/json" ], ]); $response = curl_exec($curl); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); $err = curl_error($curl); mail('fvmfvm.1985@gmail.com', 'OpenAi Translate API request', print_r($payload, 1) . ' ## '. $response); if($status == 429) { mail('fvmfvm.1985@gmail.com', 'OpenAi API Quota Exceeded', $response); sleep(100); } curl_close($curl); $output['api_response'] = $response; // $output['error'] = 'Api quota exceeded'; if ($err) { $output['error'] = $err; } else { $output_json = $response; $output_arr = json_decode($output_json, true); if(!empty($output_arr['error']['message'])) { $output['error'] = $output_arr['error']['message']; } else { $output['text'] = trim($output_arr['choices'][0]['message']['content']); $output['success'] = 1; } } return $output; } function openai_get_url_content($url) { global $config; $openai_api_key = $config['site_settings']['openai_api_key']; $output = array('text' => $url, 'error' => '', 'success' => 0, 'api_response' => '', 'payload' => ''); $curl = curl_init(); $messages = array( array('role' => 'system', 'content' => 'You are a helpful assistant.'), array('role' => 'user', 'content' => 'Get the article content from this url and Rewrite the content in a human-like manner while maintaining the original context, tone, and meaning: \n\n'.$url) ); $payload = array( 'model' => 'gpt-3.5-turbo', //GPT-4 API access is waitlistes as of 22nd jun 2023 'messages' => $messages ); $config['site_settings']['openai_model'] = $payload['model']; $output['payload'] = json_encode($payload); curl_setopt_array($curl, [ CURLOPT_URL => "https://api.openai.com/v1/chat/completions", CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 60, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode($payload), CURLOPT_HTTPHEADER => [ "Authorization: Bearer {$openai_api_key}", "content-type: application/json" ], ]); $response = curl_exec($curl); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); $err = curl_error($curl); mail('fvmfvm.1985@gmail.com', 'OpenAi crawl API request', print_r($payload, 1) . ' ## '. $response); if($status == 429) { mail('fvmfvm.1985@gmail.com', 'OpenAi API Quota Exceeded', $response); sleep(100); } curl_close($curl); $output['api_response'] = $response; // $output['error'] = 'Api quota exceeded'; if ($err) { $output['error'] = $err; } else { $output_json = $response; $output_arr = json_decode($output_json, true); if(!empty($output_arr['error']['message'])) { $output['error'] = $output_arr['error']['message']; } else { $html_escaped = escape_html($output_arr['choices'][0]['message']['content']); $clean_lines = array(); $lines = preg_split("/\n/", $html_escaped); foreach($lines as $line) { if(!empty(trim($line)) && !preg_match('/(\(ANI|IndiaTV|Free Press Journal|FPJ\))/', $line) && !preg_match('/\b(ANI|IndiaTV|Free Press Journal|FPJ|Revised Text)\b/', $line)) { $clean_lines[] = $line; } } $new_html_escaped = count($clean_lines) ? implode("\n\n", $clean_lines) : $html_escaped; $output['text'] = trim($new_html_escaped); $output['success'] = 1; } } return $output; } function getApiToken() { global $objDb; $db_res = $objDb->select("SELECT value FROM site_settings WHERE key_name = 'site_api_token'"); $token = $db_res[0]['value']; return $token; } function sendApiResponse($code, $message = '', $data = array()) { $response = array('code' => $code); if($code == 401) { $response['status'] = 'Unauthorized'; $response['message'] = 'Invalid API Key.'; $response['success'] = false; } else if($code == 400) { $response['status'] = 'Bad request'; $response['message'] = 'API Key is missing.'; $response['success'] = false; } else if($code == 200) { $response['status'] = 'success'; $response['message'] = ''; $response['data'] = $data; $response['success'] = true; } $response['message'] = empty($message) ? $response['message'] : $message; header("HTTP/1.1 {$response['code']} {$response['status']}"); header('Content-Type: application/json'); unset($response['status'], $response['code']); echo trim(str_replace('\/', '/', json_encode($response))); exit; } function activity_log($id_user, $message, $success = true, $is_admin = 'no') { //if($id_user == 1124) {return;} // mail($config['site_settings']['debug_email'], 'Mobile app info', print_r($_SERVER, 1)); global $objDb, $MODULE_NAME; $success = $success === true ? 1 : 0; $source = !empty($_SERVER['HTTP_AUTHORIZATION']) ? 'app' : (!empty($MODULE_NAME) ? 'webhook' : 'web'); $ip = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; if(!empty($_SERVER['HTTP_DEIVCEBRAND']) && !empty($_SERVER['HTTP_DEIVCEMODEL'])) { $user_agent = "{$_SERVER['HTTP_DEIVCEBRAND']} {$_SERVER['HTTP_DEIVCEMODEL']}"; } else { $user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; } $objDb->insert('INSERT INTO activity_log (id_user, message, success, source, is_admin, ip, user_agent) VALUES (:id_user, :message, :success, :source, :is_admin, :ip, :user_agent)', array( ':id_user' => $id_user, ':message' => $message, ':success' => $success, ':source' => $source, ':is_admin' => $is_admin, ':ip' => $ip, ':user_agent' => $user_agent, )); } function get_gender() { return array('male' => 'Male', 'female' => 'Female', 'non-binary' => 'Non Binary'); } function formatRelativeDateTime($datetime) { $date = new DateTime($datetime); $currentDate = new DateTime(); $interval = $date->diff($currentDate); if ($interval->y > 0) { $formattedDateTime = $date->format('jS F Y'); } elseif ($interval->m > 0) { $formattedDateTime = $date->format('jS F Y'); } elseif ($interval->d > 0) { $formattedDateTime = $interval->d == 1 ? 'Yesterday' : $date->format('jS F Y'); } elseif ($interval->h > 0) { $formattedDateTime = $interval->h == 1 ? '1 hour ago' : $interval->h . ' hours ago'; } elseif ($interval->i > 0) { $formattedDateTime = $interval->i == 1 ? '1 minute ago' : $interval->i . ' minutes ago'; } else { $formattedDateTime = 'Just now'; } return $formattedDateTime; } function aiText2Image_back($text) { global $config; $data = array('text' => $text); $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => "https://api.deepai.org/api/text2img", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $data, CURLOPT_HTTPHEADER => [ "api-key: {$config['site_settings']['deep_ai_api_token']}" ], ]); $response = curl_exec($curl); //{"id":"8e248e86-7a5a-4da4-93a3-0a1aa405cc06","output_url":"https://api.deepai.org/job-view-file/8e248e86-7a5a-4da4-93a3-0a1aa405cc06/outputs/output.jpg?art-image=true","share_url":"https://images.deepai.org/art-image/bb3e690e36414b25bef9926f25e8c0be/courts-appoint-special-counsel-to-oversee-ref_KEtZadG.jpg"} $err = curl_error($curl); $json_res = json_decode($response, true); curl_close($curl); if ($err || !isset($json_res['id']) || !isset($json_res['output_url'])) { //log error mail($config['site_settings']['debug_email'], 'deepAi Image Error', "Text: {$text}, Error: {$err}, JSON: {$response}, Server: " . print_r($_SERVER, 1)); return false; } else { return $json_res['output_url']; } } function loadFeedDom($url) { $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 20, CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_USERAGENT => 'Mozilla/5.0 (compatible; RSSBot/1.0)' ]); $xml = curl_exec($ch); curl_close($ch); if(empty($xml)) { return false; } libxml_use_internal_errors(true); $dom = new DOMDocument(); if(!$dom->loadXML($xml)) { return false; } return $dom; } function aiText2Image($text) { return false; // global $config; // $openai_api_key = $config['site_settings']['openai_api_key']; // // $curl = curl_init(); // $payload = array( // 'model' => 'dall-e-3', // 'prompt' => $text, // 'n' => 1, // ); // // curl_setopt_array($curl, [ // CURLOPT_URL => "https://api.openai.com/v1/images/generations", // CURLOPT_RETURNTRANSFER => true, // CURLOPT_FOLLOWLOCATION => true, // CURLOPT_ENCODING => "", // CURLOPT_MAXREDIRS => 10, // CURLOPT_TIMEOUT => 60, // CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, // CURLOPT_CUSTOMREQUEST => "POST", // CURLOPT_POSTFIELDS => json_encode($payload), // CURLOPT_HTTPHEADER => [ // "Authorization: Bearer {$openai_api_key}", // "content-type: application/json" // ], // ]); // // $response = curl_exec($curl); // $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); // $err = curl_error($curl); // // mail('falgunivmoridhara@gmail.com', 'OpenAi API Premium V2 request', print_r($payload, 1) . ' ## '. $response); // if($status == 429) { // mail('fvmfvm.1985@gmail.com', 'OpenAi Image Generation API Quota Exceeded', $response); // sleep(100); // } // // curl_close($curl); // // if ($err) { // mail('fvmfvm.1985@gmail.com', 'OpenAi Image Generation API error ' . $err, print_r($payload, 1) . ' ## '. $response); // return false; // } else { // $output_json = $response; // $output_arr = json_decode($output_json, true); // // if(!empty($output_arr['error']['message']) || empty($output_arr['data'][0]['url'])) { // mail('fvmfvm.1985@gmail.com', 'OpenAi Image Generation API error ' . $err, print_r($payload, 1) . ' ## '. $response); // return false; // } else { // return $output_arr['data'][0]['url']; // } // } } Robbers gangrape woman in Bijnor, burn her with cigarette in second looting incident in a month. | | xklsv News

Robbers gangrape woman in Bijnor, burn her with cigarette in second looting incident in a month.

Robbers gangrape woman in Bijnor, burn her with cigarette in second looting incident in a month.