Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jegelstaff/formulize into…
Browse files Browse the repository at this point in the history
… master
  • Loading branch information
jegelstaff committed Oct 13, 2020
2 parents 150758a + 67d4fcb commit 0451a62
Show file tree
Hide file tree
Showing 20 changed files with 240 additions and 113 deletions.
23 changes: 2 additions & 21 deletions include/checklogin.php
Expand Up @@ -19,33 +19,14 @@
icms_loadLanguageFile('core', 'user');
$uname = !isset($_POST['uname']) ? '' : trim($_POST['uname']);
$pass = !isset($_POST['pass']) ? '' : trim($_POST['pass']);
/**
* Commented out for OpenID , we need to change it to make a better validation if OpenID is used
*/
/*if ($uname == '' || $pass == '') {
redirect_header(ICMS_URL.'/user.php', 1, _US_INCORRECTLOGIN);
exit();
}*/

$member_handler = icms::handler('icms_member');

icms_loadLanguageFile('core', 'auth');
$icmsAuth =& icms_auth_Factory::getAuthConnection(icms_core_DataFilter::addSlashes($uname));

// uname&email hack GIJ
$uname4sql = addslashes(icms_core_DataFilter::stripSlashesGPC($uname));
$pass4sql = addslashes(icms_core_DataFilter::stripSlashesGPC($pass));
/*if (strstr( $uname , '@' )) {
// check by email if uname includes '@'
$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('email', $uname4sql ));
$criteria->add(new icms_db_criteria_Item('pass', $pass4sql));
$user_handler = icms::handler('icms_member_user');
$users =& $user_handler->getObjects($criteria, false);
if (empty( $users ) || count( $users ) != 1 ) $user = false ;
else $user = $users[0] ;
unset( $users ) ;
} */
if (empty($user) || !is_object($user)) {
$user =& $icmsAuth->authenticate($uname4sql, $pass4sql);
$user =& $icmsAuth->authenticate($uname, $pass);
}
// end of uname&email hack GIJ

Expand Down
2 changes: 1 addition & 1 deletion include/version.php
Expand Up @@ -10,7 +10,7 @@
* @version $Id: version.php 22698 2011-09-18 11:06:01Z phoenyx $
*/

define('ICMS_VERSION_NAME', 'Formulize 4 Standalone'); // ALTERED BY FREEFORM SOLUTIONS FOR THE FORMULIZE 4 STANDALONE VERSION
define('ICMS_VERSION_NAME', 'Formulize 6 Standalone'); // ALTERED BY FREEFORM SOLUTIONS FOR THE FORMULIZE 6 STANDALONE VERSION

