Changeset 1113
- Timestamp:
- Mar 30, 2006, 2:37:07 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r1109 r1113 6 6 // +-----------------------------------------------------------------------+ 7 7 // | branch : BSF (Best So Far) 8 // | file : $ RCSfile$8 // | file : $Id$ 9 9 // | last update : $Date$ 10 10 // | last modifier : $Author$ … … 786 786 787 787 /** 788 * Prepends and appends a string at each value of the given array.789 *790 * @param array791 * @param string prefix to each array values792 * @param string suffix to each array values793 */794 function prepend_append_array_items($array, $prepend_str, $append_str)795 {796 array_walk(797 $array,798 create_function('&$s', '$s = "'.$prepend_str.'".$s."'.$append_str.'";')799 );800 801 return $array;802 }803 804 /**805 * returns search rules stored into a serialized array in "search"806 * table. Each search rules set is numericaly identified.807 *808 * @param int search_id809 * @return array810 */811 function get_search_array($search_id)812 {813 if (!is_numeric($search_id))814 {815 die('Search id must be an integer');816 }817 818 $query = '819 SELECT rules820 FROM '.SEARCH_TABLE.'821 WHERE id = '.$search_id.'822 ;';823 list($serialized_rules) = mysql_fetch_row(pwg_query($query));824 825 return unserialize($serialized_rules);826 }827 828 /**829 * returns the SQL clause from a search identifier830 *831 * Search rules are stored in search table as a serialized array. This array832 * need to be transformed into an SQL clause to be used in queries.833 *834 * @param int search_id835 * @return string836 */837 function get_sql_search_clause($search_id)838 {839 $search = get_search_array($search_id);840 841 // SQL where clauses are stored in $clauses array during query842 // construction843 $clauses = array();844 845 foreach (array('file','name','comment','keywords','author') as $textfield)846 {847 if (isset($search['fields'][$textfield]))848 {849 $local_clauses = array();850 foreach ($search['fields'][$textfield]['words'] as $word)851 {852 array_push($local_clauses, $textfield." LIKE '%".$word."%'");853 }854 855 // adds brackets around where clauses856 $local_clauses = prepend_append_array_items($local_clauses, '(', ')');857 858 array_push(859 $clauses,860 implode(861 ' '.$search['fields'][$textfield]['mode'].' ',862 $local_clauses863 )864 );865 }866 }867 868 if (isset($search['fields']['allwords']))869 {870 $fields = array('file', 'name', 'comment', 'keywords', 'author');871 // in the OR mode, request bust be :872 // ((field1 LIKE '%word1%' OR field2 LIKE '%word1%')873 // OR (field1 LIKE '%word2%' OR field2 LIKE '%word2%'))874 //875 // in the AND mode :876 // ((field1 LIKE '%word1%' OR field2 LIKE '%word1%')877 // AND (field1 LIKE '%word2%' OR field2 LIKE '%word2%'))878 $word_clauses = array();879 foreach ($search['fields']['allwords']['words'] as $word)880 {881 $field_clauses = array();882 foreach ($fields as $field)883 {884 array_push($field_clauses, $field." LIKE '%".$word."%'");885 }886 // adds brackets around where clauses887 array_push(888 $word_clauses,889 implode(890 "\n OR ",891 $field_clauses892 )893 );894 }895 896 array_walk(897 $word_clauses,898 create_function('&$s','$s="(".$s.")";')899 );900 901 array_push(902 $clauses,903 "\n ".904 implode(905 "\n ".906 $search['fields']['allwords']['mode'].907 "\n ",908 $word_clauses909 )910 );911 }912 913 foreach (array('date_available', 'date_creation') as $datefield)914 {915 if (isset($search['fields'][$datefield]))916 {917 array_push(918 $clauses,919 $datefield." = '".$search['fields'][$datefield]['date']."'"920 );921 }922 923 foreach (array('after','before') as $suffix)924 {925 $key = $datefield.'-'.$suffix;926 927 if (isset($search['fields'][$key]))928 {929 array_push(930 $clauses,931 932 $datefield.933 ($suffix == 'after' ? ' >' : ' <').934 ($search['fields'][$key]['inc'] ? '=' : '').935 " '".$search['fields'][$key]['date']."'"936 937 );938 }939 }940 }941 942 if (isset($search['fields']['cat']))943 {944 if ($search['fields']['cat']['sub_inc'])945 {946 // searching all the categories id of sub-categories947 $cat_ids = get_subcat_ids($search['fields']['cat']['words']);948 }949 else950 {951 $cat_ids = $search['fields']['cat']['words'];952 }953 954 $local_clause = 'category_id IN ('.implode(',', $cat_ids).')';955 array_push($clauses, $local_clause);956 }957 958 // adds brackets around where clauses959 $clauses = prepend_append_array_items($clauses, '(', ')');960 961 $where_separator =962 implode(963 "\n ".$search['mode'].' ',964 $clauses965 );966 967 $search_clause = $where_separator;968 969 if (isset($forbidden))970 {971 $search_clause.= "\n AND ".$forbidden;972 }973 974 return $search_clause;975 }976 977 /**978 788 * Returns webmaster mail address depending on $conf['webmaster_id'] 979 789 * -
trunk/include/functions_category.inc.php
r1092 r1113 6 6 // +-----------------------------------------------------------------------+ 7 7 // | branch : BSF (Best So Far) 8 // | file : $ RCSfile$8 // | file : $Id$ 9 9 // | last update : $Date$ 10 10 // | last modifier : $Author$ … … 43 43 function check_restrictions($category_id) 44 44 { 45 global $user , $lang;45 global $user; 46 46 47 47 if (in_array($category_id, explode(',', $user['forbidden_categories']))) 48 48 { 49 $login_url = 50 get_root_url().'identification.php?redirect=' 51 .urlencode(urlencode($_SERVER['REQUEST_URI'])); 52 53 if (!$user['is_the_guest']) 54 { 55 die('Fatal: you are trying to reach a forbidden category'); 56 } 57 else 58 { 59 redirect($login_url); 60 } 49 access_denied(); 61 50 } 62 51 } -
trunk/include/functions_html.inc.php
r1092 r1113 6 6 // +-----------------------------------------------------------------------+ 7 7 // | branch : BSF (Best So Far) 8 // | file : $ RCSfile$8 // | file : $Id$ 9 9 // | last update : $Date$ 10 10 // | last modifier : $Author$ … … 494 494 return get_cat_display_name($cat_info['name'], $url, $replace_space); 495 495 } 496 497 /** 498 * exits the current script (either exit or redirect) 499 */ 500 function access_denied() 501 { 502 global $user, $lang; 503 504 $login_url = 505 get_root_url().'identification.php?redirect=' 506 .urlencode(urlencode($_SERVER['REQUEST_URI'])); 507 508 if ( isset($user['is_the_guest']) and !$user['is_the_guest'] ) 509 { 510 echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />'; 511 echo '<a href="'.get_root_url().'identification.php">'.$lang['identification'].'</a> '; 512 echo '<a href="'.make_index_url().'">'.$lang['home'].'</a></div>'; 513 exit(); 514 } 515 else 516 { 517 header('HTTP/1.1 401 Authorization required'); 518 header('Status: 401 Authorization required'); 519 redirect($login_url); 520 } 521 } 496 522 ?> -
trunk/include/functions_metadata.inc.php
r858 r1113 6 6 // +-----------------------------------------------------------------------+ 7 7 // | branch : BSF (Best So Far) 8 // | file : $ RCSfile$8 // | file : $Id$ 9 9 // | last update : $Date$ 10 10 // | last modifier : $Author$ … … 36 36 { 37 37 $result = array(); 38 38 39 39 // Read IPTC data 40 40 $iptc = array(); 41 41 42 42 $imginfo = array(); 43 43 getimagesize($filename, $imginfo); 44 44 45 45 if (isset($imginfo['APP13'])) 46 46 { … … 83 83 { 84 84 // strip leading zeros (weird Kodak Scanner software) 85 while ( $value[0] == chr(0))85 while ( isset($value[0]) and $value[0] == chr(0)) 86 86 { 87 87 $value = substr($value, 1); … … 89 89 // remove binary nulls 90 90 $value = str_replace(chr(0x00), ' ', $value); 91 91 92 92 return $value; 93 93 } … … 108 108 die('Exif extension not available, admin should disable exif use'); 109 109 } 110 110 111 111 // Read EXIF data 112 112 if ($exif = @read_exif_data($filename)) -
trunk/include/functions_user.inc.php
r1085 r1113 6 6 // +-----------------------------------------------------------------------+ 7 7 // | branch : BSF (Best So Far) 8 // | file : $ RCSfile$8 // | file : $Id$ 9 9 // | last update : $Date$ 10 10 // | last modifier : $Author$ 11 // | revision : $Revision$12 11 // | revision : $Revision$ 13 12 // +-----------------------------------------------------------------------+ … … 609 608 function check_status($access_type, $user_status = '') 610 609 { 611 global $lang;612 613 610 if (!is_autorize_status($access_type, $user_status)) 614 611 { 615 echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />'; 616 echo '<a href="'.PHPWG_ROOT_PATH.'identification.php">'.$lang['identification'].'</a></div>'; 617 exit(); 612 access_denied(); 618 613 } 619 614 } -
trunk/include/section_init.inc.php
r1109 r1113 6 6 // +-----------------------------------------------------------------------+ 7 7 // | branch : BSF (Best So Far) 8 // | file : $ RCSfile$8 // | file : $Id$ 9 9 // | last update : $Date$ 10 10 // | last modifier : $Author$ … … 343 343 if ($page['section'] == 'search') 344 344 { 345 include_once( PHPWG_ROOT_PATH .'include/functions_search.inc.php' ); 345 346 $query = ' 346 347 SELECT DISTINCT(id) -
trunk/index.php
r1109 r1113 55 55 'pwg_image_order', 56 56 $_GET['image_order'] > 0 ? $_GET['image_order'] : '', 57 0 57 0, cookie_path() 58 58 ); 59 59 -
trunk/language/fr_FR.iso-8859-1/common.lang.php
r1103 r1113 246 246 $lang['picture'] = 'image'; 247 247 $lang['picture_high'] = 'Cliquer sur l\'image pour la visualiser en haute définition'; 248 $lang['picture_show_metadata'] = 'Mont er les méta-données du fichier';248 $lang['picture_show_metadata'] = 'Montrer les méta-données du fichier'; 249 249 $lang['powered_by'] = 'Propulsé par'; 250 250 $lang['preferences'] = 'Préférences'; -
trunk/search_rules.php
-
Property
svn:keywords
set to
Author Date Id Revision
r1092 r1113 6 6 // +-----------------------------------------------------------------------+ 7 7 // | branch : BSF (Best So Far) 8 // | file : $ RCSfile$9 // | last update : $Date : 2005-09-27 23:57:14 +0200 (mar, 27 sep 2005)$10 // | last modifier : $Author : plg$11 // | revision : $Revision : 879$8 // | file : $Id$ 9 // | last update : $Date$ 10 // | last modifier : $Author$ 11 // | revision : $Revision$ 12 12 // +-----------------------------------------------------------------------+ 13 13 // | This program is free software; you can redistribute it and/or modify | … … 44 44 define('PHPWG_ROOT_PATH','./'); 45 45 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); 46 include_once( PHPWG_ROOT_PATH.'include/functions_search.inc.php' ); 46 47 47 48 $page['body_id'] = 'thePopuphelpPage'; -
Property
svn:keywords
set to
Note: See TracChangeset
for help on using the changeset viewer.