Example #1
0
function edit_task($user_id, $task_id)
{
    $task_text = isset($_POST["text"]) ? trim($_POST["text"]) : "";
    if ("" == $task_text) {
        add_message("You forgot write something.");
        return false;
    }
    DB::getInstance()->query("UPDATE tasks SET task_text = :task_text WHERE task_uid = :user_id AND task_id = :task_id", array("user_id" => $user_id, "task_id" => $task_id, "task_text" => encryptText($task_text)));
    add_message("Task has been edited.");
    return true;
}
Example #2
0
function createNewPost($post, $cURL, $globalCity, $colname_rsModule, $resultModule, $resultModuleFields, $modelGeneral, $tablename, $uid, $approved = 0)
{
    $return = array();
    try {
        if (empty($uid)) {
            throw new Exception('user not logged in');
        }
        $latitude = $post['lat'];
        $longitude = $post['lng'];
        $data = $post;
        if (isset($data['MM_Insert'])) {
            unset($data['MM_Insert']);
        }
        if (isset($data['submit'])) {
            unset($data['submit']);
        }
        $data['id'] = guid();
        $data['uid'] = $uid;
        $data['city_id'] = $globalCity['id'];
        $data['module_id'] = $colname_rsModule;
        $data['rc_created_dt'] = date('Y-m-d H:i:s');
        $data['rc_updated_dt'] = date('Y-m-d H:i:s');
        if (!empty($post['lat'])) {
            $data['clatitude'] = $latitude;
            unset($data['lat']);
        }
        if (!empty($post['lng'])) {
            $data['clongitude'] = $longitude;
            unset($data['lng']);
        }
        //encryption
        foreach ($resultModuleFields as $k => $v) {
            //if field is not show then calculate on bases of default value
            if ($v['field_type'] == 'noshow') {
                if (empty($data[$v['field_name']])) {
                    if ($v['field_default_value'] === 'current_date_time') {
                        $data[$v['field_name']] = date('Y-m-d H:i:s');
                    }
                }
            }
            if (isset($data[$v['field_name']]) && $v['encrypted'] == 1) {
                $data[$v['field_name']] = encryptText($data[$v['field_name']]);
            }
        }
        //encryption
        foreach ($post as $k => $v) {
            if (is_array($v)) {
                $post[$k] = !empty($post[$k]) ? array_filter($post[$k]) : array();
                $data[$k] = json_encode($post[$k]);
            }
        }
        if ($approved == 1) {
            $data['rc_approved'] = 1;
        } else {
            $data['rc_approved'] = 0;
            if ($resultModule['paid_module'] == 1 && $resultModule['paid_posting'] == 1) {
                $data['rc_approved'] = 0;
            } else {
                if ($resultModule['approval_needed'] == 0) {
                    $data['rc_approved'] = 1;
                }
            }
        }
        $result = $modelGeneral->addDetails($tablename, $data);
        //tag start
        if (!empty($post['title'])) {
            $tmp1 = !empty($post['tags']) ? explode(',', $post['tags']) : array();
            $tmp2 = explode(' ', $post['title']);
            $tmp = array_merge($tmp1, $tmp2);
            $tmp = array_unique($tmp);
            foreach ($tmp as $v) {
                $v = trim($v);
                $d = array();
                $d['id'] = $data['id'];
                $d['tag'] = $v;
                $d['module_id'] = $colname_rsModule;
                $modelGeneral->addDetails('auto_pre_tags', $d);
            }
        }
        //tag ends
        //multiselect
        foreach ($resultModuleFields as $k => $v) {
            if ($v['field_type'] === 'multipleselectbox') {
                //adding category
                if (!empty($post[$v['field_name']])) {
                    foreach ($post[$v['field_name']] as $v1) {
                        $v1 = trim($v1);
                        $d = array();
                        $d['id'] = $data['id'];
                        $d['category_id'] = $v1;
                        $d['col_name'] = $v['field_name'];
                        $d['module_id'] = $colname_rsModule;
                        $modelGeneral->addDetails('auto_pre_multiselectcats', $d);
                    }
                }
            }
        }
        //multiselect
        $return['error'] = 0;
        $return['msg'] = '';
        $return['url'] = $cURL . "/auto/confirm?id=" . $data['id'] . "&module_id=" . $colname_rsModule . "&submit=1&new=1";
    } catch (Exception $e) {
        $error = $e->getMessage();
        $return['error'] = 1;
        $return['msg'] = $error;
    }
    return $return;
}
Example #3
0
 if (isset($data['submit'])) {
     unset($data['submit']);
 }
 $data['rc_updated_dt'] = date('Y-m-d H:i:s');
 if (!empty($_POST['lat'])) {
     $data['clatitude'] = $latitude;
     unset($data['lat']);
 }
 if (!empty($_POST['lng'])) {
     $data['clongitude'] = $longitude;
     unset($data['lng']);
 }
 //encryption
 foreach ($resultModuleFields as $k => $v) {
     if (isset($data[$v['field_name']]) && $v['encrypted'] == 1) {
         $data[$v['field_name']] = encryptText($data[$v['field_name']]);
     }
 }
 //encryption
 foreach ($_POST as $k => $v) {
     if (is_array($v)) {
         $_POST[$k] = !empty($_POST[$k]) ? array_filter($_POST[$k]) : array();
         $data[$k] = json_encode($_POST[$k]);
     }
 }
 $data['rc_approved'] = 0;
 if ($resultModule['approval_needed'] == 0) {
     $data['rc_approved'] = 1;
 }
 $where = sprintf('uid = %s AND id=%s', $modelGeneral->qstr($_SESSION['user']['id']), $modelGeneral->qstr($_GET['id']));
 $result = $modelGeneral->updateDetails($tablename, $data, $where);
