/** * load template custom data */ protected function loadCustomData() { parent::loadCustomData(); $res = DB\dbQuery('SELECT l' . \CB\Config::get('user_language_index') . ' `title` ,`' . implode('`,`', $this->tableFields) . '` FROM templates_structure WHERE id = $1', $this->id) or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { $r['cfg'] = Util\toJSONArray($r['cfg']); $this->data = array_merge($this->data, $r); } else { \CB\debug("Template field load error: no field found with id = " . $this->id); // throw new \Exception("Template field load error: no field found with id = ".$this->id); } $res->close(); }
/** * load template custom data */ protected function loadCustomData() { parent::loadCustomData(); $r = DM\Objects::read($this->id); if (!empty($r)) { $r = $r['data']; } else { //read from templates_structure if object not present in tree // for backward compatibility $r = DM\TemplatesStructure::read($this->id); } if (!empty($r)) { if (isset($r['cfg'])) { $r['cfg'] = Util\toJSONArray($r['cfg']); } $r['title'] = Util\detectTitle($r); $this->data = array_merge($this->data, $r); } else { \CB\debug("Template field load error: no field found with id = " . $this->id); // throw new \Exception("Template field load error: no field found with id = ".$this->id); } }
public static function generatePreview($id, $versionId = false) { $rez = array(); $file = array(); $coreName = Config::get('core_name'); $coreUrl = Config::get('core_url'); $filesDir = Config::get('files_dir'); $filesPreviewDir = Config::get('files_preview_dir'); if (!empty($versionId)) { $file = DM\FilesVersions::read($versionId); $file['version_id'] = $versionId; $file['id'] = $id; } else { $file = DM\Files::read($id); } if (empty($file)) { \CB\debug('Error accessing file preview (' . $id . '). Record not found in DB.'); return array('html' => ''); } $content = DM\FilesContent::read($file['content_id']); $preview = DM\FilePreviews::read($content['id']); if (!empty($preview)) { switch ($preview['status']) { case 1: case 2: return array('processing' => true); case 3: return array('html' => L\get('ErrorCreatingPreview')); } } $ext = explode('.', $file['name']); $ext = array_pop($ext); $ext = strtolower($ext); $rez['ext'] = $ext; $rez['filename'] = $content['id'] . '_.html'; $previewFilename = $filesPreviewDir . $rez['filename']; $fn = $filesDir . $content['path'] . DIRECTORY_SEPARATOR . $content['id']; // $nfn = $filesPreviewDir . $content['id'] . '_.' . $ext; if (!file_exists($fn)) { \CB\debug('Error accessing file preview (' . $id . '). Its content (id: ' . @$content['id'] . ') doesnt exist on the disk.'); return false; } switch ($ext) { case 'rtf': case 'doc': case 'xls': case 'csv': case 'ppt': case 'pps': case 'docx': case 'docm': case 'xlsx': case 'pptx': case 'odt': if (empty($preview)) { DM\FilePreviews::create(array('id' => $content['id'], 'group' => 'office', 'status' => 1, 'filename' => null, 'size' => 0, 'cdate' => 'CURRENT_TIMESTAMP')); } if (file_exists($previewFilename)) { Files::deletePreview($content['id']); } $cmd = 'php -f ' . LIB_DIR . 'PreviewExtractorOffice.php -- -c ' . $coreName . ' > ' . Config::get('debug_log') . '_office &'; if (IS_WINDOWS) { $cmd = 'start /D "' . LIB_DIR . '" php -f PreviewExtractorOffice.php -- -c ' . $coreName . ' > ' . Config::get('debug_log') . '_office'; } pclose(popen($cmd, "r")); return array('processing' => true); break; case 'xml': case 'htm': case 'html': case 'dhtml': case 'xhtml': require_once LIB_DIR . 'PreviewExtractor.php'; $content = file_get_contents($fn); $pe = new PreviewExtractor(); $content = $pe->purify($content, array('URI.Base' => '/' . $coreName . '/', 'URI.MakeAbsolute' => true)); file_put_contents($previewFilename, $content); //copy($fn, $previewFilename); break; case 'txt': case 'log': case 'css': case 'js': case 'json': case 'php': case 'bat': case 'ini': case 'sys': case 'sql': file_put_contents($previewFilename, '<pre>' . Util\adjustTextForDisplay(file_get_contents($fn)) . '<pre>'); break; case 'pdf': $html = 'PDF'; //Ext panel - PreviewPanel view if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { //full browser window view $url = $coreUrl . 'download/' . $file['id'] . '/'; $html = ' <object data="' . $url . '" type="application/pdf" width="100%" height="100%"> It appears you don\'t have Adobe Reader or PDF support in this web browser. <a href="' . $url . '">Click here to download the file</a> <embed src="' . $url . '" type="application/pdf" /> </object>'; } return array('html' => $html); break; case 'tif': case 'tiff': case 'svg': $pfn = $filesPreviewDir . $content['id']; $convertedImages = array($pfn . '_.png'); if (!file_exists($convertedImages[0])) { $convertedImages = array(); try { $images = new \Imagick($fn); $i = 1; foreach ($images as $image) { $image->setImageFormat('png'); $image->writeImage($pfn . $i . '_.png'); $convertedImages[] = $content['id'] . $i . '_.png'; $i++; } } catch (\Exception $e) { return $rez; } } file_put_contents($previewFilename, '<img src="/' . $coreName . '/view/' . implode('" class="fit-img" style="margin: auto" />' . "<br /><hr />\n" . '<img src="/' . $coreName . '/view/', $convertedImages) . '" class="fit-img" style="margin: auto" />'); break; default: if (substr($content['type'], 0, 5) == 'image' && substr($content['type'], 0, 9) !== 'image/svg') { file_put_contents($previewFilename, '<div style="padding: 5px 10px"><img src="/' . $coreName . '/download/' . $file['id'] . (empty($version_id) ? '' : '/' . $version_id) . '/" class="fit-img" style="margin: auto"></div>'); } } if (!empty($preview)) { DM\FilePreviews::update(array('id' => $content['id'], 'filename' => $rez['filename'])); } else { DM\FilePreviews::create(array('id' => $content['id'], 'filename' => $rez['filename'])); } return $rez; }
} $emailFrom = extractEmailFromText($mail['from']); // user email $emailTo = extractEmailFromText($mail['to']); // <*****@*****.**> $userId = DM\User::getIdByEmail($emailFrom); $_SESSION['user'] = array('id' => $userId); $data = array('id' => null, 'pid' => $mail['pid'], 'oid' => $userId, 'cid' => $userId, 'template_id' => $templateId, 'data' => array('_title' => removeContentExtraBlock($mail['content'], $emailFrom, $emailTo)), 'sys_data' => array('mailId' => $mail['id'])); try { $commentId = $commentsObj->create($data); //add attachments if (!empty($mail['attachments'])) { saveObjectAttachments($commentId, $mail['attachments']); } } catch (Exception $e) { \CB\debug('Cannot create comment from ' . $mail['from'], $data); } $deleteMailIds[] = $mail['id']; } } if (!empty($mailConf['mailbox'])) { deleteMails($mailConf['mailbox'], $deleteMailIds); } // \CB\Solr\Client::runBackgroundCron(); } function processMails(&$mailServer) { $rez = ''; $dids = array(); //array for deleted ids $i = 0;
/** * add a security rule for an item * @param array $p json request * @return json response */ public function addObjectAccess($p) { $rez = array('success' => true, 'data' => array()); if (empty($p['data'])) { return $rez; } if (!Security::isAdmin() && !Security::canChangePermissions($p['id'])) { throw new \Exception(L\get('Access_denied')); } DB\dbQuery('INSERT INTO tree_acl (node_id, user_group_id, cid, uid) VALUES ($1, $2, $3, $3) ON DUPLICATE KEY UPDATE id = last_insert_id(id) ,uid = $3', array($p['id'], $p['data']['user_group_id'], User::getId())); $p['data']['id'] = $p['data']['user_group_id']; $rez['data'][] = $p['data']; \CB\debug($rez); Security::calculateUpdatedSecuritySets(); Solr\Client::runBackgroundCron(); return $rez; }
/** * optimize current solr core * @return null */ public function optimize() { try { $this->solr_handler->optimize(); $this->commit(); } catch (\Exception $e) { $msg = "Cannot optimize solr core" . $this->debugInfo(); \CB\debug($msg); throw new \Exception($msg, 1); } }
public static function generatePreview($id, $version_id = false) { $rez = array(); $file = array(); $coreName = Config::get('core_name'); $coreUrl = Config::get('core_url'); $filesDir = Config::get('files_dir'); $filesPreviewDir = Config::get('files_preview_dir'); $sql = 'SELECT f.id ,f.content_id ,f.name ,c.path ,c.`type` ,p.status FROM files f LEFT JOIN files_content c ON f.content_id = c.id LEFT JOIN file_previews p ON c.id = p.id WHERE f.id = $1 AND c.size > 0'; if (!empty($version_id)) { $sql = 'SELECT $1 `id` ,f.id `version_id` ,f.content_id ,f.name ,c.path ,c.`type` ,p.status FROM files_versions f LEFT JOIN files_content c ON f.content_id = c.id LEFT JOIN file_previews p ON c.id = p.id WHERE f.file_id = $1 AND f.id = $2 AND c.size > 0'; } $res = DB\dbQuery($sql, array($id, $version_id)) or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { $file = $r; } $res->close(); if (empty($file)) { \CB\debug('Error accessing file preview (' . $id . '). Record not found in DB.'); return array('html' => ''); } switch ($file['status']) { case 1: case 2: return array('processing' => true); case 3: return array('html' => L\get('ErrorCreatingPreview')); } $ext = explode('.', $file['name']); $ext = array_pop($ext); $ext = strtolower($ext); $rez['ext'] = $ext; $rez['filename'] = $file['content_id'] . '_.html'; $preview_filename = $filesPreviewDir . $rez['filename']; $fn = $filesDir . $file['path'] . DIRECTORY_SEPARATOR . $file['content_id']; $nfn = $filesPreviewDir . $file['content_id'] . '_.' . $ext; if (!file_exists($fn)) { \CB\debug('Error accessing file preview (' . $id . '). Its content (id: ' . @$file['content_id'] . ') doesnt exist on the disk.'); return false; } switch ($ext) { case 'rtf': case 'doc': case 'xls': case 'csv': case 'ppt': case 'pps': case 'docx': case 'docm': case 'xlsx': case 'pptx': case 'odt': DB\dbQuery('INSERT INTO file_previews (id, `group`, status, filename, SIZE) VALUES($1 ,\'office\' ,1 ,NULL ,0) ON DUPLICATE KEY UPDATE `group` = \'office\' ,status =1 ,filename = NULL ,SIZE = 0 ,cdate = CURRENT_TIMESTAMP', $file['content_id']) or die(DB\dbQueryError()); if (file_exists($preview_filename)) { Files::deletePreview($file['content_id']); } $cmd = 'php -f ' . LIB_DIR . 'PreviewExtractorOffice.php -- -c ' . $coreName . ' > ' . Config::get('debug_log') . '_office &'; if (IS_WINDOWS) { $cmd = 'start /D "' . LIB_DIR . '" php -f PreviewExtractorOffice.php -- -c ' . $coreName; } pclose(popen($cmd, "r")); return array('processing' => true); break; case 'xml': case 'htm': case 'html': case 'dhtml': case 'xhtml': //file_put_contents( $preview_filename, Files::purify(file_get_contents($fn)) ); require_once LIB_DIR . 'PreviewExtractor.php'; $content = file_get_contents($fn); $pe = new PreviewExtractor(); $content = $pe->purify($content, array('URI.Base' => '/' . $coreName . '/', 'URI.MakeAbsolute' => true)); file_put_contents($preview_filename, $content); //copy($fn, $preview_filename); break; case 'txt': case 'css': case 'js': case 'json': case 'php': case 'bat': case 'ini': case 'sys': case 'sql': file_put_contents($preview_filename, '<pre>' . Util\adjustTextForDisplay(file_get_contents($fn)) . '<pre>'); break; case 'pdf': $html = 'PDF'; //Ext panel - PreviewPanel view if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { //full browser window view $url = $coreUrl . 'download/' . $file['id'] . '/'; $html = ' <object data="' . $url . '" type="application/pdf" width="100%" height="100%"> It appears you don\'t have Adobe Reader or PDF support in this web browser. <a href="' . $url . '">Click here to download the file</a> <embed src="' . $url . '" type="application/pdf" /> </object>'; } return array('html' => $html); break; case 'tif': case 'tiff': case 'svg': $convertedImage = $filesPreviewDir . $file['content_id'] . '_.png'; if (!file_exists($convertedImage)) { try { $image = new \Imagick($fn); $image->setImageFormat('png'); $image->writeImage($convertedImage); } catch (\Exception $e) { return $rez; } } file_put_contents($preview_filename, '<img src="/' . $coreName . '/view/' . $file['content_id'] . '_.png" class="fit-img" style="margin: auto" />'); break; default: if (substr($file['type'], 0, 5) == 'image' && substr($file['type'], 0, 9) !== 'image/svg') { file_put_contents($preview_filename, '<div style="padding: 5px 10px"><img src="/' . $coreName . '/download/' . $file['id'] . (empty($version_id) ? '' : '/' . $version_id) . '/" class="fit-img" style="margin: auto"></div>'); } } return $rez; }
/** * method used to implement custom logic on solr query * @param array $p search params * @return void */ public function onSolrQuery(&$p) { $this->params =& $p; $ip =& $p['inputParams']; if (@$ip['view']['type'] !== $this->fromParam) { return; } // $sp = &$p['params']; $result =& $p['result']; $view =& $result['view']; $data =& $result['data']; $rez = array(); $displayColumns = $this->getDC(); //This if remains as backward compatible, but will be removed in future commits if (!empty($displayColumns['sort'])) { $view['sort'] = $displayColumns['sort']; } //get state $stateFrom = empty($displayColumns['from']) ? 'default' : $displayColumns['from']; $state = $this->getState($stateFrom); $customColumns = $this->prepareColumnsConfig($displayColumns); //set custom display columns data if (!empty($displayColumns['data'])) { // fill custom columns data foreach ($data as &$doc) { if (!is_numeric($doc['id'])) { continue; } $obj = \CB\Objects::getCachedObject($doc['id']); if (!is_object($obj)) { \CB\debug('DisplayColumns object not found: ' . $doc['id']); continue; } $template = $obj->getTemplate(); foreach ($customColumns as $fieldName => &$col) { $templateField = $template->getField($col['fieldName']); $values = array(); if (!empty($col['solr_column_name'])) { if (isset($doc[$col['solr_column_name']]) && $col['solr_column_name'] !== $col['fieldName']) { $v = $doc[$col['solr_column_name']]; $doc[$col['fieldName']] = $v; unset($doc[$col['solr_column_name']]); $values = array($v); } if (empty($templateField)) { $templateField = array('type' => empty($col['fieldType']) ? 'varchar' : $col['fieldType'], 'name' => $col['solr_column_name'], 'title' => Util\detectTitle($col)); } } elseif (!empty($col['lookup'])) { //lookup field $values = $obj->getLookupValues($col['lookup'], $templateField); } else { //default $values = isset($doc[$col['fieldName']]) ? array($doc[$col['fieldName']]) : $obj->getFieldValue($col['fieldName']); } //populate column properties if empty if (empty($col['title'])) { $col['title'] = $templateField['title']; } if (empty($col['sortType']) && empty($col['solr_column_name'])) { switch ($templateField['type']) { case 'date': case 'datetime': $col['sortType'] = 'asDate'; break; case 'float': $col['sortType'] = 'asFloat'; break; case 'checkbox': case 'int': $col['sortType'] = 'asInt'; break; case 'html': case 'memo': case 'text': $col['sortType'] = 'asUCText'; break; case '_objects': default: $col['sortType'] = 'asUCString'; break; } } //update value from document if empty from solr query if (empty($doc[$fieldName]) || in_array($templateField['type'], array('_objects', 'time'))) { $dv = array(); foreach ($values as $value) { $value = is_array($value) ? @$value['value'] : $value; $dv[] = $template->formatValueForDisplay($templateField, $value, false); } $doc[$fieldName] = implode(', ', $dv); } } } /* remove columns without title */ foreach ($customColumns as $fieldName => &$col) { if (empty($col['title'])) { unset($customColumns[$fieldName]); } } $rez = $customColumns; } /* merge the state with display columns */ $defaultColumns = array_keys(Config::getDefaultGridViewColumns()); if (!empty($state['columns'])) { $rez = array(); foreach ($state['columns'] as $k => $c) { if (!empty($customColumns[$k])) { unset($customColumns[$k]['hidden']); $c = array_merge($customColumns[$k], $c); unset($customColumns[$k]); $rez[$k] = $c; } elseif (in_array($k, $defaultColumns)) { $rez[$k] = $c; } } if (!empty($customColumns)) { $rez = array_merge($rez, $customColumns); } } /* user clicked a column to sort by */ if (!empty($ip['userSort'])) { $view['sort'] = array('property' => $ip['sort'][0]['property'], 'direction' => $ip['sort'][0]['direction']); } elseif (!empty($state['sort'])) { $view['sort'] = $state['sort']; } /* end of get user state and merge the state with display columns */ //check grouping params if (!empty($ip['userGroup']) && !empty($ip['group'])) { $view['group'] = array('property' => $ip['sourceGroupField'], 'direction' => $ip['group']['direction']); } elseif (isset($state['group'])) { $view['group'] = $state['group']; } elseif (isset($displayColumns['group'])) { $view['group'] = $displayColumns['group']; } //analize grouping $this->analizeGrouping($p); if (!empty($rez)) { $result['DC'] = $rez; } /* check if we need to sort records using php (in case sort field is not from solr)*/ if (!empty($view['sort']) && !empty($rez[$view['sort']['property']]['localSort']) && !in_array($view['sort']['property'], $defaultColumns)) { $s =& $view['sort']; Util\sortRecordsArray($data, $s['property'], $s['direction'], empty($rez[$s['property']]['sortType']) ? 'asString' : $rez[$s['property']]['sortType']); } }
private static function adjustConfig($cfg) { /* post processing the obtained config */ //facet definitions defined globally in casebox config $dfd = array(); if (!empty($cfg['default_facet_configs'])) { $dfd = Util\toJSONArray($cfg['default_facet_configs']); unset($cfg['default_facet_configs']); } //check if have defined facets in core config if (!empty($cfg['facet_configs'])) { $dfd = array_merge($dfd, Util\toJSONArray($cfg['facet_configs'])); } $cfg['facet_configs'] = $dfd; //transform boolean properties to boolean $boolProperties = array('allow_duplicates'); foreach ($boolProperties as $property) { if (isset($cfg[$property])) { $cfg[$property] = in_array($cfg[$property], array('true', true, 'y', 1, '1'), true); } } //end of transform boolean properties to boolean // detect core plugins (use defined or default if set) $plugins = array(); if (!empty($cfg['default_plugins'])) { $plugins = $cfg['default_plugins']; } if (!empty($cfg['plugins'])) { $plugins = Util\toJSONArray($cfg['plugins']); } $cfg['plugins'] = $plugins; // end of detect plugins //decode properties of the core config that should be json $jsonProperties = array('api', 'css', 'comments_config', 'files', 'js', 'plugins', 'listeners', 'node_facets', 'node_DC', 'default_DC', 'default_object_plugins', 'object_type_plugins', 'treeNodes', 'action_log', 'maintenance'); foreach ($jsonProperties as $property) { if (!empty($cfg[$property])) { $cfg[$property] = Util\toJSONArray($cfg[$property]); if (empty($cfg[$property])) { \CB\debug($cfg['core_name'] . ': Error parsing json config for property "' . $property . '".'); } } } //change date formats from mysql to php if (!empty($cfg['language_settings'])) { foreach ($cfg['language_settings'] as $k => &$v) { $v['long_date_format'] = str_replace('%', '', $v['long_date_format']); $v['short_date_format'] = str_replace('%', '', $v['short_date_format']); $v['time_format'] = str_replace('%', '', $v['time_format']); } } return static::adjustPaths($cfg); }
/** * get list of facets classes that should be available for this node * @param array &$rp request params * @return array */ public function getFacets(&$rp) { $facets = array(); $cfg = $this->getNodeParam('facets'); if (empty($cfg['data'])) { return $facets; } //creating facets $facetsDefinitions = \CB\Config::get('facet_configs'); foreach ($cfg['data'] as $k => $v) { $name = $k; $config = null; if (is_scalar($v)) { $name = $v; if (!empty($facetsDefinitions[$name])) { $config = $facetsDefinitions[$name]; } } else { $config = $v; } if (is_null($config)) { \CB\debug('Cannot find facet config:' . var_export($name, 1) . var_export($v, 1)); } else { $config['name'] = $name; $facets[$name] = \CB\Facets::getFacetObject($config); } } if (!empty($rp['view']['type'])) { $v =& $rp['view']; $rows = false; $cols = false; if (!empty($v['rows']['facet'])) { $rows = $v['rows']['facet']; } if (!empty($v['cols']['facet'])) { $cols = $v['cols']['facet']; } if ($rp['view']['type'] == 'pivot' && sizeof($facets) > 1) { if (!empty($rp['selectedFacets']) && is_array($rp['selectedFacets']) && sizeof($rp['selectedFacets'] > 1)) { $rows = $rp['selectedFacets'][0]; $cols = $rp['selectedFacets'][1]; } reset($facets); if (empty($rows)) { $rows = current($facets); next($facets); } if (empty($cols)) { $cols = current($facets); } if (is_scalar($rows) || is_scalar($cols)) { foreach ($facets as $facet) { if (is_scalar($rows) && $facet->field == $rows) { $rows = $facet; } if (is_scalar($cols) && $facet->field == $cols) { $cols = $facet; } } } $config = array('type' => 'pivot', 'name' => 'pivot', 'facet1' => $rows, 'facet2' => $cols); if (!empty($rp['selectedStat'])) { $config['stats'] = $rp['selectedStat']; } elseif (!empty($cfg['view']['stats'])) { $config['stats'] = $cfg['view']['stats']; } $facets[] = \CB\Facets::getFacetObject($config); } } return $facets; }
public function execute() { $this->init(); $processing = false; $res = DB\dbQuery('SELECT count(*) `count` FROM file_previews WHERE `status` = 2 AND `group` = $1', 'office') or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { $processing = $r['count'] > 0; } $res->close(); if ($processing) { exit(0); } $filesPreviewDir = Config::get('files_preview_dir'); $sql = 'SELECT c.id `content_id`, c.path, p.status ,(SELECT name FROM files f WHERE f.content_id = c.id LIMIT 1 ) `name` FROM file_previews p LEFT JOIN files_content c ON p.id = c.id WHERE p.`status` = 1 AND `group` = \'office\' ORDER BY p.cdate'; $res = DB\dbQuery($sql) or die(DB\dbQueryError()); while ($r = $res->fetch_assoc()) { //start the transaction so that the file status would not change on script fail DB\startTransaction(); DB\dbQuery('UPDATE file_previews SET `status` = 2 WHERE id = $1', $r['content_id']) or die(DB\dbQueryError()); $ext = explode('.', $r['name']); $ext = array_pop($ext); $ext = strtolower($ext); $fn = Config::get('files_dir') . $r['path'] . DIRECTORY_SEPARATOR . $r['content_id']; $nfn = $filesPreviewDir . $r['content_id'] . '_.' . $ext; $pfn = $filesPreviewDir . $r['content_id'] . '_.html'; copy($fn, $nfn); file_put_contents($pfn, ''); $cmd = Config::get('UNOCONV') . ' -v -f html -o ' . $pfn . ' ' . $nfn; //.' >> ' . Config::get('debug_log') . ' 2>&1'; exec($cmd, $output, $returnStatus); //returnStatus should be 0 if no error //we cant delete the file right away //because command can execute in background and could take some time //unlink($nfn); if (empty($returnStatus) && file_exists($pfn)) { file_put_contents($pfn, '<div style="padding: 5px">' . $this->purify(file_get_contents($pfn), array('URI.Base' => '/' . Config::get('core_name') . '/view/', 'URI.MakeAbsolute' => true)) . '</div>'); DB\dbQuery('UPDATE file_previews SET `status` = 0 ,`filename` = $2 ,`size` = $3 WHERE id = $1', array($r['content_id'], $r['content_id'] . '_.html', filesize($pfn))) or die(DB\dbQueryError()); $res->close(); } else { //preview not generated for some reason, probably unoconv service not started \CB\debug('UNOCONV execution error, please check if python accesible through command line' . ' and if correctly specified in config.ini: ' . $cmd); DB\dbQuery('UPDATE file_previews SET `status` = 3 WHERE id = $1', $r['content_id']) or die(DB\dbQueryError()); } DB\commitTransaction(); $res = DB\dbQuery($sql) or die(DB\dbQueryError()); } $res->close(); }
/** * verify a given code * @param varchar $code one tyme password * @return bool */ public function verifyCode($code) { $rez = true; if (substr($this->secretData['code'], 0, 12) != substr($code, 0, 12)) { $rez = false; } else { try { $auth = $this->instance->verify($code); } catch (\Exception $e) { $rez = false; \CB\debug($e->getMessage()); } } return $rez; }
public static function getRootFolderId() { if (defined('CB\\ROOT_FOLDER_ID')) { return constant('CB\\ROOT_FOLDER_ID'); } $id = DM\Tree::getRootId(); if (empty($id)) { \CB\debug('Cant find root folder.'); } define('CB\\ROOT_FOLDER_ID', $id); return $id; }