// For backward compatibility with XOOPS
define('XOOPS_VERSION', ICMS_VERSION_NAME);
Expand Down
5 changes: 3 additions & 2 deletions install/page_end.php
Expand Up @@ -76,8 +76,9 @@
if($sql) {
if(!$formulizeResult = $dbm->query($sql)) {
$content = "<h3>Error:</h3><p>Some of the configuration settings were not saved properly in the database. The website will still work, but it will behave more like a generic ImpressCMS+Formulize website, and not like a dedicated Formulize system. Please send the following information to <a href=\"mailto:formulize@freeformsolutions.ca?subject=Formulize%20Standalone%20Install%20Error\">formulize@freeformsolutions.ca</a>:</p>
<p><pre>".mysqli_error($link)."</pre></p>".$content;
}
<p><pre>".$dbm->db->error()."</pre></p>".$content;
} else {
}
}
}
// END OF MODIFIED CODE
Expand Down
2 changes: 1 addition & 1 deletion install/sql/pdo.mysql.formulize_standalone.sql
Expand Up @@ -562,7 +562,7 @@ INSERT INTO `REPLACE_WITH_PREFIX_profile_field` (`fieldid`, `catid`, `field_type
(28, 2, 'email', '1', 'email', 'Email', 'email.gif', '', 1, '255', 5, '', 1, 0, 1, 'a:0:{}', 1, 1, 1),
(29, 0, 'select', '3', '2famethod', '2-factor authentication method', '', '', 0, '0', 7, '', 1, 1, 1, 'a:4:{i:0;s:8:\"--None--\";i:1;s:14:\"Text me a code\";i:2;s:15:\"Email me a code\";i:3;s:24:\"Use an authenticator app\";}', 1, 1, 1);

ALTER TABLE `REPLACE_WITH_PREFIX_profile_profile ADD `2famethod` INT NULL DEFAULT NULL;
ALTER TABLE `REPLACE_WITH_PREFIX_profile_profile` ADD `2famethod` INT NULL DEFAULT NULL;

TRUNCATE `REPLACE_WITH_PREFIX_profile_profile`;

Expand Down
4 changes: 2 additions & 2 deletions install/sql/pdo.mysql.structure.sql
Expand Up @@ -546,7 +546,7 @@ CREATE TABLE tplsource (
CREATE TABLE users (
uid mediumint(8) unsigned NOT NULL auto_increment,
name varchar(60) NOT NULL default '',
uname varchar(255) NOT NULL default '',
uname varchar(175) NOT NULL default '',
email varchar(255) NOT NULL default '',
url varchar(255) NOT NULL default '',
user_avatar varchar(30) NOT NULL default 'blank.gif',
Expand Down Expand Up @@ -581,7 +581,7 @@ CREATE TABLE users (
user_viewoid tinyint(1) unsigned NOT NULL default '0',
pass_expired tinyint(1) unsigned NOT NULL default '0',
enc_type tinyint(2) unsigned NOT NULL default '1',
login_name varchar(255) NOT NULL default '',
login_name varchar(175) NOT NULL default '',
PRIMARY KEY (uid),
KEY uname (uname),
UNIQUE KEY login_name (login_name)
Expand Down
2 changes: 1 addition & 1 deletion integration_api.php
Expand Up @@ -14,7 +14,7 @@ class Formulize {
private static $default_mapping_active = 1;

/**
* Intialize the Formulize environment
* Initialize the Formulize environment
*/
static function init() {
if (self::$db == null) {
Expand Down
6 changes: 6 additions & 0 deletions libraries/icms/db/legacy/PdoDatabase.php
Expand Up @@ -15,6 +15,12 @@ class icms_db_legacy_PdoDatabase extends icms_db_legacy_Database {
public function __construct( $connection, $allowWebChanges = false ) {
parent::__construct($connection, $allowWebChanges);
$this->pdo = $connection;
if($res = $this->query('SELECT @@character_set_database, @@collation_database')) {
$collation = $this->fetchRow($res);
if(strstr($collation[0], 'utf8mb4') AND strstr($collation[1], 'utf8mb4')) {
$this->query('SET NAMES utf8mb4');
}
}
$getModes = 'SELECT @@SESSION.sql_mode';
$modesSet = false;
if($res = $this->query($getModes)) {
Expand Down
19 changes: 17 additions & 2 deletions modules/formulize/class/data.php
Expand Up @@ -438,15 +438,16 @@ function getFirstEntryForUsers($uids, $scope_uids=array()) {
}

// this function returns the entry ID of the first entry found in the form with the specified value in the specified element
function findFirstEntryWithValue($element_id, $value, $op="=") {
function findFirstEntryWithValue($element_id, $value, $op="=", $scope_uids=array()) {
if(!$element = _getElementObject($element_id)) {
return false;
}
$likeBits = $op == "LIKE" ? "%" : "";
global $xoopsDB;
$form_handler = xoops_getmodulehandler('forms', 'formulize');
$formObject = $form_handler->get($this->fid);
$sql = "SELECT entry_id FROM " . $xoopsDB->prefix("formulize_".$formObject->getVar('form_handle')) . " WHERE `". $element->getVar('ele_handle') . "` ".formulize_db_escape($op)." \"$likeBits" . formulize_db_escape($value) . "$likeBits\" ORDER BY entry_id LIMIT 0,1";
$scopeFilter = $this->_buildScopeFilter($scope_uids);
$sql = "SELECT entry_id FROM " . $xoopsDB->prefix("formulize_".$formObject->getVar('form_handle')) . " WHERE `". $element->getVar('ele_handle') . "` ".formulize_db_escape($op)." \"$likeBits" . formulize_db_escape($value) . "$likeBits\" $scopeFilter ORDER BY entry_id LIMIT 0,1";
if(!$res = $xoopsDB->query($sql)) {
return false;
}
Expand Down Expand Up @@ -871,6 +872,20 @@ function writeEntry($entry, $values, $proxyUser=false, $forceUpdate=false, $upda
// set metadata for new record
$element_values["`creation_datetime`"] = "NOW()";
$element_values["`creation_uid`"] = intval($creation_uid);
if($uid==0) {
foreach($_SESSION as $sessionVariable=>$value) {
if(substr($sessionVariable, 0, 19) == 'formulize_passCode_' AND is_numeric(str_replace('formulize_passCode_', '', $sessionVariable))) {

$sid = str_replace('formulize_passCode_', '', $sessionVariable);
$screen_handler = xoops_getmodulehandler('screen','formulize');
$screenObject = $screen_handler->get($sid);
$passcodeFid = $screenObject->getVar('fid');
if(in_array('anon_passcode_'.$passcodeFid, $handleElementMap)) { // passcode field exists in this data table, so we need to write the passcode to the entry
$element_values['anon_passcode_'.$passcodeFid] = $this->formatValueForQuery('anon_passcode_'.$sid, $value);
}
}
}
}

// write sql statement to insert new entry
$sql = "INSERT INTO ".$xoopsDB->prefix("formulize_".$formObject->getVar('form_handle'))." (".
Expand Down
13 changes: 11 additions & 2 deletions modules/formulize/class/passcode.php
Expand Up @@ -116,18 +116,27 @@ function getThisScreenPasscodes($sid) {
return self::getPasscodes($sid, '=');
}

function getPasscodes($sid=0, $op="") {
// returns an array of passcodes matching what is passed. In each array/passcode, the fields are keyed as - passcode, notes, expiry, id
function getPasscode($passcode) {
return self::getPasscodes(0,"",$passcode);
}

function getPasscodes($sid=0, $op="",$passcode="") {
global $xoopsDB;
$screenWhere = '';
$passcodeWhere = '';
if($sid) {
if(!$op OR ($op != '!=' AND $op != '=')) {
return array();
}
$screenWhere = ' AND screen '.$op.' '.intval($sid);
}
if($passcode) {
$passcodeWhere = ' AND passcode = "'.formulize_db_escape($passcode).'"';
}
$date = date('Y-m-d');
self::cleanupExpiredPasscodes();
$sql = 'SELECT distinct(passcode) as passcode, notes, expiry, passcode_id as id FROM '.$xoopsDB->prefix('formulize_passcodes').' WHERE (expiry > "'.$date.'" OR expiry IS NULL) '.$screenWhere.' ORDER BY passcode_id ASC';
$sql = 'SELECT distinct(passcode) as passcode, notes, expiry, passcode_id as id FROM '.$xoopsDB->prefix('formulize_passcodes').' WHERE (expiry > "'.$date.'" OR expiry IS NULL) '.$screenWhere.$passcodeWhere.' ORDER BY passcode_id ASC';
$passcodes = array();
if($res = $xoopsDB->query($sql)) {
while($array = $xoopsDB->fetchArray($res)) {
Expand Down
18 changes: 18 additions & 0 deletions modules/formulize/class/templateScreen.php
Expand Up @@ -158,6 +158,24 @@ function render($screen, $entry_id, $settings = "") {
foreach ($vars as $key => $value) {
$xoopsTpl->assign($key, $value);
}

// if the php code is not calling displayForm of some kind, then include necessary javascript
$codeContents = file_get_contents($custom_code_filename);
if(!strstr($codeContents,' displayForm(') AND !strstr($codeContents,' displayFormPages(') AND !strstr($codeContents,' ->render(') AND !strstr($codeContents,' displayElement(')) {
include_once XOOPS_ROOT_PATH.'/modules/formulize/include/formdisplay.php';
$doneDestination = $screen->getVar('donedest');
$doneDestination = substr($doneDestination,0,4) == 'http' ? $doneDestination : XOOPS_URL.$doneDestination;
print "
<script>function xoopsFormValidate_formulize_mainform(){return true;}</script>
<style> #savingmessage { display: none !important; } </style>
<div id='formulizeform' style='display: none;'><form id='formulize_mainform' name='formulize_mainform' action='$doneDestination' method='post'></form>".
drawJavascript().
writeHiddenSettings($settings, null, array($screen->getVar('fid')=>array($entry_id)), array(), $screen).
"</div></div>
";

}

$xoopsTpl->display("file:".$template_filename);
// we need to put other code in here to persist $settings if any!!
} else {
Expand Down
4 changes: 4 additions & 0 deletions modules/formulize/formulize_xhr_responder.php
Expand Up @@ -216,6 +216,7 @@
}
}
}
if(!$onetoonekey OR ($entryId AND $entryId != 'new')) {
if(security_check($fid, $entryId)) {
$html = renderElement($elementObject, $entryId);
if(count($sendBackValue)>0) {
Expand All @@ -234,6 +235,9 @@
print $html;
}
}
} else {
print '{NOCHANGE}';
}
break;


Expand Down
7 changes: 3 additions & 4 deletions modules/formulize/include/entriesdisplay.php
Expand Up @@ -2182,9 +2182,8 @@ function formulize_buildDateRangeFilter($handle, $search_text) {
}
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
$startDateElement = new XoopsFormTextDateSelect ('', 'formulize_daterange_sta_'.$handle, 15, strtotime($startText));
$startDateElement->setExtra("class='formulize_daterange'");
$endDateElement = new XoopsFormTextDateSelect ('', 'formulize_daterange_end_'.$handle, 15, strtotime($endText));
$endDateElement->setExtra("class='formulize_daterange' target='$handle'");

static $js;
if($js) { // only need to include this code once!
$js = "";
Expand All @@ -2201,7 +2200,7 @@ function formulize_buildDateRangeFilter($handle, $search_text) {
$().click(function() {
$('.formulize_daterange').change();
});
$('.formulize_daterange').change(function() {
$(\"[id^='formulize_daterange_sta_'],[id^='formulize_daterange_end_']\").change(function() {
var id = new String($(this).attr('id'));
var handle = id.substr(24);
var start = $('#formulize_daterange_sta_'+handle).val();
Expand Down Expand Up @@ -4591,7 +4590,7 @@ function formulize_screenLOEButton($button, $buttonText, $settings, $fid, $frid,
return "<input type=button class=\"formulize_button\" id=\"formulize_$button\" name=deSubmitButton value='" . $buttonText . "' onclick=\"javascript:showLoading();\"></input>";
break;
case "globalQuickSearch":
return "<input type=text id=\"formulize_$button\" name=\"global_search\" placeholder='" . $buttonText . "' value='" . $settings['global_search'] . "' onchange=\"javascript:window.document.controls.ventry.value = '';\"></input>";
return "<input type=text id=\"formulize_$button\" name=\"global_search\" value='" . $settings['global_search'] . "' onchange=\"javascript:window.document.controls.ventry.value = '';\"></input>";
break;
}
} elseif($button == "currentViewList") { // must always set a currentview value in POST even if the list is not visible
Expand Down

0 comments on commit 0451a62

Please sign in to comment.