Example #4
0
<?php

require_once '../inc/connection.inc.php';
require_once '../inc/function.inc.php';
$user_id = (int) $_GET['id'];
if (isset($_POST['submit'])) {
    $message = encryptText($_POST['message']);
    $query = "INSERT INTO `chats` (`user_id`,`flag`,`message`) VALUES ('{$user_id}',0,'{$message}')";
    mysqli_query($connection, $query);
}
?>

<!doctype html>
<html>
<head>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="author" content="prabhakar gupta">

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-8">
<?php 
$names_array = array();
if (isset($_GET['id'])) {
<?php

require_once 'inc/connection.inc.php';
require_once 'inc/function.inc.php';
$user_id = NULL;
// to check if it is a GET request or not
if (isset($_GET['device']) && isset($_GET['service'])) {
    $device_id = $_GET['device'];
    $service_provider = encryptText($_GET['service']);
    $query = "SELECT `id` FROM `users` WHERE `device_id`='{$device_id}'";
    $query_run = mysqli_query($connection, $query);
    // to check if device has already been registered or not
    if (mysqli_num_rows($query_run) > 0) {
        $query_row = mysqli_fetch_assoc($query_run);
        $user_id = $query_row['id'];
    } else {
        $query_ins = "INSERT INTO `users`(`device_id`,`service_provider`) VALUES ('{$device_id}','{$service_provider}')";
        mysqli_query($connection, $query_ins);
        $user_id = mysqli_insert_id($connection);
    }
}
echo json_encode(array('user_id' => (int) $user_id));
Example #6
0
}
if ($_POST) {
    //print_r($_POST);
    require_once 'Crypt/Blowfish.php';
    // Just including the class
    //echo "<hr>";
    //$bf = new Crypt_Blowfish('JKjVXtFdY3NNT6Fp6U9uM3m5eeWbtqXWrR5qwWpyM9b8SFSdWVK2vruN');
    //$encrypted = $bf->encrypt('prbc_id=107682291&billeo_id=505&history_flag=HP');
    //echo "encrypted: ".bin2hex($encrypted);
    //echo "<br>";
    //$plaintext = $bf->decrypt(convert('33cc757285de361a1c726a6c465fa02077482c1844311bd154c398e9da14d109c9b83af639b16e635b1caf1d00bf64b8'));
    //echo ", plain text: ".trim($plaintext);
    //echo "<hr>";
    //$bf = new Crypt_Blowfish('JKjVXtFdY3NNT6Fp6U9uM3m5eeWbtqXWrR5qwWpyM9b8SFSdWVK2vruN');
    if ($_POST['type'] == "encrypt") {
        echo "encrypted: " . encryptText($_POST['desc']);
        //$encrypted = $bf->encrypt($_POST['desc']);
        //echo "encrypted: ".bin2hex($encrypted);
    } else {
        if ($_POST['type'] == "decrypt") {
            echo 'decrypted: ' . decryptText($_POST['desc']);
            //$plaintext = $bf->decrypt(convert(trim($_POST['desc'])));
            //echo trim($plaintext);
        }
    }
}
?>
<form id="form1" name="form1" method="post" action="">
  <p>Key: 
    <input name="key" type="text" id="key" size="100" value="<?php 
