- Timestamp:
- Dec 18, 2006, 7:44:11 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_webserv.inc.php
r1671 r1674 127 127 return $list; 128 128 } 129 130 131 // FIXME Function which could already exist somewhere else 132 function convert_catlist($cat_ids) 133 { 134 $cat_list = implode(',', $cat_ids); 135 $ret_ids = array(); 136 $query = ' 137 SELECT DISTINCT image_id 138 FROM '.IMAGE_CATEGORY_TABLE.' 139 WHERE category_id in ('.$cat_list.') 140 ;'; 141 $result = pwg_query($query); 142 while ($row = mysql_fetch_array($result)) 143 { 144 $ret_ids[] = $row['image_id']; 145 } 146 return $ret_ids; 147 } 129 148 ?> -
trunk/web_service.php
r1670 r1674 28 28 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); 29 29 30 if ((!defined("PHPWG_ROOT_PATH")) or (!$conf['allow_web_services']))30 if ( !$conf['allow_web_services'] ) 31 31 { 32 32 die('Hacking attempt!'); … … 54 54 // Check call process (Keyed call) 55 55 // 56 if (!isset($_get['key'])) 56 57 if (!isset($_GET['key'])) 57 58 { 58 59 die('Hacking attempt!'); 59 60 } 60 if ( strlen($_ get['key']) < 12 )61 if ( strlen($_GET['key']) < 12 ) 61 62 { 62 63 die('Invalid key (Length issue)!'); … … 70 71 ;'; 71 72 $active = mysql_fetch_array(pwg_query($query)); 72 if ( $active='false')73 if ( $active['value']=='false' ) 73 74 { 74 75 die('Web service is temporary inactive'); … … 77 78 // Look for partner_key 78 79 // 79 $key = $_ get['key'];80 $key = $_GET['key']; 80 81 $key = ( strlen($key) > 20 ) ? substr($key,0,20) : $key; 81 82 $len = strlen($key); 82 &hash = 0;83 if (isset($_ get['pos']))84 { 85 $hash = (!is_numeric($ hash)) ? 0 : $_get['pos'];83 $hash = 0; 84 if (isset($_GET['pos'])) 85 { 86 $hash = (!is_numeric($_GET['pos'])) ? 0 : $_GET['pos']; 86 87 $hash = (int) $hash; 87 88 $hash = $hash % 12; 88 89 } 89 90 $query = ' 90 SELECT * 91 SELECT `id`, `name`, `access`, `start`, `end`, `request`, 92 `high`, `normal`, `limit`, `comment` 91 93 FROM '.WEB_SERVICES_ACCESS_TABLE.' 92 94 ;'; 95 93 96 $result = pwg_query($query); 94 97 … … 98 101 { 99 102 $len = 0; 103 $def = $row; 100 104 continue; 101 105 } … … 105 109 die('Invalid key!'); 106 110 } 111 107 112 // $def = Web service already defined partner access 108 $def = $row; 113 109 114 // 110 115 // Now, the partner will get a reply in time … … 119 124 } 120 125 121 122 123 // FIXME// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME124 125 126 // Check keywords 126 127 // Key and pos are correct 127 128 // &acc=cat/23,25-32&req=landscape&lim=5&tpl=myxml 128 129 $req_access =''; 130 if (isset($_GET['pos'])) 131 { 132 $req_access = check_target($_GET['acc']); 133 } 134 // on one hand $req_access, requested ids 135 $req_type = explode('/',$req_access); 136 $req_ids = explode( ',',$req_type[1] ); 137 $req_list = expand_id_list( $req_ids ); 138 if ($req_type[0]=='cat') 139 { 140 $req_list = convert_catlist($req_list); 141 } 142 if ($req_type[0]=='tag') 143 { 144 $req_list = get_image_ids_for_tags($req_list); 145 } 146 echo $def['name'].'<br />'; 147 // on the other hand $def['access'], authorized default ids 148 $def_type = explode('/',$def['access']); 149 $def_ids = explode( ',',$def_type[1] ); 150 $def_list = expand_id_list( $def_ids ); 151 if ($def_type[0]=='cat') 152 { 153 $def_list = convert_catlist($def_list); 154 } 155 if ($def_type[0]=='tag') 156 { 157 $def_list = get_image_ids_for_tags($def_list); 158 } 159 160 // could be no necessary, a surplus but 161 // Filter on forbidden_categories 162 $list = implode(',',$def_list); 163 164 $ret_ids = array(); 165 $query = ' 166 SELECT DISTINCT image_id 167 FROM '.IMAGE_CATEGORY_TABLE.' 168 WHERE category_id NOT IN ('.$user['forbidden_categories'].') 169 AND image_id IN ('.$list.') 170 ;'; 171 $result = pwg_query($query); 172 while ($row = mysql_fetch_array($result)) 173 { 174 $ret_ids[] = $row['image_id']; 175 } 176 177 // 77f1180bd215a0edf66939 178 // web_service.php?key=77f1180bd215&pos=3&acc=list/41,73,142,178,190,204,235-238&req=recent&lim=1&tpl=myxml 179 180 echo 'temporaire<br />'; 181 echo '$req_list' . var_dump($req_list); 182 183 if (count($req_list)==0) 184 { 185 $req_list = $def_list; 186 } 187 // 188 die('FIXME!'); 189 // FIXME// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME// FIXME 190 191 // Both may empty 192 // Both can be build on differents basis cat/tag/list 193 // Both have to be convert in list 194 // if no requested ids then is the complete default 195 // if some requested ids they must be in the complete default and only those 196 // will be transmitted. 129 197 130 198
Note: See TracChangeset
for help on using the changeset viewer.