ankitjain28may /
openchat
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Conversation Class Doc Comment |
||
| 4 | * |
||
| 5 | * PHP version 5 |
||
| 6 | * |
||
| 7 | * @category PHP |
||
| 8 | * @package OpenChat |
||
| 9 | * @author Ankit Jain <[email protected]> |
||
| 10 | * @license The MIT License (MIT) |
||
| 11 | * @link https://github.com/ankitjain28may/openchat |
||
| 12 | */ |
||
| 13 | namespace ChatApp; |
||
| 14 | |||
| 15 | require_once dirname(__DIR__).'/vendor/autoload.php'; |
||
| 16 | use ChatApp\Time; |
||
| 17 | use ChatApp\User; |
||
| 18 | use mysqli; |
||
| 19 | use Dotenv\Dotenv; |
||
| 20 | $dotenv = new Dotenv(dirname(__DIR__)); |
||
| 21 | $dotenv->load(); |
||
| 22 | |||
| 23 | /** |
||
| 24 | * To Return the Conversation Data between users |
||
| 25 | * |
||
| 26 | * @category PHP |
||
| 27 | * @package OpenChat |
||
| 28 | * @author Ankit Jain <[email protected]> |
||
| 29 | * @license The MIT License (MIT) |
||
| 30 | * @link https://github.com/ankitjain28may/openchat |
||
| 31 | */ |
||
| 32 | class Conversation |
||
| 33 | { |
||
| 34 | /* |
||
| 35 | |-------------------------------------------------------------------------- |
||
| 36 | | Conversation Class |
||
| 37 | |-------------------------------------------------------------------------- |
||
| 38 | | |
||
| 39 | | To Return the Conversation Data between users. |
||
| 40 | | |
||
| 41 | */ |
||
| 42 | |||
| 43 | protected $connect; |
||
| 44 | protected $array; |
||
| 45 | protected $obTime; |
||
| 46 | protected $obUser; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Create a new class instance. |
||
| 50 | * |
||
| 51 | * @return void |
||
| 52 | */ |
||
| 53 | View Code Duplication | public function __construct() |
|
| 54 | { |
||
| 55 | $this->connect = new mysqli( |
||
| 56 | getenv('DB_HOST'), |
||
| 57 | getenv('DB_USER'), |
||
| 58 | getenv('DB_PASSWORD'), |
||
| 59 | getenv('DB_NAME') |
||
| 60 | ); |
||
| 61 | $this->obTime = new Time(); |
||
| 62 | $this->obUser = new User(); |
||
| 63 | $this->array = array(); |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Fetch data from DB and show to user. |
||
| 68 | * |
||
| 69 | * @param string $msg To store message |
||
| 70 | * @param boolean $para To store True/False |
||
| 71 | * |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | public function conversationLoad($msg, $para) |
||
| 75 | { |
||
| 76 | $msg = json_decode($msg); |
||
| 77 | if (!empty($msg)) { |
||
| 78 | $userId = $msg->userId; |
||
| 79 | $add_load = 0; |
||
| 80 | $details = $msg->details; |
||
| 81 | $load = $msg->load; |
||
| 82 | |||
| 83 | if ($para == true) { |
||
| 84 | $details = convert_uudecode(hex2bin($details)); |
||
| 85 | } |
||
| 86 | $fetch = $this->obUser->userDetails($details, $para); |
||
|
0 ignored issues
–
show
|
|||
| 87 | |||
| 88 | if ($fetch != null) { |
||
| 89 | $login_id = (int)$fetch['login_id']; |
||
| 90 | |||
| 91 | // Unique Identifier |
||
| 92 | if ($login_id > $userId) { |
||
| 93 | $identifier = $userId.':'.$login_id; |
||
| 94 | } else { |
||
| 95 | $identifier = $login_id.':'.$userId; |
||
| 96 | } |
||
| 97 | |||
| 98 | $query = "SELECT total_messages from total_message |
||
| 99 | where identifier = '$identifier'"; |
||
| 100 | if ($result = $this->connect->query($query)) { |
||
| 101 | if ($result->num_rows > 0) { |
||
| 102 | $total = $result->fetch_assoc(); |
||
| 103 | $total = $total['total_messages']; |
||
| 104 | if ($total - $load > 0) { |
||
| 105 | if ($total - $load > 10) { |
||
| 106 | $add_load = $load + 10; |
||
| 107 | } else { |
||
| 108 | $add_load = $total; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | $query = "SELECT message, time, sent_by FROM messages WHERE |
||
| 115 | identifier_message_number = '$identifier' |
||
| 116 | ORDER BY id DESC limit ".$load; |
||
| 117 | |||
| 118 | if ($result = $this->connect->query($query)) { |
||
| 119 | if ($result->num_rows > 0) { |
||
| 120 | while ($row = $result->fetch_assoc()) { |
||
| 121 | $row['time'] = $this->obTime->timeConversion( |
||
| 122 | $row['time'] |
||
| 123 | ); |
||
| 124 | $row = array_merge($row, ['start' => $userId]); |
||
| 125 | $this->array = array_merge($this->array, [$row]); |
||
| 126 | } |
||
| 127 | |||
| 128 | $this->array = array_merge( |
||
| 129 | [[ |
||
| 130 | 'name' => $fetch['name'], |
||
| 131 | 'username' => $fetch['username'], |
||
| 132 | 'id' => bin2hex(convert_uuencode($fetch['login_id'])), |
||
| 133 | 'load' => $add_load, |
||
| 134 | 'login_status' => $fetch['login_status'], |
||
| 135 | 'type' => 1 |
||
| 136 | ]], |
||
| 137 | $this->array |
||
| 138 | ); |
||
| 139 | return json_encode($this->array); |
||
| 140 | } else { |
||
| 141 | return json_encode( |
||
| 142 | [[ |
||
| 143 | 'name' => $fetch['name'], |
||
| 144 | 'username' => $fetch['username'], |
||
| 145 | 'id' => bin2hex(convert_uuencode($fetch['login_id'])), |
||
| 146 | 'login_status' => $fetch['login_status'], |
||
| 147 | 'type' => 0 |
||
| 148 | ]] |
||
| 149 | ); |
||
| 150 | } |
||
| 151 | } |
||
| 152 | return "Query Failed"; |
||
| 153 | } |
||
| 154 | return "Query Failed"; |
||
| 155 | } |
||
| 156 | return "Empty"; |
||
| 157 | } |
||
| 158 | } |
||
| 159 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: