function cs2cs_core2($lat, $lon, $to) { $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); if (mb_eregi('^[a-z0-9_ ,.\\+\\-=]*$', $to) == 0) { die("invalid arguments in command: " . $to . "\n"); } $command = CS2CS . " +proj=latlong +ellps=WGS84 +to " . $to; $process = proc_open($command, $descriptorspec, $pipes); if (is_resource($process)) { fwrite($pipes[0], $lon . " " . $lat); fclose($pipes[0]); $stdout = stream_get_contents($pipes[1]); fclose($pipes[1]); $stderr = stream_get_contents($pipes[2]); fclose($pipes[2]); // // $procstat = proc_get_status($process); // // neither proc_close nor proc_get_status return reasonable results with PHP5 and linux 2.6.11, // see http://bugs.php.net/bug.php?id=32533 // // as temporary (?) workaround, check stderr output. // (Vinnie, 2006-02-09) if ($stderr) { die("proc_open() failed:<br />command='{$command}'<br />stderr='" . $stderr . "'"); } proc_close($process); return mb_split("\t|\n| ", mb_trim($stdout)); } else { die("proc_open() failed, command={$command}\n"); } }
/** * Validates a string as a time. * * @param string $value data to filter * @return int filtered value */ protected function doTransform($value) { $value = mb_trim($value); $regex = '/^(\\d\\d?)[\\.\\:]?(\\d\\d)?\\s*(am|pm)?$/i'; $matches = null; if (!preg_match($regex, $value, $matches)) { $this->triggerError(); } $hour = $matches[1]; $min = isset($matches[2]) ? $matches[2] : false; $am_or_pm = isset($matches[3]) ? $matches[3] : false; if ($min === false && $am_or_pm === false) { $this->triggerError(); } $hour = (int) ltrim($hour, '0'); if ($hour > 23 || $am_or_pm !== false && $hour > 12) { $this->triggerError(); } $min = (int) ltrim($min, '0'); if ($min > 59) { $this->triggerError(); } if (strcasecmp($am_or_pm, 'pm') === 0) { $hour += 12; if ($hour == 24) { $hour = 12; } } elseif (strcasecmp($am_or_pm, 'am') === 0 && $hour == 12) { $hour = 0; } return $hour * 60 * 60 + $min * 60; }
function parseOutputLine($str) { $nLon = 0; $nLat = 0; $parts = explode_multi(mb_trim($str), "\t\n "); if (count($parts) == 3) { if (strpos($parts[0], '\'') === false) { preg_match('/^(\\d+)dE$/', $parts[0], $aLon); $nLon = $aLon[1]; } else { if (strpos($parts[0], '"') === false) { preg_match('/^(\\d+)d(\\d+)\'E$/', $parts[0], $aLon); $nLon = $aLon[1] + $aLon[2] / 60; } else { preg_match('/^(\\d+)d(\\d+)\'([\\d\\.]+)"E$/', $parts[0], $aLon); $nLon = $aLon[1] + $aLon[2] / 60 + $aLon[3] / 3600; } } if (strpos($parts[1], '\'') === false) { preg_match('/^(\\d+)dN$/', $parts[1], $aLat); $nLat = $aLat[1]; } else { if (strpos($parts[1], '"') === false) { preg_match('/^(\\d+)d(\\d+)\'N$/', $parts[1], $aLat); $nLat = $aLat[1] + $aLat[2] / 60; } else { preg_match('/^(\\d+)d(\\d+)\'([\\d+\\.]+)"N$/', $parts[1], $aLat); $nLat = $aLat[1] + $aLat[2] / 60 + $aLat[3] / 3600; } } } $coord = array('lon' => $nLon, 'lat' => $nLat); return $coord; }
function test_encoding($path) { static $ur_exclude = array('lang/de/ocstyle/search1/search.result.caches', 'lib2/b2evo-captcha', 'lib2/HTMLPurifier', 'lib2/html2text.class.php', 'lib2/imagebmp.inc.php', 'lib2/Net/IDNA2', 'lib2/smarty'); $contents = file_get_contents($path, false, null, 0, 2048); $ur = stripos($contents, "Unicode Reminder"); if ($ur) { if (mb_trim(mb_substr($contents, $ur + 17, 2)) != "メモ") { $ur = mb_stripos($contents, "Unicode Reminder"); if (mb_trim(mb_substr($contents, $ur + 17, 2)) != "メモ") { echo "Bad Unicode Reminder found in {$path}: " . mb_trim(mb_substr($contents, $ur + 17, 2)) . "\n"; } else { echo "Unexpected non-ASCII chars (BOMs?) in header of {$path}\n"; } } } else { $ok = false; foreach ($ur_exclude as $exclude) { if (mb_strpos($path, $exclude) === 0) { $ok = true; } } if (!$ok) { echo "No Unicode Reminder found in {$path}\n"; } } }
function test_encoding($path) { static $ur_exclude = ['lib2/html2text.class.php', 'lib2/imagebmp.inc.php', 'lib2/Net/IDNA2']; $contents = file_get_contents($path, false, null, 0, 2048); $ur = stripos($contents, "Unicode Reminder"); if ($ur) { if (mb_trim(mb_substr($contents, $ur + 17, 2)) != "メモ") { $ur = mb_stripos($contents, "Unicode Reminder"); if (mb_trim(mb_substr($contents, $ur + 17, 2)) != "メモ") { echo "Bad Unicode Reminder found in {$path}: " . mb_trim(mb_substr($contents, $ur + 17, 2)) . "\n"; } else { echo "Unexpected non-ASCII chars (BOMs?) in header of {$path}\n"; } } } else { $ok = false; foreach ($ur_exclude as $exclude) { if (mb_strpos($path, $exclude) === 0) { $ok = true; } } if (!$ok) { echo "No Unicode Reminder found in {$path}\n"; } } }
public function index() { $tags = array(); if (!empty($this->data['Study']['search'])) { $tags = mb_convert_kana(mb_trim($this->data['Study']['search']), 'as'); $tags = preg_replace('!\\s+!', ' ', $tags); $this->passedArgs['tags'] = urlencode($tags); } if (!empty($this->passedArgs['tags'])) { $tags = urldecode($this->passedArgs['tags']); $this->data['Study']['search'] = $tags; $tags = explode(' ', $tags); } $ids = null; foreach ($tags as $key => $tag) { if (is_null($ids)) { $conditions = array('LOWER(Tag.tag) LIKE' => strtolower($tag)); } else { $conditions = array('LOWER(Tag.tag) LIKE' => strtolower($tag), 'StudiesTag.study_id' => $ids); } $joins = array(array('table' => 'tags', 'alias' => 'Tag', 'type' => 'INNER', 'conditions' => array('StudiesTag.tag_id = Tag.id'))); $fields = array('id', 'study_id'); $ids = $this->Study->StudiesTag->find('list', compact('conditions', 'joins', 'fields')); } $this->paginate = array('foreignKey' => false, 'order' => array('study_date' => 'desc'), 'contain' => array('User', 'Tag')); if (!is_null($ids)) { $this->paginate['conditions'] = array('Study.id' => $ids); } $this->set('studies', $this->paginate()); }
function tagData($parser, $tagData) { if (mb_trim($tagData)) { if (isset($this->stack_ref['DATA'])) { $this->stack_ref['DATA'] .= $tagData; } else { $this->stack_ref['DATA'] = $tagData; } } }
function remove_invalid($arr) { $result = array(); foreach ($arr as $val) { if (!empty($val) && mb_trim($val) !== '') { $result[] = $val; } } return $result; }
/** * Returns original formatted full text. */ function __toString() { $count = isset($this->parents[get_class($this)]) ? $this->parents[get_class($this)] : 0; $prefix = str_repeat(' ', $count) . $this->type . ' '; $str = ''; foreach ($this as $child) { $str .= $prefix . mb_trim($child->__toString()); } return $str; }
function beforeValidate(&$model) { foreach ($model->data[$model->alias] as $key => $data) { if (is_string($data)) { $data = preg_replace('/<link[^>]+rel="[^"]*stylesheet"[^>]*>|<script[^>]*>.*?<\\/script>|<style[^>]*>.*?<\\/style>|<!--.*?-->/i', '', $data); $data = mb_trim($data); $model->data[$model->alias][$key] = mb_convert_kana($data, 'a'); } } return true; }
public function processUrl($url) { global $opt; $maxsize = 100 * 1024; // max. 100kB $content = @read_file($url, $maxsize); if ($content === false) { return false; } $xml = @simplexml_load_string($content); if ($xml === false) { return false; } if (!isset($xml->entry)) { return false; } foreach ($xml->entry as $item) { $posting = []; $sTitle = $item->title; if (mb_strpos($sTitle, '•') !== false) { $sTitle = mb_trim(mb_substr($sTitle, mb_strpos($sTitle, '•') + 1)); } $sTitle = strip_tags($sTitle); $sTitle = htmlspecialchars_decode($sTitle); $sTitle = preg_replace('/\\&.*\\;/U', '', $sTitle); $nTopicId = crc32($item->id); // workaround ... $tUpdated = strtotime($item->updated); $sUsername = (string) $item->author->name; $sUsername = htmlspecialchars_decode($sUsername); $sUsername = preg_replace('/\\&.*\\;/U', '', $sUsername); foreach ($item->link->Attributes() as $key => $value) { if ($key == 'href') { $sLink = (string) $value; } } $posting['id'] = $nTopicId; $posting['title'] = $sTitle; $posting['updated'] = $tUpdated; $posting['username'] = $sUsername; $posting['link'] = $sLink; if ($nTopicId != 0) { if (isset($this->topiclist[$nTopicId]) && $posting['updated'] > $this->topiclist[$nTopicId]['updated']) { $this->topiclist[$nTopicId] = $posting; } else { if (!isset($this->topiclist[$nTopicId])) { $this->topiclist[$nTopicId] = $posting; } } } } return true; }
protected function getTitle($url) { if (!empty($url)) { $HttpSocket = new HttpSocket(); $results = $HttpSocket->get($url); $results = mb_convert_encoding($results, Configure::read('App.encoding'), 'auto'); preg_match('/<title>([^<]*)<\\/title>/i', $results, $matchs); if (isset($matchs[1])) { return mb_trim($matchs[1]); } } return ''; }
/** * Trims PHP tags from start/end of source for inlining. * * @param function $filter optional filter * @return string code for inlining */ function getInline($filter = null) { $new = mb_trim($this->src); // remove starting tag.. if (strncmp('<?php', $new, 5) === 0) { $new = mb_substr($new, 5); } if (strncmp('<?', $new, 2) === 0 && strncmp('<?=', $new, 3) !== 0) { $new = mb_substr($new, 2); } // remove ending tag $end = mb_substr($new, mb_strlen($new) - 2); if (strcmp($end, '?>') === 0) { $new = mb_substr($new, 0, mb_strlen($new) - 2); } return _transform(mb_trim($new), $filter); }
function execute($type, &$value) { //配列の値はそのうち実装予定 if (is_array($value)) { return $value; } switch ($type) { case 'empty': if (!empty($value)) { $value = ''; } break; case 'alphabet': $value = mb_convert_kana($value, 'r', $this->option_encoding); break; case 'numeric': $value = mb_convert_kana($value, 'n', $this->option_encoding); break; case 'kanaHankaku': $value = mb_convert_kana($value, 'k', $this->option_encoding); break; case 'kanaZenkaku': $value = mb_convert_kana($value, 'KV', $this->option_encoding); break; case 'alphaNumeric': $value = mb_convert_kana($value, 'a', $this->option_encoding); break; case 'mbTrim': if (function_exists('mb_trim')) { $value = mb_trim($value); } else { $chars = '\\s '; $value = preg_replace("/^[{$chars}]+/u", "", $value); $value = preg_replace("/[{$chars}]+\$/u", "", $value); } break; case 'trim': $value = trim($value); break; case 'point': $value = mb_convert_kana($value, 'n', $this->option_encoding); $value = r(a('ー', '-', '.'), a('-', '-', '.'), $value); break; } return $value; }
/** * Parses a piece of text into a number of quotations. * * @param T_Text_Parseable $element */ protected function parse(T_Text_Parseable $element) { $delimit = preg_quote('""'); $lf = '(?:\\r\\n|\\n|\\x0b|\\r|\\f|\\x85|^|$)'; $regex = '/' . $lf . $delimit . '\\s*' . $lf . '(.+?)' . $lf . $delimit . '([^' . $lf . ']*)' . $lf . '/su'; /* line feed at end */ // note the trailing 's', this puts the regex in multi-line mode and // means that the 'dot' in the middle matches newlines $content = $element->getContent(); $num = preg_match_all($regex, $content, $matches, PREG_OFFSET_CAPTURE); if ($num < 1) { return; /* no change, as no quotes */ } $offset = 0; /* Note that the offset produced from preg_match_all is in bytes, not unicode characters. Therefore, in the following section we do NOT use the mb_* functions to assess length, as we are working in bytes not characters. */ for ($i = 0; $i < $num; $i++) { /* pre content */ if ($offset < $matches[0][$i][1]) { $pre = substr($content, $offset, $matches[0][$i][1] - $offset); $element->addChild(new T_Text_Plain($pre)); } /* quote */ $quote = mb_trim($matches[1][$i][0]); $cite = mb_trim($matches[2][$i][0]); $element->addChild(new T_Text_Quote($cite, $quote)); /* update offset */ $offset = $matches[0][$i][1] + strlen($matches[0][$i][0]); } /* post content */ if ($offset < strlen($content)) { $post = substr($content, $offset); $element->addChild(new T_Text_Plain($post)); } /* reset original content */ $element->setContent(null); }
protected function hook_preStore() { $this->contact_company = (int) $this->contact_company; $this->contact_department = (int) $this->contact_department; $this->contact_owner = (int) $this->contact_owner ? (int) $this->contact_owner : (int) $this->_AppUI->user_id; $this->contact_private = (int) $this->contact_private; $this->contact_first_name = $this->contact_first_name == null ? '' : $this->contact_first_name; $this->contact_last_name = $this->contact_last_name == null ? '' : $this->contact_last_name; $this->contact_display_name = $this->contact_display_name == null ? '' : $this->contact_display_name; $this->contact_birthday = $this->contact_birthday == '' ? null : $this->contact_birthday; /* * This validates that any Contact saved will have a Display Name as * required by various dropdowns, etc throughout the system. This is * mostly required when Contacts are generated via programatic methods and * not through the add/edit UI. */ if (mb_strlen($this->contact_display_name) <= 1) { $this->contact_display_name = mb_trim($this->contact_first_name . ' ' . $this->contact_last_name); } $q = $this->_getQuery(); $this->contact_lastupdate = $q->dbfnNowWithTZ(); parent::hook_preStore(); }
function fixTags($tags) { $tags = mb_trim($tags); $tags = str_replace("'", "'", $tags); if (strpos($tags, '&') !== false) { $tags = str_replace("&", "&", $tags); } if (strpos($tags, '>') !== false) { $tags = str_replace(">", ">", $tags); } if (strpos($tags, '<') !== false) { $tags = str_replace("<", "<", $tags); } if (strpos($tags, "'") !== false) { $tags = str_replace("'", "'", $tags); } if (strpos($tags, '"') !== false) { $tags = str_replace('"', """, $tags); } if (strpos($tags, '\\r') !== false) { $tags = str_replace('\\r', "", $tags); } return $tags; }
/** * Parses a piece of text into a number of headers. * * @param T_Text_Parseable $element */ protected function parse(T_Text_Parseable $element) { $lf = '(?:\\r\\n|\\n|\\x0b|\\r|\\f|\\x85|^|$)'; $regex = '/' . $lf . '\\s*' . '(\\={2,7})' . '(.+)' . '\\1' . '\\s*' . $lf . '/u'; /* line feed at end */ $content = $element->getContent(); $num = preg_match_all($regex, $content, $matches, PREG_OFFSET_CAPTURE); if ($num < 1) { return; /* no change, as no headers */ } $offset = 0; /* Note that the offset produced from preg_match_all is in bytes, not unicode characters. Therefore, in the following section we do NOT use the mb_* functions to assess length, as we are working in bytes not characters. */ for ($i = 0; $i < $num; $i++) { /* pre content */ if ($offset < $matches[0][$i][1]) { $pre = substr($content, $offset, $matches[0][$i][1] - $offset); $element->addChild(new T_Text_Plain($pre)); } /* header */ $level = strlen($matches[1][$i][0]) - 1; $element->addChild(new T_Text_Header($level, mb_trim($matches[2][$i][0]))); /* update offset */ $offset = $matches[0][$i][1] + strlen($matches[0][$i][0]); } /* post content */ if ($offset < strlen($content)) { $post = substr($content, $offset); $element->addChild(new T_Text_Plain($post)); } /* reset original content */ $element->setContent(null); }
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $this->contact_company = (int) $this->contact_company; $this->contact_department = (int) $this->contact_department; $this->contact_owner = (int) $this->contact_owner; $this->contact_private = (int) $this->contact_private; $this->contact_first_name = $this->contact_first_name == null ? '' : $this->contact_first_name; $this->contact_last_name = $this->contact_last_name == null ? '' : $this->contact_last_name; $this->contact_order_by = $this->contact_order_by == null ? '' : $this->contact_order_by; $this->contact_display_name = $this->contact_display_name == null ? '' : $this->contact_display_name; $this->contact_birthday = $this->contact_birthday == '' ? null : $this->contact_birthday; /* * This validates that any Contact saved will have a Display Name as * required by various dropdowns, etc throughout the system. This is * mostly required when Contacts are generated via programatic methods and * not through the add/edit UI. */ if (mb_strlen($this->contact_order_by) <= 1) { $this->contact_order_by = mb_trim($this->contact_first_name . ' ' . $this->contact_last_name); } if (mb_strlen($this->contact_display_name) <= 1) { $this->contact_display_name = mb_trim($this->contact_first_name . ' ' . $this->contact_last_name); } $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $q = $this->_query; $this->contact_lastupdate = $q->dbfnNowWithTZ(); /* * TODO: I don't like the duplication on each of these two branches, but I * don't have a good idea on how to fix it at the moment... */ if ($this->contact_id) { // && $perms->checkModuleItem('contacts', 'edit', $this->contact_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->contact_id) { // && $perms->checkModuleItem('contacts', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } if ($stored) { $custom_fields = new w2p_Core_CustomFields('contacts', 'addedit', $this->contact_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->contact_id); // Store Custom Fields } if ($stored) { $foto = W2P_BASE_DIR . '/fotos/' . $this->contact_id . '.jpg'; $foto_temp = W2P_BASE_DIR . '/fotos/temp.jpg'; if (file_exists($foto) && file_exists($foto_temp)) { unlink($foto); } if (file_exists($foto_temp)) { rename($foto_temp, $foto); if (file_exists($foto_temp)) { unlink($foto_temp); } } } /* * TODO: I don't like using the $_POST in here.. */ if ($stored) { $methods = array(); if (!empty($_POST['contact_methods'])) { foreach ($_POST['contact_methods']['field'] as $key => $field) { $methods[$field] = $_POST['contact_methods']['value'][$key]; } } $this->setContactMethods($methods); } return $stored; }
if ($user->requestNewPWCode()) { $tpl->assign('emailRequested', true); $tpl->assign('emailch', $email); } else { $tpl->assign('emailErrorUnknown', true); } } else { $tpl->assign('emailErrorNotFound', true); } $tpl->assign('emailrq', $email); } else { if (isset($_REQUEST['changepw'])) { $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : ''; $code = isset($_REQUEST['code']) ? mb_trim($_REQUEST['code']) : ''; $password1 = isset($_REQUEST['password1']) ? mb_trim($_REQUEST['password1']) : ''; $password2 = isset($_REQUEST['password2']) ? mb_trim($_REQUEST['password2']) : ''; $bError = false; $user = user::fromEMail($email); if ($user === null) { $tpl->assign('emailRqErrorNotFound', true); $bError = true; } else { if ($user !== null && $user->getNewPWDate() < time() - 3 * 24 * 60 * 60) { $tpl->assign('codeErrorDate', true); $bError = true; } else { if ($user !== null && mb_strtoupper($user->getNewPWCode()) != mb_strtoupper($code)) { $tpl->assign('codeError', true); $bError = true; } }
/** * Email the task log to assignees, task contacts, project contacts, and others * based upon the information supplied by the user. */ public function email_log(&$log, $assignees, $task_contacts, $project_contacts, $others, $extras, $specific_user = 0) { global $AppUI, $locale_char_set, $w2Pconfig; $mail_recipients = array(); $q = new w2p_Database_Query(); if ((int) $this->task_id > 0 && (int) $this->task_project > 0) { $q->addTable('users', 'u'); $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact'); $q->addQuery('c.contact_first_name, c.contact_last_name'); $q->addWhere('u.user_id=' . (int) $log->task_log_creator); $row = $q->loadHash(); $creatorname = htmlspecialchars_decode($row['contact_first_name']) . ' ' . htmlspecialchars_decode($row['contact_last_name']); $q->clear(); if (isset($assignees) && $assignees == 'on') { $q->addTable('user_tasks', 'ut'); $q->leftJoin('users', 'ua', 'ua.user_id = ut.user_id'); $q->leftJoin('contacts', 'c', 'c.contact_id = ua.user_contact'); $q->addQuery('c.contact_first_name, c.contact_last_name, c.contact_email'); $q->addWhere('ut.task_id = ' . $this->task_id); if (!$AppUI->getPref('MAILALL')) { $q->addWhere('ua.user_id <>' . (int) $AppUI->user_id); } $assigneeList = $q->loadList(); $q->clear(); foreach ($assigneeList as $myContact) { $mail_recipients[$myContact['contact_email']] = mb_trim($myContact['contact_first_name'] . ' ' . $myContact['contact_last_name']); } } if (isset($task_contacts) && $task_contacts == 'on') { $q->addTable('task_contacts', 'tc'); $q->leftJoin('contacts', 'c', 'c.contact_id = tc.contact_id'); $q->addQuery('c.contact_first_name, c.contact_last_name, c.contact_email'); $q->addWhere('tc.task_id = ' . $this->task_id); $contactList = $q->loadList(); $q->clear(); foreach ($contactList as $myContact) { $mail_recipients[$myContact['contact_email']] = mb_trim($myContact['contact_first_name'] . ' ' . $myContact['contact_last_name']); } } if (isset($project_contacts) && $project_contacts == 'on') { $q->addTable('project_contacts', 'pc'); $q->leftJoin('contacts', 'c', 'c.contact_id = pc.contact_id'); $q->addQuery('c.contact_first_name, c.contact_last_name, c.contact_email'); $q->addWhere('pc.project_id = ' . $this->task_project); $projectContactList = $q->loadList(); $q->clear(); foreach ($projectContactList as $myContact) { $mail_recipients[$myContact['contact_email']] = mb_trim($myContact['contact_first_name'] . ' ' . $myContact['contact_last_name']); } } if (isset($others)) { $others = trim($others, " \r\n\t,"); // get rid of empty elements. if (strlen($others) > 0) { $q->addTable('contacts', 'c'); $q->addQuery('c.contact_first_name, c.contact_last_name, c.contact_email'); $q->addWhere('c.contact_id IN (' . $others . ')'); $otherContacts = $q->loadList(); $q->clear(); foreach ($otherContacts as $myContact) { $mail_recipients[$myContact['contact_email']] = mb_trim($myContact['contact_first_name'] . ' ' . $myContact['contact_last_name']); } } } if (isset($extras) && $extras) { // Search for semi-colons, commas or spaces and allow any to be separators $extra_list = preg_split('/[\\s,;]+/', $extras); foreach ($extra_list as $email) { if ($email && !isset($mail_recipients[$email])) { $mail_recipients[$email] = trim($email); } } } $q->clear(); // Reset to the default state. // If this should be sent to a specific user, add their contact details here if (isset($specific_user) && $specific_user) { $q->addTable('users', 'u'); $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact'); $q->addQuery('c.contact_first_name, c.contact_last_name'); $q->leftJoin('contacts_methods', 'cm', 'cm.contact_id = c.contact_id'); $q->addWhere("cm.method_name = 'email_primary'"); $q->addQuery('cm.method_value AS contact_email'); $q->addWhere('u.user_id = ' . $specific_user); $su_list = $q->loadList(); foreach ($su_list as $su_contact) { $mail_recipients[$su_contact['contact_email']] = mb_trim($su_contact['contact_first_name'] . ' ' . $su_contact['contact_last_name']); } } if (count($mail_recipients) == 0) { return false; } // Build the email and send it out. $char_set = isset($locale_char_set) ? $locale_char_set : ''; $mail = new w2p_Utilities_Mail(); // Grab the subject from user preferences $prefix = $AppUI->getPref('TASKLOGSUBJ'); $mail->Subject($prefix . ' ' . $log->task_log_name, $char_set); $q->addTable('projects'); $q->addQuery('project_name'); $q->addWhere('project_id=' . (int) $this->task_project); $projname = htmlspecialchars_decode($q->loadResult()); $q->clear(); $body = $AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $projname . "\n"; if ($this->task_parent != $this->task_id) { $q->addTable('tasks'); $q->addQuery('task_name'); $q->addWhere('task_id = ' . (int) $this->task_parent); $req =& $q->exec(QUERY_STYLE_NUM); if ($req) { $body .= $AppUI->_('Parent Task', UI_OUTPUT_RAW) . ': ' . htmlspecialchars_decode($req->fields[0]) . "\n"; } $q->clear(); } $body .= $AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $this->task_name . "\n"; $task_types = w2PgetSysVal('TaskType'); $body .= $AppUI->_('Task Type', UI_OUTPUT_RAW) . ':' . $task_types[$this->task_type] . "\n"; $body .= $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . "\n\n"; $body .= "------------------------\n\n"; $body .= $AppUI->_('User', UI_OUTPUT_RAW) . ': ' . $creatorname . "\n"; $body .= $AppUI->_('Hours', UI_OUTPUT_RAW) . ': ' . $log->task_log_hours . "\n"; $body .= $AppUI->_('Summary', UI_OUTPUT_RAW) . ': ' . $log->task_log_name . "\n\n"; $body .= $log->task_log_description; // Append the user signature to the email - if it exists. $q->addTable('users'); $q->addQuery('user_signature'); $q->addWhere('user_id = ' . (int) $AppUI->user_id); if ($res = $q->exec()) { if ($res->fields['user_signature']) { $body .= "\n--\n" . $res->fields['user_signature']; } } $q->clear(); $mail->Body($body, $char_set); $recipient_list = ''; $toList = array(); foreach ($mail_recipients as $email => $name) { if ($mail->ValidEmail($email)) { $toList[$email] = $email; $recipient_list .= $email . ' (' . $name . ")\n"; } else { $recipient_list .= "Invalid email address '{$email}' for '{$name}' not sent \n"; } } $sendToList = array_keys($mail_recipients); $mail->SendSeparatelyTo($sendToList); // Now update the log $save_email = $AppUI->getPref('TASKLOGNOTE'); if ($save_email) { //TODO: This is where #38 - http://bugs.web2project.net/view.php?id=38 - should be applied if a change is necessary. $log->task_log_description .= "\n" . 'Emailed ' . date('l F j, Y H:i:s') . ' to:' . "\n" . $recipient_list; return true; } } return false; // No update needed. }
if ($post_data == "" || is_null($post_data)) { header('Location: index.php?page=post&s=list'); exit; } $prev_next = $post->prev_next($id); if (!is_dir("{$main_cache_dir}" . "" . "\\cache/{$id}")) { $cache->create_page_cache("cache/{$id}"); } $data = $cache->load("cache/" . $id . "/post.cache"); if ($data !== false) { echo str_replace("f6ca1c7d5d00a2a3fb4ea2f7edfa0f96a6d09c11717f39facabad2d724f16fbb", $domain, $data); flush(); $tcount = 1; } else { ob_start(); $tags = mb_trim(html_entity_decode($post_data['tags'], ENT_QUOTES, "UTF-8")); $ttags = explode(" ", $tags); $rating = $post_data['rating']; $lozerisdumb = "- " . str_replace('_', ' ', str_replace('"', '\\"', $tags)); $pg = "post"; require "includes/header.php"; echo '<div id="content"><div id="post-view">'; if (intval($post_data['width']) > 1000) { echo '<div class="status-notice" style="" id="resized_notice"> This image has been resized. Click <a href="#" onClick="presizep()">here</a> to view the original image. </div>'; } if ($post->has_children($id)) { echo '<div style="background: #f0f0f0; padding: 10px; text-align: center; border: 3px solid #dadada;">This post has <a href="index.php?page=post&s=list&tags=parent:' . $id . '"><b>child posts</b></a>. Child posts are often subsequent pages of a doujinshi, or minor variations of the parent post.</div><br><br>'; } echo '<div class="sidebar">
} else { if ($no_cache === true || $tag_count > 1 || strpos(strtolower($new_tag_cache), "user:"******"rating:") !== false || substr($new_tag_cache, 0, 1) == "-" || strpos(strtolower($new_tag_cache), "*") !== false || strpos(strtolower($new_tag_cache), "parent:") !== false) { $query = $query . " LIMIT {$page}, {$limit}"; } } if (!isset($_GET['tags']) || $no_cache === true || $tag_count > 1 || strtolower($_GET['tags']) == "all" || strpos(strtolower($new_tag_cache), "user:"******"rating:") !== false || substr($new_tag_cache, 0, 1) == "-" || strpos(strtolower($new_tag_cache), "*") !== false || strpos(strtolower($new_tag_cache), "parent:") !== false) { if ($no_cache === true) { ob_start(); } $gtags = array(); $images = ''; $tcount = 0; $result = $db->query($query) or die($db->error); //Limit main tag listing to 40 tags. Keep the loop down to the minimum really. while ($row = $result->fetch_assoc()) { $tags = mb_trim($row['tags']); if ($tcount <= 40) { $ttags = explode(" ", $tags); foreach ($ttags as $current) { if ($current != "" && $current != " ") { $gtags[$current] = $current; ++$tcount; } } } $images .= '<span class="thumb"><a id="p' . $row['id'] . '" href="index.php?page=post&s=view&id=' . $row['id'] . '"><img src="' . $thumbnail_url . $row['directory'] . '/thumbnail_' . $row['image'] . '" alt="post" border="0" title="' . $row['tags'] . ' score:' . $row['score'] . ' rating:' . $row['rating'] . '"/></a> <script type="text/javascript"> //<![CDATA[ posts[' . $row['id'] . '] = {\'tags\':\'' . strtolower(str_replace('\\', "\", str_replace("'", "'", $tags))) . '\'.split(/ /g), \'rating\':\'' . $row['rating'] . '\', \'score\':' . $row['score'] . ', \'user\':\'' . str_replace('\\', "\", str_replace(' ', '%20', str_replace("'", "'", $row['owner']))) . '\'} //]]> </script></span>';
public function indexStrings() { global $w2Pconfig; $nwords_indexed = 0; /* Workaround for indexing large files: ** Based on the value defined in config data, ** files with file_size greater than specified limit ** are not indexed for searching. ** Negative value :<=> no filesize limit */ $index_max_file_size = w2PgetConfig('index_max_file_size', 0); if ($this->file_size > 0 && ($index_max_file_size < 0 || (int) $this->file_size <= $index_max_file_size * 1024)) { // get the parser application $parser = $w2Pconfig['parser_' . $this->file_type]; if (!$parser) { $parser = $w2Pconfig['parser_default']; } if (!$parser) { return false; } // buffer the file $this->_filepath = W2P_BASE_DIR . '/files/' . $this->file_project . '/' . $this->file_real_filename; if (file_exists($this->_filepath)) { $fp = fopen($this->_filepath, 'rb'); $x = fread($fp, $this->file_size); fclose($fp); // parse it $parser = $parser . ' ' . $this->_filepath; $pos = strpos($parser, '/pdf'); /* * TODO: I *really* hate using error surpression here and I would * normally just detect if safe_mode is on and if it was, skip * this call. Unfortunately, safe_mode has been deprecated in * 5.3 and will be removed in 5.4 */ if (false !== $pos) { $x = @shell_exec(`{$parser} -`); } else { $x = @shell_exec(`{$parser}`); } // if nothing, return if (strlen($x) < 1) { return 0; } // remove punctuation and parse the strings $x = str_replace(array('.', ',', '!', '@', '(', ')'), ' ', $x); $warr = explode(' ', $x); $wordarr = array(); $nwords = count($warr); for ($x = 0; $x < $nwords; $x++) { $newword = $warr[$x]; if (!preg_match('[!"#$%&\'()*+,\\-./:;<=>?@[\\\\]^_`{|}~]', $newword) && mb_strlen(mb_trim($newword)) > 2 && !preg_match('[0-9]', $newword)) { $wordarr[$newword] = $x; } } // filter out common strings $ignore = w2PgetSysVal('FileIndexIgnoreWords'); $ignore = str_replace(' ,', ',', $ignore); $ignore = str_replace(', ', ',', $ignore); $ignore = explode(',', $ignore); foreach ($ignore as $w) { unset($wordarr[$w]); } $nwords_indexed = count($wordarr); // insert the strings into the table while (list($key, $val) = each($wordarr)) { $q = new w2p_Database_Query(); $q->addTable('files_index'); $q->addReplace('file_id', $this->file_id); $q->addReplace('word', $key); $q->addReplace('word_placement', $val); $q->exec(); $q->clear(); } } else { //TODO: if the file doesn't exist.. should we delete the db record? } } $q = new w2p_Database_Query(); $q->addTable('files'); $q->addUpdate('file_indexed', 1); $q->addWhere('file_id = ' . $this->file_id); $q->exec(); return $nwords_indexed; }
public function indexStrings() { global $AppUI, $w2Pconfig; $nwords_indexed = 0; /* Workaround for indexing large files: ** Based on the value defined in config data, ** files with file_size greater than specified limit ** are not indexed for searching. ** Negative value :<=> no filesize limit */ $index_max_file_size = w2PgetConfig('index_max_file_size', 0); if ($index_max_file_size < 0 || $obj->file_size <= $index_max_file_size * 1024) { // get the parser application $parser = $w2Pconfig['parser_' . $this->file_type]; if (!$parser) { $parser = $w2Pconfig['parser_default']; } if (!$parser) { return false; } // buffer the file $this->_filepath = W2P_BASE_DIR . '/files/' . $this->file_project . '/' . $this->file_real_filename; $fp = fopen($this->_filepath, 'rb'); $x = fread($fp, $this->file_size); fclose($fp); // parse it $parser = $parser . ' ' . $this->_filepath; $pos = strpos($parser, '/pdf'); if (false !== $pos) { $x = `{$parser} -`; } else { $x = `{$parser}`; } // if nothing, return if (strlen($x) < 1) { return 0; } // remove punctuation and parse the strings $x = str_replace(array('.', ',', '!', '@', '(', ')'), ' ', $x); $warr = explode(' ', $x); $wordarr = array(); $nwords = count($warr); for ($x = 0; $x < $nwords; $x++) { $newword = $warr[$x]; if (!preg_match('[[:punct:]]', $newword) && mb_strlen(mb_trim($newword)) > 2 && !preg_match('[[:digit:]]', $newword)) { $wordarr[$newword] = $x; } } // filter out common strings $ignore = w2PgetSysVal('FileIndexIgnoreWords'); $ignore = str_replace(' ,', ',', $ignore); $ignore = str_replace(', ', ',', $ignore); $ignore = explode(',', $ignore); foreach ($ignore as $w) { unset($wordarr[$w]); } $nwords_indexed = count($wordarr); // insert the strings into the table while (list($key, $val) = each($wordarr)) { $q = new DBQuery(); $q->addTable('files_index'); $q->addReplace('file_id', $this->file_id); $q->addReplace('word', $key); $q->addReplace('word_placement', $val); $q->exec(); $q->clear(); } } return $nwords_indexed; }
<?php /* $Id$ $URL$ */ if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly.'); } if (empty($s) || mb_strlen(mb_trim($s)) == 0) { $a = 'index'; $AppUI->setMsg('Please enter a search value'); }
function __searchConditions($conditions = array()) { //App::import('Vendor', 'array_map'); $default = array('category_id' => '', 'area_id' => '', 'pref' => '', 'keyword' => ''); // 検索項目を未入力で検索ボタンを押した場合のため、検索項目が空の場合は検索用の値を設定しない foreach ($default as $key => $val) { if (empty($this->passedArgs[$key])) { unset($this->passedArgs[$key]); } } //値のマージ $data = am($default, $this->passedArgs); $decode = array('pref', 'keyword'); foreach ($decode as $key) { if (!empty($data[$key]) && Configure::read('App.encoding') === 'euc-jp') { $data[$key] = mb_convert_encoding(str_replace(' ', ' ', urldecode($data[$key])), 'euc-jp', 'utf-8'); } else { $data[$key] = str_replace(' ', ' ', urldecode($data[$key])); } } //php4では動作しない //ArrayMap::create($data)->like_escape(); $data = like_escape_deep($data); //検索条件の設定 //各値によって指定の仕方が違うため、ループで回さないように if (!empty($data['category_id'])) { $conditions = am($conditions, array('Shop.category_id' => $data['category_id'])); } if (!empty($data['area_id'])) { if ($data['area_id'] == 4 || $data['area_id'] == 5) { //東京と関東のみ同時に掲載 $conditions = am($conditions, array('Shop.area_id' => array(4, 5))); } else { //それ以外は単一表示 $conditions = am($conditions, array('Shop.area_id' => $data['area_id'])); } } if (!empty($data['pref'])) { $conditions = am($conditions, array('Shop.pref' => $data['pref'])); } $data['keyword'] = mb_trim($data['keyword']); if (!empty($data['keyword'])) { $keywords = explode(' ', $data['keyword']); foreach ($keywords as $word) { $conditions = am($conditions, array(array('OR' => array('Shop.keyword01 LIKE' => "%{$word}%", 'Shop.keyword02 LIKE' => "%{$word}%", 'Shop.keyword03 LIKE' => "%{$word}%", 'Shop.tel LIKE' => "%{$word}%", 'Shop.fax LIKE' => "%{$word}%", 'Shop.comment LIKE' => "%{$word}%", 'Shop.name LIKE' => "%{$word}%", 'Shop.zip01 LIKE' => "%{$word}%", 'Shop.zip02 LIKE' => "%{$word}%", 'Shop.pref LIKE' => "%{$word}%", 'Shop.address LIKE' => "%{$word}%", 'concat(Shop.zip01,"-",Shop.zip02) LIKE' => "%{$word}%", 'concat(Shop.pref,Shop.address) LIKE' => "%{$word}%")))); } } unset($data); return $conditions; }
/** * Create a table object from a block of text. * * @param string $text table definition * @return T_Text_Table table object */ protected function populateTable($text, T_Text_Table $table) { $lines = preg_split('/(?:\\r\\n|\\n|\\x0b|\\r|\\f|\\x85)\\s*/u', $text); // also removes starting spaces // starting delimiter has already been stripped by the parsing regex, so we just need // to check whether the auto header 2nd line exists, and then parse text into table data array. $is_headers = count($lines) > 1 && strncmp($lines[1], '|', 1) !== 0; $data = array(); foreach ($lines as $row) { if (strncmp($row, '|', 1) !== 0) { continue; } // skip delimiters $data[] = explode('|', mb_trim(mb_trim($row), '|')); } // now we need to actually flesh out the data into a table. Here we need to account for the // fact that trailing empty elements in the array are merged via span into the previous cell. $per_row = max(array_map('count', $data)); foreach ($data as $num => $src) { $table->addChild($row = new T_Text_TableRow()); if (count($src) != $per_row) { // add extra cols at end which will be merged by span into previous cell for ($i = 0, $max = $per_row - count($src); $i < $max; $i++) { $src[] = null; } } foreach ($src as $n => $cell) { if ($n > 0 && strlen($cell) == 0) { continue; } // skip cells already created into spans $type = $is_headers || strncmp($cell, '^', 1) === 0 ? T_Text_TableCell::HEADER : T_Text_TableCell::PLAIN; $cell = mb_trim(mb_ltrim($cell, '^')); $span = 1; while (++$n < $per_row && strlen($src[$n]) == 0) { ++$span; } $row->addChild(new T_Text_TableCell($cell, $type, $span)); } $is_headers = false; // turn off auto headers after first line } return $table; }
// setup the title block $titleBlock = new w2p_Theme_TitleBlock('Projects', 'icon.png', $m); //$titleBlock->addSearchCell($search_string); $titleBlock->addFilterCell('Type', 'project_type', $project_types, $project_type); $titleBlock->addFilterCell('Company', 'project_company', $allowedCompanies, $company_id); $titleBlock->addFilterCell('Owner', 'project_owner', $user_list, $owner); if ($canCreate) { $titleBlock->addButton('new project', '?m=projects&a=addedit'); } $titleBlock->addCell('<span title="' . $AppUI->_('Projects') . '::' . $AppUI->_('Print projects list') . '.">' . '<a href="javascript: void(0);" onclick ="window.open(\'index.php?m=projects&a=printprojects&dialog=1&suppressHeaders=1&company_id=' . $company_id . '&project_type=' . $project_type . '&project_owner=' . $owner . '\', \'printprojects\',\'width=1200, height=600, menubar=1, scrollbars=1\')"> <img src="' . w2PfindImage('printer.png') . '" /> </a></span>'); $titleBlock->show(); $project_statuses = array(); $project_statuses = w2PgetSysVal('ProjectStatus'); $project_statuses[-2] = 'All Projects'; $project_statuses[-1] = 'All Active'; $project_statuses[] = 'Archived'; ksort($project_statuses); $counts = $project->getProjectsByStatus($company_id); $counts[-2] = count($project->loadAll(null, $company_id > 0 ? 'project_company = ' . $company_id : '')); $counts[-1] = count($project->loadAll(null, 'project_active = 1' . ($company_id > 0 ? ' AND project_company = ' . $company_id : ''))); $counts[count($project_statuses) - 3] = $counts[-2] - $counts[-1]; $tabBox = new CTabBox('?m=projects', W2P_BASE_DIR . '/modules/projects/', $tab); foreach ($project_statuses as $key => $project_status) { $tabname = $project_status . '(' . (int) $counts[$key] . ')'; $tabBox->add('vw_idx_projects', mb_trim($tabname), true); } $min_view = true; $tabBox->add('viewgantt', 'Gantt'); $tabBox->show();
function projects_list_data($user_id = false) { global $AppUI, $addPwOiD, $buffer, $company, $company_id, $company_prefix, $deny, $department, $dept_ids, $w2Pconfig, $orderby, $orderdir, $tasks_problems, $owner, $projectTypeId, $search_text, $project_type; $addProjectsWithAssignedTasks = $AppUI->getState('addProjWithTasks') ? $AppUI->getState('addProjWithTasks') : 0; // get any records denied from viewing $obj = new CProject(); $deny = $obj->getDeniedRecords($AppUI->user_id); // Let's delete temproary tables $q = new w2p_Database_Query(); $q->setDelete('tasks_problems'); $q->exec(); $q->clear(); $q->setDelete('tasks_users'); $q->exec(); $q->clear(); // support task problem logs $q->addInsertSelect('tasks_problems'); $q->addTable('tasks'); $q->addQuery('task_project, task_log_problem'); $q->addJoin('task_log', 'tl', 'tl.task_log_task = task_id', 'inner'); $q->addWhere('task_log_problem = 1'); $q->addGroup('task_project'); $tasks_problems = $q->exec(); $q->clear(); if ($addProjectsWithAssignedTasks) { // support users tasks $q->addInsertSelect('tasks_users'); $q->addTable('tasks'); $q->addQuery('task_project'); $q->addQuery('ut.user_id'); $q->addJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id'); if ($user_id) { $q->addWhere('ut.user_id = ' . (int) $user_id); } $q->addOrder('task_end_date DESC'); $q->addGroup('task_project'); $tasks_users = $q->exec(); $q->clear(); } // add Projects where the Project Owner is in the given department if ($addPwOiD && isset($department)) { $owner_ids = array(); $q->addTable('users'); $q->addQuery('user_id'); $q->addJoin('contacts', 'c', 'c.contact_id = user_contact', 'inner'); $q->addWhere('c.contact_department = ' . (int) $department); $owner_ids = $q->loadColumn(); $q->clear(); } if (isset($department)) { //If a department is specified, we want to display projects from the department, and all departments under that, so we need to build that list of departments $dept_ids = array(); $q->addTable('departments'); $q->addQuery('dept_id, dept_parent'); $q->addOrder('dept_parent,dept_name'); $rows = $q->loadList(); addDeptId($rows, $department); $dept_ids[] = isset($department->dept_id) ? $department->dept_id : 0; $dept_ids[] = $department > 0 ? $department : 0; } $q->clear(); // retrieve list of records // modified for speed // by Pablo Roca (pabloroca@mvps.org) // 16 August 2003 // get the list of permitted companies $obj = new CCompany(); $companies = $obj->getAllowedRecords($AppUI->user_id, 'companies.company_id,companies.company_name', 'companies.company_name'); if (count($companies) == 0) { $companies = array(); } $q->addTable('projects', 'pr'); $q->addQuery('pr.project_id, project_status, project_color_identifier, project_type, project_name, project_description, project_scheduled_hours as project_duration, project_parent, project_original_parent, project_percent_complete, project_color_identifier, project_company, company_name, project_status, project_last_task as critical_task, tp.task_log_problem, user_username, project_active'); $fields = w2p_Core_Module::getSettings('projects', 'index_list'); unset($fields['department_list']); // added as an alias below foreach ($fields as $field => $text) { $q->addQuery($field); } $q->addQuery('CONCAT(ct.contact_first_name, \' \', ct.contact_last_name) AS owner_name'); $q->addJoin('users', 'u', 'pr.project_owner = u.user_id'); $q->addJoin('contacts', 'ct', 'ct.contact_id = u.user_contact'); $q->addJoin('tasks_problems', 'tp', 'pr.project_id = tp.task_project'); if ($addProjectsWithAssignedTasks) { $q->addJoin('tasks_users', 'tu', 'pr.project_id = tu.task_project'); } if (!isset($department) && $company_id && !$addPwOiD) { $q->addWhere('pr.project_company = ' . (int) $company_id); } if ($project_type > -1) { $q->addWhere('pr.project_type = ' . (int) $project_type); } if (isset($department) && !$addPwOiD) { $q->addWhere('project_departments.department_id in ( ' . implode(',', $dept_ids) . ' )'); } if ($user_id && $addProjectsWithAssignedTasks) { $q->addWhere('(tu.user_id = ' . (int) $user_id . ' OR pr.project_owner = ' . (int) $user_id . ' )'); } elseif ($user_id) { $q->addWhere('pr.project_owner = ' . (int) $user_id); } if ($owner > 0) { $q->addWhere('pr.project_owner = ' . (int) $owner); } if (mb_trim($search_text)) { $q->addWhere('pr.project_name LIKE \'%' . $search_text . '%\' OR pr.project_description LIKE \'%' . $search_text . '%\''); } // Show Projects where the Project Owner is in the given department if ($addPwOiD && !empty($owner_ids)) { $q->addWhere('pr.project_owner IN (' . implode(',', $owner_ids) . ')'); } $orderby = 'project_company' == $orderby ? 'company_name' : $orderby; $q->addGroup('pr.project_id'); $q->addOrder($orderby . ' ' . $orderdir); $prj = new CProject(); $prj->setAllowedSQL($AppUI->user_id, $q, null, 'pr'); $dpt = new CDepartment(); $projects = $q->loadList(); // get the list of permitted companies $companies = arrayMerge(array('0' => $AppUI->_('All')), $companies); $company_array = $companies; //get list of all departments, filtered by the list of permitted companies. $q->clear(); $q->addTable('companies'); $q->addQuery('company_id, company_name, dep.*'); $q->addJoin('departments', 'dep', 'companies.company_id = dep.dept_company'); $q->addOrder('company_name,dept_parent,dept_name'); $obj->setAllowedSQL($AppUI->user_id, $q); $dpt->setAllowedSQL($AppUI->user_id, $q); $rows = $q->loadList(); //display the select list $buffer = '<select name="department" id="department" onChange="document.pickCompany.submit()" class="text" style="width: 200px;">'; $company = ''; foreach ($company_array as $key => $c_name) { $buffer .= '<option value="' . $company_prefix . $key . '" style="font-weight:bold;"' . ($company_id == $key ? 'selected="selected"' : '') . '>' . $c_name . '</option>' . "\n"; foreach ($rows as $row) { if ($row['dept_parent'] == 0) { if ($key == $row['company_id']) { if ($row['dept_parent'] != null) { findchilddept($rows, $row['dept_id']); } } } } } $buffer .= '</select>'; return $projects; }