echo $_POST['key'];
<?php

$text = $_GET['text'];
$hashValue = $_GET['hashValue'];
$fontSize = $_GET['fontSize'];
$fontStyle = $_GET['fontStyle'];
$cssStyle = "font-size:{$fontSize};";
if ($fontStyle == 'bold') {
    $cssStyle .= "font-weight:bold;";
}
if ($fontStyle == 'normal' || $fontStyle == 'italic') {
    $cssStyle .= "font-style:{$fontStyle};";
}
$encryptedText = encryptText($text, $hashValue);
echo "<p style=\"{$cssStyle}\">{$encryptedText}</p>";
function encryptText($text, $hashValue)
{
    $result = '';
    for ($i = 0; $i < strlen($text); $i++) {
        $ch = $text[$i];
        if ($i % 2 == 0) {
            $newCh = chr(ord($ch) + $hashValue);
        } else {
            $newCh = chr(ord($ch) - $hashValue);
        }
        $result .= $newCh;
    }
    return $result;
}
<?php

$text = $_GET["text"];
$hash_value = $_GET["hashValue"];
$font_size = $_GET["fontSize"];
$font_style = $_GET["fontStyle"];
$css_style = "font-size:{$font_size};";
if ($font_style == 'bold') {
    $css_style .= "font-weight:bold;";
}
if ($font_style == 'italic' || $font_style == 'normal') {
    $css_style .= "font-style:{$font_style};";
}
$encrypted_text = encryptText($text, $hash_value);
//htmlspecialchars
function encryptText($text, $hash_value)
{
    $result = '';
    for ($i = 0; $i < strlen($text); $i++) {
        $ch = $text[$i];
        if ($i % 2 == 0) {
            $newCh = chr(ord($ch) + $hash_value);
            //$hash_value;
        } else {
            $newCh = chr(ord($ch) - $hash_value);
        }
        $result .= $newCh;
    }
    return $result;
}
echo "<p style=\"{$css_style}\">{$encrypted_text}</p>";
Example #9
0
<?php

require_once '../inc/connection.inc.php';
require_once '../inc/function.inc.php';
$user_id = (int) $_GET['user'];
$message = encryptText($_GET['message']);
$flag = intval(!(bool) $_GET['flag']);
// 0 means admin, 1 means user
$query = "INSERT INTO `chats` (`user_id`,`flag`,`message`) VALUES ('{$user_id}','{$flag}','{$message}')";
if (mysqli_query($connection, $query)) {
    echo 1;
} else {
    echo 0;
}
Example #10
0
<?php

require_once '../inc/connection.inc.php';
require_once '../inc/function.inc.php';
if (isset($_POST['submit'])) {
    //echo json_encode($_POST);
    //die;
    $event_name = encryptText($_POST['name']);
    $event_descrption = encryptText($_POST['descrption']);
    $event_date = strtotime($_POST['date']);
    $event_category = intval($_POST['category']);
    $event_image = encryptText($_POST['image']);
    $event_team_size = intval($_POST['team_size']);
    if ($event_image == '') {
        $query = "INSERT INTO `events` (`event_name`,`event_category`,`descp`,`date`,`team_size`) VALUES ('{$event_name}','{$event_category}','{$event_descrption}','{$event_date}','{$event_team_size}')";
    } else {
        $query = "INSERT INTO `events` (`event_name`,`event_category`,`image`,`descp`,`date`,`team_size`) VALUES ('{$event_name}','{$event_category}','{$event_image}','{$event_descrption}','{$event_date}','{$event_team_size}')";
    }
    mysqli_query($connection, $query);
}
?>
<!doctype html>
<html>
<head>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
	<title>Moksha 2016 | Add event to backend</title>
</head>
<body>
<hr>
<div class="container">
	<div class="row">