password protect
Signed-off-by: Jeff <jeff@gotenzing.com>
Showing
557 changed files
with
4833 additions
and
0 deletions
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBTransform.php'); | ||
| 23 | |||
| 24 | class AverageField implements CFDBTransform { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @var string field holding the value | ||
| 28 | */ | ||
| 29 | var $valueField; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @var string field to group by | ||
| 33 | */ | ||
| 34 | var $groupByField; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * @var array of $groupByField => sum | ||
| 38 | */ | ||
| 39 | var $sums = array(); | ||
| 40 | |||
| 41 | /** | ||
| 42 | * @var array of $groupByField => count | ||
| 43 | */ | ||
| 44 | var $counts = array(); | ||
| 45 | |||
| 46 | function __construct($valueField, $groupByField = null) { | ||
| 47 | $this->valueField = $valueField; | ||
| 48 | $this->groupByField = $groupByField; | ||
| 49 | } | ||
| 50 | |||
| 51 | public function addEntry(&$entry) { | ||
| 52 | if (array_key_exists($this->valueField, $entry) && is_numeric($entry[$this->valueField])) { | ||
| 53 | $value = $entry[$this->valueField]; | ||
| 54 | $groupByName = empty($this->groupByField) ? $this->valueField : $entry[$this->groupByField]; | ||
| 55 | |||
| 56 | if ($value !== null && $value !== '') { | ||
| 57 | if (!array_key_exists($groupByName, $this->sums)) { | ||
| 58 | $this->sums[$groupByName] = $value; | ||
| 59 | $this->counts[$groupByName] = 1; | ||
| 60 | } else { | ||
| 61 | $this->sums[$groupByName] += $value; | ||
| 62 | $this->counts[$groupByName]++; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | public function getTransformedData() { | ||
| 69 | $data = array(); | ||
| 70 | foreach (array_keys($this->sums) as $name) { | ||
| 71 | $average = $this->sums[$name] / $this->counts[$name]; | ||
| 72 | if (empty($this->groupByField)) { | ||
| 73 | $data[] = array($this->valueField => $average); | ||
| 74 | } else { | ||
| 75 | $data[] = array($this->groupByField => $name, $this->valueField => $average); | ||
| 76 | } | ||
| 77 | } | ||
| 78 | return $data; | ||
| 79 | } | ||
| 80 | |||
| 81 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBTransform.php'); | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Subclass this class and override getTransformedData() to return different data | ||
| 26 | */ | ||
| 27 | class BaseTransform implements CFDBTransform { | ||
| 28 | |||
| 29 | var $data = array(); | ||
| 30 | |||
| 31 | public function addEntry(&$entry) { | ||
| 32 | $this->data[] = $entry; | ||
| 33 | } | ||
| 34 | |||
| 35 | public function getTransformedData() { | ||
| 36 | return $this->data; | ||
| 37 | } | ||
| 38 | |||
| 39 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | require_once('CF7DBOptionsManager.php'); | ||
| 22 | |||
| 23 | /** | ||
| 24 | * The methods in this class are used to track whether or not the plugin has been installed. | ||
| 25 | * It writes a value in options to indicate that this plugin is installed. | ||
| 26 | * | ||
| 27 | * @author Michael Simpson | ||
| 28 | */ | ||
| 29 | |||
| 30 | abstract class CF7DBInstallIndicator extends CF7DBOptionsManager { | ||
| 31 | |||
| 32 | const optionInstalled = '_installed'; | ||
| 33 | const optionVersion = '_version'; | ||
| 34 | |||
| 35 | /** | ||
| 36 | * @return bool indicating if the plugin is installed already | ||
| 37 | */ | ||
| 38 | public function isInstalled() { | ||
| 39 | return $this->getOption(self::optionInstalled) == true; | ||
| 40 | } | ||
| 41 | |||
| 42 | /** | ||
| 43 | * Note in DB that the plugin is installed | ||
| 44 | * @return null | ||
| 45 | */ | ||
| 46 | protected function markAsInstalled() { | ||
| 47 | return $this->updateOption(self::optionInstalled, true); | ||
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 51 | * Note in DB that the plugin is uninstalled | ||
| 52 | * @return bool returned form delete_option. | ||
| 53 | * true implies the plugin was installed at the time of this call, | ||
| 54 | * false implies it was not. | ||
| 55 | */ | ||
| 56 | protected function markAsUnInstalled() { | ||
| 57 | return $this->deleteOption(self::optionInstalled); | ||
| 58 | } | ||
| 59 | |||
| 60 | /** | ||
| 61 | * Set a version string in the options. This is useful if you install upgrade and | ||
| 62 | * need to check if an older version was installed to see if you need to do certain | ||
| 63 | * upgrade housekeeping (e.g. changes to DB schema). | ||
| 64 | * @return string|null value of the version | ||
| 65 | */ | ||
| 66 | protected function getVersionSaved() { | ||
| 67 | return $this->getOption(self::optionVersion); | ||
| 68 | } | ||
| 69 | |||
| 70 | /** | ||
| 71 | * Set a version string in the options. | ||
| 72 | * need to check if | ||
| 73 | * @param $version string best practice: use a dot-delimited string like '1.2.3' so version strings can be easily | ||
| 74 | * compared using version_compare (http://php.net/manual/en/function.version-compare.php) | ||
| 75 | * @return null | ||
| 76 | */ | ||
| 77 | protected function setVersionSaved($version) { | ||
| 78 | return $this->updateOption(self::optionVersion, $version); | ||
| 79 | } | ||
| 80 | |||
| 81 | /** | ||
| 82 | * @abstract | ||
| 83 | * @return string name of the main plugin file that has the header section with | ||
| 84 | * "Plugin Name", "Version", "Description", "Text Domain", etc. | ||
| 85 | */ | ||
| 86 | protected abstract function getMainPluginFileName(); | ||
| 87 | |||
| 88 | /** | ||
| 89 | * Get a value for input key in the header section of main plugin file. | ||
| 90 | * E.g. "Plugin Name", "Version", "Description", "Text Domain", etc. | ||
| 91 | * @param $key string header value name | ||
| 92 | * @return string if found, otherwise null | ||
| 93 | */ | ||
| 94 | public function getPluginHeaderValue($key) { | ||
| 95 | // Read the string from the comment header of the main plugin file | ||
| 96 | $data = file_get_contents($this->getPluginDir() . DIRECTORY_SEPARATOR . $this->getMainPluginFileName()); | ||
| 97 | $match = array(); | ||
| 98 | preg_match('/' . $key . ':\s*(\S+)/', $data, $match); | ||
| 99 | if (count($match) >= 1) { | ||
| 100 | return $match[1]; | ||
| 101 | } | ||
| 102 | return null; | ||
| 103 | } | ||
| 104 | |||
| 105 | /** | ||
| 106 | * If your subclass of this class lives in a different directory, | ||
| 107 | * override this method with the exact same code. Since __FILE__ will | ||
| 108 | * be different, you will then get the right dir returned. | ||
| 109 | * @return string | ||
| 110 | */ | ||
| 111 | protected function getPluginDir() { | ||
| 112 | return dirname(__FILE__); | ||
| 113 | } | ||
| 114 | |||
| 115 | /** | ||
| 116 | * Version of this code. | ||
| 117 | * Best practice: define version strings to be easily compared using version_compare() | ||
| 118 | * (http://php.net/manual/en/function.version-compare.php) | ||
| 119 | * NOTE: You should manually make this match the SVN tag for your main plugin file 'Version' release and 'Stable tag' in readme.txt | ||
| 120 | * @return string | ||
| 121 | */ | ||
| 122 | public function getVersion() { | ||
| 123 | return $this->getPluginHeaderValue('Version'); | ||
| 124 | } | ||
| 125 | |||
| 126 | |||
| 127 | /** | ||
| 128 | * Useful when checking for upgrades, can tell if the currently installed version is earlier than the | ||
| 129 | * newly installed code. This case indicates that an upgrade has been installed and this is the first time it | ||
| 130 | * has been activated, so any upgrade actions should be taken. | ||
| 131 | * @return bool true if the version saved in the options is earlier than the version declared in getVersion(). | ||
| 132 | * true indicates that new code is installed and this is the first time it is activated, so upgrade actions | ||
| 133 | * should be taken. Assumes that version string comparable by version_compare, examples: '1', '1.1', '1.1.1', '2.0', etc. | ||
| 134 | */ | ||
| 135 | public function isInstalledCodeAnUpgrade() { | ||
| 136 | return $this->isSavedVersionLessThan($this->getVersion()); | ||
| 137 | } | ||
| 138 | |||
| 139 | /** | ||
| 140 | * Used to see if the installed code is an earlier version than the input version | ||
| 141 | * @param $aVersion string | ||
| 142 | * @return bool true if the saved version is earlier (by natural order) than the input version | ||
| 143 | */ | ||
| 144 | public function isSavedVersionLessThan($aVersion) { | ||
| 145 | return $this->isVersionLessThan($this->getVersionSaved(), $aVersion); | ||
| 146 | } | ||
| 147 | |||
| 148 | /** | ||
| 149 | * Used to see if the installed code is the same or earlier than the input version. | ||
| 150 | * Useful when checking for an upgrade. If you haven't specified the number of the newer version yet, | ||
| 151 | * but the last version (installed) was 2.3 (for example) you could check if | ||
| 152 | * For example, $this->isSavedVersionLessThanEqual('2.3') == true indicates that the saved version is not upgraded | ||
| 153 | * past 2.3 yet and therefore you would perform some appropriate upgrade action. | ||
| 154 | * @param $aVersion string | ||
| 155 | * @return bool true if the saved version is earlier (by natural order) than the input version | ||
| 156 | */ | ||
| 157 | public function isSavedVersionLessThanEqual($aVersion) { | ||
| 158 | return $this->isVersionLessThanEqual($this->getVersionSaved(), $aVersion); | ||
| 159 | } | ||
| 160 | |||
| 161 | /** | ||
| 162 | * @param $version1 string a version string such as '1', '1.1', '1.1.1', '2.0', etc. | ||
| 163 | * @param $version2 string a version string such as '1', '1.1', '1.1.1', '2.0', etc. | ||
| 164 | * @return bool true if version_compare of $versions1 and $version2 shows $version1 as the same or earlier | ||
| 165 | */ | ||
| 166 | public function isVersionLessThanEqual($version1, $version2) { | ||
| 167 | return (version_compare($version1, $version2) <= 0); | ||
| 168 | } | ||
| 169 | |||
| 170 | /** | ||
| 171 | * @param $version1 string a version string such as '1', '1.1', '1.1.1', '2.0', etc. | ||
| 172 | * @param $version2 string a version string such as '1', '1.1', '1.1.1', '2.0', etc. | ||
| 173 | * @return bool true if version_compare of $versions1 and $version2 shows $version1 as earlier | ||
| 174 | */ | ||
| 175 | public function isVersionLessThan($version1, $version2) { | ||
| 176 | return (version_compare($version1, $version2) < 0); | ||
| 177 | } | ||
| 178 | |||
| 179 | /** | ||
| 180 | * Record the installed version to options. | ||
| 181 | * This helps track was version is installed so when an upgrade is installed, it should call this when finished | ||
| 182 | * upgrading to record the new current version | ||
| 183 | * @param $version string optional version string. If not set, uses $this->getVersion() | ||
| 184 | * @return void | ||
| 185 | */ | ||
| 186 | protected function saveInstalledVersion($version = null) { | ||
| 187 | if (!$version) { | ||
| 188 | $version = $this->getVersion(); | ||
| 189 | } | ||
| 190 | if ($version) { | ||
| 191 | $this->setVersionSaved($version); | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | } |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBDeobfuscate.php'); | ||
| 23 | |||
| 24 | class CF7DBPluginExporter { | ||
| 25 | |||
| 26 | static function doExportFromPost() { | ||
| 27 | |||
| 28 | // Consolidate GET and POST parameters. Allow GET to override POST. | ||
| 29 | $params = array_merge($_POST, $_GET); | ||
| 30 | |||
| 31 | // print_r($params); | ||
| 32 | foreach ($params as $key => $value) { | ||
| 33 | if (is_string($value)) { | ||
| 34 | $params[$key] = stripslashes($value); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | // Assumes coming from CF7DBPlugin::whatsInTheDBPage() | ||
| 39 | $key = '3fde789a'; //substr($_COOKIE['PHPSESSID'], - 5); // session_id() doesn't work | ||
| 40 | if (isset($params['guser'])) { | ||
| 41 | $params['guser'] = CFDBDeobfuscate::deobfuscateHexString($params['guser'], $key); | ||
| 42 | } | ||
| 43 | if (isset($params['gpwd'])) { | ||
| 44 | $params['gpwd'] = CFDBDeobfuscate::deobfuscateHexString($params['gpwd'], $key); | ||
| 45 | } | ||
| 46 | |||
| 47 | if (!isset($params['enc'])) { | ||
| 48 | $params['enc'] = 'CSVUTF8'; | ||
| 49 | } | ||
| 50 | if (!isset($params['form'])) { | ||
| 51 | $params['form'] = ''; | ||
| 52 | } | ||
| 53 | CF7DBPluginExporter::export( | ||
| 54 | $params['form'], | ||
| 55 | $params['enc'], | ||
| 56 | $params); | ||
| 57 | } | ||
| 58 | |||
| 59 | static function export($formName, $encoding, $options) { | ||
| 60 | |||
| 61 | switch ($encoding) { | ||
| 62 | case 'HTML': | ||
| 63 | require_once('ExportToHtmlTable.php'); | ||
| 64 | $exporter = new ExportToHtmlTable(); | ||
| 65 | $exporter->export($formName, $options); | ||
| 66 | break; | ||
| 67 | case 'HTMLBOM': // IQY callback | ||
| 68 | require_once('ExportToHtmlTable.php'); | ||
| 69 | $exporter = new ExportToHtmlTable(); | ||
| 70 | $exporter->setUseBom(true); | ||
| 71 | $exporter->export($formName, $options); | ||
| 72 | break; | ||
| 73 | case 'DT': | ||
| 74 | require_once('ExportToHtmlTable.php'); | ||
| 75 | if (!is_array($options)) { | ||
| 76 | $options = array(); | ||
| 77 | } | ||
| 78 | $options['useDT'] = true; | ||
| 79 | if (!isset($options['printScripts'])) { | ||
| 80 | $options['printScripts'] = true; | ||
| 81 | } | ||
| 82 | if (!isset($options['printStyles'])) { | ||
| 83 | $options['printStyles'] = 'true'; | ||
| 84 | } | ||
| 85 | $exporter = new ExportToHtmlTable(); | ||
| 86 | $exporter->export($formName, $options); | ||
| 87 | break; | ||
| 88 | case 'HTMLTemplate': | ||
| 89 | require_once('ExportToHtmlTemplate.php'); | ||
| 90 | $exporter = new ExportToHtmlTemplate(); | ||
| 91 | $exporter->export($formName, $options); | ||
| 92 | break; | ||
| 93 | case 'IQY': | ||
| 94 | require_once('ExportToIqy.php'); | ||
| 95 | $exporter = new ExportToIqy(); | ||
| 96 | $exporter->export($formName, $options); | ||
| 97 | break; | ||
| 98 | case 'CSVUTF8BOM': | ||
| 99 | $options['unbuffered'] = 'true'; | ||
| 100 | require_once('ExportToCsvUtf8.php'); | ||
| 101 | $exporter = new ExportToCsvUtf8(); | ||
| 102 | $exporter->setUseBom(true); | ||
| 103 | $exporter->export($formName, $options); | ||
| 104 | break; | ||
| 105 | case 'TSVUTF16LEBOM': | ||
| 106 | $options['unbuffered'] = 'true'; | ||
| 107 | require_once('ExportToCsvUtf16le.php'); | ||
| 108 | $exporter = new ExportToCsvUtf16le(); | ||
| 109 | $exporter->export($formName, $options); | ||
| 110 | break; | ||
| 111 | case 'GLD': | ||
| 112 | require_once('ExportToGoogleLiveData.php'); | ||
| 113 | $exporter = new ExportToGoogleLiveData(); | ||
| 114 | $exporter->export($formName, $options); | ||
| 115 | break; | ||
| 116 | case 'GSS': | ||
| 117 | $options['unbuffered'] = 'true'; | ||
| 118 | require_once('ExportToGoogleSS.php'); | ||
| 119 | $exporter = new ExportToGoogleSS(); | ||
| 120 | $exporter->export($formName, $options); | ||
| 121 | break; | ||
| 122 | case 'JSON': | ||
| 123 | require_once('ExportToJson.php'); | ||
| 124 | $exporter = new ExportToJson(); | ||
| 125 | $exporter->export($formName, $options); | ||
| 126 | break; | ||
| 127 | case 'VALUE': | ||
| 128 | require_once('ExportToValue.php'); | ||
| 129 | $exporter = new ExportToValue(); | ||
| 130 | $exporter->export($formName, $options); | ||
| 131 | break; | ||
| 132 | case 'COUNT': | ||
| 133 | require_once('ExportToValue.php'); | ||
| 134 | if (!is_array($options)) { | ||
| 135 | $options = array(); | ||
| 136 | } | ||
| 137 | $options['function'] = 'count'; | ||
| 138 | unset($options['show']); | ||
| 139 | unset($options['hide']); | ||
| 140 | $exporter = new ExportToValue(); | ||
| 141 | $exporter->export($formName, $options); | ||
| 142 | break; | ||
| 143 | case 'CSVSJIS': | ||
| 144 | require_once('ExportToCsvUtf8.php'); | ||
| 145 | $exporter = new ExportToCsvUtf8(); | ||
| 146 | $exporter->setUseBom(false); | ||
| 147 | $exporter->setUseShiftJIS(true); | ||
| 148 | $exporter->export($formName, $options); | ||
| 149 | break; | ||
| 150 | case 'RSS': | ||
| 151 | require_once('ExportToRSS.php'); | ||
| 152 | $exporter = new ExportToRSS(); | ||
| 153 | $exporter->export($formName, $options); | ||
| 154 | break; | ||
| 155 | case 'ENTRY': | ||
| 156 | require_once('ExportEntry.php'); | ||
| 157 | $exporter = new ExportEntry(); | ||
| 158 | $exporter->export($formName, $options); | ||
| 159 | break; | ||
| 160 | case 'CSVUTF8': | ||
| 161 | default: | ||
| 162 | require_once('ExportToCsvUtf8.php'); | ||
| 163 | $exporter = new ExportToCsvUtf8(); | ||
| 164 | $exporter->setUseBom(false); | ||
| 165 | $exporter->export($formName, $options); | ||
| 166 | break; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CF7DBInstallIndicator.php'); | ||
| 23 | |||
| 24 | /** | ||
| 25 | * All the basic plugin life cycle functionality is implemented herein. | ||
| 26 | * A Plugin is expected to subclass this class and override method to inject | ||
| 27 | * its own specific behaviors. | ||
| 28 | * | ||
| 29 | * @author Michael Simpson | ||
| 30 | */ | ||
| 31 | |||
| 32 | abstract class CF7DBPluginLifeCycle extends CF7DBInstallIndicator { | ||
| 33 | |||
| 34 | public function install() { | ||
| 35 | |||
| 36 | // Initialize Plugin Options | ||
| 37 | $this->initOptions(); | ||
| 38 | |||
| 39 | // Initialize DB Tables used by the plugin | ||
| 40 | $this->installDatabaseTables(); | ||
| 41 | |||
| 42 | // Other Plugin initialization - for the plugin writer to override as needed | ||
| 43 | $this->otherInstall(); | ||
| 44 | |||
| 45 | // Record the installed version | ||
| 46 | $this->saveInstalledVersion(); | ||
| 47 | |||
| 48 | // To avoid running install() more then once | ||
| 49 | $this->markAsInstalled(); | ||
| 50 | } | ||
| 51 | |||
| 52 | public function uninstall() { | ||
| 53 | $this->otherUninstall(); | ||
| 54 | $this->unInstallDatabaseTables(); | ||
| 55 | $this->deleteSavedOptions(); | ||
| 56 | $this->markAsUnInstalled(); | ||
| 57 | } | ||
| 58 | |||
| 59 | /** | ||
| 60 | * Perform any version-upgrade activities prior to activation (e.g. database changes) | ||
| 61 | * @return void | ||
| 62 | */ | ||
| 63 | public function upgrade() { | ||
| 64 | } | ||
| 65 | |||
| 66 | public function activate() { | ||
| 67 | } | ||
| 68 | |||
| 69 | public function deactivate() { | ||
| 70 | } | ||
| 71 | |||
| 72 | protected function initOptions() { | ||
| 73 | } | ||
| 74 | |||
| 75 | public function addActionsAndFilters() { | ||
| 76 | } | ||
| 77 | |||
| 78 | protected function installDatabaseTables() { | ||
| 79 | } | ||
| 80 | |||
| 81 | protected function unInstallDatabaseTables() { | ||
| 82 | } | ||
| 83 | |||
| 84 | protected function otherInstall() { | ||
| 85 | } | ||
| 86 | |||
| 87 | protected function otherUninstall() { | ||
| 88 | } | ||
| 89 | |||
| 90 | /** | ||
| 91 | * Puts the configuration page in the Plugins menu by default. | ||
| 92 | * Override to put it elsewhere or create a set of submenus | ||
| 93 | * Override with an empty implementation if you don't want a configuration page | ||
| 94 | * @return void | ||
| 95 | */ | ||
| 96 | public function addSettingsSubMenuPage() { | ||
| 97 | $this->addSettingsSubMenuPageToPluginsMenu(); | ||
| 98 | //$this->addSettingsSubMenuPageToSettingsMenu(); | ||
| 99 | } | ||
| 100 | |||
| 101 | |||
| 102 | protected function requireExtraPluginFiles() { | ||
| 103 | require_once(ABSPATH . 'wp-includes/pluggable.php'); | ||
| 104 | require_once(ABSPATH . 'wp-admin/includes/plugin.php'); | ||
| 105 | } | ||
| 106 | |||
| 107 | protected function addSettingsSubMenuPageToPluginsMenu() { | ||
| 108 | $this->requireExtraPluginFiles(); | ||
| 109 | $displayName = $this->getPluginDisplayName(); | ||
| 110 | add_submenu_page('plugins.php', | ||
| 111 | $displayName, | ||
| 112 | $displayName, | ||
| 113 | 'manage_options', | ||
| 114 | get_class($this) . 'Settings', | ||
| 115 | array(&$this, 'settingsPage')); | ||
| 116 | } | ||
| 117 | |||
| 118 | |||
| 119 | protected function addSettingsSubMenuPageToSettingsMenu() { | ||
| 120 | $this->requireExtraPluginFiles(); | ||
| 121 | $displayName = $this->getPluginDisplayName(); | ||
| 122 | add_options_page($displayName, | ||
| 123 | $displayName, | ||
| 124 | 'manage_options', | ||
| 125 | get_class($this) . 'Settings', | ||
| 126 | array(&$this, 'settingsPage')); | ||
| 127 | } | ||
| 128 | |||
| 129 | /** | ||
| 130 | * @param $name string name of a database table | ||
| 131 | * @return string input prefixed with the Wordpress DB table prefix | ||
| 132 | * plus the prefix for this plugin to avoid table name collisions | ||
| 133 | */ | ||
| 134 | protected function prefixTableName($name) { | ||
| 135 | global $wpdb; | ||
| 136 | return $wpdb->prefix . $this->prefix($name); | ||
| 137 | } | ||
| 138 | |||
| 139 | |||
| 140 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | function CF7DBPlugin_init($file) { | ||
| 23 | |||
| 24 | require_once('CF7DBPlugin.php'); | ||
| 25 | $aPlugin = new CF7DBPlugin(); | ||
| 26 | |||
| 27 | // Install the plugin | ||
| 28 | // NOTE: this file gets run each time you *activate* the plugin. | ||
| 29 | // So in WP when you "install" the plugin, all that does it dump its files in the plugin-templates directory | ||
| 30 | // but it does not call any of its code. | ||
| 31 | // So here, the plugin tracks whether or not it has run its install operation, and we ensure it is run only once | ||
| 32 | // on the first activation | ||
| 33 | if (!$aPlugin->isInstalled()) { | ||
| 34 | $aPlugin->install(); | ||
| 35 | } | ||
| 36 | else { | ||
| 37 | // Perform any version-upgrade activities prior to activation (e.g. database changes) | ||
| 38 | $aPlugin->upgrade(); | ||
| 39 | } | ||
| 40 | |||
| 41 | // Add callbacks to hooks | ||
| 42 | $aPlugin->addActionsAndFilters(); | ||
| 43 | |||
| 44 | if (!$file) { | ||
| 45 | $file = __FILE__; | ||
| 46 | } | ||
| 47 | // Register the Plugin Activation Hook | ||
| 48 | register_activation_hook($file, array(&$aPlugin, 'activate')); | ||
| 49 | |||
| 50 | |||
| 51 | // Register the Plugin Deactivation Hook | ||
| 52 | register_deactivation_hook($file, array(&$aPlugin, 'deactivate')); | ||
| 53 | } |
wp-content/plugins/contact-form-7-to-database-extension/CFDBAbstractQueryResultsIterator.php
0 → 100644
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBDataIterator.php'); | ||
| 23 | |||
| 24 | |||
| 25 | abstract class CFDBAbstractQueryResultsIterator extends CFDBDataIterator { | ||
| 26 | |||
| 27 | /** | ||
| 28 | * @var string | ||
| 29 | */ | ||
| 30 | var $submitTimeKeyName; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * @var int | ||
| 34 | */ | ||
| 35 | var $limitEnd; | ||
| 36 | |||
| 37 | /** | ||
| 38 | * @var int | ||
| 39 | */ | ||
| 40 | var $idx; | ||
| 41 | |||
| 42 | /** | ||
| 43 | * @var int | ||
| 44 | */ | ||
| 45 | var $limitStart; | ||
| 46 | |||
| 47 | /** | ||
| 48 | * @var array | ||
| 49 | */ | ||
| 50 | var $columns; | ||
| 51 | |||
| 52 | /** | ||
| 53 | * @var CF7DBPlugin | ||
| 54 | */ | ||
| 55 | var $plugin; | ||
| 56 | |||
| 57 | /** | ||
| 58 | * @var CFDBEvaluator|CFDBFilterParser|CFDBSearchEvaluator | ||
| 59 | */ | ||
| 60 | var $rowFilter; | ||
| 61 | |||
| 62 | /** | ||
| 63 | * @var array | ||
| 64 | */ | ||
| 65 | // var $fileColumns; | ||
| 66 | |||
| 67 | /** | ||
| 68 | * @var bool | ||
| 69 | */ | ||
| 70 | var $onFirstRow = false; | ||
| 71 | |||
| 72 | |||
| 73 | /** | ||
| 74 | * Execute the query | ||
| 75 | * @param $sql string query | ||
| 76 | * @param $queryOptions array associative | ||
| 77 | * @return void | ||
| 78 | */ | ||
| 79 | abstract public function queryDataSource(&$sql, $queryOptions); | ||
| 80 | |||
| 81 | /** | ||
| 82 | * Get the next row from query results | ||
| 83 | * @return array associative | ||
| 84 | */ | ||
| 85 | abstract public function fetchRow(); | ||
| 86 | |||
| 87 | |||
| 88 | /** | ||
| 89 | * If you do not iterate over all the rows returned, be sure to call this function | ||
| 90 | * on all remaining rows to free resources. | ||
| 91 | * @return void | ||
| 92 | */ | ||
| 93 | abstract public function freeResult(); | ||
| 94 | |||
| 95 | /** | ||
| 96 | * @param $sql string | ||
| 97 | * @param $rowFilter CFDBEvaluator|CFDBFilterParser|CFDBSearchEvaluator | ||
| 98 | * @param $queryOptions array | ||
| 99 | */ | ||
| 100 | public function query(&$sql, $rowFilter, $queryOptions = array()) { | ||
| 101 | $this->rowFilter = $rowFilter; | ||
| 102 | $this->row = null; | ||
| 103 | $this->plugin = new CF7DBPlugin(); | ||
| 104 | $this->submitTimeKeyName = isset($queryOptions['submitTimeKeyName']) ? $queryOptions['submitTimeKeyName'] : null; | ||
| 105 | if (isset($queryOptions['limit'])) { | ||
| 106 | $limitVals = explode(',', $queryOptions['limit']); | ||
| 107 | if (isset($limitVals[1])) { | ||
| 108 | $this->limitStart = trim($limitVals[0]); | ||
| 109 | $this->limitEnd = (int) $this->limitStart + (int) trim($limitVals[1]); | ||
| 110 | } else if (isset($limitVals[0])) { | ||
| 111 | $this->limitEnd = trim($limitVals[0]); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | $this->idx = -1; | ||
| 115 | $this->queryDataSource($sql, $queryOptions); | ||
| 116 | |||
| 117 | $this->columns = array(); | ||
| 118 | $this->row = $this->fetchRow(); | ||
| 119 | if ($this->row) { | ||
| 120 | foreach (array_keys($this->row) as $aCol) { | ||
| 121 | // hide this metadata column | ||
| 122 | if ('fields_with_file' != $aCol) { | ||
| 123 | $this->columns[] = $aCol; | ||
| 124 | $this->displayColumns[] = $aCol; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | $this->onFirstRow = true; | ||
| 128 | } else { | ||
| 129 | $this->onFirstRow = false; | ||
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | /** | ||
| 134 | * Fetch next row into variable | ||
| 135 | * @return bool if next row exists | ||
| 136 | */ | ||
| 137 | public function nextRow() { | ||
| 138 | while (true) { | ||
| 139 | if (!$this->onFirstRow) { | ||
| 140 | $this->row = $this->fetchRow(); | ||
| 141 | } | ||
| 142 | $this->onFirstRow = false; | ||
| 143 | |||
| 144 | if (!$this->row) { | ||
| 145 | $this->freeResult(); | ||
| 146 | return false; | ||
| 147 | } | ||
| 148 | |||
| 149 | // Format the date | ||
| 150 | if (!isset($this->row['submit_time']) && | ||
| 151 | isset($this->row['Submitted']) && is_numeric($this->row['Submitted'])) { | ||
| 152 | $submitTime = $this->row['Submitted']; | ||
| 153 | $this->row['submit_time'] = $submitTime; | ||
| 154 | $this->row['Submitted'] = $this->plugin->formatDate($submitTime); | ||
| 155 | } | ||
| 156 | |||
| 157 | // Determine if row is filtered | ||
| 158 | if ($this->rowFilter) { | ||
| 159 | $match = $this->rowFilter->evaluate($this->row); | ||
| 160 | if (!$match) { | ||
| 161 | continue; | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | $this->idx += 1; | ||
| 166 | if ($this->limitStart && $this->idx < $this->limitStart) { | ||
| 167 | continue; | ||
| 168 | } | ||
| 169 | if ($this->limitEnd && $this->idx >= $this->limitEnd) { | ||
| 170 | while ($this->row = $this->fetchRow()) ; | ||
| 171 | $this->freeResult(); | ||
| 172 | $this->row = null; | ||
| 173 | return false; | ||
| 174 | } | ||
| 175 | |||
| 176 | // Keep the unformatted submitTime if needed | ||
| 177 | if (isset($submitTime) && $this->submitTimeKeyName) { | ||
| 178 | $this->row[$this->submitTimeKeyName] = $submitTime; | ||
| 179 | } | ||
| 180 | break; | ||
| 181 | } | ||
| 182 | if (!$this->row) { | ||
| 183 | $this->freeResult(); | ||
| 184 | } | ||
| 185 | return $this->row ? true : false; | ||
| 186 | } | ||
| 187 | |||
| 188 | |||
| 189 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | class CFDBCheckZendFramework { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Checks for the existence of the Zend Framework. If not found, prints out some (hopefully) helpful information | ||
| 26 | * @return bool true if Zend is found, *but* if not found calls wp_die() | ||
| 27 | */ | ||
| 28 | public static function checkIncludeZend() { | ||
| 29 | if (!(include 'Zend/Loader.php')) { | ||
| 30 | ob_start(); | ||
| 31 | ?> | ||
| 32 | <h1>Missing Zend Framework</h1> | ||
| 33 | <p> | ||
| 34 | This function requires part of the Zend framework that interacts with Google. <br/> | ||
| 35 | It appears that either: | ||
| 36 | </p> | ||
| 37 | <ol> | ||
| 38 | <li>The Zend Framework is not on the include_path or</li> | ||
| 39 | <li>You do not have the Zend Framework installed</li> | ||
| 40 | </ol> | ||
| 41 | <p> | ||
| 42 | <code>include_path="<?php echo(ini_get('include_path'));?>"</code><br/> | ||
| 43 | <code>php.ini file is | ||
| 44 | "<?php $phpInfo = CFDBCheckZendFramework::getPhpInfo(); echo($phpInfo['Loaded Configuration File']);?> | ||
| 45 | "</code><br/> | ||
| 46 | </p> | ||
| 47 | <ol> | ||
| 48 | <li>locate the the <span style="font-weight: bold;">Zend</span> directory on your computer</li> | ||
| 49 | <li>If found, here is one way to put it on the include path</li> | ||
| 50 | <ol> | ||
| 51 | <li style="list-style: lower-roman">copy the <span style="font-weight: bold;">php.ini</span> file to your WordPress installation to | ||
| 52 | <span style="font-weight: bold;">[wp-dir]/wp-content/plugins/contact-form-7-to-database-extension/php.ini</span> | ||
| 53 | </li> | ||
| 54 | <li style="list-style: lower-roman">add a line to this new file:<br/> | ||
| 55 | <code>include_path="<?php echo(ini_get('include_path') . PATH_SEPARATOR . "[Zend-parent-directory]");?>"</code> | ||
| 56 | </li> | ||
| 57 | </ol> | ||
| 58 | <li>If not found, install and configure Zend version 1.11.11 (or contact or administrator or host provider)<br/> | ||
| 59 | See: <a target="_blank" href="http://code.google.com/apis/gdata/articles/php_client_lib.html">Getting | ||
| 60 | Started | ||
| 61 | with the Google Data PHP Client Library</a><br/> | ||
| 62 | To download the part of Zend 1.11.11 required, see: <a target="_blank" | ||
| 63 | href="http://framework.zend.com/download/gdata/">Zend | ||
| 64 | GData</a> | ||
| 65 | </li> | ||
| 66 | </ol> | ||
| 67 | <?php | ||
| 68 | $errorHtml = ob_get_contents(); | ||
| 69 | ob_end_clean(); | ||
| 70 | include_once('CFDBDie.php'); | ||
| 71 | CFDBDie::wp_die($errorHtml, | ||
| 72 | __('Missing Zend Framework', 'contact-form-7-to-database-extension'), | ||
| 73 | array('response' => 200, 'back_link' => true)); | ||
| 74 | |||
| 75 | // Doesn't actually return because we call wp_die | ||
| 76 | return false; | ||
| 77 | } | ||
| 78 | return true; | ||
| 79 | } | ||
| 80 | |||
| 81 | |||
| 82 | /** | ||
| 83 | * Taken from: http://www.php.net/manual/en/function.phpinfo.php#87214 | ||
| 84 | * @return array key => array(values) from phpinfo call | ||
| 85 | */ | ||
| 86 | private static function getPhpInfo() { | ||
| 87 | ob_start(); | ||
| 88 | phpinfo(INFO_GENERAL); | ||
| 89 | $phpinfo = array('phpinfo' => array()); | ||
| 90 | if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER)) | ||
| 91 | foreach ($matches as $match) | ||
| 92 | if (strlen($match[1])) | ||
| 93 | $phpinfo[$match[1]] = array(); | ||
| 94 | elseif (isset($match[3])) | ||
| 95 | $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3]; | ||
| 96 | else | ||
| 97 | $phpinfo[end(array_keys($phpinfo))][] = $match[2]; | ||
| 98 | return $phpinfo['phpinfo']; | ||
| 99 | } | ||
| 100 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CF7DBPlugin.php'); | ||
| 23 | |||
| 24 | class CFDBCleanupData { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @var CF7DBPlugin | ||
| 28 | */ | ||
| 29 | var $plugin; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @param $plugin CF7DBPlugin | ||
| 33 | */ | ||
| 34 | function __construct($plugin) { | ||
| 35 | $this->plugin = $plugin; | ||
| 36 | } | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Fix entries from different forms with same submit_time | ||
| 40 | * @return int number of items fixed in the DB | ||
| 41 | */ | ||
| 42 | public function cleanupForms() { | ||
| 43 | global $wpdb; | ||
| 44 | |||
| 45 | $table = $this->plugin->getSubmitsTableName(); | ||
| 46 | $sql = sprintf('select * from (select submit_time, count(form_name) as count | ||
| 47 | from ( | ||
| 48 | select distinct submit_time, form_name from %s) t group by submit_time | ||
| 49 | ) u where count > 1', $table); | ||
| 50 | $results = $wpdb->get_results($sql, ARRAY_A); | ||
| 51 | //print_r($results); // debug | ||
| 52 | if (!$results) { | ||
| 53 | return 0; | ||
| 54 | } | ||
| 55 | |||
| 56 | $stSql = "select distinct submit_time, form_name from $table where submit_time = %F"; | ||
| 57 | $inDBSql = "select count(submit_time) from $table where submit_time = %F"; | ||
| 58 | $updateSql = "update $table set submit_time = %F where submit_time = %F and form_name = %s"; | ||
| 59 | $count = 0; | ||
| 60 | foreach ($results as $row) { | ||
| 61 | $stResults = $wpdb->get_results($wpdb->prepare($stSql, $row['submit_time']), ARRAY_A); | ||
| 62 | $idx = 0; | ||
| 63 | foreach ($stResults as $stResult) { | ||
| 64 | if ($idx++ == 0) { | ||
| 65 | continue; | ||
| 66 | } | ||
| 67 | $newST = $stResult['submit_time']; | ||
| 68 | while (true) { | ||
| 69 | $newST = $newST + 0.0001; // Get new submit time | ||
| 70 | $inDbAlready = $wpdb->get_var($wpdb->prepare($inDBSql, $newST)); | ||
| 71 | if (!$inDbAlready) { | ||
| 72 | $wpdb->query($wpdb->prepare($updateSql, $newST, $stResult['submit_time'], $stResult['form_name'])); | ||
| 73 | ++$count; | ||
| 74 | break; | ||
| 75 | } | ||
| 76 | } | ||
| 77 | } | ||
| 78 | } | ||
| 79 | return $count; | ||
| 80 | } | ||
| 81 | |||
| 82 | |||
| 83 | public function deleteEmptyEntries() { | ||
| 84 | $table = $this->plugin->getSubmitsTableName(); | ||
| 85 | global $wpdb; | ||
| 86 | return $wpdb->query("DELETE FROM $table WHERE field_name = '' AND field_value = ''"); | ||
| 87 | } | ||
| 88 | |||
| 89 | /** | ||
| 90 | * Fix entries in the same form with duplicate submit_time values | ||
| 91 | * return int | ||
| 92 | */ | ||
| 93 | public function cleanupEntries() { | ||
| 94 | $count = 0; | ||
| 95 | $table = $this->plugin->getSubmitsTableName(); | ||
| 96 | $dupSql = | ||
| 97 | "SELECT DISTINCT b.submit_time FROM ( | ||
| 98 | SELECT a.submit_time, a.form_name, a.field_name, count(a.field_value) AS count | ||
| 99 | FROM $table a | ||
| 100 | GROUP BY a.submit_time, a.submit_time, a.form_name, a.field_name) b | ||
| 101 | WHERE b.count > 1"; | ||
| 102 | |||
| 103 | $deleteWithFieldOrder = "DELETE FROM $table WHERE submit_time = %F AND form_name = %s AND field_name = %s AND field_value = %s AND field_order = %d LIMIT 1"; | ||
| 104 | $deleteNoFieldOrder = "DELETE FROM $table WHERE submit_time = %F AND form_name = %s AND field_name = %s AND field_value = %s AND field_order IS NULL LIMIT 1"; | ||
| 105 | |||
| 106 | $updateWithFieldOrder = "UPDATE $table SET submit_time = %F WHERE submit_time = %F AND form_name = %s AND field_name = %s AND field_value = %s AND field_order = %d LIMIT 1"; | ||
| 107 | $updateNoFieldOrder = "UPDATE $table SET submit_time = %F WHERE submit_time = %F AND form_name = %s AND field_name = %s AND field_value = %s AND field_order IS NULL LIMIT 1"; | ||
| 108 | |||
| 109 | $submitTimes = array(); | ||
| 110 | global $wpdb; | ||
| 111 | $results = $wpdb->get_results($dupSql, ARRAY_A); | ||
| 112 | foreach ($results as $row) { | ||
| 113 | $submitTimes[] = $row['submit_time']; | ||
| 114 | } | ||
| 115 | |||
| 116 | $stSql = "SELECT * FROM $table WHERE submit_time = %F"; | ||
| 117 | foreach ($submitTimes as $st) { | ||
| 118 | $data = array(); | ||
| 119 | $entryNum = 0; | ||
| 120 | $data[$entryNum] = array(); | ||
| 121 | $results = $wpdb->get_results($wpdb->prepare($stSql, $st)); | ||
| 122 | foreach ($results as $row) { | ||
| 123 | foreach ($data[$entryNum] as $entry) { | ||
| 124 | if ($entry->field_name == $row->field_name) { | ||
| 125 | $entryNum++; | ||
| 126 | break; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | $data[$entryNum][] = $row; | ||
| 130 | } | ||
| 131 | |||
| 132 | foreach ($data as $idx => $entry) { | ||
| 133 | //print "\n\n"; | ||
| 134 | //print_r($entry); // debug | ||
| 135 | |||
| 136 | $diff = false; | ||
| 137 | if ($idx > 0) { | ||
| 138 | // If the entries are identical, delete one. | ||
| 139 | foreach ($entry as $field) { | ||
| 140 | $diff = false; | ||
| 141 | foreach($data[0] as $firstEntryRow) { | ||
| 142 | if ($field->field_name == $firstEntryRow->field_name) { | ||
| 143 | if ($field->field_value != $firstEntryRow->field_value) { | ||
| 144 | $diff = true; | ||
| 145 | break; | ||
| 146 | } | ||
| 147 | } | ||
| 148 | } | ||
| 149 | if ($diff) { | ||
| 150 | break; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | if (!$diff) { | ||
| 154 | foreach ($entry as $field) { | ||
| 155 | // Delete duplicate entries | ||
| 156 | $deleteSql = is_numeric($field->field_order) ? | ||
| 157 | $wpdb->prepare($deleteWithFieldOrder, $field->submit_time, $field->form_name, $field->field_name, $field->field_value, intval($field->field_order)) : | ||
| 158 | $wpdb->prepare($deleteNoFieldOrder, $field->submit_time, $field->form_name, $field->field_name, $field->field_value); | ||
| 159 | //echo "$deleteSql\n"; // debug | ||
| 160 | $wpdb->query($deleteSql); | ||
| 161 | } | ||
| 162 | ++$count; | ||
| 163 | } else { | ||
| 164 | $newST = $this->getNewSubmitTime($entry[0]->submit_time + 0.0001 * $idx); | ||
| 165 | foreach ($entry as $field) { | ||
| 166 | // Give different entries a slightly different submit_time | ||
| 167 | $updateSql = is_numeric($field->field_order) ? | ||
| 168 | $wpdb->prepare($updateWithFieldOrder, $newST, $field->submit_time, $field->form_name, $field->field_name, $field->field_value, intval($field->field_order)) : | ||
| 169 | $wpdb->prepare($updateNoFieldOrder, $newST, $field->submit_time, $field->form_name, $field->field_name, $field->field_value); | ||
| 170 | //echo "$updateSql\n"; // debug | ||
| 171 | $wpdb->query($updateSql); | ||
| 172 | } | ||
| 173 | ++$count; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | } | ||
| 177 | } | ||
| 178 | |||
| 179 | return $count; | ||
| 180 | } | ||
| 181 | |||
| 182 | public function getNewSubmitTime($submitTime) { | ||
| 183 | global $wpdb; | ||
| 184 | $table = $this->plugin->getSubmitsTableName(); | ||
| 185 | $inDBSql = 'select count(submit_time) from ' . $table . ' where submit_time = %F'; | ||
| 186 | while (true) { | ||
| 187 | $submitTime = $submitTime + 0.0001; // Propose new submit time | ||
| 188 | $inDbAlready = $wpdb->get_var($wpdb->prepare($inDBSql, $submitTime)); | ||
| 189 | if (!$inDbAlready) { | ||
| 190 | break; | ||
| 191 | } | ||
| 192 | } | ||
| 193 | return $submitTime; | ||
| 194 | } | ||
| 195 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2013 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | include_once('CFDBEvaluator.php'); | ||
| 23 | |||
| 24 | class CFDBCompositeEvaluator implements CFDBEvaluator { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @var CFDBEvaluator[] | ||
| 28 | */ | ||
| 29 | var $evaluators; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @param $evaluators CFDBEvaluator[] | ||
| 33 | */ | ||
| 34 | public function setEvaluators($evaluators) { | ||
| 35 | $this->evaluators = $evaluators; | ||
| 36 | } | ||
| 37 | |||
| 38 | public function evaluate(&$data) { | ||
| 39 | if (is_array($this->evaluators)) { | ||
| 40 | foreach ($this->evaluators as $anEvaluator) { | ||
| 41 | if (!$anEvaluator->evaluate($data)) { | ||
| 42 | return false; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
| 46 | return true; | ||
| 47 | } | ||
| 48 | |||
| 49 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 5 | |||
| 6 | This file is part of Contact Form to Database. | ||
| 7 | |||
| 8 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation, either version 3 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with Contact Form to Database. | ||
| 20 | If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | abstract class CFDBDataIterator { | ||
| 24 | |||
| 25 | /** | ||
| 26 | * @var array[name=>value] | ||
| 27 | */ | ||
| 28 | var $row; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * @var array | ||
| 32 | */ | ||
| 33 | var $displayColumns = array(); | ||
| 34 | |||
| 35 | /** | ||
| 36 | * @return array[string] | ||
| 37 | */ | ||
| 38 | public function getDisplayColumns() { | ||
| 39 | return $this->displayColumns; | ||
| 40 | } | ||
| 41 | |||
| 42 | /** | ||
| 43 | * Fetch next row into variable | ||
| 44 | * @return bool if next row exists | ||
| 45 | */ | ||
| 46 | public abstract function nextRow(); | ||
| 47 | |||
| 48 | // /** | ||
| 49 | // * @return array[name=>value] | ||
| 50 | // */ | ||
| 51 | // public function &getRow() { | ||
| 52 | // return $this->row; | ||
| 53 | // } | ||
| 54 | |||
| 55 | |||
| 56 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBDataIterator.php'); | ||
| 23 | |||
| 24 | abstract class CFDBDataIteratorDecorator extends CFDBDataIterator { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @var CFDBDataIterator | ||
| 28 | */ | ||
| 29 | var $source; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @param $source CFDBDataIterator | ||
| 33 | */ | ||
| 34 | public function setSource($source) { | ||
| 35 | $this->source = $source; | ||
| 36 | } | ||
| 37 | |||
| 38 | public function getDisplayColumns() { | ||
| 39 | if (empty($this->displayColumns)) { | ||
| 40 | return $this->source->getDisplayColumns(); | ||
| 41 | } | ||
| 42 | return $this->displayColumns; | ||
| 43 | } | ||
| 44 | |||
| 45 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | interface CFDBDateFormatter { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Format input date string | ||
| 26 | * @param $time int same as returned from PHP time() | ||
| 27 | * @return string formatted date according to saved options | ||
| 28 | */ | ||
| 29 | public function formatDate($time); | ||
| 30 | |||
| 31 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | class CFDBDeobfuscate { | ||
| 23 | |||
| 24 | // Taken from http://ditio.net/2008/11/04/php-string-to-hex-and-hex-to-string-functions/ | ||
| 25 | static function hexToStr($hex) { | ||
| 26 | $string = ''; | ||
| 27 | for ($i = 0; $i < strlen($hex) - 1; $i += 2) { | ||
| 28 | $string .= chr(hexdec($hex[$i] . $hex[$i + 1])); | ||
| 29 | } | ||
| 30 | return $string; | ||
| 31 | } | ||
| 32 | |||
| 33 | static function deobfuscateHexString($hex, $key) { | ||
| 34 | return CFDBDeobfuscate::deobfuscateString(CFDBDeobfuscate::hexToStr($hex), $key); | ||
| 35 | } | ||
| 36 | |||
| 37 | static function deobfuscateString($string, $key) { | ||
| 38 | return mcrypt_decrypt(MCRYPT_3DES, $key, $string, 'ecb'); | ||
| 39 | } | ||
| 40 | |||
| 41 | |||
| 42 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | class CFDBDie { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Why this function? It is meant to do what wp_die() does. But in | ||
| 26 | * Ajax mode, wp_die just does die(-1). But in this plugin we are leveraging | ||
| 27 | * Ajax mode to put in URL hooks to do exports. So it is not really making a in-page | ||
| 28 | * call to the url, the full page is navigating to it, then it downloads a CSV file for | ||
| 29 | * example. So if there are errors we want the wp_die() error page. So this | ||
| 30 | * function is a copy of wp_die without the Ajax mode check. | ||
| 31 | * @static | ||
| 32 | * @param string $message HTML | ||
| 33 | * @param string $title HTML Title | ||
| 34 | * @param array $args see wp_die | ||
| 35 | * @return void | ||
| 36 | */ | ||
| 37 | static function wp_die($message, $title = '', $args = array()) { | ||
| 38 | // Code copied from wp_die without it stopping due to AJAX | ||
| 39 | if ( function_exists( 'apply_filters' ) ) { | ||
| 40 | $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler'); | ||
| 41 | } else { | ||
| 42 | $function = '_default_wp_die_handler'; | ||
| 43 | } | ||
| 44 | call_user_func( $function, $message, $title, $args ); | ||
| 45 | } | ||
| 46 | } |
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 5 | |||
| 6 | This file is part of Contact Form to Database. | ||
| 7 | |||
| 8 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation, either version 3 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with Contact Form to Database. | ||
| 20 | If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | require_once('CFDBDateFormatter.php'); | ||
| 24 | |||
| 25 | class CFDBErrorLog { | ||
| 26 | |||
| 27 | /** | ||
| 28 | * @var String path to file to write | ||
| 29 | */ | ||
| 30 | var $outputFilePath; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * @var String email address | ||
| 34 | */ | ||
| 35 | var $emailAddress; | ||
| 36 | |||
| 37 | /** | ||
| 38 | * @var CFDBDateFormatter | ||
| 39 | */ | ||
| 40 | var $dateFormatter; | ||
| 41 | |||
| 42 | |||
| 43 | function __construct($dateFormatter = null, $destination = null) { | ||
| 44 | $this->dateFormatter = $dateFormatter; | ||
| 45 | if ($destination) { | ||
| 46 | if ($this->isEmailAddress($destination)) { | ||
| 47 | $this->emailAddress = $destination; | ||
| 48 | } else { | ||
| 49 | $this->outputFilePath = $destination; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | /** | ||
| 55 | * @param $message String | ||
| 56 | */ | ||
| 57 | public function log($message) { | ||
| 58 | $date = time(); | ||
| 59 | if ($this->dateFormatter) { | ||
| 60 | $date = $this->dateFormatter->formatDate($date); | ||
| 61 | } | ||
| 62 | $fullMessage = sprintf("CFDB Error (%s): %s\n", $date, $message); | ||
| 63 | if ($this->outputFilePath) { | ||
| 64 | error_log($fullMessage, 3, $this->outputFilePath); | ||
| 65 | } else if ($this->emailAddress) { | ||
| 66 | error_log($fullMessage, 1, $this->emailAddress); | ||
| 67 | } else { | ||
| 68 | error_log($fullMessage, 0); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | /** | ||
| 73 | * @param $ex Exception | ||
| 74 | */ | ||
| 75 | public function logException($ex) { | ||
| 76 | $message = sprintf("%s\n\tat %s:%s\n%s", $ex->getMessage(), | ||
| 77 | $ex->getFile(), $ex->getLine(), | ||
| 78 | "\t" . str_replace("\n", "\n\t", $ex->getTraceAsString())); | ||
| 79 | $this->log($message); | ||
| 80 | } | ||
| 81 | |||
| 82 | public function isEmailAddress($email) { | ||
| 83 | $pattern = '/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}/'; | ||
| 84 | return (bool)preg_match($pattern, $email); | ||
| 85 | } | ||
| 86 | |||
| 87 | /** | ||
| 88 | * @return String | ||
| 89 | */ | ||
| 90 | public function getOutputFilePath() { | ||
| 91 | return $this->outputFilePath; | ||
| 92 | } | ||
| 93 | |||
| 94 | /** | ||
| 95 | * @return String | ||
| 96 | */ | ||
| 97 | public function getEmailAddress() { | ||
| 98 | return $this->emailAddress; | ||
| 99 | } | ||
| 100 | |||
| 101 | |||
| 102 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | interface CFDBEvaluator { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Evaluate expression against input data | ||
| 26 | * @param $data array [ key => value] | ||
| 27 | * @return boolean result of evaluating $data against expression | ||
| 28 | */ | ||
| 29 | public function evaluate(&$data); | ||
| 30 | |||
| 31 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | interface CFDBExport { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @abstract | ||
| 26 | * @param $formName string | ||
| 27 | * @param $options array of option_name => option_value | ||
| 28 | * @return void | ||
| 29 | */ | ||
| 30 | public function export($formName, $options = null); | ||
| 31 | |||
| 32 | } |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /** | ||
| 23 | * This class is an API for accessing a form and looping through its contents. | ||
| 24 | * Common shortcode options can be used to show/hide columns, search/filter fields, limit, orderby etc. | ||
| 25 | * Set them in the input $options array. | ||
| 26 | * Example code: | ||
| 27 | * <code> | ||
| 28 | * // Email all the "Mike"'s | ||
| 29 | * require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php'); | ||
| 30 | * $exp = new CFDBFormIterator(); | ||
| 31 | * $exp->export('my-form', new array('show' => 'name,email', 'search' => 'mike')); | ||
| 32 | * while ($row = $exp->nextRow()) { | ||
| 33 | * wp_mail($row['email'], 'Hello ' . $row['name], 'How are you doing?'); | ||
| 34 | * } | ||
| 35 | * | ||
| 36 | * </code> | ||
| 37 | */ | ||
| 38 | require_once('ExportBase.php'); | ||
| 39 | require_once('CFDBExport.php'); | ||
| 40 | |||
| 41 | class CFDBFormIterator extends ExportBase implements CFDBExport { | ||
| 42 | |||
| 43 | /** | ||
| 44 | * @var string | ||
| 45 | */ | ||
| 46 | var $formName; | ||
| 47 | |||
| 48 | |||
| 49 | /** | ||
| 50 | * @var CF7DBPlugin | ||
| 51 | */ | ||
| 52 | var $plugin; | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Intended to be used by people who what to programmatically loop over the rows | ||
| 56 | * of a form. | ||
| 57 | * @param $formName string | ||
| 58 | * @param $options array of option_name => option_value | ||
| 59 | * @return void | ||
| 60 | */ | ||
| 61 | public function export($formName, $options = null) { | ||
| 62 | $this->formName = $formName; | ||
| 63 | $this->setOptions($options); | ||
| 64 | $this->setCommonOptions(); | ||
| 65 | $this->setDataIterator($formName); | ||
| 66 | } | ||
| 67 | |||
| 68 | /** | ||
| 69 | * @return array|bool associative array of the row values or false if no more row exists | ||
| 70 | */ | ||
| 71 | public function nextRow() { | ||
| 72 | if ($this->dataIterator->nextRow()) { | ||
| 73 | $row = array(); | ||
| 74 | $row['submit_time'] = $this->dataIterator->row['submit_time']; | ||
| 75 | |||
| 76 | $fields_with_file = null; | ||
| 77 | if (isset($this->dataIterator->row['fields_with_file']) && | ||
| 78 | $this->dataIterator->row['fields_with_file'] != null) { | ||
| 79 | $fields_with_file = explode(',', $this->dataIterator->row['fields_with_file']); | ||
| 80 | if ($this->plugin == null) { | ||
| 81 | require_once('CF7DBPlugin.php'); | ||
| 82 | $this->plugin = new CF7DBPlugin(); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | foreach ($this->dataIterator->getDisplayColumns() as $aCol) { | ||
| 87 | $row[$aCol] = $this->dataIterator->row[$aCol]; | ||
| 88 | |||
| 89 | if ($aCol == 'filter'){ | ||
| 90 | $row[$aCol] = urldecode($row[$aCol]); | ||
| 91 | $row[$aCol] = urlencode($row[$aCol]); | ||
| 92 | } | ||
| 93 | |||
| 94 | // If it is a file, add in the URL for it by creating a field name appended with '_URL' | ||
| 95 | if ($fields_with_file && in_array($aCol, $fields_with_file)) { | ||
| 96 | $row[$aCol . '_URL'] = $this->plugin->getFileUrl($row['submit_time'], $this->formName, $aCol); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | return $row; | ||
| 100 | } | ||
| 101 | else { | ||
| 102 | return false; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | } |
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | "Contact Form to Database" Copyright (C) 2013 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 5 | |||
| 6 | This file is part of Contact Form to Database. | ||
| 7 | |||
| 8 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation, either version 3 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with Contact Form to Database. | ||
| 20 | If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | class CFDBFunctionEvaluator { | ||
| 24 | |||
| 25 | /** | ||
| 26 | * @var CFDBValueConverter callback that can be used to pre-process values in the filter string | ||
| 27 | * passed into parse($filterString). | ||
| 28 | * For example, a function might take the value '$user_email' and replace it with an actual email address | ||
| 29 | * just prior to checking it against input data in call evaluate($data) | ||
| 30 | */ | ||
| 31 | var $compValuePreprocessor; | ||
| 32 | |||
| 33 | /** | ||
| 34 | * @param $compValuePreprocessor CFDBValueConverter | ||
| 35 | */ | ||
| 36 | public function setCompValuePreprocessor($compValuePreprocessor) { | ||
| 37 | $this->compValuePreprocessor = $compValuePreprocessor; | ||
| 38 | } | ||
| 39 | |||
| 40 | |||
| 41 | /** | ||
| 42 | * @param $functionArray array ['function name', 'param1', 'param2', ...] | ||
| 43 | * @param $data array [name => value] | ||
| 44 | * @return mixed | ||
| 45 | */ | ||
| 46 | public function evaluateFunction($functionArray, &$data) { | ||
| 47 | $functionName = array_shift($functionArray); | ||
| 48 | for ($i = 0; $i < count($functionArray); $i++) { | ||
| 49 | $functionArray[$i] = $this->preprocessValues($functionArray[$i]); | ||
| 50 | |||
| 51 | // See if the parameter is a field name that can be dereferenced. | ||
| 52 | $functionArray[$i] = isset($data[$functionArray[$i]]) ? | ||
| 53 | $data[$functionArray[$i]] : | ||
| 54 | $functionArray[$i]; | ||
| 55 | |||
| 56 | // Dereference PHP Constants | ||
| 57 | if (defined($functionArray[$i])) { | ||
| 58 | $functionArray[$i] = constant($functionArray[$i]); | ||
| 59 | } | ||
| 60 | } | ||
| 61 | if (empty($functionArray)) { | ||
| 62 | // If function has no parameters, pass in the whole form entry associative array | ||
| 63 | $functionArray[] = &$data; | ||
| 64 | } | ||
| 65 | return call_user_func_array($functionName, $functionArray); | ||
| 66 | } | ||
| 67 | |||
| 68 | /** | ||
| 69 | * @param $text string | ||
| 70 | * @return mixed | ||
| 71 | */ | ||
| 72 | public function preprocessValues($text) { | ||
| 73 | if ($this->compValuePreprocessor) { | ||
| 74 | try { | ||
| 75 | $text = $this->compValuePreprocessor->convert($text); | ||
| 76 | } catch (Exception $ex) { | ||
| 77 | trigger_error($ex, E_USER_NOTICE); | ||
| 78 | } | ||
| 79 | } | ||
| 80 | return $text; | ||
| 81 | } | ||
| 82 | |||
| 83 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | /* | ||
| 2 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 3 | |||
| 4 | This file is part of Contact Form to Database. | ||
| 5 | |||
| 6 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation, either version 3 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Contact Form to Database. | ||
| 18 | If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | */ | ||
| 20 | |||
| 21 | /* This is a script to be used with a Google Spreadsheet to make it dynamically load data (similar to Excel IQuery) | ||
| 22 | Instructions: | ||
| 23 | 1. Create a new Google Spreadsheet | ||
| 24 | 2. Go to Tools menu -> Script Editor... | ||
| 25 | 3. Click Spreadsheet | ||
| 26 | 4. Copy the text from this file and paste it into the Google script editor. | ||
| 27 | 5. Save and close the script editor. | ||
| 28 | 6. Click on a cell A1 in the Spreadsheet (or any cell) | ||
| 29 | 7. Enter in the cell the formula: | ||
| 30 | =cfdbdata("site_url", "form_name", "user", "password") | ||
| 31 | Where the parameters are (be sure to quote them): | ||
| 32 | site_url: the URL of you site, e.g. "http://www.mywordpress.com" | ||
| 33 | form_name: name of the form | ||
| 34 | user: your login name on your WordPress site | ||
| 35 | pwd: password | ||
| 36 | */ | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Use this function in your spreadsheet to fetch saved form data from your WordPress Site | ||
| 40 | * @param site_url your top level WordPress site URL | ||
| 41 | * @param form_name name of the WordPress form to fetch data from | ||
| 42 | * @param user login name to your WordPress site. User must have permission to view form data | ||
| 43 | * @param password WordPress site password. If your site_url is "http" and not "https" then | ||
| 44 | * beware that your password is being sent unencrypted from a Google server to your WordPress server. | ||
| 45 | * Also beware that others who can view this code in your Google Spreadsheet can see this password. | ||
| 46 | * @param "option_name1", "option_value1", "option_name2", "option_value2", ... (optional param pairs). | ||
| 47 | * These are CFDB option such as "filter", "name=Smith", "show", "first_name,last_name" | ||
| 48 | * These should come in pairs. | ||
| 49 | * @returns {*} Your WordPress saved form data in a format suitable for Google Spreadsheet to display. | ||
| 50 | * String error message if there is an error logging into the WordPress site | ||
| 51 | */ | ||
| 52 | function cfdbdata(site_url, form_name, user, password /*, [option_name, option_value] ... */) { | ||
| 53 | var param_array = []; | ||
| 54 | param_array.push("action=cfdb-login"); | ||
| 55 | param_array.push("username=" + encodeURI(user)); | ||
| 56 | param_array.push("password=" + encodeURI(password)); | ||
| 57 | param_array.push("cfdb-action=cfdb-export"); | ||
| 58 | param_array.push("enc=JSON"); | ||
| 59 | param_array.push("format=array"); | ||
| 60 | param_array.push("form=" + encodeURI(form_name)); | ||
| 61 | |||
| 62 | var args = arg_slice(arguments, 4); | ||
| 63 | args = process_name_value_args(args); | ||
| 64 | param_array = param_array.concat(args); | ||
| 65 | |||
| 66 | return fetch_json_url(site_url, param_array); | ||
| 67 | } | ||
| 68 | |||
| 69 | function fetch_json_url(site_url, param_array) { | ||
| 70 | var url = site_url + "/wp-admin/admin-ajax.php"; | ||
| 71 | var payload = param_array.join("&"); | ||
| 72 | var response = UrlFetchApp.fetch(url, { method: "post", payload: payload }); | ||
| 73 | var content = response.getContentText(); | ||
| 74 | if (content.indexOf("<strong>ERROR") == 0) { | ||
| 75 | // If error message is returned, just return that as the content | ||
| 76 | return content; | ||
| 77 | } | ||
| 78 | //Logger.log(content); // For Debugging | ||
| 79 | return JSON.parse(content); | ||
| 80 | } | ||
| 81 | |||
| 82 | /** | ||
| 83 | * @deprecated for backward compatibility. Use cfdbdata() instead. | ||
| 84 | */ | ||
| 85 | function CF7ToDBData(site_url, form_name, search, user, password) { | ||
| 86 | if (search != "") { | ||
| 87 | return cfdbdata(site_url, form_name, user, password, "search", search); | ||
| 88 | } | ||
| 89 | return cfdbdata(site_url, form_name, user, password); | ||
| 90 | } | ||
| 91 | |||
| 92 | /** | ||
| 93 | * "slice" function for varargs Argument object | ||
| 94 | * @param args Argument object | ||
| 95 | * @param position int > 0 indicating the slice position | ||
| 96 | * @returns {Array} of args from the slide index to the end. | ||
| 97 | * Returns empty array if slice position exceeds length of args | ||
| 98 | */ | ||
| 99 | function arg_slice(args, position) { | ||
| 100 | var array = []; | ||
| 101 | if (args.length > position) { | ||
| 102 | for (var i = position; i < args.length; i++) { | ||
| 103 | array.push(args[i]); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | return array; | ||
| 107 | } | ||
| 108 | |||
| 109 | /** | ||
| 110 | * Converts array like ['a', '1', 'b', '2'] to ['a=1', 'b=2'] | ||
| 111 | * where each value is made to be URI-encoded. | ||
| 112 | * Purpose of this is to transform and array of name,value arguments | ||
| 113 | * into HTTP GET/POST parameters | ||
| 114 | * @param array Array like ['a', '1', 'b', '2'] | ||
| 115 | * @returns {Array} like ['a=1', 'b=2']. | ||
| 116 | * where each value (a, 1, b, 2) are URL-Encoded | ||
| 117 | * If there is an odd number of arguments then the last one is dropped | ||
| 118 | * (expecting pairs of name,value) | ||
| 119 | */ | ||
| 120 | function process_name_value_args(array) { | ||
| 121 | var name_value_array = []; | ||
| 122 | var flag = true; | ||
| 123 | var name = null; | ||
| 124 | for (var i = 0; i < array.length; i++) { | ||
| 125 | if (flag) { | ||
| 126 | name = array[i]; | ||
| 127 | } else { | ||
| 128 | name_value_array.push(encodeURI(name) + "=" + encodeURI(array[i])); | ||
| 129 | } | ||
| 130 | flag = !flag; | ||
| 131 | } | ||
| 132 | return name_value_array; | ||
| 133 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | header("Content-Type: text/plain"); | ||
| 23 | readfile('CFDBGoogleSSLiveData.js'); | ||
| 24 | ?> | ||
| 25 |
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 5 | |||
| 6 | This file is part of Contact Form to Database. | ||
| 7 | |||
| 8 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation, either version 3 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with Contact Form to Database. | ||
| 20 | If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | class CFDBIntegrationCalderaForms { | ||
| 24 | |||
| 25 | /** | ||
| 26 | * @var CF7DBPlugin | ||
| 27 | */ | ||
| 28 | var $plugin; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * @param $plugin CF7DBPlugin | ||
| 32 | */ | ||
| 33 | function __construct($plugin) { | ||
| 34 | $this->plugin = $plugin; | ||
| 35 | } | ||
| 36 | |||
| 37 | public function registerHooks() { | ||
| 38 | // http://docs.calderaforms.com/caldera_forms_submit_post_process_end/ | ||
| 39 | add_action('caldera_forms_submit_post_process_end', array(&$this, 'saveFormData'), 10, 3); | ||
| 40 | } | ||
| 41 | |||
| 42 | /** | ||
| 43 | * @param $form array | ||
| 44 | * @param $referrer array | ||
| 45 | * @param $process_id string | ||
| 46 | * @return bool | ||
| 47 | */ | ||
| 48 | public function saveFormData($form, $referrer, $process_id) { | ||
| 49 | try { | ||
| 50 | // debug | ||
| 51 | // $this->plugin->getErrorLog()->log('$form: ' . print_r($form, true)); | ||
| 52 | // $this->plugin->getErrorLog()->log('$referrer: ' . print_r($referrer, true)); | ||
| 53 | // $this->plugin->getErrorLog()->log('$process_id: ' . print_r($process_id, true)); | ||
| 54 | // global $processed_data; | ||
| 55 | // $this->plugin->getErrorLog()->log('$processed_data: ' . print_r($processed_data, true)); | ||
| 56 | |||
| 57 | $data = $this->convertData($form); | ||
| 58 | return $this->plugin->saveFormData($data); | ||
| 59 | } catch (Exception $ex) { | ||
| 60 | $this->plugin->getErrorLog()->logException($ex); | ||
| 61 | } | ||
| 62 | return true; | ||
| 63 | } | ||
| 64 | |||
| 65 | /** | ||
| 66 | * @param $form array | ||
| 67 | * @return null|object | ||
| 68 | */ | ||
| 69 | public function convertData($form) { | ||
| 70 | global $processed_data; | ||
| 71 | |||
| 72 | if (is_array($form) && is_array($processed_data)) { | ||
| 73 | $title = $form['name']; | ||
| 74 | $postedData = array(); | ||
| 75 | $uploadedFiles = array(); | ||
| 76 | |||
| 77 | $results = $processed_data[$form['ID']]; | ||
| 78 | |||
| 79 | foreach ($results as $field_id => $field_value) { | ||
| 80 | |||
| 81 | if (!array_key_exists($field_id, $form['fields'])) { | ||
| 82 | // ignore non-field entries _entry_id and _entry_token | ||
| 83 | continue; | ||
| 84 | } | ||
| 85 | $field_name = $form['fields'][$field_id]['label']; | ||
| 86 | $is_file = $form['fields'][$field_id]['type'] == 'file'; | ||
| 87 | |||
| 88 | if (is_array($field_value)) { | ||
| 89 | $postedData[$field_name] = implode(',', $field_value); | ||
| 90 | } else if ($is_file && $field_value != null) { | ||
| 91 | // $field_value is a URL to the file like | ||
| 92 | // http://SITE.com/wp-content/uploads/2015/05/my_file.png | ||
| 93 | $postedData[$field_name] = basename($field_value); | ||
| 94 | $path = get_home_path() . $this->getUrlWithoutSchemeHostAndPort($field_value); | ||
| 95 | $uploadedFiles[$field_name] = $path; | ||
| 96 | } else { | ||
| 97 | $postedData[$field_name] = $field_value; | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | return (object)array( | ||
| 102 | 'title' => $title, | ||
| 103 | 'posted_data' => $postedData, | ||
| 104 | 'uploaded_files' => $uploadedFiles); | ||
| 105 | } | ||
| 106 | return null; | ||
| 107 | } | ||
| 108 | |||
| 109 | /** | ||
| 110 | * Return the end part of a URL minus the "http://host:port" part | ||
| 111 | * @param $url string | ||
| 112 | * @return string|null | ||
| 113 | */ | ||
| 114 | public function getUrlWithoutSchemeHostAndPort($url) { | ||
| 115 | $matches = array(); | ||
| 116 | preg_match('#^http(s)?://[^/]+(.*)#', $url, $matches); | ||
| 117 | if (count($matches) >= 3) { | ||
| 118 | return $matches[2]; | ||
| 119 | } | ||
| 120 | return null; | ||
| 121 | } | ||
| 122 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | class CFDBIntegrationContactForm7 { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @var CF7DBPlugin | ||
| 26 | */ | ||
| 27 | var $plugin; | ||
| 28 | |||
| 29 | /** | ||
| 30 | * @param $plugin CF7DBPlugin | ||
| 31 | */ | ||
| 32 | function __construct($plugin) { | ||
| 33 | $this->plugin = $plugin; | ||
| 34 | } | ||
| 35 | |||
| 36 | public function registerHooks() { | ||
| 37 | add_action('wpcf7_before_send_mail', array(&$this, 'saveFormData')); | ||
| 38 | // Generate submit_time for CF7 mail. Some people complain this causes an error | ||
| 39 | // so this is now optional and off by default. Seems to be related to CF7 | ||
| 40 | // checking its data against blacklist | ||
| 41 | if ($this->plugin->getOption('GenerateSubmitTimeInCF7Email', 'false') == 'true') { | ||
| 42 | add_action('wpcf7_posted_data', array(&$this, 'generateSubmitTimeForCF7')); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Callback from Contact Form 7. CF7 passes an object with the posted data which is inserted into the database | ||
| 48 | * by this function. | ||
| 49 | * @param $cf7 WPCF7_ContactForm | ||
| 50 | * @return bool | ||
| 51 | */ | ||
| 52 | public function saveFormData($cf7) { | ||
| 53 | try { | ||
| 54 | $data = $this->convertData($cf7); | ||
| 55 | return $this->plugin->saveFormData($data); | ||
| 56 | } catch (Exception $ex) { | ||
| 57 | $this->plugin->getErrorLog()->logException($ex); | ||
| 58 | } | ||
| 59 | return true; | ||
| 60 | } | ||
| 61 | |||
| 62 | |||
| 63 | /** | ||
| 64 | * @param $cf7 WPCF7_ContactForm | ||
| 65 | * @return object | ||
| 66 | */ | ||
| 67 | public function convertData($cf7) { | ||
| 68 | if (!isset($cf7->posted_data) && class_exists('WPCF7_Submission')) { | ||
| 69 | // Contact Form 7 version 3.9 removed $cf7->posted_data and now | ||
| 70 | // we have to retrieve it from an API | ||
| 71 | $submission = WPCF7_Submission::get_instance(); | ||
| 72 | if ($submission) { | ||
| 73 | $data = array(); | ||
| 74 | $data['title'] = $cf7->title(); | ||
| 75 | $data['posted_data'] = $submission->get_posted_data(); | ||
| 76 | $data['uploaded_files'] = $submission->uploaded_files(); | ||
| 77 | $data['WPCF7_ContactForm'] = $cf7; | ||
| 78 | return (object) $data; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | return $cf7; | ||
| 82 | } | ||
| 83 | |||
| 84 | /** | ||
| 85 | * Generate the submit_time and submit_url so they can be added to CF7 mail | ||
| 86 | * @param $posted_data array | ||
| 87 | * @return array | ||
| 88 | */ | ||
| 89 | public function generateSubmitTimeForCF7($posted_data) { | ||
| 90 | try { | ||
| 91 | $time = $this->plugin->generateSubmitTime(); | ||
| 92 | $posted_data['submit_time'] = $time; | ||
| 93 | |||
| 94 | // No longer generating submit_url because it seems to cause CF7 to think it is | ||
| 95 | // a spam submission and it drops it. | ||
| 96 | // $url = get_admin_url() . sprintf('admin.php?page=%s&submit_time=%s', | ||
| 97 | // | ||
| 98 | // $this->getDBPageSlug(), | ||
| 99 | // $time); | ||
| 100 | // $posted_data['submit_url'] = $url; | ||
| 101 | } catch (Exception $ex) { | ||
| 102 | $this->plugin->getErrorLog()->logException($ex); | ||
| 103 | } | ||
| 104 | return $posted_data; | ||
| 105 | } | ||
| 106 | |||
| 107 | |||
| 108 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 5 | |||
| 6 | This file is part of Contact Form to Database. | ||
| 7 | |||
| 8 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation, either version 3 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with Contact Form to Database. | ||
| 20 | If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | class CFDBIntegrationEnfoldTheme { | ||
| 24 | /** | ||
| 25 | * @var CF7DBPlugin | ||
| 26 | */ | ||
| 27 | var $plugin; | ||
| 28 | |||
| 29 | /** | ||
| 30 | * @param $plugin CF7DBPlugin | ||
| 31 | */ | ||
| 32 | function __construct($plugin) { | ||
| 33 | $this->plugin = $plugin; | ||
| 34 | } | ||
| 35 | |||
| 36 | public function registerHooks() { | ||
| 37 | add_filter('avf_form_send', array(&$this, 'saveFormData'), 10, 3); | ||
| 38 | } | ||
| 39 | |||
| 40 | public function saveFormData($bool, $new_post, $form_params) { | ||
| 41 | |||
| 42 | // $msg = '$new_post=' . print_r($new_post, true) . "\n" . | ||
| 43 | // '$form_params=' . print_r($form_params, true); | ||
| 44 | // $this->plugin->getErrorLog()->log($msg); | ||
| 45 | |||
| 46 | try { | ||
| 47 | if (is_array($new_post)) { | ||
| 48 | $postedData = array(); | ||
| 49 | foreach ($new_post as $key => $value) { | ||
| 50 | $postedData[$key] = urldecode($value); | ||
| 51 | } | ||
| 52 | |||
| 53 | $title = 'Enfold'; | ||
| 54 | if (is_array($form_params) && | ||
| 55 | isset($form_params['heading']) && | ||
| 56 | $form_params['heading'] | ||
| 57 | ) { | ||
| 58 | $title = strip_tags($form_params['heading']); | ||
| 59 | } | ||
| 60 | |||
| 61 | $data = (object)array( | ||
| 62 | 'title' => $title, | ||
| 63 | 'posted_data' => $postedData, | ||
| 64 | 'uploaded_files' => array()); | ||
| 65 | $this->plugin->saveFormData($data); | ||
| 66 | |||
| 67 | } | ||
| 68 | } catch (Exception $ex) { | ||
| 69 | $this->plugin->getErrorLog()->logException($ex); | ||
| 70 | } | ||
| 71 | |||
| 72 | return true; | ||
| 73 | } | ||
| 74 | |||
| 75 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | class CFDBIntegrationFSCF { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @var CF7DBPlugin | ||
| 26 | */ | ||
| 27 | var $plugin; | ||
| 28 | |||
| 29 | /** | ||
| 30 | * @param $plugin CF7DBPlugin | ||
| 31 | */ | ||
| 32 | function __construct($plugin) { | ||
| 33 | $this->plugin = $plugin; | ||
| 34 | } | ||
| 35 | |||
| 36 | public function registerHooks() { | ||
| 37 | add_action('fsctf_mail_sent', array(&$this->plugin, 'saveFormData')); | ||
| 38 | add_action('fsctf_menu_links', array(&$this, 'fscfMenuLinks')); | ||
| 39 | } | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Function courtesy of Mike Challis, author of Fast Secure Contact Form. | ||
| 43 | * Displays Admin Panel links in FSCF plugin menu | ||
| 44 | * @return void | ||
| 45 | */ | ||
| 46 | public function fscfMenuLinks() { | ||
| 47 | $displayName = $this->plugin->getPluginDisplayName(); | ||
| 48 | echo ' | ||
| 49 | <p> | ||
| 50 | ' . $displayName . | ||
| 51 | ' | <a href="admin.php?page=' . $this->plugin->getDBPageSlug() . '">' . | ||
| 52 | __('Database', 'contact-form-7-to-database-extension') . | ||
| 53 | '</a> | <a href="admin.php?page=CF7DBPluginSettings">' . | ||
| 54 | __('Database Options', 'contact-form-7-to-database-extension') . | ||
| 55 | '</a> | <a href="admin.php?page=' . $this->plugin->getShortCodeBuilderPageSlug() . '">' . | ||
| 56 | __('Build Short Code', 'contact-form-7-to-database-extension') . | ||
| 57 | '</a> | <a href="http://cfdbplugin.com/">' . | ||
| 58 | __('Reference', 'contact-form-7-to-database-extension') . '</a> | ||
| 59 | </p> | ||
| 60 | '; | ||
| 61 | } | ||
| 62 | |||
| 63 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | class CFDBIntegrationGravityForms { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @var CF7DBPlugin | ||
| 26 | */ | ||
| 27 | var $plugin; | ||
| 28 | |||
| 29 | /** | ||
| 30 | * @param $plugin CF7DBPlugin | ||
| 31 | */ | ||
| 32 | function __construct($plugin) { | ||
| 33 | $this->plugin = $plugin; | ||
| 34 | } | ||
| 35 | |||
| 36 | public function registerHooks() { | ||
| 37 | add_action('gform_after_submission', array(&$this, 'saveFormData'), 10, 2); | ||
| 38 | } | ||
| 39 | |||
| 40 | public function saveFormData($entry, $form) { | ||
| 41 | try { | ||
| 42 | $data = $this->convertData($entry, $form); | ||
| 43 | |||
| 44 | return $this->plugin->saveFormData($data); | ||
| 45 | } catch (Exception $ex) { | ||
| 46 | $this->plugin->getErrorLog()->logException($ex); | ||
| 47 | } | ||
| 48 | return true; | ||
| 49 | } | ||
| 50 | |||
| 51 | /** | ||
| 52 | * http://www.gravityhelp.com/documentation/page/Gform_after_submission | ||
| 53 | * @param $entry Entry Object The entry that was just created. | ||
| 54 | * http://www.gravityhelp.com/documentation/page/Entry_Object | ||
| 55 | * @param $form Form Object The current form | ||
| 56 | * http://www.gravityhelp.com/documentation/page/Form_Object | ||
| 57 | * @return object | ||
| 58 | */ | ||
| 59 | public function convertData($entry, $form) { | ||
| 60 | |||
| 61 | //$errorLog = $this->plugin->getErrorLog(); | ||
| 62 | //$errorLog->log('Form Definition: ' . print_r($form, true)); // debug | ||
| 63 | //$errorLog->log('Entry Definition: ' . print_r($entry, true)); // debug | ||
| 64 | |||
| 65 | $postedData = array(); | ||
| 66 | $uploadFiles = array(); | ||
| 67 | |||
| 68 | // Iterate through the field definitions and get their values | ||
| 69 | if (!is_array($form['fields'])) { | ||
| 70 | return true; | ||
| 71 | } | ||
| 72 | foreach ($form['fields'] as $field) { | ||
| 73 | |||
| 74 | // Gravity Forms 1.8.5 $field was an array | ||
| 75 | // Gravity Forms 1.9.1.2 $field is an object | ||
| 76 | if (is_object($field)) { | ||
| 77 | $field = (array)$field; | ||
| 78 | } | ||
| 79 | |||
| 80 | $fieldName = $field['label']; | ||
| 81 | |||
| 82 | if (!empty($field['inputs']) && is_array($field['inputs'])) { | ||
| 83 | if ($field['type'] == 'checkbox') { | ||
| 84 | // This is a multi-input field | ||
| 85 | if (!isset($postedData[$fieldName]) || $postedData[$fieldName] === '') { // handle duplicate empty hidden fields | ||
| 86 | $values = array(); | ||
| 87 | foreach ($field['inputs'] as $input) { | ||
| 88 | $inputId = strval($input['id']); // Need string value of number like '1.3' | ||
| 89 | if (!empty($entry[$inputId])) { | ||
| 90 | $values[] = $entry[$inputId]; | ||
| 91 | } | ||
| 92 | } | ||
| 93 | $postedData[$fieldName] = implode(',', $values); | ||
| 94 | } | ||
| 95 | } else { | ||
| 96 | foreach ($field['inputs'] as $input) { | ||
| 97 | $inputId = strval($input['id']); // Need string value of number like '1.3' | ||
| 98 | $label = $input['label']; // Assumption: all inputs have diff labels | ||
| 99 | $effectiveFieldName = $fieldName; | ||
| 100 | if (!empty($label)) { | ||
| 101 | $effectiveFieldName = $fieldName . ' ' . $label; | ||
| 102 | } | ||
| 103 | if (!isset($postedData[$effectiveFieldName]) || $postedData[$effectiveFieldName] === '') { // handle duplicate empty hidden fields | ||
| 104 | $postedData[$effectiveFieldName] = $entry[$inputId]; | ||
| 105 | } | ||
| 106 | } | ||
| 107 | } | ||
| 108 | } else { | ||
| 109 | $fieldId = $field['id']; | ||
| 110 | switch ($field['type']) { | ||
| 111 | case 'list' : | ||
| 112 | $list = unserialize($entry[$fieldId]); | ||
| 113 | if ($list) { | ||
| 114 | // $list may be a list of strings or | ||
| 115 | // or in the case of Gravity Form List with columns, | ||
| 116 | /* | ||
| 117 | Array | ||
| 118 | ( | ||
| 119 | [0] => Array | ||
| 120 | ( | ||
| 121 | [Column 1] => hi | ||
| 122 | [Column 2] => there | ||
| 123 | [Column 3] => howdy | ||
| 124 | ) | ||
| 125 | ) | ||
| 126 | */ | ||
| 127 | if (! empty($list) && is_array($list[0])) { | ||
| 128 | $colMatrix = array(); | ||
| 129 | foreach ($list as $colArray) { | ||
| 130 | $colList = array(); | ||
| 131 | foreach ($colArray as $colKey => $colValue) { | ||
| 132 | $colList[] = $colKey . '=' . $colValue; | ||
| 133 | } | ||
| 134 | $colMatrix[] = implode('|', $colList); | ||
| 135 | } | ||
| 136 | $postedData[$fieldName] = implode("\n", $colMatrix); | ||
| 137 | } else { | ||
| 138 | $postedData[$fieldName] = implode('|', $list); | ||
| 139 | } | ||
| 140 | } else { | ||
| 141 | if (!isset($postedData[$fieldName]) || $postedData[$fieldName] === '') { // handle duplicate empty hidden fields | ||
| 142 | // List - value is serialized array | ||
| 143 | $valueArray = @unserialize($entry[$fieldId]); | ||
| 144 | if (is_array($valueArray)) { | ||
| 145 | //$postedData[$fieldName] = ''; | ||
| 146 | // Array of (Array of column-name => value) | ||
| 147 | $tmpArray = array(); | ||
| 148 | foreach ($valueArray as $listArray) { | ||
| 149 | $tmpArray[] = implode(',', array_values($listArray)); | ||
| 150 | } | ||
| 151 | $postedData[$fieldName] = implode('|', $tmpArray); | ||
| 152 | } else { | ||
| 153 | $postedData[$fieldName] = $entry[$fieldId]; | ||
| 154 | } | ||
| 155 | } | ||
| 156 | } | ||
| 157 | break; | ||
| 158 | |||
| 159 | case 'fileupload': | ||
| 160 | if (!isset($postedData[$fieldName]) || $postedData[$fieldName] === '') { // handle duplicate empty hidden fields | ||
| 161 | // File Upload - value is file URL | ||
| 162 | // http://<SITE>/wp-content/uploads/gravity_forms/<PATH>/<FILE> | ||
| 163 | $url = $entry[$fieldId]; | ||
| 164 | $fileName = basename($url); | ||
| 165 | $postedData[$fieldName] = $fileName; | ||
| 166 | |||
| 167 | $filePath = ABSPATH . substr($url, strlen(get_site_url())); | ||
| 168 | $uploadFiles[$fieldName] = $filePath; | ||
| 169 | } | ||
| 170 | break; | ||
| 171 | |||
| 172 | default: | ||
| 173 | if (!isset($postedData[$fieldName]) || $postedData[$fieldName] === '') { // handle duplicate empty hidden fields | ||
| 174 | $postedData[$fieldName] = $entry[$fieldId]; | ||
| 175 | } | ||
| 176 | break; | ||
| 177 | } | ||
| 178 | |||
| 179 | } | ||
| 180 | } | ||
| 181 | |||
| 182 | // Other form metadata | ||
| 183 | $paymentMetaData = array( | ||
| 184 | //'currency', | ||
| 185 | 'payment_status', 'payment_date', | ||
| 186 | 'transaction_id', 'payment_amount', 'payment_method', | ||
| 187 | 'is_fulfilled', 'transaction_type'); | ||
| 188 | foreach ($paymentMetaData as $pmt) { | ||
| 189 | $hasPaymentInfo = false; | ||
| 190 | if (!empty($entry[$pmt])) { | ||
| 191 | $postedData[$pmt] = $entry[$pmt]; | ||
| 192 | $hasPaymentInfo = true; | ||
| 193 | } | ||
| 194 | if ($hasPaymentInfo && !empty($entry['currency'])) { | ||
| 195 | // It seems currency is always set but only meaningful | ||
| 196 | // if the other payment info is set. | ||
| 197 | $postedData['currency'] = $entry['currency']; | ||
| 198 | } | ||
| 199 | } | ||
| 200 | |||
| 201 | |||
| 202 | return (object)array( | ||
| 203 | 'title' => $form['title'], | ||
| 204 | 'posted_data' => $postedData, | ||
| 205 | 'uploaded_files' => $uploadFiles); | ||
| 206 | } | ||
| 207 | |||
| 208 | |||
| 209 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | class CFDBIntegrationJetPack { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @var CF7DBPlugin | ||
| 26 | */ | ||
| 27 | var $plugin; | ||
| 28 | |||
| 29 | /** | ||
| 30 | * @param $plugin CF7DBPlugin | ||
| 31 | */ | ||
| 32 | function __construct($plugin) { | ||
| 33 | $this->plugin = $plugin; | ||
| 34 | } | ||
| 35 | |||
| 36 | public function registerHooks() { | ||
| 37 | add_action('grunion_pre_message_sent', array(&$this, 'saveFormData'), 10, 3); | ||
| 38 | } | ||
| 39 | |||
| 40 | /** | ||
| 41 | * @param $post_id int | ||
| 42 | * @param $all_values array | ||
| 43 | * @param $extra_values array | ||
| 44 | * @return object | ||
| 45 | */ | ||
| 46 | public function saveFormData($post_id, $all_values, $extra_values) { | ||
| 47 | try { | ||
| 48 | $data = $this->convertData($post_id, $all_values); | ||
| 49 | |||
| 50 | return $this->plugin->saveFormData($data); | ||
| 51 | } catch (Exception $ex) { | ||
| 52 | $this->plugin->getErrorLog()->logException($ex); | ||
| 53 | } | ||
| 54 | return true; | ||
| 55 | } | ||
| 56 | |||
| 57 | public function convertData($post_id, $all_values) { | ||
| 58 | |||
| 59 | // $errorLog = $this->plugin->getErrorLog(); | ||
| 60 | // $errorLog->log('POST=' . print_r($_POST, true)); | ||
| 61 | // $errorLog->log('$all_values=' . print_r($all_values, true)); | ||
| 62 | // $errorLog->log('$extra_values=' . print_r($extra_values, true)); | ||
| 63 | |||
| 64 | $title = 'JetPack Contact Form'; | ||
| 65 | if (isset($_POST['contact-form-id'])) { | ||
| 66 | $title .= ' ' . $_POST['contact-form-id']; | ||
| 67 | //$all_values['contact-form-id'] = $_POST['contact-form-id']; | ||
| 68 | } | ||
| 69 | else { | ||
| 70 | $title .= ' ' . $post_id; | ||
| 71 | } | ||
| 72 | |||
| 73 | $all_values['post_id'] = $post_id; | ||
| 74 | return (object) array( | ||
| 75 | 'title' => $title, | ||
| 76 | 'posted_data' => $all_values, | ||
| 77 | 'uploaded_files' => null); | ||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 5 | |||
| 6 | This file is part of Contact Form to Database. | ||
| 7 | |||
| 8 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation, either version 3 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with Contact Form to Database. | ||
| 20 | If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | |||
| 24 | class CFDBIntegrationNinjaForms { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @var CF7DBPlugin | ||
| 28 | */ | ||
| 29 | var $plugin; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @param $plugin CF7DBPlugin | ||
| 33 | */ | ||
| 34 | function __construct($plugin) { | ||
| 35 | $this->plugin = $plugin; | ||
| 36 | } | ||
| 37 | |||
| 38 | public function registerHooks() { | ||
| 39 | // http://docs.ninjaforms.com/article/106-ninjaformspostprocess | ||
| 40 | add_action('init', array(&$this, 'registerHook2')); | ||
| 41 | } | ||
| 42 | |||
| 43 | public function registerHook2() { | ||
| 44 | add_action('ninja_forms_post_process', array(&$this, 'saveFormData')); | ||
| 45 | } | ||
| 46 | |||
| 47 | /** | ||
| 48 | * @return bool | ||
| 49 | */ | ||
| 50 | public function saveFormData() { | ||
| 51 | try { | ||
| 52 | $data = $this->convertData(); | ||
| 53 | return $this->plugin->saveFormData($data); | ||
| 54 | } catch (Exception $ex) { | ||
| 55 | $this->plugin->getErrorLog()->logException($ex); | ||
| 56 | } | ||
| 57 | return true; | ||
| 58 | } | ||
| 59 | |||
| 60 | /** | ||
| 61 | * @return object | ||
| 62 | */ | ||
| 63 | public function convertData() { | ||
| 64 | /** | ||
| 65 | * @global $ninja_forms_processing Ninja_Forms_Processing | ||
| 66 | */ | ||
| 67 | global $ninja_forms_processing; | ||
| 68 | // $this->plugin->getErrorLog()->log( | ||
| 69 | // print_r($ninja_forms_processing, true)); // debug | ||
| 70 | |||
| 71 | $postedData = array(); | ||
| 72 | $uploadFiles = array(); | ||
| 73 | |||
| 74 | // Get all the user submitted values | ||
| 75 | $submitted_field_ids = array_keys($ninja_forms_processing->get_all_submitted_fields()); | ||
| 76 | $all_fields = $ninja_forms_processing->get_all_fields(); | ||
| 77 | |||
| 78 | if (is_array($all_fields)) { | ||
| 79 | foreach ($all_fields as $field_id => $user_value) { | ||
| 80 | if (in_array($field_id, $submitted_field_ids)) { | ||
| 81 | if ($ninja_forms_processing->get_field_setting($field_id, 'type') == '_honeypot') { | ||
| 82 | continue; | ||
| 83 | } | ||
| 84 | $field_name = $ninja_forms_processing->get_field_setting($field_id, 'label'); | ||
| 85 | if (is_array($user_value)) { | ||
| 86 | $postedData[$field_name] = implode(',', $user_value); | ||
| 87 | } else { | ||
| 88 | $postedData[$field_name] = $user_value; | ||
| 89 | } | ||
| 90 | } | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | $formTitle = 'Ninja Form'; | ||
| 95 | if (isset($ninja_forms_processing->data['form']['form_title'])) { | ||
| 96 | $formTitle = $ninja_forms_processing->data['form']['form_title']; | ||
| 97 | } | ||
| 98 | |||
| 99 | return (object)array( | ||
| 100 | 'title' => $formTitle, | ||
| 101 | 'posted_data' => $postedData, | ||
| 102 | 'uploaded_files' => $uploadFiles); | ||
| 103 | } | ||
| 104 | |||
| 105 | |||
| 106 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 5 | |||
| 6 | This file is part of Contact Form to Database. | ||
| 7 | |||
| 8 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation, either version 3 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with Contact Form to Database. | ||
| 20 | If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | class CFDBIntegrationQuform { | ||
| 24 | |||
| 25 | /** | ||
| 26 | * @var CF7DBPlugin | ||
| 27 | */ | ||
| 28 | var $plugin; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * @param $plugin CF7DBPlugin | ||
| 32 | */ | ||
| 33 | function __construct($plugin) { | ||
| 34 | $this->plugin = $plugin; | ||
| 35 | } | ||
| 36 | |||
| 37 | public function registerHooks() { | ||
| 38 | // http://support.themecatcher.net/quform-wordpress/guides/hooks/iphorm_post_process | ||
| 39 | add_action('iphorm_post_process', array(&$this, 'saveFormData'), 10, 1); | ||
| 40 | } | ||
| 41 | |||
| 42 | /** | ||
| 43 | * @param $form iPhorm | ||
| 44 | * @return bool | ||
| 45 | */ | ||
| 46 | public function saveFormData($form) { | ||
| 47 | try { | ||
| 48 | $data = $this->convertData($form); | ||
| 49 | return $this->plugin->saveFormData($data); | ||
| 50 | } catch (Exception $ex) { | ||
| 51 | $this->plugin->getErrorLog()->logException($ex); | ||
| 52 | } | ||
| 53 | return true; | ||
| 54 | } | ||
| 55 | |||
| 56 | |||
| 57 | /** | ||
| 58 | * @param $form iPhorm | ||
| 59 | * @return object | ||
| 60 | */ | ||
| 61 | public function convertData($form) { | ||
| 62 | // http://support.themecatcher.net/quform-wordpress/guides/basic/getting-form-values | ||
| 63 | $allValues = $form->getValues(); | ||
| 64 | |||
| 65 | // $this->plugin->getErrorLog()->log( | ||
| 66 | // print_r($form, true)); | ||
| 67 | |||
| 68 | if (is_array($allValues)) { | ||
| 69 | |||
| 70 | $postedData = array(); | ||
| 71 | $uploadFiles = array(); | ||
| 72 | |||
| 73 | foreach ($allValues as $fieldId => $value) { | ||
| 74 | // $fieldId is something like "iphorm_2_1" | ||
| 75 | // get the human-readable field label | ||
| 76 | $fieldName = $fieldId; //iPhorm_Element | ||
| 77 | $element = $form->getElement($fieldId); | ||
| 78 | if (is_object($element)) { | ||
| 79 | $fieldName = $element->getLabel(); | ||
| 80 | } | ||
| 81 | |||
| 82 | if (is_array($value)) { | ||
| 83 | if (array_key_exists('day', $value)) { | ||
| 84 | $postedData[$fieldName] = sprintf('%s-%s-%s', $value['year'], $value['month'], $value['day']); | ||
| 85 | } else if (array_key_exists('hour', $value)) { | ||
| 86 | $postedData[$fieldName] = sprintf('%s:%s %s', $value['hour'], $value['minute'], $value['ampm']); | ||
| 87 | } else if (array_key_exists(0, $value)) { | ||
| 88 | if (is_array($value[0])) { | ||
| 89 | // file upload | ||
| 90 | foreach ($value as $upload) { | ||
| 91 | $postedData[$fieldName] = $upload['text']; | ||
| 92 | $uploadFiles[$fieldName] = $upload['fullPath']; | ||
| 93 | } | ||
| 94 | } else { | ||
| 95 | $postedData[$fieldName] = implode(',', array_values($value)); | ||
| 96 | } | ||
| 97 | } | ||
| 98 | } else { | ||
| 99 | $postedData[$fieldName] = $value; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | return (object)array( | ||
| 104 | 'title' => $form->getName(), | ||
| 105 | 'posted_data' => $postedData, | ||
| 106 | 'uploaded_files' => $uploadFiles); | ||
| 107 | } | ||
| 108 | |||
| 109 | } | ||
| 110 | |||
| 111 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | "Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 5 | |||
| 6 | This file is part of Contact Form to Database. | ||
| 7 | |||
| 8 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation, either version 3 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with Contact Form to Database. | ||
| 20 | If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | class CFDBIntegrationWRContactForm { | ||
| 24 | |||
| 25 | /** | ||
| 26 | * @var CF7DBPlugin | ||
| 27 | */ | ||
| 28 | var $plugin; | ||
| 29 | |||
| 30 | /** | ||
| 31 | * @param $plugin CF7DBPlugin | ||
| 32 | */ | ||
| 33 | function __construct($plugin) { | ||
| 34 | $this->plugin = $plugin; | ||
| 35 | } | ||
| 36 | |||
| 37 | public function registerHooks() { | ||
| 38 | add_action('wr_contactform_before_save_form', array(&$this, 'saveFormData'), 10, 7); | ||
| 39 | } | ||
| 40 | |||
| 41 | /** | ||
| 42 | * @param $dataForms array | ||
| 43 | * @param $postID array | ||
| 44 | * @param $post array | ||
| 45 | * @param $submissionsData array | ||
| 46 | * @param $dataContentEmail array | ||
| 47 | * @param $nameFileByIdentifier array | ||
| 48 | * @param $requiredField array | ||
| 49 | * @param $fileAttach array | ||
| 50 | * @return bool | ||
| 51 | */ | ||
| 52 | public function saveFormData($dataForms, $postID, $post, $submissionsData, $dataContentEmail, | ||
| 53 | $nameFileByIdentifier, $requiredField, $fileAttach) { | ||
| 54 | |||
| 55 | try { | ||
| 56 | $data = $this->convertData($dataForms, $postID, $post, $submissionsData, $dataContentEmail, | ||
| 57 | $nameFileByIdentifier, $requiredField, $fileAttach); | ||
| 58 | return $this->plugin->saveFormData($data); | ||
| 59 | } catch (Exception $ex) { | ||
| 60 | $this->plugin->getErrorLog()->logException($ex); | ||
| 61 | } | ||
| 62 | return true; | ||
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 | public function convertData($dataForms, $postID, $post, $submissionsData, $dataContentEmail, | ||
| 67 | $nameFileByIdentifier, $requiredField, $fileAttach) { | ||
| 68 | |||
| 69 | $postedData = array(); | ||
| 70 | $uploadFiles = array(); | ||
| 71 | |||
| 72 | foreach ($dataContentEmail as $fieldKey => $fieldValue) { | ||
| 73 | $fieldName = $nameFileByIdentifier[$fieldKey]; | ||
| 74 | |||
| 75 | if (strpos($fieldKey, 'file_upload_') === 0) { | ||
| 76 | // Handle upload files | ||
| 77 | $filePath = $this->parseFileUrl($fieldValue); | ||
| 78 | if ($filePath) { | ||
| 79 | $uploadFiles[$fieldName] = $filePath; | ||
| 80 | } | ||
| 81 | } | ||
| 82 | $fieldValue = trim(preg_replace('#<[^>]+>#', ' ', $fieldValue)); | ||
| 83 | $postedData[$fieldName] = $fieldValue; | ||
| 84 | } | ||
| 85 | |||
| 86 | $data = (object)array( | ||
| 87 | 'title' => get_the_title($postID), | ||
| 88 | 'posted_data' => $postedData, | ||
| 89 | 'uploaded_files' => $uploadFiles); | ||
| 90 | return $data; | ||
| 91 | } | ||
| 92 | |||
| 93 | /** | ||
| 94 | * @param $fileUrl | ||
| 95 | * @return string | ||
| 96 | */ | ||
| 97 | public function parseFileUrl($fileUrl) { | ||
| 98 | $href = array(); | ||
| 99 | preg_match('#<a href=\"([^\"]*)/wp-content/([^\"]*)\">(.*)</a>#iU', $fileUrl, $href); | ||
| 100 | if (count($href) >= 3) { | ||
| 101 | // [0] => <a href="http://www.site.com/wp-content/uploads/2015/08/Amazon-icon1.png">Amazon.png</a> | ||
| 102 | // [1] => http://www.site.com | ||
| 103 | // [2] => uploads/2015/08/Amazon-icon1.png | ||
| 104 | // [3] => Amazon.png | ||
| 105 | $wpContentDirPath = dirname(dirname(dirname(__FILE__))); | ||
| 106 | return $wpContentDirPath . DIRECTORY_SEPARATOR . $href[2]; | ||
| 107 | } | ||
| 108 | return null; | ||
| 109 | } | ||
| 110 | |||
| 111 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed.
Click to expand it.
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBFunctionEvaluator.php'); | ||
| 23 | |||
| 24 | abstract class CFDBParserBase { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @var CFDBFunctionEvaluator | ||
| 28 | */ | ||
| 29 | var $functionEvaluator; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @var CFDBPermittedFunctions | ||
| 33 | */ | ||
| 34 | var $permittedFilterFunctions; | ||
| 35 | |||
| 36 | public function __construct() { | ||
| 37 | $this->functionEvaluator = new CFDBFunctionEvaluator(); | ||
| 38 | } | ||
| 39 | |||
| 40 | public abstract function parse($string); | ||
| 41 | |||
| 42 | /** | ||
| 43 | * @param $converter CFDBValueConverter | ||
| 44 | * @return void | ||
| 45 | */ | ||
| 46 | public function setComparisonValuePreprocessor($converter) { | ||
| 47 | $this->functionEvaluator->setCompValuePreprocessor($converter); | ||
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 51 | * @param $cFDBPermittedFilterFunctions CFDBPermittedFunctions | ||
| 52 | * @return void | ||
| 53 | */ | ||
| 54 | public function setPermittedFilterFunctions($cFDBPermittedFilterFunctions) { | ||
| 55 | $this->permittedFilterFunctions = $cFDBPermittedFilterFunctions; | ||
| 56 | } | ||
| 57 | |||
| 58 | /** | ||
| 59 | * To prevent a security hole, not all functions are permitted | ||
| 60 | * @param $functionName string | ||
| 61 | * @return bool | ||
| 62 | */ | ||
| 63 | public function functionIsPermitted($functionName) { | ||
| 64 | if ($this->permittedFilterFunctions) { | ||
| 65 | return $this->permittedFilterFunctions->isFunctionPermitted($functionName); | ||
| 66 | } | ||
| 67 | return true; | ||
| 68 | } | ||
| 69 | |||
| 70 | public function parseValidFunction($filterString) { | ||
| 71 | $parsed = $this->parseFunction($filterString); | ||
| 72 | if (is_array($parsed)) { | ||
| 73 | if (!is_callable($parsed[0]) || !$this->functionIsPermitted($parsed[0])) { | ||
| 74 | return $filterString; | ||
| 75 | } | ||
| 76 | } | ||
| 77 | return $parsed; | ||
| 78 | } | ||
| 79 | |||
| 80 | public function parseValidFunctionOrClassTransform($transString) { | ||
| 81 | $parsed = $this->parseFunction($transString); | ||
| 82 | |||
| 83 | if (!is_array($parsed)) { | ||
| 84 | return $parsed; | ||
| 85 | } | ||
| 86 | |||
| 87 | if (class_exists($parsed[0])) { | ||
| 88 | return $parsed; | ||
| 89 | } | ||
| 90 | |||
| 91 | $isFunction = is_callable($parsed[0]); | ||
| 92 | $isPermitted = $this->functionIsPermitted($parsed[0]); | ||
| 93 | if ($isFunction && $isPermitted) { | ||
| 94 | return $parsed; | ||
| 95 | } | ||
| 96 | |||
| 97 | return $transString; | ||
| 98 | } | ||
| 99 | |||
| 100 | |||
| 101 | /** | ||
| 102 | * @param $filterString string | ||
| 103 | * @return string|array if a function like "funct(arg1, arg2, ...)" then returns array['funct', arg1, arg2, ...] | ||
| 104 | * otherwise just returns the string passed in | ||
| 105 | */ | ||
| 106 | public function parseFunction($filterString) { | ||
| 107 | $matches = array(); | ||
| 108 | // Parse function name | ||
| 109 | if (preg_match('/^(\w+)\((.*)\)$/', trim($filterString), $matches)) { | ||
| 110 | $functionArray = array(); | ||
| 111 | $functionArray[] = $matches[1]; // function name | ||
| 112 | // Parse function parameters | ||
| 113 | $matches[2] = trim($matches[2]); | ||
| 114 | if ($matches[2] != '') { | ||
| 115 | $paramMatches = explode(',', $matches[2]); | ||
| 116 | foreach ($paramMatches as $param) { | ||
| 117 | $param = trim($param); | ||
| 118 | $param = stripslashes($param); | ||
| 119 | $param = $this->unSingleQuoteString($param); | ||
| 120 | if ($param != '') { | ||
| 121 | $functionArray[] = $param; | ||
| 122 | } | ||
| 123 | } | ||
| 124 | } | ||
| 125 | return $functionArray; | ||
| 126 | } | ||
| 127 | return $filterString; | ||
| 128 | } | ||
| 129 | |||
| 130 | /** | ||
| 131 | * @param $string string | ||
| 132 | * @return string | ||
| 133 | */ | ||
| 134 | public function unSingleQuoteString($string) { | ||
| 135 | $matches = array(); | ||
| 136 | if (preg_match("/'(.*)'/", $string, $matches)) { | ||
| 137 | return $matches[1]; | ||
| 138 | } | ||
| 139 | return $string; | ||
| 140 | } | ||
| 141 | |||
| 142 | /** | ||
| 143 | * @param $string | ||
| 144 | * @return array | ||
| 145 | */ | ||
| 146 | public function parseORs($string) { | ||
| 147 | return preg_split('/\|\|/', $string, -1, PREG_SPLIT_NO_EMPTY); | ||
| 148 | } | ||
| 149 | |||
| 150 | /** | ||
| 151 | * @param $string | ||
| 152 | * @return array | ||
| 153 | */ | ||
| 154 | public function parseANDs($string) { | ||
| 155 | // Deal with various && encoding problems | ||
| 156 | $string = html_entity_decode($string); | ||
| 157 | |||
| 158 | $retVal = preg_split('/&&/', $string, -1, PREG_SPLIT_NO_EMPTY); | ||
| 159 | //echo "<pre>Parsed '$filterString' into " . print_r($retVal, true) . '</pre>'; | ||
| 160 | return $retVal; | ||
| 161 | } | ||
| 162 | |||
| 163 | public function setTimezone() { | ||
| 164 | static $timezoneNotSet = true; | ||
| 165 | if ($timezoneNotSet && function_exists('get_option')) { | ||
| 166 | $tz = get_option('CF7DBPlugin_Timezone'); // see CFDBPlugin->setTimezone() | ||
| 167 | if (!$tz) { | ||
| 168 | $tz = get_option('timezone_string'); | ||
| 169 | } | ||
| 170 | if ($tz) { | ||
| 171 | date_default_timezone_set($tz); | ||
| 172 | } | ||
| 173 | $timezoneNotSet = false; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 177 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | |||
| 3 | /* | ||
| 4 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 5 | |||
| 6 | This file is part of Contact Form to Database. | ||
| 7 | |||
| 8 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 9 | it under the terms of the GNU General Public License as published by | ||
| 10 | the Free Software Foundation, either version 3 of the License, or | ||
| 11 | (at your option) any later version. | ||
| 12 | |||
| 13 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | GNU General Public License for more details. | ||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License | ||
| 19 | along with Contact Form to Database. | ||
| 20 | If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | */ | ||
| 22 | |||
| 23 | /** | ||
| 24 | * @singleton | ||
| 25 | */ | ||
| 26 | class CFDBPermittedFunctions { | ||
| 27 | |||
| 28 | var $permitAllFunctions = false; | ||
| 29 | |||
| 30 | var $permittedFunctions; | ||
| 31 | |||
| 32 | static $defaultPermitted = array( | ||
| 33 | |||
| 34 | // PHP functions | ||
| 35 | 'addcslashes', | ||
| 36 | 'addslashes', | ||
| 37 | 'chop', | ||
| 38 | 'chr', | ||
| 39 | 'count_chars', | ||
| 40 | 'localeconv', | ||
| 41 | 'ltrim', | ||
| 42 | 'md5', | ||
| 43 | 'money_format', | ||
| 44 | 'nl2br', | ||
| 45 | 'number_format', | ||
| 46 | 'rtrim', | ||
| 47 | 'sha1', | ||
| 48 | 'str_ireplace', | ||
| 49 | 'str_pad', | ||
| 50 | 'str_repeat', | ||
| 51 | 'str_replace', | ||
| 52 | 'str_shuffle', | ||
| 53 | 'str_word_count', | ||
| 54 | 'strcasecmp', | ||
| 55 | 'strchr', | ||
| 56 | 'strcmp', | ||
| 57 | 'strcoll', | ||
| 58 | 'strcspn', | ||
| 59 | 'strip_tags', | ||
| 60 | 'stripcslashes', | ||
| 61 | 'stripos', | ||
| 62 | 'strlen', | ||
| 63 | 'strnatcasecmp', | ||
| 64 | 'strnatcmp', | ||
| 65 | 'strncasecmp', | ||
| 66 | 'strncmp', | ||
| 67 | 'strpbrk', | ||
| 68 | 'strpos', | ||
| 69 | 'strspn', | ||
| 70 | 'strrev', | ||
| 71 | 'strstr', | ||
| 72 | 'strtok', | ||
| 73 | 'strtolower', | ||
| 74 | 'strtoupper', | ||
| 75 | 'strtr', | ||
| 76 | 'substr', | ||
| 77 | 'substr_compare', | ||
| 78 | 'substr_count', | ||
| 79 | 'substr_replace', | ||
| 80 | 'trim', | ||
| 81 | 'ucfirst', | ||
| 82 | 'ucwords', | ||
| 83 | 'wordwrap', | ||
| 84 | 'date', | ||
| 85 | 'microtime', | ||
| 86 | 'strtotime', | ||
| 87 | 'idate', | ||
| 88 | 'gmstrftime', | ||
| 89 | 'mktime', | ||
| 90 | 'strftime', | ||
| 91 | 'time', | ||
| 92 | 'intval', | ||
| 93 | 'boolval', | ||
| 94 | 'floatval', | ||
| 95 | 'strval', | ||
| 96 | 'bcmul', | ||
| 97 | 'bcdiv', | ||
| 98 | 'abs', | ||
| 99 | 'acos', | ||
| 100 | 'acoh', | ||
| 101 | 'asin', | ||
| 102 | 'asinh', | ||
| 103 | 'atan2', | ||
| 104 | 'atan', | ||
| 105 | 'atanh', | ||
| 106 | 'base_convert', | ||
| 107 | 'bindec', | ||
| 108 | 'ceil', | ||
| 109 | 'cos', | ||
| 110 | 'cosh', | ||
| 111 | 'decbin', | ||
| 112 | 'dechex', | ||
| 113 | 'decoct', | ||
| 114 | 'deg2rad', | ||
| 115 | 'exp', | ||
| 116 | 'expm1', | ||
| 117 | 'floor', | ||
| 118 | 'fmod', | ||
| 119 | 'getrandmax', | ||
| 120 | 'hexdec', | ||
| 121 | 'hypot', | ||
| 122 | 'intdiv', | ||
| 123 | 'is_finite', | ||
| 124 | 'is_infinite', | ||
| 125 | 'is_nan', | ||
| 126 | 'lcg_value', | ||
| 127 | 'log10', | ||
| 128 | 'log1p', | ||
| 129 | 'log', | ||
| 130 | 'max', | ||
| 131 | 'min', | ||
| 132 | 'mb_strtolower', | ||
| 133 | 'mb_check_encoding', | ||
| 134 | 'mb_convert_case', | ||
| 135 | 'mb_convert_encoding', | ||
| 136 | 'mb_convert_kana', | ||
| 137 | 'mb_decode_numericentity', | ||
| 138 | 'mb_detect_encoding', | ||
| 139 | 'mb_detect_order', | ||
| 140 | 'mb_encode_numericentity', | ||
| 141 | 'mb_ereg_match', | ||
| 142 | 'mb_ereg_replace', | ||
| 143 | 'mb_ereg_search_getpos', | ||
| 144 | 'mb_ereg_search_pos', | ||
| 145 | 'mb_ereg_search', | ||
| 146 | 'mb_ereg', | ||
| 147 | 'mb_eregi_replace', | ||
| 148 | 'mb_eregi', | ||
| 149 | 'mb_internal_encoding', | ||
| 150 | 'mb_language', | ||
| 151 | 'mb_preferred_mime_name', | ||
| 152 | 'mb_regex_encoding', | ||
| 153 | 'mb_regex_set_options', | ||
| 154 | 'mb_strcut', | ||
| 155 | 'mb_strimwidth', | ||
| 156 | 'mb_stripos', | ||
| 157 | 'mb_stristr', | ||
| 158 | 'mb_strlen', | ||
| 159 | 'mb_strpos', | ||
| 160 | 'mb_strrchr', | ||
| 161 | 'mb_strrichr', | ||
| 162 | 'mb_strripos', | ||
| 163 | 'mb_strstr', | ||
| 164 | 'mb_strtolower', | ||
| 165 | 'mb_strtoupper', | ||
| 166 | 'mb_strwidth', | ||
| 167 | 'mb_substr_count', | ||
| 168 | 'mb_substr', | ||
| 169 | 'mt_getrandmax', | ||
| 170 | 'mt_rand', | ||
| 171 | 'mt_srand', | ||
| 172 | 'octdec', | ||
| 173 | 'pi', | ||
| 174 | 'pow', | ||
| 175 | 'rad2deg', | ||
| 176 | 'rand', | ||
| 177 | 'round', | ||
| 178 | 'sin', | ||
| 179 | 'sqrt', | ||
| 180 | 'srand', | ||
| 181 | 'tan', | ||
| 182 | 'tanh', | ||
| 183 | |||
| 184 | |||
| 185 | // WordPress-defined functions | ||
| 186 | 'human_time_diff', | ||
| 187 | 'current_time', | ||
| 188 | |||
| 189 | // CFDB-defined functions | ||
| 190 | 'concat', | ||
| 191 | 'sum', | ||
| 192 | 'multiply' | ||
| 193 | |||
| 194 | ); | ||
| 195 | |||
| 196 | |||
| 197 | public function init() { | ||
| 198 | $this->permittedFunctions = CFDBPermittedFunctions::$defaultPermitted; | ||
| 199 | } | ||
| 200 | |||
| 201 | public static function getInstance() { | ||
| 202 | static $inst = null; | ||
| 203 | if ($inst === null) { | ||
| 204 | $inst = new CFDBPermittedFunctions(); | ||
| 205 | $inst->init(); | ||
| 206 | } | ||
| 207 | return $inst; | ||
| 208 | } | ||
| 209 | |||
| 210 | public function setPermitAllFunctions($trueOrFalse) { | ||
| 211 | $this->permitAllFunctions = $trueOrFalse; | ||
| 212 | } | ||
| 213 | |||
| 214 | public function isFunctionPermitted($functionName) { | ||
| 215 | if ($this->permitAllFunctions === true) { | ||
| 216 | return true; | ||
| 217 | } else { | ||
| 218 | return in_array($functionName, $this->permittedFunctions); | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | public function addPermittedFunction($functionName) { | ||
| 223 | if ($functionName && !in_array($functionName, $this->permittedFunctions)) { | ||
| 224 | $this->permittedFunctions[] = $functionName; | ||
| 225 | } | ||
| 226 | } | ||
| 227 | |||
| 228 | |||
| 229 | } | ||
| 230 | |||
| 231 | /** | ||
| 232 | * A function wrapper to register function names in a CFDBPermittedFunctions singleton | ||
| 233 | * @param $function_name | ||
| 234 | */ | ||
| 235 | function cfdb_register_function($function_name) { | ||
| 236 | CFDBPermittedFunctions::getInstance()->addPermittedFunction($function_name); | ||
| 237 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2013 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBAbstractQueryResultsIterator.php'); | ||
| 23 | |||
| 24 | class CFDBQueryResultIterator extends CFDBAbstractQueryResultsIterator { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @var resource|mysqli_result | ||
| 28 | */ | ||
| 29 | var $results; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @var boolean | ||
| 33 | */ | ||
| 34 | var $useMysqli; | ||
| 35 | |||
| 36 | |||
| 37 | /** | ||
| 38 | * If you do not iterate over all the rows returned, be sure to call this function | ||
| 39 | * on all remaining rows to free resources. | ||
| 40 | * @return void | ||
| 41 | */ | ||
| 42 | public function freeResult() { | ||
| 43 | if ($this->results) { | ||
| 44 | if ($this->useMysqli) { | ||
| 45 | mysqli_free_result($this->results); | ||
| 46 | } else { | ||
| 47 | mysql_free_result($this->results); | ||
| 48 | } | ||
| 49 | $this->results = null; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | /** | ||
| 53 | * @return array associative | ||
| 54 | */ | ||
| 55 | public function fetchRow() { | ||
| 56 | if ($this->useMysqli) { | ||
| 57 | return mysqli_fetch_assoc($this->results); | ||
| 58 | } else { | ||
| 59 | return mysql_fetch_assoc($this->results); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | public function hasResults() { | ||
| 64 | return !empty($this->results); | ||
| 65 | } | ||
| 66 | |||
| 67 | /** | ||
| 68 | * @param $sql | ||
| 69 | * @param $queryOptions | ||
| 70 | * @return void | ||
| 71 | */ | ||
| 72 | public function queryDataSource(&$sql, $queryOptions) { | ||
| 73 | // For performance reasons, we bypass $wpdb so we can call mysql_unbuffered_query | ||
| 74 | |||
| 75 | $this->useMysqli = $this->shouldUseMySqli(); | ||
| 76 | |||
| 77 | $con = null; | ||
| 78 | if ($this->useMysqli) { | ||
| 79 | $con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); | ||
| 80 | if (!$con) { | ||
| 81 | trigger_error("MySQL Connection failed: " . mysqli_error($con), E_USER_NOTICE); | ||
| 82 | return; | ||
| 83 | } | ||
| 84 | } else { | ||
| 85 | $con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true); | ||
| 86 | if (!$con) { | ||
| 87 | trigger_error("MySQL Connection failed: " . mysql_error($con), E_USER_NOTICE); | ||
| 88 | return; | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | // Target charset is in wp-config.php DB_CHARSET | ||
| 93 | if (defined('DB_CHARSET')) { | ||
| 94 | if (DB_CHARSET != '') { | ||
| 95 | global $wpdb; | ||
| 96 | if (method_exists($wpdb, 'set_charset')) { | ||
| 97 | $collate = null; | ||
| 98 | if (defined('DB_COLLATE')) { | ||
| 99 | if (DB_COLLATE != '') { | ||
| 100 | $collate = DB_COLLATE; | ||
| 101 | } | ||
| 102 | } | ||
| 103 | $wpdb->set_charset($con, DB_CHARSET, $collate); | ||
| 104 | } else { | ||
| 105 | $setCharset = 'SET NAMES \'' . DB_CHARSET . '\''; | ||
| 106 | if (defined('DB_COLLATE')) { | ||
| 107 | if (DB_COLLATE != '') { | ||
| 108 | $setCharset = $setCharset . ' COLLATE \'' . DB_COLLATE . '\''; | ||
| 109 | } | ||
| 110 | } | ||
| 111 | if ($this->useMysqli) { | ||
| 112 | mysqli_query($con, $setCharset); | ||
| 113 | } else { | ||
| 114 | mysql_query($setCharset, $con); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | } | ||
| 118 | } | ||
| 119 | |||
| 120 | if (!$this->useMysqli) { | ||
| 121 | if (!mysql_select_db(DB_NAME, $con)) { | ||
| 122 | trigger_error('MySQL DB Select failed: ' . mysql_error(), E_USER_NOTICE); | ||
| 123 | return; | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | if (isset($queryOptions['unbuffered']) && $queryOptions['unbuffered'] === 'true') { | ||
| 128 | // FYI: using mysql_unbuffered_query disrupted nested shortcodes if the nested one does a query also | ||
| 129 | if ($this->useMysqli) { | ||
| 130 | $this->results = mysqli_query($con, $sql, MYSQLI_USE_RESULT); | ||
| 131 | if (!$this->results) { | ||
| 132 | trigger_error('mysqli_query failed: ' . mysql_error(), E_USER_NOTICE); | ||
| 133 | return; | ||
| 134 | } | ||
| 135 | } else { | ||
| 136 | $this->results = mysql_unbuffered_query($sql, $con); | ||
| 137 | if (!$this->results) { | ||
| 138 | trigger_error('mysql_unbuffered_query failed: ' . mysql_error(), E_USER_NOTICE); | ||
| 139 | return; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | } else { | ||
| 143 | if ($this->useMysqli) { | ||
| 144 | $this->results = @mysqli_query($con, $sql); | ||
| 145 | if (!$this->results) { | ||
| 146 | trigger_error('mysqli_query failed. Try adding <code>unbuffered="true"</code> to your short code. <br/>' . mysql_error(), E_USER_WARNING); | ||
| 147 | return; | ||
| 148 | } | ||
| 149 | } else { | ||
| 150 | $this->results = @mysql_query($sql, $con); | ||
| 151 | if (!$this->results) { | ||
| 152 | trigger_error('mysql_query failed. Try adding <code>unbuffered="true"</code> to your short code. <br/>' . mysql_error(), E_USER_WARNING); | ||
| 153 | return; | ||
| 154 | } | ||
| 155 | } | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 159 | public function shouldUseMySqli() { | ||
| 160 | // This code taken from wp-db.php and adapted | ||
| 161 | $use_mysqli = false; | ||
| 162 | if ( function_exists( 'mysqli_connect' ) ) { | ||
| 163 | if ( defined( 'WP_USE_EXT_MYSQL' ) ) { | ||
| 164 | $use_mysqli = ! WP_USE_EXT_MYSQL; | ||
| 165 | } elseif ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) { | ||
| 166 | $use_mysqli = true; | ||
| 167 | } elseif ( false !== strpos( $GLOBALS['wp_version'], '-' ) ) { | ||
| 168 | $use_mysqli = true; | ||
| 169 | } | ||
| 170 | } | ||
| 171 | return $use_mysqli; | ||
| 172 | } | ||
| 173 | |||
| 174 | } |
wp-content/plugins/contact-form-7-to-database-extension/CFDBQueryResultIteratorFactory.php
0 → 100644
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBWpdbResultIterator.php'); | ||
| 23 | require_once('CFDBWpdbUnbufferedResultIterator.php'); | ||
| 24 | |||
| 25 | /** | ||
| 26 | * @singleton | ||
| 27 | */ | ||
| 28 | class CFDBQueryResultIteratorFactory { | ||
| 29 | |||
| 30 | /** | ||
| 31 | * @var CFDBAbstractQueryResultsIterator mock instance | ||
| 32 | */ | ||
| 33 | var $mock; | ||
| 34 | |||
| 35 | public static function getInstance() { | ||
| 36 | static $inst = null; | ||
| 37 | if ($inst === null) { | ||
| 38 | $inst = new CFDBQueryResultIteratorFactory(); | ||
| 39 | } | ||
| 40 | return $inst; | ||
| 41 | } | ||
| 42 | |||
| 43 | /** | ||
| 44 | * @param $mock CFDBAbstractQueryResultsIterator mock for CFDBQueryResultIterator | ||
| 45 | */ | ||
| 46 | public function setQueryResultsIteratorMock($mock) { | ||
| 47 | $this->mock = $mock; | ||
| 48 | } | ||
| 49 | |||
| 50 | public function clearMock() { | ||
| 51 | $this->mock = null; | ||
| 52 | } | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Factory method for getting a new CFDBQueryResultIterator or mock. | ||
| 56 | * @param $unbuffered bool | ||
| 57 | * @return CFDBAbstractQueryResultsIterator (or mock) | ||
| 58 | */ | ||
| 59 | public function newQueryIterator($unbuffered = false) { | ||
| 60 | if ($this->mock) { | ||
| 61 | return $this->mock; | ||
| 62 | } | ||
| 63 | if ($unbuffered) { | ||
| 64 | return new CFDBWpdbUnbufferedResultIterator; | ||
| 65 | } else { | ||
| 66 | return new CFDBWpdbResultIterator; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | include_once('CFDBEvaluator.php'); | ||
| 23 | |||
| 24 | class CFDBSearchEvaluator implements CFDBEvaluator { | ||
| 25 | |||
| 26 | var $search; | ||
| 27 | |||
| 28 | public function setSearch($search) { | ||
| 29 | $this->search = strtolower($search); | ||
| 30 | } | ||
| 31 | |||
| 32 | /** | ||
| 33 | * Evaluate expression against input data. This is intended to mimic the search field on DataTables | ||
| 34 | * @param $data array [ key => value] | ||
| 35 | * @return boolean result of evaluating $data against expression | ||
| 36 | */ | ||
| 37 | public function evaluate(&$data) { | ||
| 38 | if (!$this->search) { | ||
| 39 | return true; | ||
| 40 | } | ||
| 41 | foreach ($data as $key => $value) { | ||
| 42 | // Any field can match, case insensitive | ||
| 43 | if (false !== strrpos(strtolower($value), $this->search)) { | ||
| 44 | return true; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | return false; | ||
| 48 | } | ||
| 49 | |||
| 50 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2013 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | |||
| 23 | class CFDBShortCodeContentParser { | ||
| 24 | |||
| 25 | const BEFORE_START_DELIMITER = '{{BEFORE}}'; | ||
| 26 | const BEFORE_END_DELIMITER = '{{/BEFORE}}'; | ||
| 27 | |||
| 28 | const AFTER_START_DELIMITER = '{{AFTER}}'; | ||
| 29 | const AFTER_END_DELIMITER = '{{/AFTER}}'; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @param $content string | ||
| 33 | * @return array[$before, $template, $after] | ||
| 34 | */ | ||
| 35 | public function parseBeforeContentAfter($content) { | ||
| 36 | $before = null; | ||
| 37 | $startDelimiter = self::BEFORE_START_DELIMITER; | ||
| 38 | $endDelimiter = self::BEFORE_END_DELIMITER; | ||
| 39 | $startDelimiterStartPos = strpos($content, $startDelimiter); | ||
| 40 | $endDelimiterStartPos = strpos($content, $endDelimiter); | ||
| 41 | if ($startDelimiterStartPos !== false && | ||
| 42 | $endDelimiterStartPos !== false && | ||
| 43 | $startDelimiterStartPos < $endDelimiterStartPos) { | ||
| 44 | $startDelimiterEndPos = $startDelimiterStartPos + strlen($startDelimiter); | ||
| 45 | $endDelimiterEndPos = $endDelimiterStartPos + strlen($endDelimiter); | ||
| 46 | $before = substr($content, $startDelimiterEndPos, $endDelimiterStartPos - $startDelimiterEndPos); | ||
| 47 | $content = substr($content, $endDelimiterEndPos, strlen($content) - $startDelimiterEndPos); | ||
| 48 | } | ||
| 49 | |||
| 50 | $after = null; | ||
| 51 | $startDelimiter = self::AFTER_START_DELIMITER; | ||
| 52 | $endDelimiter = self::AFTER_END_DELIMITER; | ||
| 53 | $startDelimiterStartPos = strpos($content, $startDelimiter); | ||
| 54 | $endDelimiterStartPos = strpos($content, $endDelimiter); | ||
| 55 | if ($startDelimiterStartPos !== false && | ||
| 56 | $endDelimiterStartPos !== false && | ||
| 57 | $startDelimiterStartPos < $endDelimiterStartPos) { | ||
| 58 | $startDelimiterEndPos = $startDelimiterStartPos + strlen($startDelimiter); | ||
| 59 | $after = substr($content, $startDelimiterEndPos, $endDelimiterStartPos - $startDelimiterEndPos); | ||
| 60 | $content = substr($content, 0, $startDelimiterStartPos); | ||
| 61 | } | ||
| 62 | |||
| 63 | return array($before, $content, $after); | ||
| 64 | } | ||
| 65 | |||
| 66 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/contact-form-7-to-database-extension/CFDBShortCodeSaveFormMakerSubmission.php
0 → 100644
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('ShortCodeLoader.php'); | ||
| 23 | |||
| 24 | class CFDBShortCodeSaveFormMakerSubmission extends ShortCodeLoader { | ||
| 25 | |||
| 26 | const FORM_TITLE_FIELD = 'form_title'; | ||
| 27 | const DEFAULT_FORM_TITLE = 'Form Maker'; | ||
| 28 | |||
| 29 | |||
| 30 | /** | ||
| 31 | * @param $atts array (associative) of shortcode inputs | ||
| 32 | * @param $content string inner content of short code | ||
| 33 | * @return string shortcode content | ||
| 34 | */ | ||
| 35 | public function handleShortcode($atts, $content = null) { | ||
| 36 | // echo '<pre>'; | ||
| 37 | // print_r($_POST); | ||
| 38 | // echo "\n"; | ||
| 39 | // print_r($_FILES); | ||
| 40 | // echo '</pre>'; | ||
| 41 | |||
| 42 | if (is_array($_POST) && !empty($_POST)) { | ||
| 43 | $title = isset($_POST[self::FORM_TITLE_FIELD]) ? $_POST[self::FORM_TITLE_FIELD] : self::DEFAULT_FORM_TITLE; | ||
| 44 | $posted_data = array(); | ||
| 45 | $uploaded_files = array(); | ||
| 46 | |||
| 47 | // Get posted values | ||
| 48 | foreach ($_POST as $key => $val) { | ||
| 49 | $posted_data[$key] = $val; | ||
| 50 | } | ||
| 51 | |||
| 52 | |||
| 53 | // Deal with upload files | ||
| 54 | // $_FILES = Array ( | ||
| 55 | // [your-upload] => Array | ||
| 56 | // ( | ||
| 57 | // [name] => readme.txt | ||
| 58 | // [type] => text/plain | ||
| 59 | // [tmp_name] => /tmp/php3tQ1zg | ||
| 60 | // [error] => 0 | ||
| 61 | // [size] => 1557 | ||
| 62 | // ) | ||
| 63 | //) | ||
| 64 | if (is_array($_FILES) && !empty($_FILES)) { | ||
| 65 | foreach ($_FILES as $key => $file) { | ||
| 66 | if (is_uploaded_file($file['tmp_name'])) { | ||
| 67 | $posted_data[$key] = $file['name']; | ||
| 68 | $uploaded_files[$key] = $file['tmp_name']; | ||
| 69 | } | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | |||
| 74 | // Prepare data structure for call to hook | ||
| 75 | $data = (object)array('title' => $title, | ||
| 76 | 'posted_data' => $posted_data, | ||
| 77 | 'uploaded_files' => $uploaded_files); | ||
| 78 | |||
| 79 | // Call hook to submit data | ||
| 80 | do_action_ref_array('cfdb_submit', array(&$data)); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('ShortCodeLoader.php'); | ||
| 23 | |||
| 24 | class CFDBShortCodeSavePostData extends ShortCodeLoader { | ||
| 25 | |||
| 26 | const FORM_TITLE_FIELD = 'form_title'; | ||
| 27 | |||
| 28 | /** | ||
| 29 | * @param $atts array of short code attributes | ||
| 30 | * @param $content string not used | ||
| 31 | * @return void | ||
| 32 | */ | ||
| 33 | public function handleShortcode($atts, $content = null) { | ||
| 34 | |||
| 35 | $atts = $this->decodeAttributes($atts); | ||
| 36 | |||
| 37 | if (is_array($atts) && isset($atts['debug']) && $atts['debug'] == 'true') { | ||
| 38 | echo '<pre>'; | ||
| 39 | print_r($_POST); | ||
| 40 | echo "\n"; | ||
| 41 | print_r($_FILES); | ||
| 42 | echo '</pre>'; | ||
| 43 | } | ||
| 44 | |||
| 45 | if (is_array($_POST) && !empty($_POST)) { | ||
| 46 | $title = isset($_POST[self::FORM_TITLE_FIELD]) ? $_POST[self::FORM_TITLE_FIELD] : 'Untitled'; | ||
| 47 | $posted_data = array(); | ||
| 48 | $uploaded_files = array(); | ||
| 49 | |||
| 50 | // Get posted values | ||
| 51 | foreach ($_POST as $key => $val) { | ||
| 52 | if ($key != self::FORM_TITLE_FIELD) { | ||
| 53 | $posted_data[$key] = $val; | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | |||
| 58 | // Deal with upload files | ||
| 59 | // $_FILES = Array ( | ||
| 60 | // [your-upload] => Array | ||
| 61 | // ( | ||
| 62 | // [name] => readme.txt | ||
| 63 | // [type] => text/plain | ||
| 64 | // [tmp_name] => /tmp/php3tQ1zg | ||
| 65 | // [error] => 0 | ||
| 66 | // [size] => 1557 | ||
| 67 | // ) | ||
| 68 | //) | ||
| 69 | if (is_array($_FILES) && !empty($_FILES)) { | ||
| 70 | foreach ($_FILES as $key => $file) { | ||
| 71 | if (is_uploaded_file($file['tmp_name'])) { | ||
| 72 | $posted_data[$key] = $file['name']; | ||
| 73 | $uploaded_files[$key] = $file['tmp_name']; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | |||
| 79 | // Prepare data structure for call to hook | ||
| 80 | $data = (object)array('title' => $title, | ||
| 81 | 'posted_data' => $posted_data, | ||
| 82 | 'uploaded_files' => $uploaded_files); | ||
| 83 | |||
| 84 | // Call hook to submit data | ||
| 85 | do_action_ref_array('cfdb_submit', array(&$data)); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBShortcodeValue.php'); | ||
| 23 | |||
| 24 | class CFDBShortcodeCount extends CFDBShortcodeValue { | ||
| 25 | |||
| 26 | public function handleShortcode($atts, $content = null) { | ||
| 27 | $atts = $this->decodeAttributes($atts); | ||
| 28 | $atts['content'] = $content; | ||
| 29 | $atts['function'] = 'count'; | ||
| 30 | unset($atts['show']); | ||
| 31 | unset($atts['hide']); | ||
| 32 | return parent::handleShortcode($atts, $content); | ||
| 33 | } | ||
| 34 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2013 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('ShortCodeScriptLoader.php'); | ||
| 23 | |||
| 24 | class CFDBShortcodeDataTable extends ShortCodeScriptLoader { | ||
| 25 | |||
| 26 | public function handleShortcode($atts, $content = null) { | ||
| 27 | $atts['content'] = $content; | ||
| 28 | $atts['useDT'] = true; | ||
| 29 | require_once('CFDBShortcodeTable.php'); | ||
| 30 | $sc = new CFDBShortcodeTable(); | ||
| 31 | return $sc->handleShortcode($atts, $content); | ||
| 32 | } | ||
| 33 | |||
| 34 | public function register($shortcodeName) { | ||
| 35 | parent::register($shortcodeName); | ||
| 36 | |||
| 37 | // Unfortunately, can't put styles in the footer so we have to always add this style sheet | ||
| 38 | // There is an article about how one might go about this here: | ||
| 39 | // http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-needed-by-the-posts/ | ||
| 40 | // But it appears to expects posts on the page and I'm concerned it will not work in all cases | ||
| 41 | |||
| 42 | // Just enqueuing it causes problems in some pages. Need a targeted way to do this. | ||
| 43 | // wp_enqueue_style('datatables-demo', 'http://www.datatables.net/release-datatables/media/css/demo_table.css'); | ||
| 44 | } | ||
| 45 | |||
| 46 | public function addScript() { | ||
| 47 | // wp_register_style('datatables-demo', 'http://www.datatables.net/release-datatables/media/css/demo_table.css'); | ||
| 48 | // wp_print_styles('datatables-demo'); | ||
| 49 | |||
| 50 | // wp_register_script('datatables', 'http://www.datatables.net/release-datatables/media/js/jquery.dataTables.js', array('jquery'), false, true); | ||
| 51 | wp_enqueue_script('datatables', plugins_url('/', __FILE__) . 'DataTables/media/js/jquery.dataTables.min.js', array('jquery')); | ||
| 52 | do_action_ref_array('cfdb_edit_enqueue', array()); | ||
| 53 | wp_print_scripts('datatables'); | ||
| 54 | } | ||
| 55 | |||
| 56 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('ShortCodeLoader.php'); | ||
| 23 | |||
| 24 | class CFDBShortcodeExportUrl extends ShortCodeLoader { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @param $atts array of short code attributes | ||
| 28 | * @param $content string not used | ||
| 29 | * @return string export link | ||
| 30 | */ | ||
| 31 | public function handleShortcode($atts, $content = null) { | ||
| 32 | $atts = $this->decodeAttributes($atts); | ||
| 33 | $params = array(); | ||
| 34 | $params[] = admin_url('admin-ajax.php'); | ||
| 35 | $params[] = '?action=cfdb-export'; | ||
| 36 | |||
| 37 | $special = array('urlonly', 'linktext', 'role'); | ||
| 38 | foreach ($atts as $key => $value) { | ||
| 39 | if (!in_array($key, $special)) { | ||
| 40 | $params[] = sprintf('&%s=%s', urlencode($key), urlencode($value)); | ||
| 41 | } else if ($key == 'role') { | ||
| 42 | require_once('CF7DBPlugin.php'); | ||
| 43 | $plugin = new CF7DBPlugin(); | ||
| 44 | $isAuth = $plugin->isUserRoleEqualOrBetterThan($value); | ||
| 45 | if (!$isAuth) { | ||
| 46 | // Not authorized. Print no link. | ||
| 47 | return ''; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } | ||
| 51 | $url = implode($params); | ||
| 52 | |||
| 53 | if (isset($atts['urlonly']) && $atts['urlonly'] == 'true') { | ||
| 54 | return $url; | ||
| 55 | } | ||
| 56 | |||
| 57 | $linkText = __('Export', 'contact-form-7-to-database-extension'); | ||
| 58 | if (isset($atts['linktext'])) { | ||
| 59 | $linkText = $atts['linktext']; | ||
| 60 | } | ||
| 61 | |||
| 62 | return sprintf('<a href="%s">%s</a>', $url, $linkText); | ||
| 63 | } | ||
| 64 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('ShortCodeLoader.php'); | ||
| 23 | |||
| 24 | class CFDBShortcodeHtml extends ShortCodeLoader { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @param $atts array of short code attributes | ||
| 28 | * @param $content string contents inside the shortcode tag | ||
| 29 | * @return string value submitted to a form field as selected by $atts. See ExportToValue.php | ||
| 30 | */ | ||
| 31 | public function handleShortcode($atts, $content = null) { | ||
| 32 | if ($content && isset($atts['form'])) { | ||
| 33 | $atts = $this->decodeAttributes($atts); | ||
| 34 | $atts['fromshortcode'] = true; | ||
| 35 | $atts['content'] = $content; | ||
| 36 | require_once('ExportToHtmlTemplate.php'); | ||
| 37 | $export = new ExportToHtmlTemplate(); | ||
| 38 | return $export->export($atts['form'], $atts); | ||
| 39 | } | ||
| 40 | return ''; | ||
| 41 | } | ||
| 42 | |||
| 43 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('ShortCodeLoader.php'); | ||
| 23 | |||
| 24 | class CFDBShortcodeJson extends ShortCodeLoader { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @param $atts array of short code attributes | ||
| 28 | * @param $content string inner content of short code | ||
| 29 | * @return string JSON. See ExportToJson.php | ||
| 30 | */ | ||
| 31 | public function handleShortcode($atts, $content = null) { | ||
| 32 | if (isset($atts['form'])) { | ||
| 33 | $atts = $this->decodeAttributes($atts); | ||
| 34 | $atts['content'] = $content; | ||
| 35 | $atts['html'] = true; | ||
| 36 | $atts['fromshortcode'] = true; | ||
| 37 | require_once('ExportToJson.php'); | ||
| 38 | $export = new ExportToJson(); | ||
| 39 | return $export->export($atts['form'], $atts); | ||
| 40 | } | ||
| 41 | return ''; | ||
| 42 | } | ||
| 43 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('ShortCodeLoader.php'); | ||
| 23 | |||
| 24 | class CFDBShortcodeTable extends ShortCodeLoader { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Shortcode callback for writing the table of form data. Can be put in a page or post to show that data. | ||
| 28 | * Shortcode options: | ||
| 29 | * [cfdb-table form="your-form"] (shows the whole table with default options) | ||
| 30 | * Controlling the Display: Apply your CSS to the table; set the table's 'class' or 'id' attribute: | ||
| 31 | * [cfdb-table form="your-form" class="css_class"] (outputs <table class="css_class"> (default: class="cf7-db-table") | ||
| 32 | * [cfdb-table form="your-form" id="css_id"] (outputs <table id="css_id"> (no default id) | ||
| 33 | * [cfdb-table form="your-form" id="css_id" class="css_class"] (outputs <table id="css_id" class="css_class"> | ||
| 34 | * Filtering Columns: | ||
| 35 | * [cfdb-table form="your-form" show="field1,field2,field3"] (optionally show selected fields) | ||
| 36 | * [cfdb-table form="your-form" hide="field1,field2,field3"] (optionally hide selected fields) | ||
| 37 | * [cfdb-table form="your-form" show="f1,f2,f3" hide="f1"] (hide trumps show) | ||
| 38 | * Filtering Rows: | ||
| 39 | * [cfdb-table form="your-form" filter="field1=value1"] (show only rows where field1=value1) | ||
| 40 | * [cfdb-table form="your-form" filter="field1!=value1"] (show only rows where field1!=value1) | ||
| 41 | * [cfdb-table form="your-form" filter="field1=value1&&field2!=value2"] (Logical AND the filters using '&&') | ||
| 42 | * [cfdb-table form="your-form" filter="field1=value1||field2!=value2"] (Logical OR the filters using '||') | ||
| 43 | * [cfdb-table form="your-form" filter="field1=value1&&field2!=value2||field3=value3&&field4=value4"] (Mixed &&, ||) | ||
| 44 | * @param $atts array of short code attributes | ||
| 45 | * @param $content string inner content of short code | ||
| 46 | * @return string HTML output of shortcode | ||
| 47 | */ | ||
| 48 | public function handleShortcode($atts, $content = null) { | ||
| 49 | if (isset($atts['form'])) { | ||
| 50 | $atts = $this->decodeAttributes($atts); | ||
| 51 | $atts['content'] = $content; | ||
| 52 | $atts['canDelete'] = false; | ||
| 53 | $atts['fromshortcode'] = true; | ||
| 54 | require_once('ExportToHtmlTable.php'); | ||
| 55 | $export = new ExportToHtmlTable(); | ||
| 56 | return $export->export($atts['form'], $atts); | ||
| 57 | } | ||
| 58 | return ''; | ||
| 59 | } | ||
| 60 | |||
| 61 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('ShortCodeLoader.php'); | ||
| 23 | |||
| 24 | class CFDBShortcodeValue extends ShortCodeLoader { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @param $atts array of short code attributes | ||
| 28 | * @param $content string short code inner content | ||
| 29 | * @return string value submitted to a form field as selected by $atts. See ExportToValue.php | ||
| 30 | */ | ||
| 31 | public function handleShortcode($atts, $content = null) { | ||
| 32 | if (isset($atts['form'])) { | ||
| 33 | $atts = $this->decodeAttributes($atts); | ||
| 34 | $atts['content'] = $content; | ||
| 35 | $atts['fromshortcode'] = true; | ||
| 36 | require_once('ExportToValue.php'); | ||
| 37 | $export = new ExportToValue(); | ||
| 38 | return $export->export($atts['form'], $atts); | ||
| 39 | } | ||
| 40 | return ''; | ||
| 41 | } | ||
| 42 | |||
| 43 | } |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /** | ||
| 23 | * Interface CFDBTransform for user-defined classes that can be used to transform data | ||
| 24 | * as it is returned from the database but before it is is formatted for display. | ||
| 25 | * See: short code "trans" option. | ||
| 26 | */ | ||
| 27 | interface CFDBTransform { | ||
| 28 | |||
| 29 | /** | ||
| 30 | * @param $entry array associative array of a single for entry | ||
| 31 | * @return void | ||
| 32 | */ | ||
| 33 | public function addEntry(&$entry); | ||
| 34 | |||
| 35 | /** | ||
| 36 | * Call this when done adding entries. Apply transform across all entered data, | ||
| 37 | * then return the entire set. The returned set may be entirely different data than | ||
| 38 | * what was input (e.g. statistics) | ||
| 39 | * @return array of associative of array of data. | ||
| 40 | */ | ||
| 41 | public function getTransformedData(); | ||
| 42 | |||
| 43 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | //require_once('CFDBTransform.php'); | ||
| 23 | require_once('CFDBDataIteratorDecorator.php'); | ||
| 24 | |||
| 25 | class CFDBTransformByClassIterator extends CFDBDataIteratorDecorator { | ||
| 26 | |||
| 27 | /** | ||
| 28 | * @var CFDBTransform | ||
| 29 | */ | ||
| 30 | var $transformObject; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * @var array[array[name=>value], ...] transformed data set | ||
| 34 | */ | ||
| 35 | var $transformedData; | ||
| 36 | |||
| 37 | /** | ||
| 38 | * @var int | ||
| 39 | */ | ||
| 40 | var $count; | ||
| 41 | |||
| 42 | /** | ||
| 43 | * @var int | ||
| 44 | */ | ||
| 45 | var $idx; | ||
| 46 | |||
| 47 | /** | ||
| 48 | * @param $transformObject CFDBTransform interface but allow for duck-typing | ||
| 49 | */ | ||
| 50 | public function setTransformObject($transformObject) { | ||
| 51 | $this->transformObject = $transformObject; | ||
| 52 | } | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Fetch next row into variable | ||
| 56 | * @return bool if next row exists | ||
| 57 | */ | ||
| 58 | public function nextRow() { | ||
| 59 | if (!$this->transformedData) { | ||
| 60 | $this->initData(); | ||
| 61 | $this->idx = 0; | ||
| 62 | return $this->count > 0; | ||
| 63 | } else { | ||
| 64 | if (++$this->idx < $this->count) { | ||
| 65 | $this->row =& $this->transformedData[$this->idx]; | ||
| 66 | return true; | ||
| 67 | } else { | ||
| 68 | return false; | ||
| 69 | } | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | /** | ||
| 74 | * @return bool | ||
| 75 | */ | ||
| 76 | protected function initData() { | ||
| 77 | if ($this->transformedData) { | ||
| 78 | return; // Already initialized | ||
| 79 | } | ||
| 80 | |||
| 81 | // Loop the entire $source data set and transform it. | ||
| 82 | while ($this->source->nextRow()) { | ||
| 83 | $this->transformObject->addEntry($this->source->row); | ||
| 84 | } | ||
| 85 | |||
| 86 | // Transform the data | ||
| 87 | $this->transformedData = $this->transformObject->getTransformedData(); | ||
| 88 | |||
| 89 | // Init count for iteration | ||
| 90 | $this->count = count($this->transformedData); | ||
| 91 | if ($this->count > 0) { | ||
| 92 | $this->idx = -1; // nextRow will ++ it | ||
| 93 | $this->row =& $this->transformedData[0]; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | public function getDisplayColumns() { | ||
| 98 | if (empty($this->displayColumns)) { | ||
| 99 | $sourceDisplayCols = parent::getDisplayColumns(); // gets form source transform | ||
| 100 | $this->fixDisplayColumns($sourceDisplayCols); | ||
| 101 | return $this->displayColumns; | ||
| 102 | } | ||
| 103 | return $this->displayColumns; | ||
| 104 | } | ||
| 105 | |||
| 106 | protected function fixDisplayColumns($sourceDisplayCols) { | ||
| 107 | |||
| 108 | if (empty($this->transformedData)) { | ||
| 109 | $this->initData(); | ||
| 110 | } | ||
| 111 | |||
| 112 | if (!empty($this->displayColumns)) { | ||
| 113 | return; | ||
| 114 | } | ||
| 115 | |||
| 116 | $dataCols = null; | ||
| 117 | if ($this->transformedData == null || | ||
| 118 | !isset($this->transformedData[0]) || | ||
| 119 | !is_array($this->transformedData[0])) { | ||
| 120 | $dataCols = array(); | ||
| 121 | } else { | ||
| 122 | $dataCols = array_keys($this->transformedData[0]); | ||
| 123 | } | ||
| 124 | $newDisplayColumns = array(); | ||
| 125 | |||
| 126 | foreach ($sourceDisplayCols as $col) { | ||
| 127 | if (in_array($col, $dataCols)) { | ||
| 128 | $newDisplayColumns[] = $col; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | // Ignore metadata columns for purposes of determining display columns) | ||
| 133 | $metadataCols = array('fields_with_file', 'submit_time', 'Submit_Time_Key'); | ||
| 134 | foreach ($dataCols as $col) { | ||
| 135 | if (!in_array($col, $metadataCols) && !in_array($col, $newDisplayColumns)) { | ||
| 136 | $newDisplayColumns[] = $col; | ||
| 137 | } | ||
| 138 | } | ||
| 139 | |||
| 140 | $this->displayColumns = $newDisplayColumns; | ||
| 141 | } | ||
| 142 | |||
| 143 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
wp-content/plugins/contact-form-7-to-database-extension/CFDBTransformByFunctionIterator.php
0 → 100644
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBDataIteratorDecorator.php'); | ||
| 23 | |||
| 24 | class CFDBTransformByFunctionIterator extends CFDBDataIteratorDecorator { | ||
| 25 | |||
| 26 | /** | ||
| 27 | * @var array | ||
| 28 | */ | ||
| 29 | var $functionArray; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * @var CFDBFunctionEvaluator | ||
| 33 | */ | ||
| 34 | var $functionEvaluator; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * @var string name of field to assign the returned value of the function | ||
| 38 | */ | ||
| 39 | var $fieldToAssign; | ||
| 40 | |||
| 41 | /** | ||
| 42 | * @param array $functionArray [function_name, arg1, arg2, ...] | ||
| 43 | */ | ||
| 44 | public function setFunctionArray($functionArray) { | ||
| 45 | $this->functionArray = $functionArray; | ||
| 46 | } | ||
| 47 | |||
| 48 | /** | ||
| 49 | * @param $functionEvaluator CFDBFunctionEvaluator | ||
| 50 | */ | ||
| 51 | public function setFunctionEvaluator($functionEvaluator) { | ||
| 52 | $this->functionEvaluator = $functionEvaluator; | ||
| 53 | } | ||
| 54 | |||
| 55 | /** | ||
| 56 | * @param string $fieldToAssign | ||
| 57 | */ | ||
| 58 | public function setFieldToAssign($fieldToAssign) { | ||
| 59 | $this->fieldToAssign = $fieldToAssign; | ||
| 60 | } | ||
| 61 | |||
| 62 | /** | ||
| 63 | * Fetch next row into variable | ||
| 64 | * @return bool if next row exists | ||
| 65 | */ | ||
| 66 | public function nextRow() { | ||
| 67 | if ($this->source->nextRow()) { | ||
| 68 | $this->row =& $this->source->row; | ||
| 69 | if (empty($this->displayColumns) && !empty($this->source->displayColumns)) { | ||
| 70 | $this->displayColumns = $this->source->displayColumns; | ||
| 71 | } | ||
| 72 | $origKeys = array_keys($this->row); | ||
| 73 | $functionReturn = $this->functionEvaluator->evaluateFunction($this->functionArray, $this->row); | ||
| 74 | if ($this->fieldToAssign) { | ||
| 75 | $this->source->row[$this->fieldToAssign] = $functionReturn; | ||
| 76 | if (!in_array($this->fieldToAssign, $this->displayColumns)) { | ||
| 77 | $this->displayColumns[] = $this->fieldToAssign; | ||
| 78 | } | ||
| 79 | } else if ($functionReturn === null || is_array($functionReturn)) { | ||
| 80 | // $functionReturn when a reference was passed in and row may be modified | ||
| 81 | |||
| 82 | // New row returned | ||
| 83 | if (is_array($functionReturn)) { | ||
| 84 | // function returns new array for the entry | ||
| 85 | $this->source->row = $functionReturn; | ||
| 86 | $this->row =& $this->source->row; | ||
| 87 | } | ||
| 88 | |||
| 89 | // Reconcile display columns | ||
| 90 | |||
| 91 | // 1. Check for the addition of new columns to add to displays | ||
| 92 | $newFieldsSeen = array(); | ||
| 93 | $newKeys = array_keys($this->row); | ||
| 94 | $addedKeys = array_diff($newKeys, $origKeys); | ||
| 95 | if (!empty($addedKeys)) { | ||
| 96 | foreach ($addedKeys as $add) { | ||
| 97 | if (!in_array($add, $this->displayColumns)) { | ||
| 98 | $this->displayColumns[] = $add; | ||
| 99 | $newFieldsSeen[] = $add; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | // 2. Remove display columns that no longer exist | ||
| 105 | $updatedDisplays = array(); | ||
| 106 | foreach($this->displayColumns as $aDisplay) { | ||
| 107 | if (in_array($aDisplay, $newKeys) || in_array($aDisplay, $newFieldsSeen)) { | ||
| 108 | $updatedDisplays[] = $aDisplay; | ||
| 109 | } | ||
| 110 | } | ||
| 111 | $this->displayColumns = $updatedDisplays; | ||
| 112 | } | ||
| 113 | return true; | ||
| 114 | } | ||
| 115 | return false; | ||
| 116 | } | ||
| 117 | |||
| 118 | public function getDisplayColumns() { | ||
| 119 | if (empty($this->displayColumns)) { | ||
| 120 | $cols = $this->source->getDisplayColumns(); | ||
| 121 | if ($this->fieldToAssign && !in_array($this->fieldToAssign, $cols)) { | ||
| 122 | $cols[] = $this->fieldToAssign; | ||
| 123 | return $cols; | ||
| 124 | } | ||
| 125 | } | ||
| 126 | return $this->displayColumns; | ||
| 127 | } | ||
| 128 | |||
| 129 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBAbstractQueryResultsIterator.php'); | ||
| 23 | require_once('CFDBDataIteratorDecorator.php'); | ||
| 24 | |||
| 25 | class CFDBTransformEndpoint extends CFDBDataIteratorDecorator { | ||
| 26 | |||
| 27 | /** | ||
| 28 | * @var CFDBTransformEndpointQueryResultsIterator | ||
| 29 | */ | ||
| 30 | var $postProcessor; | ||
| 31 | |||
| 32 | function __construct() { | ||
| 33 | $this->postProcessor = new CFDBTransformEndpointQueryResultsIterator($this); | ||
| 34 | } | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Fetch next row into variable | ||
| 38 | * @return bool if next row exists | ||
| 39 | */ | ||
| 40 | public function nextRow() { | ||
| 41 | if ($this->postProcessor->nextRow()) { | ||
| 42 | $this->row =& $this->source->row; | ||
| 43 | if (empty($this->displayColumns)) { | ||
| 44 | $this->displayColumns =& $this->source->displayColumns; | ||
| 45 | } | ||
| 46 | return true; | ||
| 47 | } else { | ||
| 48 | $this->row = null; | ||
| 49 | return false; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | /** | ||
| 54 | * @return CFDBTransformEndpointQueryResultsIterator | ||
| 55 | */ | ||
| 56 | public function getPostProcessor() { | ||
| 57 | return $this->postProcessor; | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 61 | |||
| 62 | class CFDBTransformEndpointQueryResultsIterator extends CFDBAbstractQueryResultsIterator { | ||
| 63 | |||
| 64 | /** | ||
| 65 | * @var CFDBTransformEndpoint | ||
| 66 | */ | ||
| 67 | var $endPoint; | ||
| 68 | |||
| 69 | function __construct($endPoint) { | ||
| 70 | $this->endPoint = $endPoint; | ||
| 71 | } | ||
| 72 | |||
| 73 | /** | ||
| 74 | * Execute the query | ||
| 75 | * @param $sql string query | ||
| 76 | * @param $queryOptions array associative | ||
| 77 | * @return void | ||
| 78 | */ | ||
| 79 | public function queryDataSource(&$sql, $queryOptions) { | ||
| 80 | // Do nothing. Data is in $this->$endPoint->source | ||
| 81 | } | ||
| 82 | |||
| 83 | /** | ||
| 84 | * Get the next row from query results | ||
| 85 | * @return array associative | ||
| 86 | */ | ||
| 87 | public function fetchRow() { | ||
| 88 | if($this->endPoint->source->nextRow()) { | ||
| 89 | return $this->endPoint->source->row; | ||
| 90 | } | ||
| 91 | return null; | ||
| 92 | } | ||
| 93 | |||
| 94 | /** | ||
| 95 | * @return boolean | ||
| 96 | */ | ||
| 97 | public function hasResults() { | ||
| 98 | // this is called by nextRow() in superclass | ||
| 99 | // return true and let next row sort it out | ||
| 100 | return true; | ||
| 101 | } | ||
| 102 | |||
| 103 | /** | ||
| 104 | * If you do not iterate over all the rows returned, be sure to call this function | ||
| 105 | * on all remaining rows to free resources. | ||
| 106 | * @return void | ||
| 107 | */ | ||
| 108 | public function freeResult() { | ||
| 109 | // Do nothing | ||
| 110 | } | ||
| 111 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | require_once('CFDBParserBase.php'); | ||
| 23 | require_once('CFDBTransformByFunctionIterator.php'); | ||
| 24 | require_once('CFDBTransformByClassIterator.php'); | ||
| 25 | require_once('CFDBTransformEndpoint.php'); | ||
| 26 | |||
| 27 | // Includes these just to have them as known classes in case they are in the transform. | ||
| 28 | require_once('SortByField.php'); | ||
| 29 | require_once('SortByMultiField.php'); | ||
| 30 | require_once('NaturalSortByField.php'); | ||
| 31 | require_once('NaturalSortByMultiField.php'); | ||
| 32 | require_once('SortByDateField.php'); | ||
| 33 | require_once('SummationRow.php'); | ||
| 34 | |||
| 35 | require_once('CountField.php'); | ||
| 36 | require_once('SumField.php'); | ||
| 37 | require_once('MinField.php'); | ||
| 38 | require_once('MaxField.php'); | ||
| 39 | require_once('AverageField.php'); | ||
| 40 | require_once('TotalField.php'); | ||
| 41 | |||
| 42 | require_once('cfdb-transform-functions.php'); | ||
| 43 | |||
| 44 | class CFDBTransformParser extends CFDBParserBase { | ||
| 45 | |||
| 46 | var $tree = array(); | ||
| 47 | |||
| 48 | /** | ||
| 49 | * @var array[CFDBDataIterator] | ||
| 50 | */ | ||
| 51 | var $transformIterators = array(); | ||
| 52 | |||
| 53 | |||
| 54 | public function getExpressionTree() { | ||
| 55 | return $this->tree; | ||
| 56 | } | ||
| 57 | |||
| 58 | public function parse($string) { | ||
| 59 | $arrayOfANDedStrings = $this->parseANDs($string); // e.g. "xx=yy()&&zz()" -> ["xx=yy(a,b,c)", "zz"] | ||
| 60 | foreach ($arrayOfANDedStrings as $expressionString) { | ||
| 61 | $rawExpression = $this->parseExpression(trim($expressionString)); // e.g. ["xx" "=" "yy(a,b,c)"] or ["zz"] | ||
| 62 | if (empty($rawExpression)) { | ||
| 63 | continue; | ||
| 64 | } | ||
| 65 | $expression = array(); | ||
| 66 | $function = null; | ||
| 67 | if (count($rawExpression) >= 3) { // e.g. ["xx" "=" "yy(a,b,c)"] | ||
| 68 | $expression[] = trim($rawExpression[0]); // field name | ||
| 69 | $expression[] = trim($rawExpression[1]); // = | ||
| 70 | $function = trim($rawExpression[2]); // function call | ||
| 71 | } else { | ||
| 72 | $function = trim($rawExpression[0]); // function call | ||
| 73 | } | ||
| 74 | $function = $this->parseValidFunctionOrClassTransform($function); // ["zz(a,b,c)"] -> ["zz", "a", "b", "c"] | ||
| 75 | if (is_array($function)) { | ||
| 76 | $expression = array_merge($expression, $function); | ||
| 77 | } else { | ||
| 78 | $expression[] = $function; | ||
| 79 | } | ||
| 80 | $this->tree[] = $expression; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | |||
| 85 | /** | ||
| 86 | * Parse a comparison expression into its three components | ||
| 87 | * @param $comparisonExpression string in the form 'value1' . 'operator' . 'value2' where | ||
| 88 | * operator is a php comparison operator or '=' | ||
| 89 | * @return array of string [ value1, operator, value2 ] | ||
| 90 | */ | ||
| 91 | public function parseExpression($comparisonExpression) { | ||
| 92 | return preg_split('/(=)/', $comparisonExpression, -1, | ||
| 93 | PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
| 97 | public function setupTransforms() { | ||
| 98 | if ($this->tree) { | ||
| 99 | /** @var $previousTransformIterator CFDBDataIteratorDecorator */ | ||
| 100 | $previousTransformIterator = null; | ||
| 101 | foreach ($this->tree as $transformArray) { | ||
| 102 | // [field, =, func, a1, a2, ...] or [func] or [class] or [class, a1, a2, ...] | ||
| 103 | $transform = null; | ||
| 104 | if (!empty($transformArray)) { | ||
| 105 | $transform = null; | ||
| 106 | if (class_exists($transformArray[0])) { | ||
| 107 | $reflect = new ReflectionClass($transformArray[0]); | ||
| 108 | $args = array_slice($transformArray, 1); | ||
| 109 | $instance = $reflect->newInstanceArgs($args); | ||
| 110 | $transform = new CFDBTransformByClassIterator(); | ||
| 111 | /** @var $instance CFDBTransform */ | ||
| 112 | $transform->setTransformObject($instance); | ||
| 113 | } else { | ||
| 114 | // assume it is a function | ||
| 115 | $transform = new CFDBTransformByFunctionIterator(); | ||
| 116 | $transform->setFunctionEvaluator($this->functionEvaluator); | ||
| 117 | if (count($transformArray) > 1 && $transformArray[1] == '=') { | ||
| 118 | // [field_name, =, function_name, arg1, arg2, ...] | ||
| 119 | $transform->setFieldToAssign($transformArray[0]); | ||
| 120 | $transform->setFunctionArray(array_slice($transformArray, 2)); | ||
| 121 | } else { | ||
| 122 | // [function_name, arg1, arg2, ...] | ||
| 123 | $transform->setFunctionArray($transformArray); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | // Set the data source for each transform as the previous transform | ||
| 127 | // to set up a pipeline/decorator pattern. | ||
| 128 | // The first transform is left with null data source to be hooked up later | ||
| 129 | // to query results. | ||
| 130 | $transform->setSource($previousTransformIterator); // is null for first one | ||
| 131 | $previousTransformIterator = $transform; | ||
| 132 | $this->transformIterators[] = $transform; | ||
| 133 | } | ||
| 134 | } | ||
| 135 | if ($previousTransformIterator) { | ||
| 136 | // Stick a CFDBTransformEndpoint at the end of the list of transforms | ||
| 137 | $transform = new CFDBTransformEndpoint(); | ||
| 138 | $transform->setSource($previousTransformIterator); | ||
| 139 | $this->transformIterators[] = $transform; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | } | ||
| 143 | |||
| 144 | /** | ||
| 145 | * @param $dataSource CFDBDataIterator | ||
| 146 | */ | ||
| 147 | public function setDataSource($dataSource) { | ||
| 148 | if (count($this->transformIterators) > 0) { | ||
| 149 | $this->transformIterators[0]->setSource($dataSource); | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | /** | ||
| 154 | * @return CFDBDataIteratorDecorator | ||
| 155 | */ | ||
| 156 | public function getIterator() { | ||
| 157 | return end($this->transformIterators); | ||
| 158 | } | ||
| 159 | |||
| 160 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | <?php | ||
| 2 | /* | ||
| 3 | "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) | ||
| 4 | |||
| 5 | This file is part of Contact Form to Database. | ||
| 6 | |||
| 7 | Contact Form to Database is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 3 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | Contact Form to Database is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with Contact Form to Database. | ||
| 19 | If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | interface CFDBValueConverter { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @abstract | ||
| 26 | * @param $value mixed object to convert | ||
| 27 | * @return mixed converted value | ||
| 28 | */ | ||
| 29 | public function convert($value); | ||
| 30 | } |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/CFDBWpdbUnbufferedResultIterator.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/css/demo_page.css
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/css/demo_table.css
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/css/demo_table_jui.css
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/css/jquery.dataTables.css
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/images/back_disabled.png
0 → 100644
1.33 KB
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/images/back_enabled.png
0 → 100644
1.35 KB
1.34 KB
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/images/favicon.ico
0 → 100644
No preview for this file type
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/images/forward_disabled.png
0 → 100644
1.33 KB
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/images/forward_enabled.png
0 → 100644
1.35 KB
1.35 KB
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/images/sort_asc.png
0 → 100644
1.09 KB
1.03 KB
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/images/sort_both.png
0 → 100644
1.11 KB
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/images/sort_desc.png
0 → 100644
1.1 KB
1.02 KB
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/js/jquery.dataTables.js
0 → 100644
This diff could not be displayed because it is too large.
wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/js/jquery.dataTables.min.js
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
119 KB
97.1 KB
49.8 KB
77.5 KB
230 KB
130 KB
6.35 KB
487 Bytes
373 Bytes
180 Bytes
178 Bytes
120 Bytes
105 Bytes
111 Bytes
110 Bytes
119 Bytes
101 Bytes
wp-content/plugins/contact-form-7-to-database-extension/jquery-ui/images/ui-icons_222222_256x240.png
0 → 100644
4.27 KB
wp-content/plugins/contact-form-7-to-database-extension/jquery-ui/images/ui-icons_2e83ff_256x240.png
0 → 100644
4.27 KB
wp-content/plugins/contact-form-7-to-database-extension/jquery-ui/images/ui-icons_454545_256x240.png
0 → 100644
4.27 KB
wp-content/plugins/contact-form-7-to-database-extension/jquery-ui/images/ui-icons_888888_256x240.png
0 → 100644
4.27 KB
wp-content/plugins/contact-form-7-to-database-extension/jquery-ui/images/ui-icons_cd0a0a_256x240.png
0 → 100644
4.27 KB
wp-content/plugins/contact-form-7-to-database-extension/jquery-ui/jquery-ui-1.8.21.custom.css
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/CFDBIntegrationCalderaFormsTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/CFDBIntegrationWRContactFormTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/CFDBPermittedFunctionsTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/CFDBShortCodeContentParserTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/CFDBTransformParserTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/DereferenceShortcodeVarsTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/HtmlTemplateMissingFieldTest.json
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/HtmlTemplateMissingFieldTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/HtmlTemplateTransformTest.json
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/HtmlTemplateTransformTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/MockQueryResultIterator.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/NaturalSortByMultiFieldTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/ShortCodeBeforeAfterTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/SortByDateField_TransformTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/TransformEntryFunctionTest.json
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/contact-form-7-to-database-extension/phpunit/TransformEntryFunctionTest.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
63.1 KB
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
9.54 KB
5.19 KB
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
1.3 KB
2.68 KB
2.22 MB
This diff is collapsed.
Click to expand it.
10.6 KB
46.3 KB
117 KB
76.8 KB
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
9.16 KB
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/debug/class-fs-debug-bar-panel.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/entities/class-fs-affiliate-terms.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/entities/class-fs-plugin-info.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/entities/class-fs-plugin-license.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/entities/class-fs-plugin-plan.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/entities/class-fs-scope-entity.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/entities/class-fs-subscription.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-admin-menu-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-admin-notice-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-cache-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-clone-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-gdpr-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-key-value-storage.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-license-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-option-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-permission-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-plan-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/managers/class-fs-plugin-manager.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/sdk/Exceptions/ArgumentNotExistException.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/sdk/Exceptions/EmptyArgumentException.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/sdk/Exceptions/InvalidArgumentException.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/sdk/Exceptions/OAuthException.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/supplements/fs-essential-functions-2.2.1.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/includes/supplements/fs-migration-2.5.1.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/templates/account/partials/disconnect-button.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/templates/forms/deactivation/retry-skip.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/templates/forms/premium-versions-upgrade-handler.php
0 → 100644
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/templates/forms/premium-versions-upgrade-metadata.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
wp-content/plugins/password-protected/freemius/templates/forms/subscription-cancellation.php
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment