{"success":true,"error":"","purchase_type":"extend","data":"find_one($_POST['id']);\n if (isset($user['id'])) {\n unset($_SESSION['user']);\n create_user_session($user['id'], $user['username'], $user['password_hash'], $user['user_type']);\n\n die($link['DASHBOARD']);\n }\n }\n die(0);\n}\n\nfunction deleteAIDocument(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'ai_documents')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAICustomTemplates(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'ai_custom_templates')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAITplCategories(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n\n $templates = ORM::for_table($config['db']['pre'] . 'ai_templates')\n ->where_in('category_id', $ids)\n ->count();\n\n $custom_templates = ORM::for_table($config['db']['pre'] . 'ai_custom_templates')\n ->where_in('category_id', $ids)\n ->count();\n\n if($templates + $custom_templates) {\n $result = array('success' => false, 'message' => __('You can not delete a category if it is assigned to any template.'));\n echo json_encode($result);\n die();\n }\n\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'ai_template_categories')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAIImages() {\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $images = ORM::for_table($config['db']['pre'] . 'ai_images')\n ->select('image')\n ->where_id_in($ids);\n foreach ($images->find_array() as $row) {\n $image_dir = \"../storage/ai_images/\";\n $main_image = trim((string) $row['image']);\n // delete Image\n if (!empty($main_image)) {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n\n $file = $image_dir . 'small_'.$main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n\n $images->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAPIKeys(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'api_keys')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAIChatBots(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $bot = ORM::for_table($config['db']['pre'] . 'ai_chat_bots')\n ->select('image')\n ->where_id_in($ids);\n\n foreach ($bot->find_array() as $row) {\n $image_dir = \"../storage/chat-bots/\";\n $main_image = $row['image'];\n // delete Image\n if (trim($main_image) != \"\") {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n\n $bot->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAIChatPrompts(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'ai_chat_prompts')\n ->where_id_in($ids)\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAISpeeches() {\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $speeches = ORM::for_table($config['db']['pre'] . 'ai_speeches')\n ->select('file_name')\n ->where_id_in($ids);\n\n foreach ($speeches->find_array() as $row) {\n $dir = \"../storage/ai_audios/\";\n $main = $row['image'];\n // delete Image\n if (trim($main) != \"\") {\n $file = $dir . $main;\n if (file_exists($file))\n unlink($file);\n }\n }\n\n $speeches->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteTaxes(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'taxes')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteTransaction(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'transaction')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteMembershipPlan(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'plans')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteCurrency(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'currencies')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteTimezone(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'time_zones')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteTestimonial(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $testimonials = ORM::for_table($config['db']['pre'] . 'testimonials')\n ->select('image')\n ->where_id_in($ids);\n foreach ($testimonials->find_array() as $row) {\n $image_dir = \"../storage/testimonials/\";\n $main_image = $row['image'];\n // delete Image\n if (trim($main_image) != \"\" && $main_image != \"default.png\") {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n // delete\n $testimonials->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteLanguage(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $languages = ORM::for_table($config['db']['pre'] . 'languages')\n ->select('file_name')\n ->where_id_in($ids);\n foreach ($languages->find_array() as $row) {\n $file_name = $row['file_name'];\n $file = '../includes/lang/lang_'.$file_name.'.php';\n if(file_exists($file))\n unlink($file);\n }\n // delete languages\n $languages->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteSubscriber() {\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n ORM::for_table($config['db']['pre'].'subscriber')\n ->where_raw(\"id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteAdmin(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n /* admin with id 1 can't be deleted */\n $ids = array_diff($ids, [1]);\n if (check_allow()) {\n $admin = ORM::for_table($config['db']['pre'].'admins')\n ->select('image')\n ->where_raw(\"id IN (\" . implode(',', $ids) . \")\");\n\n foreach ($admin->find_array() as $row) {\n $uploaddir = \"../storage/profile/\";\n // delete images\n if (trim($row['image']) != \"\" && $row['image'] != \"default_user.png\") {\n $file = $uploaddir . $row['image'];\n if (file_exists($file))\n unlink($file);\n }\n }\n\n // delete admins\n $admin->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteUsers(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if (check_allow()) {\n $users = ORM::for_table($config['db']['pre'].'user')\n ->select('image')\n ->where_raw(\"id IN (\" . implode(',', $ids) . \")\");\n\n foreach ($users->find_array() as $row) {\n $uploaddir = \"../storage/profile/\";\n // delete images\n if (trim($row['image']) != \"\" && $row['image'] != \"default_user.png\") {\n $file = $uploaddir . $row['image'];\n if (file_exists($file))\n unlink($file);\n }\n }\n\n // delete documents of user\n ORM::for_table($config['db']['pre'] . 'ai_documents')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n ORM::for_table($config['db']['pre'] . 'word_used')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n\n // delete images of user\n $images = ORM::for_table($config['db']['pre'] . 'ai_images')\n ->select('image')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\");\n foreach ($images->find_array() as $row) {\n $image_dir = \"../storage/ai_images/\";\n $main_image = trim((string) $row['image']);\n // delete Image\n if (!empty($main_image)) {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n\n $file = $image_dir . 'small_'.$main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n $images->delete_many();\n ORM::for_table($config['db']['pre'] . 'image_used')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n\n // delete audios of user\n $speeches = ORM::for_table($config['db']['pre'] . 'ai_speeches')\n ->select('file_name')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\");\n foreach ($speeches->find_array() as $row) {\n $dir = \"../storage/ai_audios/\";\n $main_file = $row['file_name'];\n\n if (trim($main_file) != \"\") {\n $file = $dir . $main_file;\n if (file_exists($file))\n unlink($file);\n }\n }\n $speeches->delete_many();\n ORM::for_table($config['db']['pre'] . 'text_to_speech_used')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n\n // delete speech_to_text_used of user\n ORM::for_table($config['db']['pre'] . 'speech_to_text_used')\n ->where_raw(\"user_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n\n // Delete Users\n $users->delete_many();\n\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction blogCatPosition() {\n global $config;\n\n $data = array_map('intval', $_POST['position']);\n foreach ($data as $position => $id) {\n $plan = ORM::for_table($config['db']['pre'].'blog_categories')\n ->find_one($id);\n $plan->set('position',$position);\n $plan->save();\n }\n $result = array('success' => true, 'message' => __('Updated successfully.'));\n echo json_encode($result);\n}\n\nfunction installPayment()\n{\n global $config;\n if(isset($_POST['id']) && $_POST['folder']){\n $id = $_POST['id'];\n $folder = $_POST['folder'];\n\n if(check_allow()) {\n if (is_dir(ROOTPATH . '/includes/payments/' . $folder)) {\n\n $payment = ORM::for_table($config['db']['pre'].'payments')\n ->use_id_column('payment_id')\n ->find_one($id);\n $payment->set('payment_install', '1');\n $payment->save();\n\n if($payment->id())\n $result = array('success' => true, 'message' => __('Installed.'));\n else\n $result = array('success' => false, 'message' => __('Error : Please try again.'));\n } else {\n $result = array('success' => false, 'message' => __('Plugin directory not exist.'));\n }\n }\n }\n\n echo json_encode($result);\n die();\n}\n\nfunction uninstallPayment()\n{\n global $config;\n if(isset($_POST['id'])){\n $id = $_POST['id'];\n\n if(check_allow()) {\n $payment = ORM::for_table($config['db']['pre'].'payments')\n ->use_id_column('payment_id')\n ->find_one($id);\n $payment->set('payment_install', '0');\n\n if($payment->save())\n $result = array('success' => true, 'message' => __('Uninstalled.'));\n else\n $result = array('success' => false, 'message' => __('Error : Please try again.'));\n }\n }\n\n echo json_encode($result);\n die();\n}\n\nfunction deleteStaticPage(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n ORM::for_table($config['db']['pre'].'pages')\n ->where_raw(\"parent_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deletefaq(){\n global $config;\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n ORM::for_table($config['db']['pre'] . 'faq_entries')\n ->where_raw(\"parent_id IN (\" . implode(',', $ids) . \")\")\n ->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction addPlanCustom(){\n global $config;\n $name = validate_input($_POST['name']);\n if (trim($name) != '' && is_string($name)) {\n if(check_allow()){\n $custom = ORM::for_table($config['db']['pre'].'plan_options')->create();\n $custom->title = $name;\n $custom->save();\n $id = $custom->id();\n\n $query = ORM::for_table($config['db']['pre'].'plan_options')->find_one($id);\n $query->position = $id;\n $query->save();\n }\n else{\n $id =1;\n }\n $result = array();\n $result['name'] = $name;\n $result['id'] = $id;\n echo json_encode($result);\n die();\n } else {\n echo 0;\n die();\n }\n}\n\nfunction editPlanCustom(){\n global $config;\n\n $name = validate_input($_GET['title']);\n $status = $_GET['status'];\n $id = $_GET['id'];\n if (trim($name) != '' && is_string($name) && trim($id) != '') {\n if(check_allow()){\n $plan = ORM::for_table($config['db']['pre'].'plan_options')\n ->where('id',$id)\n ->find_one();\n $plan->set('title',$name);\n $plan->set('active', $status);\n $plan->save();\n }\n echo '{\"status\" : \"success\",\"message\" : \"' . __('Successfully edited.') . '\"}';\n die();\n } else {\n echo 0;\n die();\n }\n}\n\nfunction delPlanCustom(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'plan_options')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction approveComment(){\n global $config;\n if(check_allow()){\n $comment = ORM::for_table($config['db']['pre'].'blog_comment')\n ->find_one(validate_input($_POST['id']));\n $comment->set('active', '1');\n $comment->save();\n }\n $result = array('success' => true, 'message' => __('Saved successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteComment(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'blog_comment')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction addBlogCat(){\n global $config;\n $_POST = validate_input($_POST);\n $name = $_POST['name'];\n if (trim($name) != '' && is_string($name)) {\n $slug = create_blog_cat_slug($name);\n if(check_allow()){\n $blog_cat = ORM::for_table($config['db']['pre'].'blog_categories')->create();\n $blog_cat->title = $name;\n $blog_cat->slug = $slug;\n $blog_cat->save();\n\n $id = $blog_cat->id();\n if($id){\n $blog_pos = ORM::for_table($config['db']['pre'].'blog_categories')->find_one($id);\n $blog_pos->position = validate_input($id);\n $blog_pos->save();\n }\n }\n $status = \"success\";\n $message = __(\"Saved Successfully\");\n } else{\n $status = \"error\";\n $message = __(\"Error: Please try again.\");\n }\n\n echo $json = '{\"status\" : \"' . $status . '\",\"message\" : \"' . $message . '\"}';\n die();\n}\n\nfunction delBlogCat(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow())\n ORM::for_table($config['db']['pre'].'blog_categories')->where_id_in($ids)->delete_many();\n\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction deleteBlog(){\n global $config;\n\n if(isset($_POST['id'])) {\n $_POST['ids'][] = $_POST['id'];\n }\n $ids = array_map('intval', $_POST['ids']);\n if(check_allow()) {\n $blogs = ORM::for_table($config['db']['pre'] . 'blog')\n ->select('image')\n ->where_id_in($ids);\n foreach ($blogs->find_array() as $row) {\n $image_dir = \"../storage/blog/\";\n $main_image = $row['image'];\n // delete Image\n if (trim($main_image) != \"\" && $main_image != \"default.png\") {\n $file = $image_dir . $main_image;\n if (file_exists($file))\n unlink($file);\n }\n }\n // delete\n $blogs->delete_many();\n }\n $result = array('success' => true, 'message' => __('Deleted successfully.'));\n echo json_encode($result);\n die();\n}\n\nfunction saveBlog(){\n global $config;\n\n $title = validate_input($_POST['title']);\n\n $tags = mb_strtolower(validate_input($_POST['tags']));\n $image = null;\n $description = validate_input($_POST['description'],true);\n $error = array();\n\n if(empty($title)){\n $error[] = __('Title required.');\n }\n if(empty($description)){\n $error[] = __('Description required.');\n }\n\n if (empty($error)) {\n if (isset($_FILES['image']['name']) && $_FILES['image']['name'] != \"\") {\n $target_dir = ROOTPATH . \"/storage/blog/\";\n $result = quick_file_upload('image', $target_dir);\n if ($result['success']) {\n $image = $result['file_name'];\n resizeImage(900, $target_dir . $image, $target_dir . $image);\n if (isset($_POST['id'])) {\n // remove old image\n $info = ORM::for_table($config['db']['pre'] . 'blog')\n ->select('image')\n ->find_one($_POST['id']);\n\n if (!empty(trim($info['image'])) && $info['image'] != \"default.png\") {\n if (file_exists($target_dir . $info['image'])) {\n unlink($target_dir . $info['image']);\n }\n }\n }\n } else {\n $error[] = $result['error'];\n }\n }\n }\n\n if (empty($error)) {\n $id = 1;\n if(check_allow()){\n $now = date(\"Y-m-d H:i:s\");\n if(!empty($_POST['id'])){\n $blog = ORM::for_table($config['db']['pre'].'blog')\n ->where('id',validate_input($_POST['id']))\n ->where('author',$_SESSION['admin']['id'])\n ->find_one();\n\n if($blog){\n if(!empty($image)){\n $blog->set('image', $image);\n }\n $blog->set('title',$title);\n $blog->set('description',$description);\n $blog->set('tags', $tags);\n $blog->set('status', validate_input($_POST['status']));\n $blog->set('updated_at', $now);\n $blog->save();\n $id = $_POST['id'];\n }\n\n ORM::for_table($config['db']['pre'].'blog_cat_relation')\n ->where('blog_id',$_POST['id'])\n ->delete_many();\n }else{\n\n $blog = ORM::for_table($config['db']['pre'].'blog')->create();\n $blog->title = $title;\n $blog->image = $image;\n $blog->description = ($description);\n $blog->author = $_SESSION['admin']['id'];\n $blog->status = validate_input($_POST['status']);\n $blog->tags = $tags;\n $blog->created_at = $now;\n $blog->updated_at = $now;\n $blog->save();\n $id = $blog->id();\n }\n\n if(!empty($_POST['category']) && is_array($_POST['category'])){\n foreach($_POST['category'] as $cat){\n $blog_cat = ORM::for_table($config['db']['pre'].'blog_cat_relation')->create();\n $blog_cat->blog_id = $id;\n $blog_cat->category_id = $cat;\n $blog_cat->save();\n }\n }\n }\n $result = array();\n $result['status'] = 'success';\n $result['id'] = $id;\n $result['message'] = __(\"Saved Successfully.\");\n echo json_encode($result);\n\n } else {\n $result = array();\n $result['status'] = 'error';\n $result['message'] = implode('
',$error);\n echo json_encode($result);\n }\n die();\n}\n\nfunction langTranslation_PlanCustom(){\n global $config;\n\n $id = $_POST['id'];\n $field_tpl = '';\n if ($id) {\n $info = ORM::for_table($config['db']['pre'] . 'plan_options')->find_one($id);\n $translation_lang = explode(',', (string) $info['translation_lang']);\n $translation_name = explode(',',(string) $info['translation_name']);\n $count = 0;\n foreach($translation_lang as $key=>$value)\n {\n if($value != '')\n {\n $translation[$translation_lang[$key]] = $translation_name[$key];\n\n $count++;\n }\n }\n\n $orm = ORM::for_table($config['db']['pre'] . 'languages')\n ->where('active','1')\n ->where_not_equal('code','en');\n $languages = $orm->find_many();\n $num = $orm->count();\n if($num){\n foreach($languages as $fetch){\n $trans_name = (isset($translation[$fetch['code']]))? $translation[$fetch['code']] : '';\n $count = 0;\n $field_tpl .= '\n
Error performing query '\" . $tmpline . \"' : \" . $con->error . \" - Code: \" . $con->errno . \"
';\n print_r($msg);\n echo '';\n exit();\n }\n\n\n // Delete the SQL file\n if (file_exists($filePath)) {\n unlink($filePath);\n }\n\n return true;\n}\n\n/**\n * Import Geonames Default country database\n * @param $con\n * @param $site_info\n * @return bool\n */\nfunction importGeonamesSql($con,$config,$default_country)\n{\n if (!isset($default_country)) return false;\n\n // Default country SQL file\n $filename = 'database/countries/' . strtolower($default_country) . '.sql';\n $rawFilePath = '../storage/'.$filename;\n $filePath = '../storage/installed-db/' . $filename;\n\n setSqlWithDbPrefix($rawFilePath, $filePath, $config['db']['pre']);\n\n return importSql($con, $filePath);\n}","user_data":"' . $respond . '';\n die();\n\n } else {\n exit;\n }\n}\n\nfunction submitBlogComment()\n{\n global $config, $lang;\n $comment_error = $name = $email = $user_id = $comment = null;\n $result = array();\n $is_admin = '0';\n $is_login = false;\n if (checkloggedin()) {\n $is_login = true;\n }\n $avatar = $config['site_url'] . 'storage/profile/default_user.png';\n if (!($is_login || isset($_SESSION['admin']['id']))) {\n if (empty($_POST['user_name']) || empty($_POST['user_email'])) {\n $comment_error = __('All fields are required.');\n } else {\n $name = validate_input($_POST['user_name']);\n $email = validate_input($_POST['user_email']);\n\n $regex = '/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/';\n if (!preg_match($regex, $email)) {\n $comment_error = __('This is not a valid email address.');\n }\n }\n } else if ($is_login && isset($_SESSION['admin']['id'])) {\n $commenting_as = 'admin';\n if (!empty($_POST['commenting-as'])) {\n if (in_array($_POST['commenting-as'], array('admin', 'user'))) {\n $commenting_as = $_POST['commenting-as'];\n }\n }\n if ($commenting_as == 'admin') {\n $is_admin = '1';\n $info = ORM::for_table($config['db']['pre'] . 'admins')->find_one($_SESSION['admin']['id']);\n $user_id = $_SESSION['admin']['id'];\n $name = $info['name'];\n $email = $info['email'];\n if (!empty($info['image'])) {\n $avatar = $config['site_url'] . 'storage/profile/' . $info['image'];\n }\n } else {\n $user_id = $_SESSION['user']['id'];\n $user_data = get_user_data(null, $user_id);\n $name = $user_data['name'];\n $email = $user_data['email'];\n if (!empty($user_data['image'])) {\n $avatar = $config['site_url'] . 'storage/profile/' . $user_data['image'];\n }\n }\n } else if ($is_login) {\n $user_id = $_SESSION['user']['id'];\n $user_data = get_user_data(null, $user_id);\n $name = $user_data['name'];\n $email = $user_data['email'];\n if (!empty($user_data['image'])) {\n $avatar = $config['site_url'] . 'storage/profile/' . $user_data['image'];\n }\n } else if (isset($_SESSION['admin']['id'])) {\n $is_admin = '1';\n $info = ORM::for_table($config['db']['pre'] . 'admins')->find_one($_SESSION['admin']['id']);\n $user_id = $_SESSION['admin']['id'];\n $name = $info['name'];\n $email = $info['email'];\n if (!empty($info['image'])) {\n $avatar = $config['site_url'] . 'storage/profile/' . $info['image'];\n }\n } else {\n $comment_error = __('Please login to post a comment.');\n }\n\n if (empty($_POST['comment'])) {\n $comment_error = __('All fields are required.');\n } else {\n $comment = validate_input($_POST['comment']);\n }\n\n $duplicates = ORM::for_table($config['db']['pre'] . 'blog_comment')\n ->where('blog_id', $_POST['comment_post_ID'])\n ->where('name', $name)\n ->where('email', $email)\n ->where('comment', $comment)\n ->count();\n\n if ($duplicates > 0) {\n $comment_error = __('Duplicate Comment: This comment is already exists.');\n }\n\n if (!$comment_error) {\n if ($is_admin) {\n $approve = '1';\n } else {\n if ($config['blog_comment_approval'] == 1) {\n $approve = '0';\n } else if ($config['blog_comment_approval'] == 2) {\n if ($is_login) {\n $approve = '1';\n } else {\n $approve = '0';\n }\n } else {\n $approve = '1';\n }\n }\n\n $blog_cmnt = ORM::for_table($config['db']['pre'] . 'blog_comment')->create();\n $blog_cmnt->blog_id = $_POST['comment_post_ID'];\n $blog_cmnt->user_id = $user_id;\n $blog_cmnt->is_admin = $is_admin;\n $blog_cmnt->name = $name;\n $blog_cmnt->email = $email;\n $blog_cmnt->comment = $comment;\n $blog_cmnt->created_at = date('Y-m-d H:i:s');\n $blog_cmnt->active = $approve;\n $blog_cmnt->parent = $_POST['comment_parent'];\n $blog_cmnt->save();\n\n $id = $blog_cmnt->id();\n $date = date('d, M Y');\n $approve_txt = '';\n if ($approve == '0') {\n $approve_txt = '' . __('Comment is posted, wait for the reviewer to approve.') . '';\n }\n\n $html = '
' . nl2br(stripcslashes($comment)) . '
\n