|
@@ 566-605 (lines=40) @@
|
| 563 |
|
$guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
| 564 |
|
$shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
| 565 |
|
$category = mysqli_real_escape_string($conn, $moduleModule[6]); |
| 566 |
|
if (!file_exists($filecontent)) { |
| 567 |
|
$installDataLevel['modules'][$moduleModule[0]]['error'] = array( |
| 568 |
|
'type' => 'file_not_found' |
| 569 |
|
); |
| 570 |
|
} else { |
| 571 |
|
// Create the category if it does not already exist |
| 572 |
|
$category = getCreateDbCategory($category, $sqlParser); |
| 573 |
|
|
| 574 |
|
$module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
| 575 |
|
// $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab |
| 576 |
|
$module = mysqli_real_escape_string($conn, $module); |
| 577 |
|
$rs = mysqli_query($sqlParser->conn, |
| 578 |
|
"SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'"); |
| 579 |
|
if (mysqli_num_rows($rs)) { |
| 580 |
|
$installDataLevel['modules'][$moduleModule[0]]['type'] = 'update'; |
| 581 |
|
$row = mysqli_fetch_assoc($rs); |
| 582 |
|
$props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
| 583 |
|
if (!mysqli_query($sqlParser->conn, |
| 584 |
|
"UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
| 585 |
|
$installDataLevel['modules'][$moduleModule[0]]['error'] = array( |
| 586 |
|
'type' => 'sql', |
| 587 |
|
'content' => mysqli_error($sqlParser->conn) |
| 588 |
|
); |
| 589 |
|
$errorData = true; |
| 590 |
|
break; |
| 591 |
|
} |
| 592 |
|
} else { |
| 593 |
|
$installDataLevel['modules'][$moduleModule[0]]['type'] = 'create'; |
| 594 |
|
$properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 595 |
|
if (!mysqli_query($sqlParser->conn, |
| 596 |
|
"INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) { |
| 597 |
|
$installDataLevel['modules'][$moduleModule[0]]['error'] = array( |
| 598 |
|
'type' => 'sql', |
| 599 |
|
'content' => mysqli_error($sqlParser->conn) |
| 600 |
|
); |
| 601 |
|
$errorData = true; |
| 602 |
|
break; |
| 603 |
|
} |
| 604 |
|
} |
| 605 |
|
} |
| 606 |
|
} else { |
| 607 |
|
$installDataLevel['modules'][$moduleModule[0]]['type'] = 'skip'; |
| 608 |
|
} |
|
@@ 776-815 (lines=40) @@
|
| 773 |
|
$filecontent = $moduleSnippet[2]; |
| 774 |
|
$properties = $moduleSnippet[3]; |
| 775 |
|
$category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
| 776 |
|
if (!file_exists($filecontent)) { |
| 777 |
|
$installDataLevel['snippets'][$moduleSnippet[0]]['error'] = array( |
| 778 |
|
'type' => 'file_not_found' |
| 779 |
|
); |
| 780 |
|
} else { |
| 781 |
|
// Create the category if it does not already exist |
| 782 |
|
$category = getCreateDbCategory($category, $sqlParser); |
| 783 |
|
|
| 784 |
|
$snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent))); |
| 785 |
|
$snippet = removeDocblock($snippet, 'snippet'); |
| 786 |
|
$snippet = mysqli_real_escape_string($conn, $snippet); |
| 787 |
|
$rs = mysqli_query($sqlParser->conn, |
| 788 |
|
"SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'"); |
| 789 |
|
if (mysqli_num_rows($rs)) { |
| 790 |
|
$installDataLevel['snippets'][$moduleSnippet[0]]['type'] = 'update'; |
| 791 |
|
$row = mysqli_fetch_assoc($rs); |
| 792 |
|
$props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
| 793 |
|
if (!mysqli_query($sqlParser->conn, |
| 794 |
|
"UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
| 795 |
|
$installDataLevel['snippets'][$moduleSnippet[0]]['error'] = array( |
| 796 |
|
'type' => 'sql', |
| 797 |
|
'content' => mysqli_error($sqlParser->conn) |
| 798 |
|
); |
| 799 |
|
$errorData = true; |
| 800 |
|
break; |
| 801 |
|
} |
| 802 |
|
} else { |
| 803 |
|
$installDataLevel['snippets'][$moduleSnippet[0]]['type'] = 'create'; |
| 804 |
|
$properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 805 |
|
if (!mysqli_query($sqlParser->conn, |
| 806 |
|
"INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
| 807 |
|
$installDataLevel['snippets'][$moduleSnippet[0]]['error'] = array( |
| 808 |
|
'type' => 'sql', |
| 809 |
|
'content' => mysqli_error($sqlParser->conn) |
| 810 |
|
); |
| 811 |
|
$errorData = true; |
| 812 |
|
break; |
| 813 |
|
} |
| 814 |
|
} |
| 815 |
|
} |
| 816 |
|
} else { |
| 817 |
|
$installDataLevel['snippets'][$moduleSnippet[0]]['type'] = 'skip'; |
| 818 |
|
} |