public function __set($key, $value) { switch ($key) { case 'id': case 'name': case 'type': case 'max_length': case 'item_order': case 'public': case 'value': $this->_data[$key] = $value; break; case 'alias': debug_display('set ' . $key); die; throw new Exception('Attempt to set invalid data into field object: ' . $key); break; case 'create_date': case 'modified_date': break; default: debug_display('set ' . $key); die; throw new Exception('Attempt to set invalid data into field object: ' . $key); } }
private function get_template($name) { if (!is_array(self::$_templates) || !isset(self::$_templates[$name])) { if (!is_array(self::$_templates)) { self::$_templates = array(); } $templateops = cmsms()->GetTemplateOperations(); if ($name == -1) { $templateobj = $templateops->LoadDefaultTemplate(); } else { $templateobj = $templateops->LoadTemplateByID($name); } if (is_object($templateobj) && $templateobj !== FALSE) { $name = $templateobj->name; self::$_templates[$name] = $templateobj; } else { debug_display('no template ' . $name); } } if (isset(self::$_templates[$name])) { return self::$_templates[$name]; } }
public static function install_module($module_meta, $is_upgrade = FALSE) { // get the module xml to a temporary location $mod = cms_utils::get_module('ModuleManager'); $xml_filename = modulerep_client::get_repository_xml($module_meta['filename'], $module_meta['size']); if (!$xml_filename) { return array(FALSE, $mod->Lang('error_downloadxml', $module_meta['filename'])); } // get the md5sum of the data from the server. $server_md5 = modulerep_client::get_module_md5($module_meta['filename']); // verify the md5 $dl_md5 = md5_file($xml_filename); if ($server_md5 != $dl_md5) { @unlink($xml_filename); return array(FALSE, $mod->Lang('error_checksum', array($server_md5, $dl_md5))); } // expand the xml $ops = cmsms()->GetModuleOperations(); if (!$ops->ExpandXMLPackage($xml_filename, 1)) { debug_display('error:'); die($ops->GetLastError()); return array(FALSE, $ops->GetLastError()); } @unlink($xml_filename); // update the database. ModuleOperations::get_instance()->QueueForInstall($module_meta['name']); return array(true, ''); }
public function handle_upload($name, $destfilename = '', $subfield = false) { $fldname = $this->_prefix . $name; if (!isset($this->_files) || !isset($this->_files[$fldname])) { $this->_errno = self::NOFILE; return false; } $file = ''; if (empty($subfield)) { if (!is_array($this->_files[$fldname]) || !isset($this->_files[$fldname]['name']) || empty($this->_files[$fldname]['name'])) { // there's nothing to handle $this->_errno = self::NOFILE; return false; } else { $file = $this->_files[$fldname]; } } else { // the files are an array, so each element is an array // we gotta build $file from the $_FILES one step at a time $tmp = array(); foreach ($this->_files[$fldname] as $key => $value) { if (isset($value[$subfield])) { $tmp[$key] = $value[$subfield]; } } $file = $tmp; if (!is_array($file) || !isset($file['name']) || empty($file['name'])) { $this->_errno = self::NOFILE; return false; } } // Normalize the file variables if (!isset($file['type'])) { $file['type'] = ''; } if (!isset($file['size'])) { $file['size'] = ''; } if (!isset($file['tmp_name'])) { $file['tmp_name'] = ''; } $file['name'] = preg_replace('/[^a-zA-Z0-9\\.\\$\\%\'\\`\\-\\@\\{\\}\\~\\!\\#\\(\\)\\&\\_\\^]/', '', str_replace(array(' ', '%20'), array('_', '_'), $file['name'])); $extension = strrchr($file['name'], "."); // Check the file size if ($this->_maxfilesize > 0 && $file['size'] > $this->_maxfilesize || $file['size'] == 0) { debug_display($file); die; $this->_errno = self::FILESIZE; return false; } // Check the file extension if (!$this->is_accepted_file($file['name'])) { $this->_errno = self::FILETYPE; return false; } // check the destination directory if (!is_dir($this->_destdir)) { $this->_errno = self::BADDESTDIR; return false; } if (!is_writable($this->_destdir)) { $this->_errno = self::BADPERMS; return false; } $newname = $file['name']; if (empty($destfilename) && !empty($this->_destname)) { $destfilename = $this->_destname; } if (!empty($destfilename)) { // put the extensionof the input file on the new destination name. // this prevents a .jpg from being named a .gif or something. $destfilename = basename($destfilename); $textension = strrchr($destfilename, '.'); $tmp = substr($destfilename, 0, strlen($destfilename) - strlen($textension)); $newname = $tmp . $extension; } $destname = cms_join_path($this->_destdir, $newname); if (file_exists($destname)) { if (!$this->_allow_overwrite) { $this->_errno = self::FILEEXISTS; return false; } else { if (!is_writable($destname)) { $this->_errno = self::BADPERMS; return false; } } } // here we could do any preprocessing on the file. $srcname = $file['tmp_name']; $tmp = $this->preprocess_upload($file); if (!$tmp) { $this->_errno = self::PREPROCESSING_FAILED; return false; } $srcname = $tmp; // And Attempt the copy $this->_destname = $destname; $res = @copy($srcname, $destname); if (!$res) { $this->_errno = self::MOVEFAILED; return false; } return $newname; }
} header("Content-Type: {$ct}; charset=" . get_encoding()); echo $html; @ob_flush(); $endtime = microtime(); $db =& cmsms()->GetDb(); if ($config['debug'] == TRUE || isset($config['show_performance_info']) && $showtemplate == true) { $memory = function_exists('memory_get_usage') ? memory_get_usage() : 0; $memory = $memory - $orig_memory; $memory_peak = function_exists('memory_get_peak_usage') ? memory_get_peak_usage() : 0; if (!is_sitedown() && $config["debug"] == true) { echo "<p>Generated in " . microtime_diff($starttime, $endtime) . " seconds by CMS Made Simple using " . (isset($db->query_count) ? $db->query_count : '') . " SQL queries and {$memory} bytes of memory (peak memory usage was {$memory_peak})</p>"; } else { if (isset($config['show_performance_info']) && $showtemplate == true) { $txt = microtime_diff($starttime, $endtime) . " / " . (isset($db->query_count) ? $db->query_count : '') . " / {$memory} / {$memory_peak}"; debug_display($txt); echo '<!-- ' . $txt . " -->\n"; } } } if (is_sitedown() || $config['debug'] == true) { $smarty->clear_compiled_tpl(); } if (!is_sitedown() && $config["debug"] == true) { #$db->LogSQL(false); // turn off logging # output summary of SQL logging results #$perf = NewPerfMonitor($db); #echo $perf->SuspiciousSQL(); #echo $perf->ExpensiveSQL(); #echo $sql_queries; foreach ($gCms->errors as $error) {
function DebugDisplay() { $tmp = $this->form_ptr; $this->form_ptr = '[frmptr: ' . $tmp->GetId() . ']'; debug_display($this); $this->form_ptr = $tmp; }
/** * Display the debugging information. */ function display() { include_once TEMPLATE_PATH . 'debug.tpl'; debug_display($this->DBAccessNumber, $this->executionTime(), &$this->trackString, $this->foowd->config_settings['debug']['debug_var'], $this->foowd->template->values); }
<?php include 'header.php'; ?> <h3>welcome to flubber, <?php echo $_SESSION['username']; ?> </h3> <p>You may want to <a href="index.php?action=createGrid">create a grid</a> | <a href="index.php?action=logout">logout</a></p> <h2>Your grid was created successfully</h2> <?php debug_display($gridData); include 'footer.php';
$validinfo = false; } } if ($content == "") { $error .= "<li>" . lang('nofieldgiven', array(lang('content'))) . "</li>"; $validinfo = false; } if ($validinfo) { try { $parser = cmsms()->get_template_parser(); cms_utils::set_app_data('tmp_template', $content); try { $parser->fetch('template:appdata;tmp_template'); // do the magic. } catch (SmartyCompilerException $e) { debug_display($e); die; $error .= "<li>" . $e->getMessage() . '</li>'; $validinfo = false; } $contentBlocks = CMS_Content_Block::get_content_blocks(); if (!is_array($contentBlocks) || count($contentBlocks) == 0) { throw new CmsEditContentException('No content blocks defined in template'); } if (!isset($contentBlocks['content_en'])) { throw new CmsEditContentException('No default content block {content} or {content block=\'content_en\'} defined in template'); } // if we got here, we're golden. } catch (CmsEditContentException $e) { $error .= "<li>" . $e->getMessage() . '</li>'; $validinfo = false;
function StoreResponse($response_id = -1, $approver = '', &$formBuilderDisposition) { $mod = $this->module_ptr; $db = $this->module_ptr->dbHandle; $fields = $this->GetFields(); $newrec = false; $crypt = false; $hash_fields = false; $sort_fields = array(); // Check if form has Database fields, do init if (is_object($formBuilderDisposition) && ($formBuilderDisposition->GetFieldType() == 'DispositionFormBrowser' || $formBuilderDisposition->GetFieldType() == 'DispositionDatabase')) { $crypt = $formBuilderDisposition->GetOption('crypt', '0') == '1'; $hash_fields = $formBuilderDisposition->GetOption('hash_sort', '0') == '1'; for ($i = 0; $i < 5; $i++) { $sort_fields[$i] = $formBuilderDisposition->getSortFieldVal($i + 1); } } // If new field if ($response_id == -1) { if (is_object($formBuilderDisposition) && $formBuilderDisposition->GetOption('feu_bind', '0') == '1') { $feu = $mod->GetModuleInstance('FrontEndUsers'); if ($feu == false) { debug_display("FAILED to instatiate FEU!"); return; } $feu_id = $feu->LoggedInId(); } else { $feu_id = -1; } $response_id = $db->GenID(cms_db_prefix() . 'module_fb_formbrowser_seq'); foreach ($fields as $thisField) { // set the response_id to be the attribute of the database disposition if ($thisField->GetFieldType() == 'DispositionDatabase' || $thisField->GetFieldType() == 'DispositionFormBrowser') { $thisField->SetValue($response_id); } } $newrec = true; } else { $feu_id = $mod->getFEUIDFromResponseID($response_id); } // Convert form to XML $xml = $this->ResponseToXML(); // Do the actual adding if (!$crypt) { $output = $this->StoreResponseXML($response_id, $newrec, $approver, isset($sort_fields[0]) ? $sort_fields[0] : '', isset($sort_fields[1]) ? $sort_fields[1] : '', isset($sort_fields[2]) ? $sort_fields[2] : '', isset($sort_fields[3]) ? $sort_fields[3] : '', isset($sort_fields[4]) ? $sort_fields[4] : '', $feu_id, $xml); } elseif (!$hash_fields) { list($res, $xml) = $mod->crypt($xml, $formBuilderDisposition); if (!$res) { return array(false, $xml); } $output = $this->StoreResponseXML($response_id, $newrec, $approver, isset($sort_fields[0]) ? $sort_fields[0] : '', isset($sort_fields[1]) ? $sort_fields[1] : '', isset($sort_fields[2]) ? $sort_fields[2] : '', isset($sort_fields[3]) ? $sort_fields[3] : '', isset($sort_fields[4]) ? $sort_fields[4] : '', $feu_id, $xml); } else { list($res, $xml) = $mod->crypt($xml, $formBuilderDisposition); if (!$res) { return array(false, $xml); } $output = $this->StoreResponseXML($response_id, $newrec, $approver, isset($sort_fields[0]) ? $mod->getHashedSortFieldVal($sort_fields[0]) : '', isset($sort_fields[1]) ? $mod->getHashedSortFieldVal($sort_fields[1]) : '', isset($sort_fields[2]) ? $mod->getHashedSortFieldVal($sort_fields[2]) : '', isset($sort_fields[3]) ? $mod->getHashedSortFieldVal($sort_fields[3]) : '', isset($sort_fields[4]) ? $mod->getHashedSortFieldVal($sort_fields[4]) : '', $feu_id, $xml); } //return array(true,''); Stikki replaced: instead of true, return actual data, didn't saw any side effects. return $output; }
function HandleResponseFromXML(&$fbField, &$responseObj) { $crypt = $fbField->GetOption('crypt', '0'); if ($crypt == '1') { $cryptlib = $fbField->GetOption('crypt_lib'); $keyfile = $fbField->GetOption('keyfile'); if ($cryptlib == 'openssl') { $openssl = $this->GetModuleInstance('OpenSSL'); $pkey = $fbField->GetOption('private_key'); $openssl->Reset(); $openssl->load_private_keyfile($pkey, $keyfile); } else { if (file_exists($keyfile)) { $keyfile = file_get_contents($keyfile); } } } if ($crypt == '1') { if ($cryptlib == 'openssl') { $responseObj->xml = $openssl->decrypt_from_payload($responseObj->xml); if ($responseObj->xml == false) { debug_display($openssl->openssl_errors()); } } else { $responseObj->xml = $this->fbdecrypt($responseObj->xml, $keyfile); } } }
// insert field definitions if (empty($status)) { // delete existing custom field values first. $query = 'DELETE FROM ' . $this->event_field_values_table_name . ' WHERE event_id = ?'; $db->Execute($query, array($event['event_id'])); $query = 'INSERT INTO ' . $this->event_field_values_table_name . ' (field_name, event_id, field_value) VALUES (?,?,?)'; foreach ($fields as $field) { $fieldname = $field->name; //$field->value = get_parameter_value($params, 'field_' . $field->safename, ''); if (!empty($field->value)) { if ($field->searchable) { $fieldtext .= $field->value . ' '; } $dbr = $db->Execute($query, array($field->name, $event['event_id'], $field->value)); if (!$dbr) { debug_display($db->sql . ' -- ' . $db->ErrorMsg()); die; } } } } // insert category values if (empty($status)) { $query = 'DELETE FROM ' . $this->events_to_categories_table_name . ' WHERE event_id = ?'; $db->Execute($query, array($event['event_id'])); $query = 'INSERT INTO ' . $this->events_to_categories_table_name . ' (category_id,event_id) VALUES (?,?)'; foreach ($categories as &$one) { if (!$one->checked) { continue; } if ($one->id <= 0) {
/** * Debug an sql command * * @internal * @param string SQL query * @param boolean (unused) */ function debug_sql($str, $newline = false) { global $gCms; if ($gCms) { $config =& $gCms->GetConfig(); if ($config["debug"] == true) { $gCms->errors[] = debug_display($str, '', false, true); } } }
A Module for CMS Made Simple, Copyright (c) 2007 by Ted Kulp (wishy@cmsmadesimple.org) This project's homepage is: http://www.cmsmadesimple.org */ if (!isset($gCms)) { exit; } if (!$this->CheckAccess()) { exit; } $this->initialize(); $db = $this->GetDb(); $current_version = $oldversion; $dict = NewDataDictionary($db); $taboptarray = array('mysql' => 'TYPE=MyISAM'); debug_display('Current-version: ' . $current_version); switch ($current_version) { case "0.1": case "0.2": case "0.2.2": case "0.2.3": case "0.2.4": $flds = "\n\t\t\t\t\tsent_id I KEY,\n\t\t\t\t\tsrc_ip C(16),\n\t\t\t\t\tsent_time " . CMS_ADODB_DT; $sqlarray = $dict->CreateTableSQL(cms_db_prefix() . 'module_fb_ip_log', $flds, $taboptarray); $dict->ExecuteSQLArray($sqlarray); $db->CreateSequence(cms_db_prefix() . 'module_fb_ip_log_seq'); case "0.3": // read the old templates $temp_tab_left = file_get_contents(dirname(__FILE__) . '/templates/RenderFormTableTitleLeft.tpl'); $temp_tab_top = file_get_contents(dirname(__FILE__) . '/templates/RenderFormTableTitleTop.tpl'); $temp_tab_css = file_get_contents(dirname(__FILE__) . '/templates/RenderFormCSS.tpl');
<?php debug_display($_SESSION); ?> </body> </html>
/** * Debug an sql command * * @internal * @param string SQL query * @param boolean (unused) * Rolf: only used in lib/adodb.functions.php */ function debug_sql($str, $newline = false) { $config = cmsms()->GetConfig(); if ($config["debug"] == true) { cmsms()->add_error(debug_display($str, '', false, true)); } }
public static function expand_events($eventids, $returnid, $parameters, $limit = 10000, $startoffset = 0) { if (!is_array($eventids) || count($eventids) < 1) { return FALSE; } $module = cge_utils::get_module(MOD_CGCALENDAR); $gCms = CmsApp::get_instance(); $db = $gCms->GetDb(); $events_to_categories_table_name = $module->events_to_categories_table_name; $categories_table_name = $module->categories_table_name; $event_field_values_table_name = $module->event_field_values_table_name; $userops = $gCms->GetUserOperations(); $tmp = $userops->LoadUsers(); $users = array(); foreach ($tmp as $oneuser) { $users[$oneuser->id] = $oneuser; } $query = 'SELECT * FROM ' . $module->events_table_name . ' WHERE event_id IN (' . implode(',', $eventids) . ') ORDER BY event_date_start ASC'; $rs = $db->SelectLimit($query, $limit, $startoffset); $feu_users = array(); while (!$rs->EOF()) { $row = $rs->fields; $uid = $row['event_created_by']; if ($uid < 1 && !in_array($uid, $feu_users)) { $feu_users[] = $uid; } $rs->MoveNext(); } debug_display($feu_users); die; $rs->MoveFirst(); $events = array(); while ($rs && ($row = $rs->FetchRow())) { $titleSEO = munge_string_to_url($row['event_title']); $destpage = $module->GetPreference('defaultcalendarpage', -1); $destpage = $destpage > 0 ? $destpage : $returnid; //$destpage =$detailpage!=''?$detailpage:$destpage; $prefix = $module->GetPreference('url_prefix'); if (!$prefix) { $prefix = 'calendar'; } $prettyurl = sprintf($prefix . "/%d/%d-%s", $destpage, $row['event_id'], $titleSEO); $parms = array(); $parms['event_id'] = $row['event_id']; $parms['display'] = 'event'; if (isset($parameters['eventtemplate'])) { $parms['eventtemplate'] = $parameters['eventtemplate']; } $url = $module->CreateLink('cntnt01', 'default', $destpage, $contents = '', $parms, '', true, '', '', '', $prettyurl); $row['url'] = $url; $row['author'] = $users[$row['event_created_by']]->username; $row['authorname'] = $users[$row['event_created_by']]->firstname . ' ' . $users[$row['event_created_by']]->lastname; // Build the sql to retrieve the categories for this event. $sql = "SELECT category_name FROM {$events_to_categories_table_name}\n\t INNER JOIN {$categories_table_name} ON {$events_to_categories_table_name}.category_id = {$categories_table_name}.category_id\n\t WHERE event_id = ?"; $crs = $db->Execute($sql, array($row['event_id'])); // Get the field values $categories = array(); $categories_temp = array(); if ($crs) { // make sure there are results and assign to the $categories array $categories_temp = $crs->GetArray(); foreach ($categories_temp as $category) { $category_name = $category['category_name']; $categories[$category_name] = '1'; } } // Attach the custom fields to the event $row['categories'] = $categories; // Build the sql to retrieve the field values for this event. $sql = "SELECT field_name,field_value FROM {$event_field_values_table_name} WHERE event_id = ?"; $frs = $db->Execute($sql, array($row['event_id'])); // Get the field values $fields = array(); $fields_temp = array(); if ($frs) { // make sure there are results and assign to the $fields array $fields_temp = $frs->GetArray(); foreach ($fields_temp as $field) { $field_name = $field['field_name']; $field_value = $field['field_value']; $fields[$field_name] = $field_value; } } // Attach the custom fields to the event $row['fields'] = $fields; // End custom fields retrieval // and add it to the list of completed, expanded events. $events[] = $row; } if ($rs) { $rs->Close(); } return $events; }
public static function &from_array($data) { $obj = new CmsNls(); // name and key if (isset($data['englishlang'])) { foreach ($data['englishlang'] as $k => $v) { $obj->_fullname = $v; $obj->_key = $k; break; } } // get the display value if (isset($data['language'][$obj->_key])) { $obj->_display = $data['language'][$obj->_key]; } // get the isocode? if (isset($data['isocode'][$obj->_key])) { $obj->_isocode = $data['isocode'][$obj->_key]; } else { $t = explode('_', $obj->_key); if (is_array($t) && count($t)) { $obj->_isocode = $t[0]; } } // get the locale if (isset($data['locale'][$obj->_key])) { $obj->_locale = $data['locale'][$obj->_key]; } // get the encoding if (isset($data['encoding'][$obj->_key])) { $obj->_encoding = $data['encoding'][$obj->_key]; } if (isset($data['htmlarea'][$obj->_key])) { $obj->_htmlarea = $data['htmlarea'][$obj->_key]; } // get the direction if (isset($data['direction'][$obj->_key])) { $obj->_direction = $data['direction'][$obj->_key]; } // get aliases if (isset($data['alias'])) { $obj->_aliases = array_keys($data['alias']); } if ($obj->_key == '') { debug_display($data); debug_display($obj); die; } return $obj; }
} if (!isset($params['form_id']) && isset($params['form'])) { // get the form by name, not ID $params['form_id'] = $this->GetFormIDFromAlias($params['form']); } $inline = false; if (isset($params['inline']) && preg_match('/t(rue)*|y(yes)*|1/i', $params['inline'])) { $inline = true; } $fbrp_callcount = 0; $aeform = new fbForm($this, $params, true, true); $fld = $aeform->GetFormBrowserField(); if ($fld !== false && $fld->GetOption('feu_bind', '0') == '1') { $feu = $this->GetModuleInstance('FrontEndUsers'); if ($feu == false) { debug_display("FAILED to instantiate FEU!"); return; } if ($feu->LoggedInId() === false) { echo $this->Lang('please_login'); return; } } if (!($inline || $aeform->GetAttr('inline', '0') == '1')) { $id = 'cntnt01'; } $this->smarty->assign('fb_form_has_validation_errors', 0); $this->smarty->assign('fb_show_submission_errors', 0); $this->smarty->assign('fb_form_header', $aeform->RenderFormHeader()); $this->smarty->assign('fb_form_footer', $aeform->RenderFormFooter()); $finished = false;
"/> <span class="tip">[you can leave prefix and suffix empty; 1 will taken as default value is starting from field is emtpy]</span> </p> </div> <div class="grid_step2_additional_options" id="grid_step2_lookup_div"> <p>which column in this grid : <?php displaySelectBox($currentColumns, "grid_step2_lookup_fromcolumn", "grid_step2_lookup_fromcolumn", get_form_value($grid_step2_column_data, "grid_step2_column" . $current_column . "_lookup_fromcolumn")); ?> </p> <p>length of field : <input type="text" size="2" name="grid_step2_lookup_size" /></p> <p>select grid : <select id="grid_step2_lookup_gridname" name="grid_step2_lookup_gridname"></select> </p> <p>select column : <select id="grid_step2_lookup_columnname" name="grid_step2_lookup_columnname"></select> </p> <p>partial match? <input type="checkbox" name="grid_step2_lookup_partial" /></p> <p>match mandatory? <input type="checkbox" name="grid_step2_lookup_mandatory" /></p> </div> </fieldset> <input type="hidden" id="grid_step2_column_datatype_val" value="<?php echo $grid_step2_column_datatype; ?> "/> <input type="hidden" name="grid_step2_column_no" value="<?php echo $current_column; ?> "/> <p><input type="submit" name="grid_step2_submit" value="next"></p> </form> <?php debug_display($grid_step2_column_data); debug_display($_SESSION['gridData']); include 'footer.php';