Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/flow-flo.../libs/flowflow/core/src/db
File: LADBManager.php
$conn->rollbackAndClose();
[1000] Fix | Delete
}
[1001] Fix | Delete
}
[1002] Fix | Delete
[1003] Fix | Delete
public function cleanFeed($feedId){
[1004] Fix | Delete
$conn = $this->conn();
[1005] Fix | Delete
try{
[1006] Fix | Delete
if ($conn->beginTransaction()){
[1007] Fix | Delete
$partOfSql = $conn->parse('WHERE `feed_id` = ?s', $feedId);
[1008] Fix | Delete
$conn->query('DELETE FROM ?n ?p', $this->posts_table_name, $partOfSql);
[1009] Fix | Delete
$conn->query('DELETE FROM ?n ?p', $this->post_media_table_name, $partOfSql);
[1010] Fix | Delete
$this->setCacheInfo($feedId, [ 'last_update' => 0, 'status' => 0 ] );
[1011] Fix | Delete
$conn->commit();
[1012] Fix | Delete
}
[1013] Fix | Delete
$conn->rollback();
[1014] Fix | Delete
}catch (Exception $e){
[1015] Fix | Delete
$conn->rollbackAndClose();
[1016] Fix | Delete
}
[1017] Fix | Delete
}
[1018] Fix | Delete
[1019] Fix | Delete
public function cleanByFeedType($feedType){
[1020] Fix | Delete
$conn = $this->conn();
[1021] Fix | Delete
try{
[1022] Fix | Delete
if ($conn->beginTransaction()){
[1023] Fix | Delete
$feeds = $conn->getCol('SELECT DISTINCT `feed_id` FROM ?n WHERE `post_type` = ?s', $this->posts_table_name, $feedType);
[1024] Fix | Delete
if (!empty($feeds)){
[1025] Fix | Delete
$conn->query("DELETE FROM ?n WHERE `feed_id` IN (?a)", $this->posts_table_name, $feeds);
[1026] Fix | Delete
$conn->query("DELETE FROM ?n WHERE `feed_id` IN (?a)", $this->post_media_table_name, $feeds);
[1027] Fix | Delete
$conn->commit();
[1028] Fix | Delete
}
[1029] Fix | Delete
}
[1030] Fix | Delete
$conn->rollback();
[1031] Fix | Delete
}catch (Exception $e){
[1032] Fix | Delete
$conn->rollbackAndClose();
[1033] Fix | Delete
}
[1034] Fix | Delete
}
[1035] Fix | Delete
[1036] Fix | Delete
/**
[1037] Fix | Delete
* @param $only4insertPartOfSql
[1038] Fix | Delete
* @param $imagePartOfSql
[1039] Fix | Delete
* @param $mediaPartOfSql
[1040] Fix | Delete
* @param $common
[1041] Fix | Delete
*
[1042] Fix | Delete
* @throws Exception
[1043] Fix | Delete
*/
[1044] Fix | Delete
public function addOrUpdatePost($only4insertPartOfSql, $imagePartOfSql, $mediaPartOfSql, $common){
[1045] Fix | Delete
$sql = "INSERT INTO ?n SET ?p, ?p ?p ?u ON DUPLICATE KEY UPDATE ?p ?p ?u";
[1046] Fix | Delete
if (false == $this->conn()->query($sql, $this->posts_table_name, $only4insertPartOfSql, $imagePartOfSql, $mediaPartOfSql, $common, $imagePartOfSql, $mediaPartOfSql, $common)){
[1047] Fix | Delete
throw new Exception($this->conn()->getError());
[1048] Fix | Delete
}
[1049] Fix | Delete
}
[1050] Fix | Delete
[1051] Fix | Delete
/**
[1052] Fix | Delete
* @param $posts
[1053] Fix | Delete
*
[1054] Fix | Delete
* @throws Exception
[1055] Fix | Delete
*/
[1056] Fix | Delete
public function updateAdditionalInfo($posts){
[1057] Fix | Delete
$conn = $this->conn();
[1058] Fix | Delete
foreach ($posts as $post) {
[1059] Fix | Delete
$sql = $conn->parse('UPDATE ?n SET `post_additional` = ?s WHERE `post_id` = ?s AND `feed_id` = ?s AND `post_type` = ?s',
[1060] Fix | Delete
$this->posts_table_name, json_encode($post->additional), $post->id, $post->feed_id, $post->type);
[1061] Fix | Delete
if (false == $conn->query($sql)){
[1062] Fix | Delete
throw new Exception($conn->getError());
[1063] Fix | Delete
}
[1064] Fix | Delete
}
[1065] Fix | Delete
}
[1066] Fix | Delete
[1067] Fix | Delete
public function getCarousel($feed_id, $post_id){
[1068] Fix | Delete
return $this->conn(true)->getAll('SELECT `feed_id`, `post_id`, `media_url`, `media_width`, `media_height`, `media_type` FROM ?n WHERE `feed_id`=?s AND `post_id`=?s',
[1069] Fix | Delete
$this->post_media_table_name, $feed_id, $post_id);
[1070] Fix | Delete
}
[1071] Fix | Delete
[1072] Fix | Delete
/**
[1073] Fix | Delete
* @param $feed_id
[1074] Fix | Delete
* @param $post_id
[1075] Fix | Delete
* @param $post_type
[1076] Fix | Delete
* @param $mediaPartOfSql4carousel
[1077] Fix | Delete
*
[1078] Fix | Delete
* @throws Exception
[1079] Fix | Delete
*/
[1080] Fix | Delete
public function addCarouselMedia($feed_id, $post_id, $post_type, $mediaPartOfSql4carousel){
[1081] Fix | Delete
$common = [];
[1082] Fix | Delete
$common['feed_id'] = $feed_id;
[1083] Fix | Delete
$common['post_id'] = $post_id;
[1084] Fix | Delete
$common['post_type'] = $post_type;
[1085] Fix | Delete
[1086] Fix | Delete
$conn = $this->conn();
[1087] Fix | Delete
$sql = $conn->parse('INSERT INTO ?n SET ?p ?u', $this->post_media_table_name, $mediaPartOfSql4carousel, $common);
[1088] Fix | Delete
if (false == $conn->query($sql)){
[1089] Fix | Delete
throw new Exception($conn->getError());
[1090] Fix | Delete
}
[1091] Fix | Delete
}
[1092] Fix | Delete
[1093] Fix | Delete
/**
[1094] Fix | Delete
* @param $post_id
[1095] Fix | Delete
* @param $comment
[1096] Fix | Delete
*
[1097] Fix | Delete
* @throws Exception
[1098] Fix | Delete
*/
[1099] Fix | Delete
public function addComments($post_id, $comment){
[1100] Fix | Delete
$time = time();
[1101] Fix | Delete
$sql_insert = "INSERT INTO ?n SET `id` = ?s, `post_id` = ?s, `from` = ?s, `text` = ?s, `created_time` = ?s, `updated_time` = ?s ON DUPLICATE KEY UPDATE ?u";
[1102] Fix | Delete
$result = $this->conn()->query($sql_insert, $this->comments_table_name, $comment->id, $post_id, is_string($comment->from) ? $comment->from : (is_object($comment->from) ? $comment->from->name : 'Facebook user' ), $comment->text, $comment->created_time, $comment->created_time, [ 'updated_time' => $time, 'text' => $comment->text ] );
[1103] Fix | Delete
if (false === $result){
[1104] Fix | Delete
throw new Exception($this->conn()->getError());
[1105] Fix | Delete
}
[1106] Fix | Delete
}
[1107] Fix | Delete
[1108] Fix | Delete
public function removeComments($post_id){
[1109] Fix | Delete
$sql_delete = "DELETE FROM ?n WHERE `post_id` = ?s";
[1110] Fix | Delete
$this->conn()->query($sql_delete, $this->comments_table_name, $post_id);
[1111] Fix | Delete
}
[1112] Fix | Delete
[1113] Fix | Delete
/**
[1114] Fix | Delete
* @param $feed_id
[1115] Fix | Delete
* @param $post_id
[1116] Fix | Delete
*
[1117] Fix | Delete
* @throws Exception
[1118] Fix | Delete
*/
[1119] Fix | Delete
public function deleteCarousel4Post($feed_id, $post_id){
[1120] Fix | Delete
$sql = "delete from ?n where feed_id = ?s and post_id = ?s";
[1121] Fix | Delete
if (false == $this->conn()->query($sql, $this->post_media_table_name, $feed_id, $post_id)){
[1122] Fix | Delete
throw new Exception($this->conn()->getError());
[1123] Fix | Delete
}
[1124] Fix | Delete
}
[1125] Fix | Delete
[1126] Fix | Delete
/**
[1127] Fix | Delete
* @param $feed_id
[1128] Fix | Delete
*
[1129] Fix | Delete
* @throws Exception
[1130] Fix | Delete
*/
[1131] Fix | Delete
public function deleteCarousel4Feed($feed_id){
[1132] Fix | Delete
$sql = "delete from ?n where feed_id = ?s";
[1133] Fix | Delete
if (false == $this->conn()->query($sql, $this->post_media_table_name, $feed_id)){
[1134] Fix | Delete
throw new Exception($this->conn()->getError());
[1135] Fix | Delete
}
[1136] Fix | Delete
}
[1137] Fix | Delete
[1138] Fix | Delete
/**
[1139] Fix | Delete
* @param string $feedId
[1140] Fix | Delete
*
[1141] Fix | Delete
* @return array|false
[1142] Fix | Delete
*/
[1143] Fix | Delete
public function getIdPosts($feedId){
[1144] Fix | Delete
return $this->conn(true)->getCol('SELECT `post_id` FROM ?n WHERE `feed_id`=?s', $this->posts_table_name, $feedId);
[1145] Fix | Delete
}
[1146] Fix | Delete
[1147] Fix | Delete
public function getPostsIf($fields, $condition, $order, $offset = null, $limit = null){
[1148] Fix | Delete
$conn = $this->conn();
[1149] Fix | Delete
$limitPart = ($offset !== null) ? $conn->parse("LIMIT ?i, ?i", $offset, $limit) : '';
[1150] Fix | Delete
$sql = $conn->parse("SELECT ?p FROM ?n post INNER JOIN ?n stream ON stream.feed_id = post.feed_id INNER JOIN ?n cach ON post.feed_id = cach.feed_id WHERE ?p ORDER BY ?p ?p",
[1151] Fix | Delete
$fields, $this->posts_table_name, $this->streams_sources_table_name, $this->cache_table_name, $condition, $order, $limitPart);
[1152] Fix | Delete
return $conn->getAll($sql);
[1153] Fix | Delete
}
[1154] Fix | Delete
[1155] Fix | Delete
public function getPostsIf2($fields, $condition){
[1156] Fix | Delete
return $this->conn()->getAll("SELECT ?p FROM ?n post INNER JOIN ?n stream ON stream.feed_id = post.feed_id INNER JOIN ?n cach ON post.feed_id = cach.feed_id WHERE ?p ORDER BY post.post_timestamp DESC, post.post_id",
[1157] Fix | Delete
$fields, $this->posts_table_name, $this->streams_sources_table_name, $this->cache_table_name, $condition);
[1158] Fix | Delete
}
[1159] Fix | Delete
[1160] Fix | Delete
public function countPostsIf($condition){
[1161] Fix | Delete
return $this->conn()->getOne('SELECT COUNT(*) FROM ?n post INNER JOIN ?n stream ON stream.feed_id = post.feed_id INNER JOIN ?n cach ON post.feed_id = cach.feed_id WHERE ?p',
[1162] Fix | Delete
$this->posts_table_name, $this->streams_sources_table_name, $this->cache_table_name, $condition);
[1163] Fix | Delete
}
[1164] Fix | Delete
[1165] Fix | Delete
public function getLastUpdateHash($streamId){
[1166] Fix | Delete
return $this->getHashIf($this->conn()->parse('stream.`stream_id` = ?s', $streamId));
[1167] Fix | Delete
}
[1168] Fix | Delete
[1169] Fix | Delete
public function getHashIf($condition){
[1170] Fix | Delete
return $this->conn()->getOne("SELECT MAX(post.creation_index) FROM ?n post INNER JOIN ?n stream ON stream.feed_id = post.feed_id INNER JOIN ?n cach ON post.feed_id = cach.feed_id WHERE cach.boosted = 'nope' AND ?p",
[1171] Fix | Delete
$this->posts_table_name, $this->streams_sources_table_name, $this->cache_table_name, $condition);
[1172] Fix | Delete
}
[1173] Fix | Delete
[1174] Fix | Delete
public function getLastUpdateTime($streamId){
[1175] Fix | Delete
return $this->conn()->getOne('SELECT MAX(`last_update`) FROM ?n `cach` inner join ?n `st2src` on `st2src`.`feed_id` = `cach`.`feed_id` WHERE `stream_id` = ?s', $this->cache_table_name, $this->streams_sources_table_name, $streamId);
[1176] Fix | Delete
}
[1177] Fix | Delete
[1178] Fix | Delete
public function getLastUpdateTimeAllStreams(){
[1179] Fix | Delete
return $this->conn()->getIndCol('stream_id', 'SELECT MAX(`last_update`), `stream_id` FROM ?n `cach` inner join ?n `st2src` on `st2src`.`feed_id` = `cach`.`feed_id` GROUP BY `stream_id`', $this->cache_table_name, $this->streams_sources_table_name);
[1180] Fix | Delete
}
[1181] Fix | Delete
[1182] Fix | Delete
public function deleteEmptyRecordsFromCacheInfo($streamId){
[1183] Fix | Delete
//$this->conn()->query("DELETE FROM ?n where `stream_id`=?s", $this->cache_table_name, $streamId);
[1184] Fix | Delete
}
[1185] Fix | Delete
[1186] Fix | Delete
public function systemDisableSource($feedId, $enabled){
[1187] Fix | Delete
$values = [ 'system_enabled' => $enabled ];
[1188] Fix | Delete
if($enabled == 0){
[1189] Fix | Delete
$values['send_email'] = 0;
[1190] Fix | Delete
}
[1191] Fix | Delete
return $this->saveSource($feedId, $values);
[1192] Fix | Delete
}
[1193] Fix | Delete
[1194] Fix | Delete
public function saveSource( $feedId, $values ) {
[1195] Fix | Delete
return LADB::saveFeed($this->conn(), $this->cache_table_name, $feedId, $values);
[1196] Fix | Delete
}
[1197] Fix | Delete
[1198] Fix | Delete
/**
[1199] Fix | Delete
* @param $feedId
[1200] Fix | Delete
* @param $values
[1201] Fix | Delete
*
[1202] Fix | Delete
* @return FALSE|mysqli|resource
[1203] Fix | Delete
* @deprecated
[1204] Fix | Delete
* Use \flow\db\LADBManager::saveSource
[1205] Fix | Delete
*/
[1206] Fix | Delete
public function setCacheInfo($feedId, $values){
[1207] Fix | Delete
$sql = 'INSERT INTO ?n SET `feed_id`=?s, ?u ON DUPLICATE KEY UPDATE ?u';
[1208] Fix | Delete
return $this->conn()->query( $sql, $this->cache_table_name, $feedId, $values, $values );
[1209] Fix | Delete
}
[1210] Fix | Delete
[1211] Fix | Delete
public function setOrders($feedId){
[1212] Fix | Delete
$conn = $this->conn();
[1213] Fix | Delete
$conn->query('SET @ROW = -1;');//test mysql_query("SELECT @ROW = -1");
[1214] Fix | Delete
return $conn->query('UPDATE ?n SET `rand_order` = RAND(), `smart_order` = @ROW := @ROW+1 WHERE `feed_id`=?s ORDER BY post_timestamp DESC', $this->posts_table_name, $feedId);
[1215] Fix | Delete
}
[1216] Fix | Delete
[1217] Fix | Delete
public function removeOldRecords($c_count){
[1218] Fix | Delete
$conn = $this->conn();
[1219] Fix | Delete
$result = $conn->getAll('select count(*) as `count`, `feed_id` from ?n group by `feed_id` order by 1 desc', $this->posts_table_name);
[1220] Fix | Delete
foreach ( $result as $row ) {
[1221] Fix | Delete
$count = (int)$row['count'];
[1222] Fix | Delete
if ($count > $c_count) {
[1223] Fix | Delete
$feed = $row['feed_id'];
[1224] Fix | Delete
$count = $count - $c_count;
[1225] Fix | Delete
$sub_query = $conn->parse('select max(tmp.`post_timestamp`) from (select `post_timestamp` from ?n where `feed_id` = ?s order by `post_timestamp` limit 0, ?i) as tmp',$this->posts_table_name, $feed, $count);
[1226] Fix | Delete
$sub_query2 = $conn->parse('select tmp2.post_id from ?n as tmp2 where tmp2.post_timestamp <= (?p)', $this->posts_table_name, $sub_query);
[1227] Fix | Delete
$conn->query('delete from ?n where feed_id = ?s and post_id in (?p)', $this->post_media_table_name, $feed, $sub_query2);
[1228] Fix | Delete
$conn->query('delete from ?n where feed_id = ?s and post_timestamp <= (?p)', $this->posts_table_name, $feed, $sub_query);
[1229] Fix | Delete
continue;
[1230] Fix | Delete
}
[1231] Fix | Delete
}
[1232] Fix | Delete
}
[1233] Fix | Delete
[1234] Fix | Delete
/**
[1235] Fix | Delete
* @param $status
[1236] Fix | Delete
* @param $condition
[1237] Fix | Delete
* @param null $creation_index
[1238] Fix | Delete
*
[1239] Fix | Delete
* @throws Exception
[1240] Fix | Delete
*/
[1241] Fix | Delete
public function setPostStatus($status, $condition, $creation_index = null){
[1242] Fix | Delete
$sql = "UPDATE ?n SET `post_status` = ?s";
[1243] Fix | Delete
$sql .= ($creation_index != null) ? ", `creation_index` = " . $creation_index . " ?p" : " ?p";
[1244] Fix | Delete
if (false == $this->conn()->query($sql, $this->posts_table_name, $status, $condition)){
[1245] Fix | Delete
throw new Exception($this->conn()->getError());
[1246] Fix | Delete
}
[1247] Fix | Delete
}
[1248] Fix | Delete
[1249] Fix | Delete
public abstract function getLoadCacheUrl($streamId = null, $force = false);
[1250] Fix | Delete
[1251] Fix | Delete
/**
[1252] Fix | Delete
* @return bool
[1253] Fix | Delete
* @throws Exception
[1254] Fix | Delete
*/
[1255] Fix | Delete
public function registrationCheck(){
[1256] Fix | Delete
$activated = false;
[1257] Fix | Delete
if (false !== ($registration_id = $this->getOption('registration_id'))){
[1258] Fix | Delete
if ((false !== ($registration_date = $this->getOption('registration_date'))) &&
[1259] Fix | Delete
(time() > $registration_date + 604800)){
[1260] Fix | Delete
$ch = curl_init( 'https://flow.looks-awesome.com/wp-admin/admin-ajax.php?action=la_check&registration_id=' . $registration_id);
[1261] Fix | Delete
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
[1262] Fix | Delete
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
[1263] Fix | Delete
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 5000);
[1264] Fix | Delete
curl_setopt($ch, CURLOPT_POST, false);
[1265] Fix | Delete
$result = curl_exec( $ch );
[1266] Fix | Delete
curl_close( $ch );
[1267] Fix | Delete
$result = json_decode($result);
[1268] Fix | Delete
if (isset($result->registration_id) && $registration_id == $result->registration_id){
[1269] Fix | Delete
$settings = $this->getGeneralSettings();
[1270] Fix | Delete
$settings = $settings->original();
[1271] Fix | Delete
$current_subscription = $settings['news_subscription'];
[1272] Fix | Delete
$remote_subscription = $result->subscription == "1" ? LASettingsUtils::YEP : LASettingsUtils::NOPE;
[1273] Fix | Delete
if ($remote_subscription != $current_subscription){
[1274] Fix | Delete
$settings['news_subscription'] = $remote_subscription;
[1275] Fix | Delete
$this->setOption('options', $settings, true);
[1276] Fix | Delete
}
[1277] Fix | Delete
$this->setOption('registration_id', $result->registration_id);
[1278] Fix | Delete
$this->setOption('registration_date', time());
[1279] Fix | Delete
return true;
[1280] Fix | Delete
}
[1281] Fix | Delete
return false;
[1282] Fix | Delete
}
[1283] Fix | Delete
$activated = !empty($registration_id);
[1284] Fix | Delete
}
[1285] Fix | Delete
return $activated;
[1286] Fix | Delete
}
[1287] Fix | Delete
[1288] Fix | Delete
/**
[1289] Fix | Delete
* @param $settings
[1290] Fix | Delete
*
[1291] Fix | Delete
* @return bool
[1292] Fix | Delete
* @throws Exception
[1293] Fix | Delete
*/
[1294] Fix | Delete
private function activate($settings){
[1295] Fix | Delete
$activated = $this->registrationCheck();
[1296] Fix | Delete
$option_name = 'flow_flow_options';
[1297] Fix | Delete
if (!$activated
[1298] Fix | Delete
&& isset($settings[$option_name]['company_email']) && isset($settings[$option_name]['purchase_code'])
[1299] Fix | Delete
&& !empty($settings[$option_name]['company_email']) && !empty($settings[$option_name]['purchase_code'])){
[1300] Fix | Delete
[1301] Fix | Delete
$name = isset($settings[$option_name]['company_name']) ? $settings[$option_name]['company_name'] : 'Unnamed';
[1302] Fix | Delete
$subscription = 0;
[1303] Fix | Delete
if (isset($settings[$option_name]['news_subscription']) && !empty($settings[$option_name]['news_subscription'])){
[1304] Fix | Delete
$subscription = $settings[$option_name]['news_subscription'] == LASettingsUtils::YEP ? 1 : 0;
[1305] Fix | Delete
}
[1306] Fix | Delete
$post = [
[1307] Fix | Delete
'action' => 'la_activation',
[1308] Fix | Delete
'name' => $name,
[1309] Fix | Delete
'email' => @$settings[$option_name]['company_email'],
[1310] Fix | Delete
'purchase_code' => @$settings[$option_name]['purchase_code'],
[1311] Fix | Delete
'subscription' => $subscription,
[1312] Fix | Delete
'plugin_name' => $this->plugin_slug
[1313] Fix | Delete
];
[1314] Fix | Delete
[1315] Fix | Delete
list($result, $error) = $this->sendRequest2lo($post);
[1316] Fix | Delete
if (false !== $result){
[1317] Fix | Delete
$result = json_decode($result);
[1318] Fix | Delete
if (isset($result->registration_id)){
[1319] Fix | Delete
$this->setOption('registration_id', $result->registration_id);
[1320] Fix | Delete
$this->setOption('registration_date', time());
[1321] Fix | Delete
return true;
[1322] Fix | Delete
}
[1323] Fix | Delete
else if (isset($result->error)){
[1324] Fix | Delete
throw new Exception(is_string($result->error) ? $result->error : print_r($result->error, true));
[1325] Fix | Delete
}
[1326] Fix | Delete
}
[1327] Fix | Delete
else {
[1328] Fix | Delete
throw new Exception($error);
[1329] Fix | Delete
}
[1330] Fix | Delete
}
[1331] Fix | Delete
if ($activated){
[1332] Fix | Delete
$registration_id = $this->getOption('registration_id');
[1333] Fix | Delete
$name = isset($settings[$option_name]['company_name']) ? $settings[$option_name]['company_name'] : 'Unnamed';
[1334] Fix | Delete
$post = [
[1335] Fix | Delete
'action' => 'la_activation',
[1336] Fix | Delete
'registration_id' => $registration_id,
[1337] Fix | Delete
'name' => $name,
[1338] Fix | Delete
'email' => @$settings[$option_name]['company_email'],
[1339] Fix | Delete
'purchase_code' => @$settings[$option_name]['purchase_code'],
[1340] Fix | Delete
'subscription' => 1,
[1341] Fix | Delete
'plugin_name' => $this->plugin_slug
[1342] Fix | Delete
];
[1343] Fix | Delete
[1344] Fix | Delete
//subscribe
[1345] Fix | Delete
if (isset($_POST['doSubcribe']) && $_POST['doSubcribe'] == 'true'){
[1346] Fix | Delete
$result = $this->sendRequest2lo($post);
[1347] Fix | Delete
$result = json_decode($result[0]);
[1348] Fix | Delete
if (isset($result->registration_id)){
[1349] Fix | Delete
$this->setOption('registration_id', $result->registration_id);
[1350] Fix | Delete
$this->setOption('registration_date', time());
[1351] Fix | Delete
return true;
[1352] Fix | Delete
}
[1353] Fix | Delete
return false;
[1354] Fix | Delete
}
[1355] Fix | Delete
[1356] Fix | Delete
//remove registration
[1357] Fix | Delete
if (!isset($settings[$option_name]['purchase_code']) || empty($settings[$option_name]['purchase_code'])){
[1358] Fix | Delete
$post['purchase_code'] = '';
[1359] Fix | Delete
$this->sendRequest2lo($post);
[1360] Fix | Delete
$this->deleteOption('registration_id');
[1361] Fix | Delete
$this->deleteOption('registration_date');
[1362] Fix | Delete
return false;
[1363] Fix | Delete
}
[1364] Fix | Delete
}
[1365] Fix | Delete
return true;
[1366] Fix | Delete
}
[1367] Fix | Delete
[1368] Fix | Delete
private function sendRequest2lo($data){
[1369] Fix | Delete
$ch = curl_init( 'https://flow.looks-awesome.com/wp-admin/admin-ajax.php' );
[1370] Fix | Delete
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
[1371] Fix | Delete
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
[1372] Fix | Delete
curl_setopt($ch, CURLOPT_POST, true);
[1373] Fix | Delete
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
[1374] Fix | Delete
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 5000);
[1375] Fix | Delete
$error = null;
[1376] Fix | Delete
$result = curl_exec( $ch );
[1377] Fix | Delete
if ($result === false){
[1378] Fix | Delete
$error = curl_error($ch);
[1379] Fix | Delete
}
[1380] Fix | Delete
curl_close( $ch );
[1381] Fix | Delete
return [ $result, $error ];
[1382] Fix | Delete
}
[1383] Fix | Delete
[1384] Fix | Delete
private function getStreamFromRequestWithoutErrors(){
[1385] Fix | Delete
$stream = $_POST['stream'];
[1386] Fix | Delete
[1387] Fix | Delete
// cleaning if error was saved in database stream model, can be removed in future, now it's needed for affected users
[1388] Fix | Delete
if ( isset( $stream['error'] ) ) unset( $stream['error'] );
[1389] Fix | Delete
[1390] Fix | Delete
// casting object
[1391] Fix | Delete
return (object)$stream;
[1392] Fix | Delete
}
[1393] Fix | Delete
[1394] Fix | Delete
private function checkSecurity() {
[1395] Fix | Delete
if (FF_USE_WP) {
[1396] Fix | Delete
if (!current_user_can('manage_options') || !check_ajax_referer( 'flow_flow_nonce', 'security', false ) ) {
[1397] Fix | Delete
die( json_encode( [ 'error' => 'not_allowed' ] ) );
[1398] Fix | Delete
}
[1399] Fix | Delete
}
[1400] Fix | Delete
}
[1401] Fix | Delete
[1402] Fix | Delete
/**
[1403] Fix | Delete
* @return array|mixed
[1404] Fix | Delete
* @throws Exception
[1405] Fix | Delete
*/
[1406] Fix | Delete
public function getBoostSources(){
[1407] Fix | Delete
$token = $this->getToken();
[1408] Fix | Delete
if (!empty($token)){
[1409] Fix | Delete
Request::jsonOpts(true);
[1410] Fix | Delete
Request::timeout(120);
[1411] Fix | Delete
$response = Request::post(FF_BOOST_SERVER . 'flow-flow/ff', [
[1412] Fix | Delete
'Content-Type: application/x-www-form-urlencoded'
[1413] Fix | Delete
], http_build_query(['action' => 'get_sources', 'token' => $token]));
[1414] Fix | Delete
[1415] Fix | Delete
if ($response->code == 200) {
[1416] Fix | Delete
foreach ($response->body as &$source){
[1417] Fix | Delete
LADB::prepareSource($source);
[1418] Fix | Delete
}
[1419] Fix | Delete
return $response->body;
[1420] Fix | Delete
}
[1421] Fix | Delete
else if ($this->isExpiredToken($response)){
[1422] Fix | Delete
return $this->getBoostSources();
[1423] Fix | Delete
}
[1424] Fix | Delete
}
[1425] Fix | Delete
return [];
[1426] Fix | Delete
}
[1427] Fix | Delete
[1428] Fix | Delete
/**
[1429] Fix | Delete
* @param array $data
[1430] Fix | Delete
*
[1431] Fix | Delete
* @return array|mixed|Response
[1432] Fix | Delete
* @throws Exception
[1433] Fix | Delete
*/
[1434] Fix | Delete
private function proxyRequest($data){
[1435] Fix | Delete
$response = [];
[1436] Fix | Delete
if (null != ($token = $this->getToken())){
[1437] Fix | Delete
Request::jsonOpts(true);
[1438] Fix | Delete
Request::timeout(120);
[1439] Fix | Delete
$data['token'] = $token;
[1440] Fix | Delete
$response = Request::post(FF_BOOST_SERVER . 'flow-flow/ff', [
[1441] Fix | Delete
'Content-Type: application/x-www-form-urlencoded'
[1442] Fix | Delete
], http_build_query($data));
[1443] Fix | Delete
if ($this->isExpiredToken($response)){
[1444] Fix | Delete
$response = $this->proxyRequest($data);
[1445] Fix | Delete
}
[1446] Fix | Delete
}
[1447] Fix | Delete
[1448] Fix | Delete
return $response;
[1449] Fix | Delete
}
[1450] Fix | Delete
[1451] Fix | Delete
/**
[1452] Fix | Delete
* @param false $force
[1453] Fix | Delete
*
[1454] Fix | Delete
* @return array|false|mixed|string|null
[1455] Fix | Delete
* @throws Exception
[1456] Fix | Delete
*/
[1457] Fix | Delete
public function getToken( $force = false ) {
[1458] Fix | Delete
$email = $this->getOption('boosts_email');
[1459] Fix | Delete
if (!empty($email)){
[1460] Fix | Delete
$domain = $_SERVER['HTTP_HOST'];
[1461] Fix | Delete
[1462] Fix | Delete
$token = $this->getOption('boosts_token');
[1463] Fix | Delete
if ($force || (false == $token)){
[1464] Fix | Delete
Request::jsonOpts(true);
[1465] Fix | Delete
Request::timeout(120);
[1466] Fix | Delete
$response = Request::post(FF_BOOST_SERVER . 'token', [
[1467] Fix | Delete
'Content-Type: application/form-data'
[1468] Fix | Delete
], ['domain' => $domain, 'email' => $email]);
[1469] Fix | Delete
if ($response->code == 200 && isset($response->body['token']) && is_string($response->body['token'])) {
[1470] Fix | Delete
$token = $response->body['token'];
[1471] Fix | Delete
$this->setOption('boosts_token', $token);
[1472] Fix | Delete
$this->conn()->commit();
[1473] Fix | Delete
}
[1474] Fix | Delete
else {
[1475] Fix | Delete
return null;
[1476] Fix | Delete
}
[1477] Fix | Delete
}
[1478] Fix | Delete
return $token;
[1479] Fix | Delete
}
[1480] Fix | Delete
return null;
[1481] Fix | Delete
}
[1482] Fix | Delete
[1483] Fix | Delete
/**
[1484] Fix | Delete
* @param $response
[1485] Fix | Delete
*
[1486] Fix | Delete
* @return bool
[1487] Fix | Delete
* @throws Exception
[1488] Fix | Delete
*/
[1489] Fix | Delete
private function isExpiredToken( $response ) {
[1490] Fix | Delete
if ($response->code == 400 &&
[1491] Fix | Delete
((isset($response->body->error) && $response->body->error == 'Provided token is expired.') ||
[1492] Fix | Delete
(isset($response->body['error']) && $response->body['error'] == 'Provided token is expired.'))
[1493] Fix | Delete
){
[1494] Fix | Delete
$this->deleteOption('boosts_token');
[1495] Fix | Delete
$this->deleteOption('boosts_subscription');
[1496] Fix | Delete
$this->conn()->commit();
[1497] Fix | Delete
return true;
[1498] Fix | Delete
}
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function